CN108984569A - Database switching method, system and computer readable storage medium - Google Patents
Database switching method, system and computer readable storage medium Download PDFInfo
- Publication number
- CN108984569A CN108984569A CN201710413201.8A CN201710413201A CN108984569A CN 108984569 A CN108984569 A CN 108984569A CN 201710413201 A CN201710413201 A CN 201710413201A CN 108984569 A CN108984569 A CN 108984569A
- Authority
- CN
- China
- Prior art keywords
- database
- primary database
- primary
- node
- log information
- 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
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/14—Error detection or correction of the data by redundancy in operation
- G06F11/1402—Saving, restoring, recovering or retrying
- G06F11/1446—Point-in-time backing up or restoration of persistent data
- G06F11/1458—Management of the backup or restore process
- G06F11/1469—Backup restoration techniques
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/14—Error detection or correction of the data by redundancy in operation
- G06F11/1402—Saving, restoring, recovering or retrying
- G06F11/1471—Saving, restoring, recovering or retrying involving logging of persistent data for recovery
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Quality & Reliability (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
- Hardware Redundancy (AREA)
Abstract
The invention discloses a kind of database switching method, system and computer readable storage medium, database switching method includes: that the state of primary database is obtained from the corresponding resource manager of primary database in the node of distributed data base;When the normal condition of primary database can not be obtained, the log information of primary database is obtained;According to the log information of primary database, to one or more of node from database complement evidence;One is selected as new primary database, using primary database as newly from database from one or more from database;Into node, all resource managers issue the request for updating master-slave relationship.According to the present invention, the state of each node of distributed data base is detected to be abnormal in time, and according to the log information of primary database to after database synchronization, it selects from database as new primary database, it is consistent with the data of new primary database to ensure former primary database, to safeguard normal master-slave relationship in distributed data base.
Description
Technical field
The present invention relates to field of computer technology more particularly to a kind of database switching methods, system and computer-readable
Storage medium.
Background technique
A large amount of dispersed nodes involved in distributed data base, once some node breaks down, it will influencing affairs just
It often executes, therefore needs enough to quickly find suitable database instance as new host to carry this when node occurs abnormal
The affairs of node.
Distributed experiment & measurement system is divided into two kinds of situations in handle node failures at present:
1) if proxy server does not have delay machine and database instance delay machine, the log information of former primary database example is covered
It covers from database, then will be switched to primary database from database.
2) if proxy server and database instance all delay machines, directly will be switched to primary database from database.
Both master-slave swap modes suffer from apparent limitation:
1) it can not reliably guarantee the data consistency of new and old primary database.In the first way, by former primary database
Log information covers after database, does not test to the data of former primary database and new primary database, if covering
Occur exception in the process, cannot reliably guarantee that former primary database is consistent with the data of new primary database.In the second way,
To directly be switched to primary database from database, former primary database with when may switch from database with regard to inconsistent, so also not
It can guarantee that former primary database is consistent with the data of new primary database.
2) it is abnormal that database principal and subordinate role can not be handled.Only in the case where proxy server or database delay machine
It will do it master-slave swap, abnormal in case of database principal and subordinate role, principal and subordinate's data can not be synchronized, may be further resulted in subsequent
Master-slave swap data are inconsistent.
Summary of the invention
The purpose of the present invention is to provide a kind of database switching method, system and computer readable storage medium, with
When being abnormal in distributed data base, switch master-slave database, and ensure the data one of former primary database and new primary database
Cause property simultaneously safeguards normal master-slave relationship.
It is as follows that the present invention solves technical solution used by above-mentioned technical problem:
A kind of database switching method provided, the database switching method includes: the node in distributed data base
In, the state of the primary database is obtained from the corresponding resource manager of the primary database;Primary database can not obtained
When normal condition, the log information of the primary database is obtained;According to the log information of the primary database, in the node
It is one or more from database complement evidence;One is selected as new primary database from database from one or more of, is incited somebody to action
The primary database is as newly from database;Into the node, all resource managers issue the request for updating master-slave relationship.
Optionally, database switching method above-mentioned, it is described when the normal condition of primary database can not be obtained, obtain institute
The step of stating the log information of primary database, comprising: when getting the abnormality of the primary database, from the master data
The corresponding resource manager in library obtains the log information of the primary database.
Optionally, database switching method above-mentioned, it is described when the normal condition of primary database can not be obtained, obtain institute
The step of stating the log information of primary database, comprising: described that can not be obtained from the corresponding resource manager of the primary database
When the state of primary database, the log information of the primary database backed up is obtained from preset log server.
Optionally, database switching method above-mentioned, it is described from it is one or more of from database select one as
The step of new primary database, comprising: calculate one or more of degree of consistency from database and the primary database, root
According to the height of the degree of consistency select one as the new primary database.
Optionally, database switching method above-mentioned is issued in the resource managers all into the node and is updated
After the step of request of master-slave relationship, further includes: notify the master-slave relationship to meta data server.
Optionally, database switching method above-mentioned is obtained described when that can not obtain the normal condition of primary database
Before the step of log information of the primary database, further includes: the node is no longer received new business information notify to
Proxy server;After described the step of notifying the master-slave relationship to meta data server, further includes: by the node
The information for receiving new business is notified to proxy server;
A kind of database switching system provided, the database switching system include that processor, memory and communication are total
Line;The communication bus is for realizing the connection communication between processor and memory;The processor is for executing memory
The database changeover program of middle storage, to perform the steps of in the node of distributed data base, from the primary database pair
The resource manager answered obtains the state of the primary database;When the normal condition of primary database can not be obtained, described in acquisition
The log information of primary database;According to the log information of the primary database, to one or more of described node from data
Library complement evidence;One is selected as new primary database, using the primary database as new from database from one or more of
From database;Into the node, all resource managers issue the request for updating master-slave relationship.
Optionally, database switching system above-mentioned is obtained described when that can not obtain the normal condition of primary database
In the step of log information of the primary database, the processor executes the database changeover program stored in memory, with
It performs the steps of when getting the abnormality of the primary database, from the corresponding resource manager of the primary database
Obtain the log information of the primary database.
Optionally, database switching system above-mentioned is obtained described when that can not obtain the normal condition of primary database
In the step of log information of the primary database, the processor executes the database changeover program stored in memory, with
It performs the steps of when the state of the primary database can not be obtained from the corresponding resource manager of the primary database, from
Preset log server obtains the log information of the primary database backed up.
A kind of computer readable storage medium provided, the computer-readable recording medium storage have one or more
Program, one or more of programs can be executed by one or more processor, to realize following database as the aforementioned
The step of switching method.
According to above technical scheme, it is known that database switching method, system and computer readable storage medium of the invention
It has at least the following advantages:
In the inventive solutions, the state of each node of distributed data base is detected to be abnormal in time, and
According to the log information of primary database to after database synchronization, selecting from database as new primary database, it is ensured that original is main
Database is consistent with the data of new primary database, and all resource managers are issued with the request of change master-slave relationship, thus
Safeguard normal master-slave relationship in distributed data base.
Detailed description of the invention
Fig. 1 is a kind of flow chart of database switching method of the embodiment of the present invention;
Fig. 2 is a kind of schematic diagram of database switching method of the embodiment of the present invention;
Fig. 3 is a kind of flow chart of database switching method of the embodiment of the present invention;
Fig. 4 is a kind of flow chart of database switching method of the embodiment of the present invention;
Fig. 5 is a kind of flow chart of database switching method of the embodiment of the present invention;
Fig. 6 is a kind of flow chart of database switching method of the embodiment of the present invention;
Fig. 7 is a kind of block diagram of database switching system of the embodiment of the present invention;
Fig. 8 is a kind of block diagram of calculating section readable storage medium storing program for executing of the embodiment of the present invention.
The embodiments will be further described with reference to the accompanying drawings for the realization, the function and the advantages of the object of the present invention.
Specific embodiment
In order to be clearer and more clear technical problems, technical solutions and advantages to be solved, tie below
Drawings and examples are closed, the present invention will be described in further detail.It should be appreciated that specific embodiment described herein is only
To explain the present invention, it is not intended to limit the present invention.
Embodiment one
As shown in Figure 1, a kind of database switching method provided in one embodiment of the present of invention, the data of the present embodiment
Library switching method includes:
Step S110 obtains master data from the corresponding resource manager of primary database in the node of distributed data base
The state in library.
Technical solution in the present embodiment can realize on the cluster manager dual system in distributed data, distributed data base
Structure it is as shown in Figure 2:
1, cluster manager dual system: upper-layer service is received to the association requests of distributed experiment & measurement system, to distributed data base
Cluster is managed, and the database positioning for coordinating resource manager reports, and notice resource manager is switched over, backed up and again
The order such as distribution.
2, resource manager.It is in response to upper layer request and answers database usually as the upper layer proxy of database
The local data base monitoring programme of miscellaneous operation.In the technical scheme of this embodiment, its main function is in response to cluster management
The redistribution of device is requested, and redistribution process is executed.
3, database.It is the fundamental node for saving data.In the technical scheme of this embodiment, only resource manager
It is interacted with it.
4, proxy server.It is that upper layer executes DDL (Data Definition Language, Data Definition Language) language
The component of sentence, is directly written and read database.
5. meta data server.It is the middleware for connecting cluster manager dual system and user interface, is responsible for turning for upper layer request
The preservation of hair and all metadata.
6.Binlog server.That is log server, it and primary database synchronization log file, primary resource management in node
The machine journal file is backuped to the server by device, when master resource manager delay machine, from database from the server complement evidence.
Step S120 obtains the log information of primary database when that can not obtain the normal condition of primary database.
In the present embodiment, the case where can not obtaining the normal condition of primary database, includes but is not limited to: primary database hair
Raw failure, corresponding resource manager return to the state of master data exception;The corresponding resource manager failure of primary database, does not return
Any data.
In the present embodiment, resource manager periodically reports the state of current database to cluster manager dual system, once cluster
Manager receives the report of node primary database abnormal state or cluster manager dual system continues not receive node master in a period of time
The heartbeat message that resource manager reports, then cluster manager dual system checks whether the node there are available from database, if deposited
Available from database, then cluster manager dual system prepares to initiate failure master-slave swap.
Alternatively, cluster manager dual system is quasi- when the Role Information of its role of data report and cluster manager dual system maintenance are inconsistent
Preparation plays role's master-slave swap.
Step S130, according to the log information of primary database, to one or more of node from database complement evidence.
In the present embodiment, cluster manager dual system obtains the log information of all databases of the node, and provides a kind of basis
The method of log information complement evidence:
The first step sets the format comprising the date for the title of journal file when generating journal file.
Second step, in complement before, until obtaining the starting position i and end position j of complement evidence and journal file
Path.
Journal file is sorted by date third step, scans the pervious (upper one recorded in file header from the near to the distant
It is a) position, until the position found is not more than the journal file of specified starting position, i.e. pervious≤i.
4th step is scanned since the journal file found, generates the sql sentence from i+1 to j.If not specifying j,
Scan the last one position of newest journal file.
5th step rolls data before executing the sql sentence of generation, and complement is according to completion.
Step S140 selects one as new primary database, using primary database as new from one or more from database
From database.
Step S150, into node, all resource managers issue the request for updating master-slave relationship.
In the present embodiment, cluster manager dual system available issues benefit data command, Ge Gezi from resource manager to each
Source manager complement ensure accordingly it is consistent with former master data from data, to cluster manager dual system report complement according to as a result, collection after completion
Group's manager chooses complement evidence successfully from as new master, issues the request of switching master-slave database.
According to the technical solution of the present embodiment, the state of each node of distributed data base is detected to be abnormal in time,
And according to the log information of primary database to after database synchronization, selecting from database as new primary database, it is ensured that former
Primary database is consistent with the data of new primary database, and all resource managers are issued with the request of change master-slave relationship, from
And safeguard normal master-slave relationship in distributed data base.
Embodiment two
As shown in figure 3, a kind of database switching method provided in one embodiment of the present of invention, the data of the present embodiment
Library switching method includes:
Step S310 obtains master data from the corresponding resource manager of primary database in the node of distributed data base
The state in library.
Step S320, the information that node is no longer received to new business are notified to proxy server.
Step S330 is obtained in the abnormality for getting primary database from the corresponding resource manager of primary database
The log information of primary database.
In the present embodiment, cluster manager dual system is after confirmation proxy server successfully stops malfunctioning node server, to each
A resource manager obtains its database journal information managed, and log is believed after playing back in resource manager pending data library
Breath is sent to cluster manager dual system, and cluster manager dual system preserves the log information of each database.
Step S340, according to the log information of primary database, to one or more of node from database complement evidence.
In the present embodiment, cluster manager dual system checks the state of former master resource manager, if former master resource manager is just
Often database delay machine, then cluster manager dual system issues benefit request of data to former master resource manager, and former master resource manager utilizes
The primary database log information and the log information of itself of acquisition, remaining is synchronous with primary database from the data of database.
Step S350 calculates one or more degree of consistency from database and primary database, according to the degree of consistency
Height select one as new primary database.
In the present embodiment, cluster manager dual system is by complement according to the new primary database for being successfully set as candidate from database.
If under High Availabitity mode, by all available databases be set as candidate new primary database and by with former master data number
It sorts according to consistency degree of closeness.Database identical for the degree of consistency, then according to ip (agreement interconnected between network)
It is worth ascending sequence sequence, selects new primary database until successful from primary database is switched in order.
Step S360, into node, all resource managers issue the request for updating master-slave relationship.
In the present embodiment, after new primary database handover success, cluster manager dual system updates master-slave relationship information, meanwhile,
All available resource managers are sent and establish new master-slave relationship request, to cluster manager dual system report after resource manager completion
Accuse result.
Step S370, master-slave relationship is notified to meta data server.
In the present embodiment, after receiving all resource manager implementing results, cluster manager dual system is to meta data server
Report new master-slave relationship information, meta data server is preserved.
Step S380 notifies the information that node receives new business to proxy server.
In the present embodiment, the cluster manager dual system notification agent server node can accept business, and by present node
Primary database notification agent server.
One specific example of the present embodiment technical solution is as shown in Figure 4:
It include tri- databases of A, B, C and its corresponding resource manager assuming that some node in existing cluster,
Middle A is primary database, and B, C are from database.
After cluster manager dual system, which receives A resource manager, reports the message of its database failure, cluster manager dual system checks each
A state from database, if in good condition, cluster manager dual system initiates the request of failure master-slave swap.
Cluster manager dual system notification agent server node first rejects new business.
After previous step success, cluster manager dual system initiates to obtain the request of log information to each resource manager A, B, C,
The response as much as possible for collecting each resource manager.
If before the timeout, having received the response that resource manager obtains log information, cluster manager dual system requests resource
Slave database complement evidence of the manager A to all success responses of previous step, the result of cluster manager dual system waiting complement evidence.
If complement successfully sets candidate new main B, C from database for complement evidence according to success, cluster manager dual system.Successively
It selects new primary database to switch successfully until new primary database, updates master-slave relationship later.
The master-slave relationship information for notifying meta data server new.
The current primary database of the notification agent server node, the node starts request of accepting business if available,
The node is offline if unavailable.
Embodiment three
As shown in figure 5, a kind of database switching method provided in one embodiment of the present of invention, the data of the present embodiment
Library switching method includes:
Step S510 obtains master data from the corresponding resource manager of primary database in the node of distributed data base
The state in library.
Step S520, the information that node is no longer received to new business are notified to proxy server.
Step S530, when the state of primary database can not be obtained from the corresponding resource manager of primary database, from default
Log server obtain the log information of primary database backed up.
In the present embodiment, if former master resource manager delay machine, cluster manager dual system is to each under resource manager
Hair mends request of data, each to utilize the log information synchrodata stored on binlog server from resource manager.Complement evidence
After, former master resource manager or each from resource manager to the result of cluster manager dual system report complement evidence.
Step S540, according to the log information of primary database, to one or more of node from database complement evidence.
Step S550 calculates one or more degree of consistency from database and primary database, according to the degree of consistency
Height select one as new primary database.
Step S560, into node, all resource managers issue the request for updating master-slave relationship.
Step S570, master-slave relationship is notified to meta data server.
Step S580 notifies the information that node receives new business to proxy server.
One specific example of the present embodiment technical solution is as shown in Figure 6:
Cluster manager dual system detects all states from database of present node first, including state it is whether normal, whether save
Point is carrying out master-slave swap.If there is available from database, then cluster manager dual system notification agent server node
It does not accept business request.
Log information from cluster manager dual system to all resource manager A, B, C request databases, if former primary resource
Manager is unavailable, then only obtain it is available from log information.
Get from log information after, if former master resource manager is unavailable, cluster manager dual system is one step up
The slave database request of middle success response passes through binlog server complement evidence from binlog server complement evidence, i.e. B, C.
If complement is according to success, cluster manager dual system is by complement according to successfully from database by ip sequence, it is assumed that puts in order
For C, B.C is selected first as new main, if C is switched to new main success, change A, B be from.If C handover failure, again
B is selected as new main, if B is switched to new main success, change A, C be from.The new master switched successfully if there is one, then
To other available requests for establishing new master-slave relationship from resource manager transmission.
Notify the master-slave relationship information of the current node of meta data server.
Last notification agent server is accepted business in the node in new Your Majesty.If there is no any one handover success
New master, then active-standby switch fails, which does not accept business.
The technical solution of the present embodiment is compared to distributed data base failure master-slave swap scheme at this stage, beneficial effect
The several aspects of major embodiment:
1, adaptability is more extensive.Using configurable mode, it was not only able to satisfy highly reliable requirement, but also being able to satisfy height can
Use occasion.Under highly reliable mode, it can ensure that all new primary databases are consistent with former primary database, if without one
The slave database caused, then it is the node is offline.It is new according to being selected with former master data consistency degree of closeness under High Availabitity mode
It is main.Two kinds of configuration modes can satisfy major applications occasion needs, use more flexible.
2, guarantee the reliability and maintainability of distributed data base.The program can ensure that the master of each database in node
It is consistent with meta data server from relationship, whole system high reliablity.Meanwhile the program can dynamically additions and deletions from database,
Facilitate the dilatation of system.
3, guarantee the safety and precise of data.By complement according to guaranteeing that host data is rear consistent before the handover, differentiation is avoided
binlog。
4, it is compared with traditional pure covering journal file, which only needs according to all journal files of copy are not had to
The data of polishing missing, it is more efficient.
Example IV
As shown in fig. 7, a kind of database switching system provided in one embodiment of the present of invention, the data of the present embodiment
Library switching system includes processor 710, memory 720 and communication bus 730;Communication bus 730 is for realizing 710 He of processor
Connection communication between memory 720;Processor 710 is used to execute the Transaction Identifier operation sequence stored in memory 720, with
It performs the steps of
In the node of distributed data base, the state of primary database is obtained from the corresponding resource manager of primary database.
Technical solution in the present embodiment can realize on the cluster manager dual system in distributed data, distributed data base
Structure it is as shown in Figure 2:
1, cluster manager dual system: upper-layer service is received to the association requests of distributed experiment & measurement system, to distributed data base
Cluster is managed, and the database positioning for coordinating resource manager reports, and notice resource manager is switched over, backed up and again
The order such as distribution.
2, resource manager.It is in response to upper layer request and answers database usually as the upper layer proxy of database
The local data base monitoring programme of miscellaneous operation.In the technical scheme of this embodiment, its main function is in response to cluster management
The redistribution of device is requested, and redistribution process is executed.
3, database.It is the fundamental node for saving data.In the technical scheme of this embodiment, only resource manager
It is interacted with it.
4, proxy server.It is that upper layer executes DDL (Data Definition Language, Data Definition Language) language
The component of sentence, is directly written and read database.
5. meta data server.It is the middleware for connecting cluster manager dual system and user interface, is responsible for turning for upper layer request
The preservation of hair and all metadata.
6.Binlog server.That is log server, it and primary database synchronization log file, primary resource management in node
The machine journal file is backuped to the server by device, when master resource manager delay machine, from database from the server complement evidence.
When the normal condition of primary database can not be obtained, the log information of primary database is obtained.
In the present embodiment, the case where can not obtaining the normal condition of primary database, includes but is not limited to: primary database hair
Raw failure, corresponding resource manager return to the state of master data exception;The corresponding resource manager failure of primary database, does not return
Any data.
In the present embodiment, resource manager periodically reports the state of current database to cluster manager dual system, once cluster
Manager receives the report of node primary database abnormal state or cluster manager dual system continues not receive node master in a period of time
The heartbeat message that resource manager reports, then cluster manager dual system checks whether the node there are available from database, if deposited
Available from database, then cluster manager dual system prepares to initiate failure master-slave swap.
Alternatively, cluster manager dual system is quasi- when the Role Information of its role of data report and cluster manager dual system maintenance are inconsistent
Preparation plays role's master-slave swap.
According to the log information of primary database, to one or more of node from database complement evidence.
In the present embodiment, cluster manager dual system obtains the log information of all databases of the node, and provides a kind of basis
The method of log information complement evidence:
The first step sets the format comprising the date for the title of journal file when generating journal file.
Second step, in complement before, until obtaining the starting position i and end position j of complement evidence and journal file
Path.
Journal file is sorted by date third step, scans the pervious (upper one recorded in file header from the near to the distant
It is a) position, until the position found is not more than the journal file of specified starting position, i.e. pervious≤i.
4th step is scanned since the journal file found, generates the sql sentence from i+1 to j.If not specifying j,
Scan the last one position of newest journal file.
5th step rolls data before executing the sql sentence of generation, and complement is according to completion.
One is selected as new primary database, using primary database as newly from database from one or more from database.
Into node, all resource managers issue the request for updating master-slave relationship.
In the present embodiment, cluster manager dual system available issues benefit data command, Ge Gezi from resource manager to each
Source manager complement ensure accordingly it is consistent with former master data from data, to cluster manager dual system report complement according to as a result, collection after completion
Group's manager chooses complement evidence successfully from as new master, issues the request of switching master-slave database.
According to the technical solution of the present embodiment, the state of each node of distributed data base is detected to be abnormal in time,
And according to the log information of primary database to after database synchronization, selecting from database as new primary database, it is ensured that former
Primary database is consistent with the data of new primary database, and all resource managers are issued with the request of change master-slave relationship, from
And safeguard normal master-slave relationship in distributed data base.
Embodiment five
As shown in figure 8, a kind of computer readable storage medium 810 provided in one embodiment of the present of invention, computer
Readable storage medium storing program for executing 810 is stored with one or more program 820, one or more program 820 can be by one or more
Processor 830 executes, to realize following step:
In the node of distributed data base, the state of primary database is obtained from the corresponding resource manager of primary database.
Technical solution in the present embodiment can realize on the cluster manager dual system in distributed data, distributed data base
Structure it is as shown in Figure 2:
1, cluster manager dual system: upper-layer service is received to the association requests of distributed experiment & measurement system, to distributed data base
Cluster is managed, and the database positioning for coordinating resource manager reports, and notice resource manager is switched over, backed up and again
The order such as distribution.
2, resource manager.It is in response to upper layer request and answers database usually as the upper layer proxy of database
The local data base monitoring programme of miscellaneous operation.In the technical scheme of this embodiment, its main function is in response to cluster management
The redistribution of device is requested, and redistribution process is executed.
3, database.It is the fundamental node for saving data.In the technical scheme of this embodiment, only resource manager
It is interacted with it.
4, proxy server.It is that upper layer executes DDL (Data Definition Language, Data Definition Language) language
The component of sentence, is directly written and read database.
5. meta data server.It is the middleware for connecting cluster manager dual system and user interface, is responsible for turning for upper layer request
The preservation of hair and all metadata.
6.Binlog server.That is log server, it and primary database synchronization log file, primary resource management in node
The machine journal file is backuped to the server by device, when master resource manager delay machine, from database from the server complement evidence.
When the normal condition of primary database can not be obtained, the log information of primary database is obtained.
In the present embodiment, the case where can not obtaining the normal condition of primary database, includes but is not limited to: primary database hair
Raw failure, corresponding resource manager return to the state of master data exception;The corresponding resource manager failure of primary database, does not return
Any data.
In the present embodiment, resource manager periodically reports the state of current database to cluster manager dual system, once cluster
Manager receives the report of node primary database abnormal state or cluster manager dual system continues not receive node master in a period of time
The heartbeat message that resource manager reports, then cluster manager dual system checks whether the node there are available from database, if deposited
Available from database, then cluster manager dual system prepares to initiate failure master-slave swap.
Alternatively, cluster manager dual system is quasi- when the Role Information of its role of data report and cluster manager dual system maintenance are inconsistent
Preparation plays role's master-slave swap.
According to the log information of primary database, to one or more of node from database complement evidence.
In the present embodiment, cluster manager dual system obtains the log information of all databases of the node, and provides a kind of basis
The method of log information complement evidence:
The first step sets the format comprising the date for the title of journal file when generating journal file.
Second step, in complement before, until obtaining the starting position i and end position j of complement evidence and journal file
Path.
Journal file is sorted by date third step, scans the pervious (upper one recorded in file header from the near to the distant
It is a) position, until the position found is not more than the journal file of specified starting position, i.e. pervious≤i.
4th step is scanned since the journal file found, generates the sql sentence from i+1 to j.If not specifying j,
Scan the last one position of newest journal file.
5th step rolls data before executing the sql sentence of generation, and complement is according to completion.
One is selected as new primary database, using primary database as newly from database from one or more from database.
Into node, all resource managers issue the request for updating master-slave relationship.
In the present embodiment, cluster manager dual system available issues benefit data command, Ge Gezi from resource manager to each
Source manager complement ensure accordingly it is consistent with former master data from data, to cluster manager dual system report complement according to as a result, collection after completion
Group's manager chooses complement evidence successfully from as new master, issues the request of switching master-slave database.
According to the technical solution of the present embodiment, the state of each node of distributed data base is detected to be abnormal in time,
And according to the log information of primary database to after database synchronization, selecting from database as new primary database, it is ensured that former
Primary database is consistent with the data of new primary database, and all resource managers are issued with the request of change master-slave relationship, from
And safeguard normal master-slave relationship in distributed data base.
Preferred embodiments of the present invention have been described above with reference to the accompanying drawings, not thereby limiting the scope of the invention.This
Without departing from the scope and spirit of the invention, there are many variations to implement the present invention by field technical staff, for example as one
The feature of a embodiment can be used for another embodiment and obtain another embodiment.It is all to use institute within technical concept of the invention
Any modifications, equivalent replacements, and improvements of work, should all be within interest field of the invention.
Claims (10)
1. a kind of database switching method, which is characterized in that the database switching method includes:
In the node of distributed data base, the shape of the primary database is obtained from the corresponding resource manager of the primary database
State;
When the normal condition of primary database can not be obtained, the log information of the primary database is obtained;
According to the log information of the primary database, to one or more of described node from database complement evidence;
One is selected as new primary database, using the primary database as newly from data from database from one or more of
Library;
Into the node, all resource managers issue the request for updating master-slave relationship.
2. database switching method according to claim 1, which is characterized in that described to obtain primary database just
When normal state, the step of obtaining the log information of the primary database, comprising:
When getting the abnormality of the primary database, the master is obtained from the corresponding resource manager of the primary database
The log information of database.
3. database switching method according to claim 1, which is characterized in that described to obtain primary database just
When normal state, the step of obtaining the log information of the primary database, comprising:
When the state of the primary database can not be obtained from the corresponding resource manager of the primary database, from preset log
Server obtains the log information of the primary database backed up.
4. database switching method according to claim 1, which is characterized in that described from one or more of from data
Library select one as new primary database the step of, comprising:
One or more of degree of consistency from database and the primary database are calculated, according to the degree of consistency
Height select one as the new primary database.
5. database switching method according to claim 1, which is characterized in that in the resources all into the node
Manager issued after the step of request for updating master-slave relationship, further includes:
The master-slave relationship is notified to meta data server.
6. database switching method according to claim 5, which is characterized in that primary database can not obtained described
When normal condition, before the step of obtaining the log information of the primary database, further includes:
The information that the node is no longer received to new business is notified to proxy server;
After described the step of notifying the master-slave relationship to meta data server, further includes:
The information that the node receives new business is notified to proxy server.
7. a kind of database switching system, which is characterized in that the database switching system includes processor, memory and communication
Bus;
The communication bus is for realizing the connection communication between processor and memory;
The processor is for executing the database changeover program stored in memory, to perform the steps of
In the node of distributed data base, the shape of the primary database is obtained from the corresponding resource manager of the primary database
State;
When the normal condition of primary database can not be obtained, the log information of the primary database is obtained;
According to the log information of the primary database, to one or more of described node from database complement evidence;
One is selected as new primary database, using the primary database as newly from data from database from one or more of
Library;
Into the node, all resource managers issue the request for updating master-slave relationship.
8. database switching system according to claim 7, which is characterized in that primary database can not obtained described
When normal condition, in the step of obtaining the log information of the primary database, the processor executes the number stored in memory
According to library changeover program, to perform the steps of
When getting the abnormality of the primary database, the master is obtained from the corresponding resource manager of the primary database
The log information of database.
9. database switching system according to claim 7, which is characterized in that primary database can not obtained described
When normal condition, in the step of obtaining the log information of the primary database, the processor executes the number stored in memory
According to library changeover program, to perform the steps of
When the state of the primary database can not be obtained from the corresponding resource manager of the primary database, from preset log
Server obtains the log information of the primary database backed up.
10. a kind of computer readable storage medium, which is characterized in that the computer-readable recording medium storage have one or
Multiple programs, one or more of programs can be executed by one or more processor, following such as claim 1 to realize
To any one of 6 database switching method the step of.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710413201.8A CN108984569A (en) | 2017-06-05 | 2017-06-05 | Database switching method, system and computer readable storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710413201.8A CN108984569A (en) | 2017-06-05 | 2017-06-05 | Database switching method, system and computer readable storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN108984569A true CN108984569A (en) | 2018-12-11 |
Family
ID=64501965
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710413201.8A Pending CN108984569A (en) | 2017-06-05 | 2017-06-05 | Database switching method, system and computer readable storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108984569A (en) |
Cited By (21)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109376174A (en) * | 2018-12-30 | 2019-02-22 | 北京奇艺世纪科技有限公司 | A kind of method and apparatus selecting database |
CN110069365A (en) * | 2019-04-26 | 2019-07-30 | 腾讯科技(深圳)有限公司 | Manage the method and corresponding device, computer readable storage medium of database |
CN110166524A (en) * | 2019-04-12 | 2019-08-23 | 陆金所(上海)科技服务有限公司 | Switching method, device, equipment and the storage medium of data center |
CN110442650A (en) * | 2019-08-09 | 2019-11-12 | 中国工商银行股份有限公司 | Database switching method, device, system, electronic equipment and storage medium |
CN110825763A (en) * | 2020-01-08 | 2020-02-21 | 上海爱可生信息技术股份有限公司 | MySQL database high-availability system based on shared storage and high-availability method thereof |
CN110955647A (en) * | 2019-12-04 | 2020-04-03 | 世纪龙信息网络有限责任公司 | Database assistance method, database assistance device, computer equipment and storage medium |
CN111400285A (en) * | 2020-03-25 | 2020-07-10 | 杭州浮云网络科技有限公司 | MySQ L data fragment processing method, apparatus, computer device and readable storage medium |
CN111581287A (en) * | 2020-05-07 | 2020-08-25 | 上海茂声智能科技有限公司 | Control method, system and storage medium for database management |
CN111723066A (en) * | 2020-05-08 | 2020-09-29 | 武汉达梦数据库有限公司 | Database switching method and database switching system based on log analysis synchronization |
CN111949726A (en) * | 2020-06-07 | 2020-11-17 | 中信银行股份有限公司 | Relational database synchronization method and system based on block chain |
CN112015595A (en) * | 2020-08-28 | 2020-12-01 | 掌阅科技股份有限公司 | Master-slave database switching method, computing device and storage medium |
CN112214551A (en) * | 2020-10-22 | 2021-01-12 | 微医云(杭州)控股有限公司 | Data synchronization method, system, device, electronic equipment and storage medium |
CN112463448A (en) * | 2020-11-27 | 2021-03-09 | 苏州浪潮智能科技有限公司 | Distributed cluster database synchronization method, device, equipment and storage medium |
CN112636990A (en) * | 2020-12-31 | 2021-04-09 | 中国电子科技集团公司第十四研究所 | Resource management system |
CN113254536A (en) * | 2021-06-09 | 2021-08-13 | 蚂蚁金服(杭州)网络技术有限公司 | Database transaction processing method, system, electronic device and storage medium |
CN113515574A (en) * | 2021-05-17 | 2021-10-19 | 聚好看科技股份有限公司 | Data synchronization method and device |
CN113868022A (en) * | 2021-09-18 | 2021-12-31 | 聚好看科技股份有限公司 | Master-slave switching method and device for database |
CN114201549A (en) * | 2020-09-17 | 2022-03-18 | 金篆信科有限责任公司 | Switching method, system, server and storage medium |
CN114661827A (en) * | 2022-05-23 | 2022-06-24 | 武汉四通信息服务有限公司 | Database taking-over method and device, electronic equipment and storage medium |
WO2022142665A1 (en) * | 2020-12-28 | 2022-07-07 | 深圳壹账通智能科技有限公司 | Database cluster-based data processing method and apparatus, and electronic device |
CN116431397A (en) * | 2023-06-13 | 2023-07-14 | 北京中实信息技术有限公司 | Main and auxiliary node switching system of server |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103425645A (en) * | 2012-05-14 | 2013-12-04 | 阿里巴巴集团控股有限公司 | Monitoring system and monitoring method for single point of failure of database cluster |
WO2016173179A1 (en) * | 2015-04-29 | 2016-11-03 | 中兴通讯股份有限公司 | Method and device for switching primary database and secondary database |
CN106126652A (en) * | 2016-06-24 | 2016-11-16 | 武汉斗鱼网络科技有限公司 | Mishap Database changing method and system for distributed experiment & measurement system |
CN106254100A (en) * | 2016-07-27 | 2016-12-21 | 腾讯科技(深圳)有限公司 | A kind of data disaster tolerance methods, devices and systems |
-
2017
- 2017-06-05 CN CN201710413201.8A patent/CN108984569A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103425645A (en) * | 2012-05-14 | 2013-12-04 | 阿里巴巴集团控股有限公司 | Monitoring system and monitoring method for single point of failure of database cluster |
WO2016173179A1 (en) * | 2015-04-29 | 2016-11-03 | 中兴通讯股份有限公司 | Method and device for switching primary database and secondary database |
CN106126652A (en) * | 2016-06-24 | 2016-11-16 | 武汉斗鱼网络科技有限公司 | Mishap Database changing method and system for distributed experiment & measurement system |
CN106254100A (en) * | 2016-07-27 | 2016-12-21 | 腾讯科技(深圳)有限公司 | A kind of data disaster tolerance methods, devices and systems |
Cited By (28)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109376174A (en) * | 2018-12-30 | 2019-02-22 | 北京奇艺世纪科技有限公司 | A kind of method and apparatus selecting database |
CN110166524A (en) * | 2019-04-12 | 2019-08-23 | 陆金所(上海)科技服务有限公司 | Switching method, device, equipment and the storage medium of data center |
CN110069365A (en) * | 2019-04-26 | 2019-07-30 | 腾讯科技(深圳)有限公司 | Manage the method and corresponding device, computer readable storage medium of database |
CN110442650A (en) * | 2019-08-09 | 2019-11-12 | 中国工商银行股份有限公司 | Database switching method, device, system, electronic equipment and storage medium |
CN110955647A (en) * | 2019-12-04 | 2020-04-03 | 世纪龙信息网络有限责任公司 | Database assistance method, database assistance device, computer equipment and storage medium |
CN110825763A (en) * | 2020-01-08 | 2020-02-21 | 上海爱可生信息技术股份有限公司 | MySQL database high-availability system based on shared storage and high-availability method thereof |
CN110825763B (en) * | 2020-01-08 | 2020-05-19 | 上海爱可生信息技术股份有限公司 | MySQL database high-availability system based on shared storage and high-availability method thereof |
CN111400285A (en) * | 2020-03-25 | 2020-07-10 | 杭州浮云网络科技有限公司 | MySQ L data fragment processing method, apparatus, computer device and readable storage medium |
CN111400285B (en) * | 2020-03-25 | 2023-06-20 | 杭州浮云网络科技有限公司 | mySQL data fragment processing method, device, computer equipment and readable storage medium |
CN111581287A (en) * | 2020-05-07 | 2020-08-25 | 上海茂声智能科技有限公司 | Control method, system and storage medium for database management |
CN111723066A (en) * | 2020-05-08 | 2020-09-29 | 武汉达梦数据库有限公司 | Database switching method and database switching system based on log analysis synchronization |
CN111949726A (en) * | 2020-06-07 | 2020-11-17 | 中信银行股份有限公司 | Relational database synchronization method and system based on block chain |
CN112015595A (en) * | 2020-08-28 | 2020-12-01 | 掌阅科技股份有限公司 | Master-slave database switching method, computing device and storage medium |
CN112015595B (en) * | 2020-08-28 | 2021-03-02 | 掌阅科技股份有限公司 | Master-slave database switching method, computing device and storage medium |
CN114201549A (en) * | 2020-09-17 | 2022-03-18 | 金篆信科有限责任公司 | Switching method, system, server and storage medium |
CN114201549B (en) * | 2020-09-17 | 2022-11-25 | 金篆信科有限责任公司 | Switching method, system, server and storage medium |
CN112214551A (en) * | 2020-10-22 | 2021-01-12 | 微医云(杭州)控股有限公司 | Data synchronization method, system, device, electronic equipment and storage medium |
CN112463448A (en) * | 2020-11-27 | 2021-03-09 | 苏州浪潮智能科技有限公司 | Distributed cluster database synchronization method, device, equipment and storage medium |
CN112463448B (en) * | 2020-11-27 | 2022-06-07 | 苏州浪潮智能科技有限公司 | Distributed cluster database synchronization method, device, equipment and storage medium |
WO2022142665A1 (en) * | 2020-12-28 | 2022-07-07 | 深圳壹账通智能科技有限公司 | Database cluster-based data processing method and apparatus, and electronic device |
CN112636990A (en) * | 2020-12-31 | 2021-04-09 | 中国电子科技集团公司第十四研究所 | Resource management system |
CN113515574A (en) * | 2021-05-17 | 2021-10-19 | 聚好看科技股份有限公司 | Data synchronization method and device |
CN113515574B (en) * | 2021-05-17 | 2023-05-19 | 聚好看科技股份有限公司 | Data synchronization method and device |
CN113254536A (en) * | 2021-06-09 | 2021-08-13 | 蚂蚁金服(杭州)网络技术有限公司 | Database transaction processing method, system, electronic device and storage medium |
CN113868022A (en) * | 2021-09-18 | 2021-12-31 | 聚好看科技股份有限公司 | Master-slave switching method and device for database |
CN114661827A (en) * | 2022-05-23 | 2022-06-24 | 武汉四通信息服务有限公司 | Database taking-over method and device, electronic equipment and storage medium |
CN116431397A (en) * | 2023-06-13 | 2023-07-14 | 北京中实信息技术有限公司 | Main and auxiliary node switching system of server |
CN116431397B (en) * | 2023-06-13 | 2023-09-01 | 北京中实信息技术有限公司 | Main and auxiliary node switching system of server |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108984569A (en) | Database switching method, system and computer readable storage medium | |
US11360854B2 (en) | Storage cluster configuration change method, storage cluster, and computer system | |
US9747301B2 (en) | Distributed file system using consensus nodes | |
US9846704B2 (en) | Distributed file system using consensus nodes | |
US8862928B2 (en) | Techniques for achieving high availability with multi-tenant storage when a partial fault occurs or when more than two complete faults occur | |
CN102640108B (en) | The monitoring of replicated data | |
US7451215B2 (en) | OPC server redirection manager | |
CN107016087B (en) | Hierarchical database high-availability system based on sentry's model | |
WO2022007552A1 (en) | Processing node management method, configuration method and related apparatus | |
CN107291787A (en) | Master/slave data storehouse switching method and apparatus | |
US7937716B2 (en) | Managing collections of appliances | |
CN110581782B (en) | Disaster tolerance data processing method, device and system | |
US20090063650A1 (en) | Managing Collections of Appliances | |
WO2003096231A1 (en) | Database scattering system | |
CN101706805A (en) | Method and system for storing object | |
CN108897641B (en) | Log analysis service real-time synchronization system under database master-slave environment | |
CN110677282B (en) | Hot backup method of distributed system and distributed system | |
CN105701159A (en) | Data synchronization device and method | |
CN106685688A (en) | Cluster computer device synchronous upgrade method | |
CN108733808B (en) | Big data software system switching method, system, terminal equipment and storage medium | |
CN110069365A (en) | Manage the method and corresponding device, computer readable storage medium of database | |
US8201017B2 (en) | Method for queuing message and program recording medium thereof | |
CN116185697B (en) | Container cluster management method, device and system, electronic equipment and storage medium | |
CN105007172A (en) | Method for realizing HDFS high-availability scheme | |
CN111698301A (en) | Service management method, device and storage medium for ensuring service continuation |
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 | ||
TA01 | Transfer of patent application right | ||
TA01 | Transfer of patent application right |
Effective date of registration: 20220107 Address after: 100176 602, floor 6, building 6, courtyard 10, KEGU 1st Street, Beijing Economic and Technological Development Zone, Daxing District, Beijing (Yizhuang group, high-end industrial area of Beijing Pilot Free Trade Zone) Applicant after: Jinzhuan Xinke Co.,Ltd. Address before: 518000 Zhongnan communication tower, South China Road, Nanshan District high tech Industrial Park, Shenzhen, Guangdong Applicant before: ZTE Corp. |