CN107368485A - The management method and Database Systems of a kind of database - Google Patents

The management method and Database Systems of a kind of database Download PDF

Info

Publication number
CN107368485A
CN107368485A CN201610312657.0A CN201610312657A CN107368485A CN 107368485 A CN107368485 A CN 107368485A CN 201610312657 A CN201610312657 A CN 201610312657A CN 107368485 A CN107368485 A CN 107368485A
Authority
CN
China
Prior art keywords
subregion
nodes
data
slave
master
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201610312657.0A
Other languages
Chinese (zh)
Inventor
陈华军
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Suning Commerce Group Co Ltd
Original Assignee
Suning Commerce Group Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Suning Commerce Group Co Ltd filed Critical Suning Commerce Group Co Ltd
Priority to CN201610312657.0A priority Critical patent/CN107368485A/en
Publication of CN107368485A publication Critical patent/CN107368485A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/284Relational databases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases

Abstract

The embodiment of the invention discloses a kind of management method of database and Database Systems, it is related to database technical field, it is possible to increase the stability of reading and writing data in system.The present invention includes:The data to be written that user equipment is sent are received, and the Master nodes being written into data write-in cluster;At least two Slave node-node transmissions corresponding with Master nodes being written into data subregion where from Master nodes to Master nodes, and detecting whether Master nodes receive the response message that at least one Slave nodes are sent, response message is sent by the Slave nodes for being successfully written the data of reception;If Master nodes receive the response message that at least one Slave nodes are sent, to notification of user equipment message, notification message is used to represent the database that data to be written are successfully written.The present invention is applied to the reading and writing data management of relevant database.

Description

The management method and Database Systems of a kind of database
Technical field
The present invention relates to the management method and data base set of database technical field, more particularly to a kind of database System.
Background technology
Relevant database is a kind of now widely used type of database, in the construction of relevant database In usually require by more number of units according to server group into cluster.MySQL (a kind of Relational DBMS) It is then a kind of currently used Relational DBMS, and for managing cluster.
It is currently based in the group scheme of MySQL designs, it is necessary to which the role that node undertakes Master is respectively configured With Slave role, the data that user equipment is submitted can be respectively written into by the form partly synchronously replicated Master nodes and Slave nodes, so as to improve the security of data writing process.
In the actual motion of system, network congestion, data write error mistake and equipment fault etc. also occurs Problems, these problems normally result in data and write Slave nodes time-out by Master nodes, in order to protect The operation stability of card system, half synchronous replicate can be deteriorated to asynchronous replication.And in asynchronous replication, number Do not associated according to the opportunity of write-in Slave nodes with writing the opportunity of Master nodes, i.e. data write-in Master Judge to write successfully after node.If deteriorating to data after asynchronous replication does not write Slave nodes, hold very much This part of loss of data is easily caused, causes the data corruption in system.Also, when Master nodes break down, Need corresponding Slave nodes upgrading to Master nodes, but due to system for fault verification it is inaccurate or The reasons such as person's wrong report, after Slave nodes can be caused to upgrade to new Master nodes, former Master nodes are still transported The situation of work, now writing data can then cause data to write two Master nodes " double to write " problems, so as to The data corruption being further exacerbated by system, cause data stability very low.
The content of the invention
Embodiments of the invention provide the management method and Database Systems of database, it is possible to increase number in system According to the stability of read-write.
To reach above-mentioned purpose, embodiments of the invention adopt the following technical scheme that:
In a first aspect, embodiments of the invention provide a kind of management method of database, including:Receive user The data to be written that equipment is sent, and the Master nodes that the data to be written are write in cluster;By described in Data to be written from the Master nodes into subregion where the Master nodes at least two with it is described Slave node-node transmissions corresponding to Master nodes, and detect the Master nodes whether receive it is at least one The response message that Slave nodes are sent, the response message are saved by the Slave for being successfully written the data of the reception Point is sent;If the Master nodes receive the response message that at least one Slave nodes are sent, to institute Notification of user equipment message is stated, the notification message is used to represent the data that the data to be written are successfully written Storehouse.
With reference in a first aspect, in the first possible implementation of first aspect, the reception user sets The data to be written that preparation is sent, and by the Master nodes in the data write-in cluster to be written, including:It is logical The read-write route reception crossed in the cluster is sent described to be written by the application run on the user equipment Enter data, the read-write route is bound the Master nodes in the cluster and configured in the cluster On Master nodes;Target section is filtered out from the Master nodes in the cluster by the read-write route Point, and the data to be written are drained to the destination node.
With reference to the first possible implementation of first aspect, in second of possible implementation, go back Including:Receive what is sent by the application run on the user equipment by the read-only route in the cluster Read requests, the read-only route are bound the Slave nodes in the cluster and configured in the cluster On Slave nodes;The data pointed to from read requests described in the Slave Node extractions in the cluster, and by institute The data of extraction are sent to the user equipment.
With reference in a first aspect, in the third possible implementation of first aspect, in addition to:For institute Each subregion in cluster is stated, when the Master node failures in a subregion, is detected in one subregion Number of nodes whether be more than 2;If so, the Slave nodes in one subregion are then upgraded into Master sections Point, and by the compensation data of Slave nodes all in one subregion to last state, the newest shape The Master nodes that state refers in one subregion complete data mode after finishing touch affairs before failure, its In, the time-out time of one zone configuration is more than or equal to max-thresholds, and the time-out time is judgement institute The time parameter whether the Slave nodes in a subregion degrade is stated, if the Slave in one subregion Node degrades, then same by half from the Master nodes of one subregion to the mode of Slave node-node transmission data Step duplication deteriorates to asynchronous replication.
With reference to the third possible implementation of first aspect, in the 4th kind of possible implementation, go back Including:By the load equalizer configured, the renewal shape of all Slave nodes in one subregion is monitored State, the load equalizer configuration is on the Slave nodes in one subregion;According in the subregion of place Each Slave nodes in subregion where the more new states of all Slave nodes judges whether failure.
With reference to the 4th kind of possible implementation of first aspect, in the 5th kind of possible implementation, go back Including:According to the loading condition of the read-only route of one subregion, pass through what is configured in one subregion Load equalizer, asynchronous Slave nodes are set up in one subregion;By the Master of one subregion Node transmits data to the asynchronous Slave nodes by the way of asynchronous replication.
With reference to the three, the 4th or the 5th kind of possible implementation of first aspect, in the 6th kind of possible realization In mode, in addition to:The number of nodes of each subregion in the cluster is detected, and screens illegal subregion, wherein, The number of nodes of the illegal subregion is less than or equal to specified quantity;Release is distributed to the resource of the illegal subregion.
Second aspect, embodiments of the invention provide a kind of Database Systems, including:Read-write route, is used for The data to be written that user equipment is sent are received, and destination node is filtered out from the Master nodes in cluster, And the data to be written are drained to the destination node, the read-write route is bound in the cluster Master nodes are simultaneously configured on the Master nodes in the cluster;Master nodes, for writing described treat Write data, and will the data to be written from the Master nodes to the Master nodes place subregion in At least two Slave node-node transmissions corresponding with the Master nodes;At least two correspond to the Master The Slave nodes of node, for writing the data of the Master node-node transmissions, and after data write successfully Response message is sent to the Master nodes;The Master nodes, be additionally operable to receive it is at least one During the response message that Slave nodes are sent, to the notification of user equipment message, the notification message is used for table Show the database that the data to be written are successfully written.
With reference to second aspect, in the first possible implementation of second aspect, in addition to:Read-only road By for receiving the read requests that are sent by the application run on the user equipment, and from the cluster In Slave Node extractions described in the data pointed to of read requests, and the data extracted are set to the user Preparation is sent, and the read-only route binds the Slave nodes in the cluster and configures the Slave in the cluster On node;Load equalizer, for monitoring the more new state of all Slave nodes in one subregion, The load equalizer configuration is on the Slave nodes in one subregion;And the institute in the subregion of place Each Slave nodes in subregion where the more new state for having Slave nodes judges whether failure;The load balancing Device, the loading condition of the read-only route according to one subregion is additionally operable to, is set up in one subregion Asynchronous Slave nodes, and from the Master nodes of one subregion to the asynchronous Slave nodes using asynchronous The mode of duplication transmits data.
With reference to second aspect or the first possible implementation, in second of possible implementation, go back Including:Fault management module, for when the Master node failures in a subregion, detecting one point Whether the number of nodes in area is more than 2;If so, then the Slave nodes in one subregion are upgraded to Master nodes, and by the compensation data of Slave nodes all in one subregion to last state, institute State the Master nodes that last state refers in one subregion and data after finishing touch affairs are completed before failure State, wherein, the time-out time of one zone configuration is more than or equal to max-thresholds, the time-out time The time parameter whether to degrade for the Slave nodes in the one subregion of judgement, if one subregion In Slave nodes degrade, then from the Master nodes of one subregion to the side of Slave node-node transmission data Formula deteriorates to asynchronous replication by half synchronous replicate;The fault management module, it is additionally operable to detect in the cluster The number of nodes of each subregion, and screen illegal subregion, wherein, the number of nodes of the illegal subregion is less than etc. In specified quantity;And distribution is discharged to the resource of the illegal subregion.
The management method and Database Systems of database provided in an embodiment of the present invention, by the data to be written At least two and the Master nodes pair in subregion where from the Master nodes to the Master nodes The Slave node-node transmissions answered, and detect whether the Master nodes receive at least one Slave nodes transmission Response message;If the Master nodes receive the response message that at least one Slave nodes are sent, To the notification of user equipment message, the notification message is used to represent what the data to be written were successfully written Database.Force Master nodes to be in during due to writing in data partly synchronously to replicate and wait Slave Node response state (such as:Parameter rpl_semi_sync_master_timeout is configured into one to be more than most The numerical value of big threshold value, half synchronous replicate is prevented to deteriorate to asynchronous replication so that Slave nodes are no longer sent out substantially Raw degradation problem, realizing in subregion, which necessarily has a Slave node to possess on Master nodes, finally completes thing The binlog records of business) so that a successful data writing operation just needs a Master node and extremely Few one is configured to the half Slave nodes synchronously replicated and participates in, it is therefore prevented that half synchronous replicate deteriorates to asynchronous replication The problem of caused loss of data, improve the stability of reading and writing data in system.And also in a subregion Middle to set 3 HA nodes, i.e. a Master node and two are configured to the half Slave nodes synchronously replicated, The possibility for the leader follower replication relation to form 2 groups of independence is avoided, writes, improves so as to solve the problems, such as that data are double The stability of reading and writing data in system.
Brief description of the drawings
Technical scheme in order to illustrate the embodiments of the present invention more clearly, below will be to required in embodiment The accompanying drawing used is briefly described, it should be apparent that, drawings in the following description are only the one of the present invention A little embodiments, for those of ordinary skill in the art, on the premise of not paying creative work, also Other accompanying drawings can be obtained according to these accompanying drawings.
Fig. 1 is a kind of equipment configuration diagram provided in an embodiment of the present invention;
Fig. 2, Fig. 4 are system architecture schematic diagram provided in an embodiment of the present invention;
Fig. 3 is the schematic flow sheet of the management method of database provided in an embodiment of the present invention;
The structural representation of Fig. 5, Fig. 6, Fig. 7 Database Systems provided in an embodiment of the present invention.
Embodiment
To make those skilled in the art more fully understand technical scheme, below in conjunction with the accompanying drawings and specifically Embodiment is described in further detail to the present invention.Embodiments of the present invention are described in more detail below, The example of the embodiment is shown in the drawings, wherein same or similar label represents identical from beginning to end Or similar element or the element with same or like function.Below with reference to the embodiment party of accompanying drawing description Formula is exemplary, is only used for explaining the present invention, and is not construed as limiting the claims.This technology is led Field technique personnel are appreciated that unless expressly stated, singulative " one " used herein, "one", " institute State " and "the" may also comprise plural form.It is to be further understood that used in the specification of the present invention Wording " comprising " refers to the feature, integer, step, operation, element and/or component be present, but not Exclude to exist or other one or more features of addition, integer, step, operation, element, component and/or it Group.It should be understood that when we claim element to be " connected " or during " coupled " to another element, it can be direct Other elements are connected or coupled to, or there may also be intermediary element.In addition, " connection " used herein Or " coupling " can include wireless connection or coupling.Wording "and/or" used herein includes one or more Any cell of associated list items and all combination.Those skilled in the art of the present technique be appreciated that unless Definition in addition, all terms (including technical term and scientific terminology) used herein have and institute of the present invention The general understanding identical meaning of those of ordinary skill in category field.It is it should also be understood that such as general Those terms defined in dictionary should be understood that with consistent with the meaning in the context of prior art Meaning, and unless defined as here, will not be explained with the implication of idealization or overly formal.
The embodiment of the present invention, it can specifically realize in a kind of system as shown in Figure 1, the system is by multiple sections Point composition, the present embodiment interior joint can be specifically the hardware devices such as a kind of server, work station;Can also It is in the device clusters being made up of excessively individual server apparatus, using a kind of MySQL (relational data depositary managements Reason system) etc. technology the hardware in device clusters is provided into management, and carry out unified configuring corresponding hardware resource With the node of foundation.Specific implementation procedure in the present embodiment, can be by the Pacemaker that is run in the system A kind of a kind of (cluster resource manager)+Corosync (cluster management external member)+RA (Resource Agent, Resource Broker) composition cluster component be responsible for implementation, in the present embodiment, whole cluster component also may be used With referred to as " Pacemaker " or for fault management module.
Further, in system as shown in Figure 1, it can be provided for reading and writing the automatic route of data, example Such as:As shown in Figure 2.The application programs such as the APP run on user equipment by read and write route (or for read Write VIP) and it is read-only route (or be read-only VIP) can respectively with read-write mode and read-only mode access such as System cluster shown in Fig. 1.VIP is specifically a kind of automatic route, is transported for managing on the user equipmenies such as APP Data write operation of the capable application program to storage cluster.
In the present embodiment, user equipment can be with implementation into an independent table apparatus, or is integrated in a variety of In media data playing device, such as set top box, mobile phone, tablet personal computer (Tablet Personal Computer), laptop computer (Laptop Computer), multimedia player, digital camera, individual Personal digital assistant (personal digital assistant, abbreviation PDA), guider, mobile Internet access device (Mobile Internet Device, MID) or wearable device (Wearable Device) etc..
The embodiment of the present invention provides a kind of management method of database, as shown in figure 3, including:
S1, the data to be written that user equipment is sent are received, and by the data write-in cluster to be written Master nodes.
Should by what is run on the user equipment specifically, can be received by the read-write route in the cluster With the data to be written sent;And by the read-write route from the Master nodes in the cluster Destination node is filtered out, and the data to be written are drained to the destination node.The read-write route is tied up Master nodes and configuration in the fixed cluster is on the Master nodes in the cluster.The destination node Can be specifically that loading condition meets the Master nodes that data are write in desired subregion;Either according to advance The data write-in of configuration is regular, the Master nodes in the subregion selected.Such as:As shown in Figure 2, one Individual subregion includes a Master node and at least two Slave nodes, i.e. HA nodes in a subregion Amount is at least 3, and Master nodes are selected from 3 HA nodes, and other nodes save as Slave Put and be configured to half synchronous duplication.
S2, by the data to be written from the Master nodes into subregion where the Master nodes extremely Few two Slave node-node transmissions corresponding with the Master nodes, and detect whether the Master nodes receive The response message sent at least one Slave nodes.
Wherein, the response message is sent by the Slave nodes for being successfully written the data of the reception.The sound Message is answered to be used to represent the database that the data to be written are successfully written.In the present embodiment, half is synchronous multiple The process of system mainly includes:After Master nodes receive the write request of user equipment transmission, execution is written locally Action be written into data write-in Master nodes caching or other memories in, when replicate data to be written to Each Slave nodes in same subregion, be configured to the half Slave nodes synchronously replicated after data are successfully written to Master sends response message, and after Master receives response message, notifying user equipment writes successfully;It is asynchronous multiple System refers to:Master be written locally act successfully after i.e. notice APP write successfully, and be not to wait for being configured to The Slave node response messages of asynchronous replication.
If S3, the Master nodes receive the response message that at least one Slave nodes are sent, to institute State notification of user equipment message.
If the Master nodes are not received by the response message of any one Slave node transmission, this is represented Secondary data write operation is also failed, then judges data write-in failure and send failed message to user equipment, Or continue waiting for Master nodes and receive response message.
The management method of database provided in an embodiment of the present invention, by the data to be written by the Master At least two with the Master node corresponding Slaves of the node into subregion where the Master nodes are saved Point transmission, and detect whether the Master nodes receive the response message that at least one Slave nodes are sent; If the Master nodes receive the response message that at least one Slave nodes are sent, set to the user Standby notification message, the notification message are used to represent the database that the data to be written are successfully written.Due to Force Master nodes to be in during data write partly synchronously to replicate and wait the shape of Slave node responses State so that a successful data writing operation just needs a Master node and at least one is configured to The Slave nodes partly synchronously replicated are participated in, it is therefore prevented that data caused by half synchronous duplication deteriorates to asynchronous replication are lost The problem of mistake, improve the stability of reading and writing data in system.
In the present embodiment, read-write route route and the Master role bindings of the framework based on MySQL, It is and Master node bindings in Fig. 2;Read-only route and load equalizer and the framework based on MySQL Slave role bindings, it is and Slave node bindings in fig. 2.Based on above-mentioned flow, in the present embodiment Also include:
The reading sent by the application run on the user equipment is received by the read-only route in the cluster Request is taken, the read-only route binds the Slave nodes in the cluster and configures the Slave in the cluster On node.And the data pointed to from read requests described in the Slave Node extractions in the cluster, and will be carried The data taken are sent to the user equipment.
Wherein, load equalizer is specially a kind of application for being used to realize network load sum, such as:Can be with For LVS or it is that LVS is acted on behalf of, the life for the Slave nodes in framework of the indirect monitor based on MySQL Extremely, IO threads and renewal LVS configurations are replicated.In the present embodiment, can also be by calling MHA (Master High Availability Manager and Tools for MySQL) implement actual online switching and failure is cut Change, and reduce daily record compensation while online switching and failover.
In the present embodiment, for the stability of reading and writing data in raising system and fundamentally to prevent data double The problem of writing, following scheme is additionally provided, specifically included:
For each subregion in the cluster, when the Master node failures in a subregion, described in detection Whether the number of nodes in one subregion is more than 2.If so, then the Slave nodes in one subregion are upgraded For Master nodes, and by the compensation data of Slave nodes all in one subregion to last state.
Wherein, described Master node failures mainly include:MySQL process crash, that is, pass through original place weight Open MySQL processes, if unsuccessfully retried, if unsuccessfully more than 3 times if failover occurs, stop former Master The hardware resource distributed on node, and select and lifted a Slave node being in identical partitions and upgrade to Master nodes.Further, failover trigger condition occurs in the present embodiment also to be included:Network disconnects, MySQL data disks damage, physical machine or empty machine crash etc..For the network flash in the range of certain time, Such as the network flash in 3~10 seconds, failover can be initiated by Pacemaker, and if not yet calling MHA failover examination phase, the network recovery of former Master nodes, then stop failover.
The Master nodes that the last state refers in one subregion complete finishing touch affairs before failure Data mode afterwards, wherein, the time-out time of one zone configuration is more than or equal to max-thresholds, wherein, Max-thresholds can be a maximum such as 200 days.The time-out time is in the one subregion of judgement The time parameter whether Slave nodes degrade, if the Slave nodes in one subregion degrade, by Mode from the Master nodes of one subregion to Slave node-node transmission data by half it is synchronous replicate deteriorate to it is different Step replicates.
Wherein, the time-out time of one zone configuration is more than or equal to max-thresholds, and the time-out time is The time parameter whether the Slave nodes in one subregion degrade is judged, if in one subregion Slave nodes degrade, then from one subregion mode from Master nodes to Slave node-node transmission data Asynchronous replication is deteriorated to by half synchronous replicate.It is common, can be in Master in the framework based on MySQL Duplication between node and Slave nodes is broken down and exceedes certain time (such as by parameter The time-out time of rpl_semi_sync_master_timeout controls) when automatically will half it is synchronous replicate deteriorate to it is asynchronous Replicate, in the present embodiment, in order to prevent half synchronous duplication deteriorates to the situation of asynchronous replication from occurring, will join Number rpl_semi_sync_master_timeout is configured to the numerical value for being more than max-thresholds, such as max-thresholds It can be 300 days.Force Master nodes to be in during so as to write in data partly synchronously to replicate and wait The state of Slave node responses, a successful data writing operation just need a Master node and At least one half Slave nodes synchronously replicated that are configured to are participated in, and at least 2 are specifically just needed in a subregion Individual HA nodes participate in.In the preferred scheme of the present embodiment, 3 HA nodes of setting in a subregion, i.e., one Individual Master nodes and two are configured to the half Slave nodes synchronously replicated, and 2 groups of independence is formed so as to avoid The possibility of leader follower replication relation, write from solving the problems, such as that data are double, improve the steady of reading and writing data in system It is qualitative.
Specifically, the Slave nodes in a subregion are upgraded to the process of Master nodes can pass through MHA Complete, after failover occurs MHA by the compensation data of Slave nodes all in subregion to newest so that The Slave nodes that Pacemaker chooses are owned by newest daily record after the generation of Master node failures.Simultaneously will ginseng Number rpl_semi_sync_master_timeout is configured to the numerical value for being more than max-thresholds, prevents half synchronously Duplication deteriorates to asynchronous replication so that degradation problem no longer occurs substantially for Slave nodes, realizes one in subregion Surely a Slave node possesses the binlog records for finally completing affairs on Master nodes, so as to avoid Loss of data occurs during failover.
On the other hand, if Pacemaker detect Slave nodes break downs, by the Slave nodes of failure from Deleted in LVS real server lists, the application program for preventing from running on user equipment is visited by read-only route Ask the Slave nodes of malfunction and failure.And after Slave nodes recover normal, then will recover automatically normal Slave nodes add LVS real server lists.
In the present embodiment, because when network failure causes the cluster subregion occur, processing procedure includes:
In the case of Pacemaker obtains quorum subregion, if Master nodes also on the subregion, Failover does not occur then, but LVS and read-only route can be reallocated.But if this Master Node is unique HA nodes on the subregion, then being sent to the write access of Master nodes will be blocked, wherein hindering Plug time span is determined by parameter rpl_semi_sync_master_timeout.If Master nodes are not in this point Qu Shang, and have the HA nodes of more than 2 on the subregion, then failover occurs.If Master nodes are not at this On subregion, and there was only 1 HA node on the subregion, then occur failover, but failover examination phase (i.e. Not yet calling MHA) failover can fail.And the hardware on the node after failure predetermined number of times (such as 3 times) Resource is stopped.If Master nodes do not have HA nodes not on the subregion on the subregion, then do not send out Raw failover.
In the case of Pacemaker does not obtain quorum subregion, all resources will be stopped on the subregion Only.For Pacemaker or Corosync in the case of of breaking down in itself:By Corosync process crash, and Resource on malfunctioning node maintains the original state, and makes malfunctioning node in heaven relative to other nodes, processing mode and net Network disconnects identical;By Pacemaker process crash, if Corosync processes are normal, malfunctioning node is relative Also lived in other nodes, but malfunctioning node can not respond the instruction that DC nodes are sent.
In the present embodiment, the flow of the data recovery after failture evacuation includes:Pulled from new Master nodes Full backup is recovered, inconsistent so as to avoid the data of the new Master after malfunctioning node and failover Problem.
Further, in the present embodiment, the number of nodes section in a subregion can be less than or equal to specify The resource that these subregions occupy is rejected and discharged to the subregion of quantity.Also include on the basis of foregoing schemes: The number of nodes of each subregion in the cluster is detected, and screens illegal subregion, and discharges and distributes to described illegal The resource of subregion.Wherein, the number of nodes of the illegal subregion is less than or equal to specified quantity.In preferred scheme In, specified quantity is set as 2.
In the present embodiment, all Slave monitored by the load equalizer configured in one subregion are saved That puts is whether working properly.Also include on the basis of foregoing schemes:
By the load equalizer configured, the renewal shape of all Slave nodes in one subregion is monitored State, the load equalizer configuration is on the Slave nodes in one subregion.And according in the subregion of place All Slave nodes more new state judge where each Slave nodes in subregion whether failure.Such as:Such as Shown in Fig. 2, lvsdr (Resource Broker of LVS DR patterns) and MySQL Slave node bindings, and lvsdr LVS is updated according to the duplication health status of Slave nodes dynamic.And by LVS by monitoring Slave nodes more Whether new state is normal so as to judge monitored Slave nodes.Relative to passing through monitoring port in existing scheme Carry out the online situation of monitoring node, because equipment goes offline only a kind of possible failure situation, and deposited toward contact But the still situation of failure online in miscellaneous equipment, the present embodiment is the same as the more new state by monitoring Slave nodes The accuracy rate of fault verification can be improved.
When judging Slave node failures, MySQL processes crash and MySQL processes are restarted in original place, if Unsuccessfully retry, stop the related resource distributing on this node if the frequency of failure is more than 3 times, if the failure LVS and read-only route are assigned on Slave nodes, then it is normal LVS and read-only route to be re-assigned into another On the Slave nodes of work;When there is network disconnection problem, MySQL data disks damage, then physical machine or Virtual machine crash stops at the related resource to that should distribute on MySQL data disks Slave nodes, if should LVS and read-only route are assigned on Slave nodes, then it is normal LVS and read-only route to be re-assigned into another On the Slave nodes of work;During the network in the case of network flash disconnects, by being disconnected on node Pacemaker stops the related resource being disconnected on node, will be disconnected node automatically again after network recovery Rejoin cluster and start mysql services, related resource can not also be done if flash time is shorter any Practical operation.
Relative to being that LVS configures special execution node in the prior art, and to ensure that LVS High Availabitity needs More than two LVS nodes are configured, the scheme for needing real-time heart beat to detect between each LVS node.This In embodiment, by the way that LVS is configured on Slave nodes, the real using all Slave nodes as LVS server.Distribution read-write route on Master nodes, and read-only route is dispensed on and LVS positions identical node On, i.e. read-write route binds current Master, so that the cluster component in the present embodiment is provided simultaneously with supervising LVS function is controlled, LVS is configured on a Slave node wherein, so as to save hardware resource.
In the present embodiment, the Slave nodes that at least two configurations partly synchronously replicate in subregion is ensured be present At the same time it can also set up the asynchronous Slave nodes for being configured to asynchronous replication as shown in Figure 4 in subregion.Exist Also include on the basis of foregoing schemes:
It is negative by what is configured in one subregion according to the loading condition of the read-only route of one subregion Balanced device is carried, asynchronous Slave nodes are set up in one subregion, and by the Master of one subregion Node transmits data to the asynchronous Slave nodes by the way of asynchronous replication.So as to increase telescopic reading Load balance ability, while system reliability is improved, further improve load capacity.
The management method of database provided in an embodiment of the present invention, by the data to be written by the Master At least two with the Master node corresponding Slaves of the node into subregion where the Master nodes are saved Point transmission, and detect whether the Master nodes receive the response message that at least one Slave nodes are sent; If the Master nodes receive the response message that at least one Slave nodes are sent, set to the user Standby notification message, the notification message are used to represent the database that the data to be written are successfully written.Due to Force Master nodes to be in during data write partly synchronously to replicate and wait the shape of Slave node responses State (such as:Parameter rpl_semi_sync_master_timeout is configured to a number for being more than max-thresholds Value, half synchronous replicate is prevented to deteriorate to asynchronous replication so that degradation problem no longer occurs substantially for Slave nodes, Realizing necessarily has a Slave node to possess the binlog notes for finally completing affairs on Master nodes in subregion Record) so that a successful data writing operation just needs a Master node and at least one configuration Slave nodes partly synchronously to replicate participate in, it is therefore prevented that half synchronous replicate deteriorates to data caused by asynchronous replication The problem of loss, improve the stability of reading and writing data in system.And 3 HA are set also in a subregion Node, i.e. a Master node and two are configured to the half Slave nodes synchronously replicated, avoid to form 2 groups The possibility of independent leader follower replication relation, write so as to solve the problems, such as that data are double, improve data in system The stability of read-write.
With reference to the framework as shown in Fig. 1,2,4, the embodiment of the present invention also provides a kind of Database Systems, such as schemes Shown in 5, including:
Read-write route, for receiving the data to be written of user equipment transmission, and from the Master nodes in cluster In filter out destination node, and the data to be written are drained to the destination node, the read-write route Bind the Master nodes in the cluster and configure on the Master nodes in the cluster.
Master nodes, for writing the data to be written, and by the data to be written by the Master At least two with the Master node corresponding Slaves of the node into subregion where the Master nodes are saved Point transmission.
At least two correspond to the Slave nodes of the Master nodes, for writing the Master node-node transmissions Data, and after data write successfully to the Master nodes send response message.
The Master nodes, it is additionally operable to when receiving the response message that at least one Slave nodes are sent, To the notification of user equipment message, the notification message is used to represent what the data to be written were successfully written Database.
Further, as shown in Figure 6, in addition to:Read-only route, for receiving by the user equipment The read requests that the application of operation is sent, and from read requests described in the Slave Node extractions in the cluster The data of sensing, and the data extracted are sent to the user equipment, described in the read-only route binding Slave nodes and configuration in cluster is on the Slave nodes in the cluster.
Load equalizer, it is described for monitoring the more new state of all Slave nodes in one subregion Load equalizer configuration is on the Slave nodes in one subregion.It is and all in the subregion of place Each Slave nodes in subregion where the more new states of Slave nodes judges whether failure.
The load equalizer, the loading condition of the read-only route according to one subregion is additionally operable to, in institute State and asynchronous Slave nodes are set up in a subregion, and from the Master nodes of one subregion to described asynchronous Slave nodes transmit data by the way of asynchronous replication.
Further, as shown in Figure 7, in addition to:Fault management module, for as the Master in a subregion During node failure, detect whether the number of nodes in one subregion is more than 2.If so, then will be one Slave nodes in subregion upgrade to Master nodes, and by Slave nodes all in one subregion For compensation data to last state, the Master nodes that the last state refers in one subregion are complete before failure Data mode after into finishing touch affairs, wherein, the time-out time of one zone configuration is more than or equal to most Big threshold value, the time whether time-out time degrades for the Slave nodes in the one subregion of judgement Parameter, if Slave nodes in one subregion degrade, from one subregion Master nodes to The mode of Slave node-node transmission data deteriorates to asynchronous replication by half synchronous replicate.
The fault management module, is additionally operable to detect the number of nodes of each subregion in the cluster, and screens non- Method subregion, wherein, the number of nodes of the illegal subregion is less than or equal to specified quantity.And distribution is discharged to institute State the resource of illegal subregion.
Database Systems provided in an embodiment of the present invention, by by the data to be written by the Master nodes At least two Slave nodes corresponding with the Master nodes in subregion where to the Master nodes pass It is defeated, and detect whether the Master nodes receive the response message that at least one Slave nodes are sent;If The Master nodes receive the response message that at least one Slave nodes are sent, then to the user equipment Notification message, the notification message are used to represent the database that the data to be written are successfully written.Due to Pressure Master nodes, which are in, during data write partly synchronously replicates and waits the state of Slave node responses (such as:Parameter rpl_semi_sync_master_timeout is configured to the numerical value for being more than max-thresholds, And max-thresholds are then a maximum, such as 300 days.Prevent half synchronous replicate to deteriorate to asynchronous replication, make Obtain Slave nodes and degradation problem no longer occurs substantially, realizing in subregion necessarily has a Slave node to possess The binlog records of affairs are finally completed on Master nodes) so that a successful data writing operation is just A Master node and at least one half Slave nodes synchronously replicated that are configured to is needed to participate in, it is therefore prevented that half It is synchronous replicate deteriorate to asynchronous replication caused by loss of data the problem of, improve the steady of reading and writing data in system It is qualitative.And 3 HA nodes are set also in a subregion, i.e. a Master node and two are configured to half The Slave nodes synchronously replicated, the possibility for the leader follower replication relation to form 2 groups of independence is avoided, so as to solve The problem of data pair are write, improve the stability of reading and writing data in system.
Each embodiment in this specification is described by the way of progressive, identical phase between each embodiment As part mutually referring to, what each embodiment stressed be it is different from other embodiment it Place.For apparatus embodiments, because it is substantially similar to embodiment of the method, so describing Fairly simple, the relevent part can refer to the partial explaination of embodiments of method.Those of ordinary skill in the art can It is that can be referred to by computer program to understand all or part of flow realized in above-described embodiment method Related hardware is made to complete, described program can be stored in a computer read/write memory medium, the journey Sequence is upon execution, it may include such as the flow of the embodiment of above-mentioned each method.Wherein, described storage medium can Remember for magnetic disc, CD, read-only memory (Read-Only Memory, ROM) or random storage Body (Random Access Memory, RAM) etc..It is described above, it is only the specific embodiment party of the present invention Formula, but protection scope of the present invention is not limited thereto, and any one skilled in the art is at this Invent in the technical scope disclosed, the change or replacement that can be readily occurred in, should all cover the protection in the present invention Within the scope of.Therefore, protection scope of the present invention should be defined by scope of the claims.

Claims (10)

  1. A kind of 1. management method of database, it is characterised in that including:
    Receive the data to be written that user equipment is sent, and the Master that the data to be written are write in cluster Node;
    By the data to be written from the Master nodes into subregion where the Master nodes at least Two Slave node-node transmissions corresponding with the Master nodes, and detect whether the Master nodes receive The response message that at least one Slave nodes are sent, the response message is by being successfully written the data of the reception Slave nodes send;
    If the Master nodes receive the response message that at least one Slave nodes are sent, to the use Family equipment notification message, the notification message are used to represent the database that the data to be written are successfully written.
  2. 2. management method according to claim 1, it is characterised in that the reception user equipment is sent Data to be written, and by the Master nodes in the data to be written write-in cluster, including:
    The institute sent by the application run on the user equipment is received by the read-write route in the cluster Data to be written are stated, the read-write route is bound the Master nodes in the cluster and configured in the cluster Master nodes on;
    Destination node is filtered out from the Master nodes in the cluster by the read-write route, and by described in Data to be written are drained to the destination node.
  3. 3. management method according to claim 2, it is characterised in that also include:
    The reading sent by the application run on the user equipment is received by the read-only route in the cluster Request is taken, the read-only route binds the Slave nodes in the cluster and configures the Slave in the cluster On node;
    The data pointed to from read requests described in the Slave Node extractions in the cluster, and the number that will be extracted Sent according to the user equipment.
  4. 4. management method according to claim 1, it is characterised in that also include:
    For each subregion in the cluster, when the Master node failures in a subregion, described in detection Whether the number of nodes in one subregion is more than the node member of cluster half;
    If so, the Slave nodes in one subregion are then upgraded into Master nodes, and will be one The compensation data of all Slave nodes refers to one subregion to last state, the last state in subregion In Master nodes data mode after finishing touch affairs is completed before failure, wherein, one subregion is matched somebody with somebody The time-out time put is more than or equal to max-thresholds, and the time-out time is the Slave in the one subregion of judgement The time parameter whether node degrades, if the Slave nodes in one subregion degrade, by described Mode from the Master nodes of one subregion to Slave node-node transmission data by half it is synchronous replicate deteriorate to it is asynchronous multiple System.
  5. 5. management method according to claim 4, it is characterised in that also include:
    By the load equalizer configured, the more new state of all Slave nodes in one subregion is monitored, The load equalizer configuration is on the Slave nodes in one subregion;
    Each Slave sections in subregion where the more new state of all Slave nodes in the subregion of place judges Point whether failure.
  6. 6. management method according to claim 5, it is characterised in that also include:
    It is negative by what is configured in one subregion according to the loading condition of the read-only route of one subregion Balanced device is carried, asynchronous Slave nodes are set up in one subregion;
    Passed from the Master nodes of one subregion to the asynchronous Slave nodes by the way of asynchronous replication Transmission of data.
  7. 7. according to the management method described in any one in claim 4-6, it is characterised in that also include:
    The number of nodes of each subregion in the cluster is detected, and screens illegal subregion, wherein, described illegal point The number of nodes in area is less than or equal to specified quantity;
    Release is distributed to the resource of the illegal subregion.
  8. A kind of 8. Database Systems, it is characterised in that including:
    Read-write route, for receiving the data to be written of user equipment transmission, and from the Master nodes in cluster In filter out destination node, and the data to be written are drained to the destination node, the read-write route Bind the Master nodes in the cluster and configure on the Master nodes in the cluster;
    Master nodes, for writing the data to be written, and by the data to be written by the Master At least two with the Master node corresponding Slaves of the node into subregion where the Master nodes are saved Point transmission;
    At least two correspond to the Slave nodes of the Master nodes, for writing the Master node-node transmissions Data, and after data write successfully to the Master nodes send response message;
    The Master nodes, it is additionally operable to when receiving the response message that at least one Slave nodes are sent, To the notification of user equipment message, the notification message is used to represent what the data to be written were successfully written Database.
  9. 9. Database Systems according to claim 8, it is characterised in that also include:
    Read-only route, for receiving the read requests sent by the application run on the user equipment, and From described in the Slave Node extractions in the cluster read requests point to data, and by the data extracted to The user equipment is sent, and the read-only route is bound the Slave nodes in the cluster and configured in the collection On Slave nodes in group;
    Load equalizer, it is described for monitoring the more new state of all Slave nodes in one subregion Load equalizer configuration is on the Slave nodes in one subregion;It is and all in the subregion of place Each Slave nodes in subregion where the more new states of Slave nodes judges whether failure;
    The load equalizer, the loading condition of the read-only route according to one subregion is additionally operable to, in institute State and asynchronous Slave nodes are set up in a subregion, and from the Master nodes of one subregion to described asynchronous Slave nodes transmit data by the way of asynchronous replication.
  10. 10. Database Systems according to claim 8 or claim 9, it is characterised in that also include:
    Fault management module, for when the Master node failures in a subregion, detecting one subregion In number of nodes whether be more than 2;If so, the Slave nodes in one subregion are then upgraded into Master Node, and by the compensation data of Slave nodes all in one subregion to last state, it is described newest The Master nodes that state refers in one subregion complete data mode after finishing touch affairs before failure, its In, the time-out time of one zone configuration is more than or equal to max-thresholds, and the time-out time is judgement institute The time parameter whether the Slave nodes in a subregion degrade is stated, if the Slave in one subregion Node degrades, then same by half from the Master nodes of one subregion to the mode of Slave node-node transmission data Step duplication deteriorates to asynchronous replication;
    The fault management module, is additionally operable to detect the number of nodes of each subregion in the cluster, and screens non- Method subregion, wherein, the number of nodes of the illegal subregion is less than or equal to specified quantity;And distribution is discharged to institute State the resource of illegal subregion.
CN201610312657.0A 2016-05-12 2016-05-12 The management method and Database Systems of a kind of database Pending CN107368485A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610312657.0A CN107368485A (en) 2016-05-12 2016-05-12 The management method and Database Systems of a kind of database

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610312657.0A CN107368485A (en) 2016-05-12 2016-05-12 The management method and Database Systems of a kind of database

Publications (1)

Publication Number Publication Date
CN107368485A true CN107368485A (en) 2017-11-21

Family

ID=60304565

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610312657.0A Pending CN107368485A (en) 2016-05-12 2016-05-12 The management method and Database Systems of a kind of database

Country Status (1)

Country Link
CN (1) CN107368485A (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108959604A (en) * 2018-07-13 2018-12-07 浙江彩虹鱼科技有限公司 Safeguard the method, apparatus and computer readable storage medium of data-base cluster
CN108984602A (en) * 2018-06-05 2018-12-11 网易(杭州)网络有限公司 A kind of database control method and Database Systems
CN110413686A (en) * 2019-04-26 2019-11-05 财付通支付科技有限公司 A kind of method for writing data, device, equipment and storage medium
CN110955382A (en) * 2018-09-26 2020-04-03 华为技术有限公司 Method and device for writing data in distributed system
CN111209130A (en) * 2019-12-27 2020-05-29 中国建设银行股份有限公司 MySQL master-slave replication cluster-based fault processing method, system, device and medium
CN113326251A (en) * 2021-06-25 2021-08-31 深信服科技股份有限公司 Data management method, system, device and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102955851A (en) * 2012-10-30 2013-03-06 北京奇虎科技有限公司 Database switching method and device
CN103412860A (en) * 2012-10-25 2013-11-27 华为技术有限公司 Method and device for extending database and database system
CN104036043A (en) * 2014-07-01 2014-09-10 浪潮(北京)电子信息产业有限公司 High availability method of MYSQL and managing node
CN104394142A (en) * 2014-11-24 2015-03-04 北京京东尚科信息技术有限公司 Method and device for achieving automatic Redis master-slave conversion

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103412860A (en) * 2012-10-25 2013-11-27 华为技术有限公司 Method and device for extending database and database system
CN102955851A (en) * 2012-10-30 2013-03-06 北京奇虎科技有限公司 Database switching method and device
CN104036043A (en) * 2014-07-01 2014-09-10 浪潮(北京)电子信息产业有限公司 High availability method of MYSQL and managing node
CN104394142A (en) * 2014-11-24 2015-03-04 北京京东尚科信息技术有限公司 Method and device for achieving automatic Redis master-slave conversion

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
张伟丽 等: ""MySQL复制技术的研究及应用"", 《计算机科学》 *
田关伟: ""MySQL复制技术分析研究"", 《哈尔滨师范大学自然科学学报》 *
赵鹏飞: ""利用DRBD和Pacemaker技术构建高可用数据容灾备份系统"", 《甘肃科技纵横》 *

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108984602A (en) * 2018-06-05 2018-12-11 网易(杭州)网络有限公司 A kind of database control method and Database Systems
CN108984602B (en) * 2018-06-05 2021-04-16 网易(杭州)网络有限公司 Database control method and database system
CN108959604A (en) * 2018-07-13 2018-12-07 浙江彩虹鱼科技有限公司 Safeguard the method, apparatus and computer readable storage medium of data-base cluster
CN108959604B (en) * 2018-07-13 2020-11-10 浙江彩虹鱼科技有限公司 Method, apparatus and computer readable storage medium for maintaining database cluster
CN110955382A (en) * 2018-09-26 2020-04-03 华为技术有限公司 Method and device for writing data in distributed system
CN110413686A (en) * 2019-04-26 2019-11-05 财付通支付科技有限公司 A kind of method for writing data, device, equipment and storage medium
CN110413686B (en) * 2019-04-26 2024-02-13 财付通支付科技有限公司 Data writing method, device, equipment and storage medium
CN111209130A (en) * 2019-12-27 2020-05-29 中国建设银行股份有限公司 MySQL master-slave replication cluster-based fault processing method, system, device and medium
CN111209130B (en) * 2019-12-27 2023-12-29 中国建设银行股份有限公司 Fault processing method, system, equipment and medium based on MySQL master-slave replication cluster
CN113326251A (en) * 2021-06-25 2021-08-31 深信服科技股份有限公司 Data management method, system, device and storage medium
CN113326251B (en) * 2021-06-25 2024-02-23 深信服科技股份有限公司 Data management method, system, device and storage medium

Similar Documents

Publication Publication Date Title
CN107368485A (en) The management method and Database Systems of a kind of database
CN106341454B (en) Across computer room distributed data base management system (DDBMS) mostly living and method
CN106775959B (en) distributed transaction processing method and system
CN109729129B (en) Configuration modification method of storage cluster system, storage cluster and computer system
DE602004005344T2 (en) METHOD, SYSTEM AND PROGRAM FOR HANDLING A FAILOVER TO A REMOTE MEMORY
US7640451B2 (en) Failover processing in a storage system
CN101578586B (en) Using virtual copies in a failover and failback environment
JP5102901B2 (en) Method and system for maintaining data integrity between multiple data servers across a data center
CN105406980B (en) A kind of multinode backup method and device
CN102088490B (en) Data storage method, device and system
CN103777897A (en) Method and system for copying data between primary and secondary storage locations
CN110807064B (en) Data recovery device in RAC distributed database cluster system
CN103647668A (en) Host group decision system in high availability cluster and switching method for host group decision system
CN108153622A (en) The method, apparatus and equipment of a kind of troubleshooting
CN103885854A (en) Data backup method, data backup device and data backup system
CN103118093A (en) Large-scale distributed network examination method based on multi-level cache
CN106484565A (en) Method of data synchronization between multiple data centers and relevant device
CN107506266A (en) A kind of data reconstruction method and system
CN110209526A (en) A kind of accumulation layer synchronization system and storage medium
CN110348826A (en) Strange land disaster recovery method, system, equipment and readable storage medium storing program for executing mostly living
WO2021115043A1 (en) Distributed database system and data disaster backup drilling method
CN104794026B (en) A kind of failover method of cluster instance multi-data source binding
CN111309515B (en) Disaster recovery control method, device and system
CN107181608A (en) A kind of method and operation management system for recovering service and performance boost
KR101513943B1 (en) Method and system for operating management of real-time replicated database

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20171121

RJ01 Rejection of invention patent application after publication