CN106383755A - Method, apparatus and system for recovering slave database from master-slave database system - Google Patents
Method, apparatus and system for recovering slave database from master-slave database system Download PDFInfo
- Publication number
- CN106383755A CN106383755A CN201610848284.9A CN201610848284A CN106383755A CN 106383755 A CN106383755 A CN 106383755A CN 201610848284 A CN201610848284 A CN 201610848284A CN 106383755 A CN106383755 A CN 106383755A
- Authority
- CN
- China
- Prior art keywords
- mdl
- database
- backup
- master
- storehouse
- 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/1448—Management of the data involved in backup or backup restore
-
- 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
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)
Abstract
The invention discloses a method, an apparatus and a system for recovering a slave database from a master-slave database system. The method comprises the steps of sending a backup instruction to a master database side to enable the master database side to back up a master database; obtaining backup data of the master database and storing the backup data in a corresponding position of a to-be-recovered specified database, wherein the backup data of the master database comprises a database configuration file of the master database; modifying the stored database configuration file to enable the specified database to become the slave database of the master database; and starting up the specified database. According to the technical scheme, the master database is backed up when the backup is needed, so that the timeliness of the backup data is ensured; the database recovered by utilizing the backup data can be directly used as the slave database of the master database; and compared with the prior art, the method, the apparatus and the system have the advantage that the availability of the recovered slave database is remarkably improved.
Description
Technical field
The present invention relates to database field and in particular to a kind of method from storehouse of recovering in Database Systems in master-slave mode,
Device and system.
Background technology
The database structure of master-slave mode (Master/Slave) can effectively alleviate the pressure of data base read-write access, but by
In needing to be consistent with master library data from database data, thus also bring the many of the aspects such as master-slave database is synchronous, back up
Problem.
In prior art, can be from lab setting backup, one can be recovered from storehouse using this backup.But this method is deposited
In following shortcoming:
1) because backup is not real-time generation, also need to carry out together with master library from storehouse hence with Backup and Restore
Step, takes considerable time and resource, and especially in the case that the backward current master library data of Backup Data is too many, synchronizing relay is very
Greatly, exacerbate this problem;
2) back up disabled in the case of cannot realize from storehouse recovery, or recover unavailable from storehouse.
Content of the invention
In view of the above problems it is proposed that the present invention so as to provide one kind overcome the problems referred to above or at least in part solve on
State the methods, devices and systems recovering in master-slave mode Database Systems from storehouse of problem.
According to one aspect of the present invention, there is provided recover the method from storehouse in a kind of Database Systems in master-slave mode, bag
Include:
Send backup instruction to MDL side so that MDL side is backed up to MDL;
Obtain the Backup Data of MDL and be saved in the correspondence position of specified database to be restored, MDL
Backup Data includes the data base configuration file of MDL;
Modification preserve described data base configuration file so that described specified database become described MDL from
Storehouse;
Start described specified database.
Alternatively, wherein, send backup instruction to MDL side to include:
Obtain IP address and the port numbers of MDL;
IP address according to MDL and port numbers send backup instruction to MDL side.
Alternatively, the described correspondence position obtaining the Backup Data of MDL and being saved in specified database to be restored
Including:
Using Rsync mode, the correspondence position that the completed Backup Data of MDL passes to specified database is carried out
Preserve;
Or,
Using i.e. standby pass by the way of the Backup Data of MDL is transferred to specified database correspondence position carry out
Preserve.
Alternatively, the method further includes:
Judge whether there is described MDL as other in the data of correspondence position being saved in described specified database
The master-slave synchronisation information from storehouse of database;
If it has, then deleting described master-slave synchronisation information.
Alternatively, the method further includes:
Obtain the master-slave synchronisation information between MDL and described specified database;
After starting described specified database, according to described master-slave synchronisation information by the data syn-chronization of MDL to work
It is from the described specified database of database.
Alternatively, the described master-slave synchronisation information obtaining between MDL and described specified database includes:
Find out the synchronizing information file specified from being saved in the data of correspondence position of described specified database;
The master-slave synchronisation between MDL and described specified database is obtained from the described synchronizing information file specified
Information.
Alternatively, described specified database is mysql database, and the method further includes:
Judge to whether there is GTID in the described synchronizing information file specified;
If it is present principal and subordinate's data synchronization processing is carried out using first method;
If it does not exist, then principal and subordinate's data synchronization processing is carried out using second method.
Alternatively, the method further includes:
Before the Backup Data of MDL is saved in the correspondence position of specified database to be restored, check described
Whether there is Relational database on the machine of correspondence position place;
If so, then stop the service of described Relational database, delete the corresponding file of Relational database or change described phase
Close the mark of database.
According to another aspect of the present invention, there is provided recover the method from storehouse in a kind of Database Systems in master-slave mode, bag
Include:
Receive the backup instruction from specified database;
MDL is backed up to generate Backup Data, wherein, the Backup Data of MDL includes master data
The data base configuration file in storehouse;
The Backup Data of MDL is transferred to the correspondence position of specified database so that described specified database according to
Described Backup Data become MDL from storehouse.
Alternatively, before database is backed up, the method further includes:
Determine whether that enough spaces to carry out full backup to MDL;
If there are enough spaces, then after full backup is carried out to MDL, open Rsync service, using Rsync
The completed Backup Data of MDL is transferred to the correspondence position of specified database by mode;
Without enough spaces, using i.e. standby pass by the way of MDL backed up and Backup Data passed
The defeated correspondence position to specified database.
Alternatively, described MDL is carried out backup include:
Using dbbackup utility xtrabackup, MDL is backuped to locally.
Alternatively, the method further includes:
During MDL is backed up, by the master-slave synchronisation between MDL and described specified database
Information output is in specified synchronizing information file;
The described synchronizing information file specified is transferred to described specifying as a part for the Backup Data of MDL
The correspondence position of database.
According to another aspect of the present invention, there is provided recover the device from storehouse in a kind of Database Systems in master-slave mode, bag
Include:
Transmitting element, be suitable to MDL side send backup instruction so that MDL side MDL is carried out standby
Part;
Acquiring unit, is suitable to the corresponding position obtaining the Backup Data of MDL and being saved in specified database to be restored
Put, the Backup Data of MDL includes the data base configuration file of MDL;
Modification unit, is suitably modified to the described data base configuration file preserving, so that described specified database becomes described
MDL from storehouse;
Start unit, is suitable to start described specified database.
Alternatively, described transmitting element, is suitable to obtain IP address and the port numbers of MDL;IP according to MDL
Address and port numbers send backup instruction to MDL side.
Alternatively, acquiring unit, be suitable for use with Rsync mode the completed Backup Data of MDL is passed to specified
The correspondence position of database is preserved;Or, the Backup Data of MDL is transmitted by the i.e. standby mode passing that is suitable for use with
Correspondence position to specified database is preserved.
Alternatively, change unit, be further adapted in the data judge the correspondence position being saved in described specified database
Whether there is the master-slave synchronisation information as other databases from storehouse for the described MDL;If it has, it is same then to delete described principal and subordinate
Step information.
Alternatively, this device further includes:
Lock unit, is suitable to obtain the master-slave synchronisation information between MDL and described specified database;In described finger
Determine database start after, according to described master-slave synchronisation information using the data syn-chronization of MDL to as from database described in
In specified database.
Alternatively, described lock unit, be suitable to from be saved in the data of correspondence position of described specified database search
Go out the synchronizing information file specified;Obtain from the described synchronizing information file specified MDL and described specified database it
Between master-slave synchronisation information.
Alternatively, described specified database is mysql database,
Described lock unit, is further adapted for judging to whether there is GTID in the described synchronizing information file specified;If
Exist, then principal and subordinate's data synchronization processing is carried out using first method;If it does not exist, then principal and subordinate's data is carried out using second method
Synchronization process.
Alternatively, this device further includes:
Pretreatment unit, is suitable in the corresponding position that the Backup Data of MDL is saved in specified database to be restored
Before putting, check whether there is Relational database on the machine of described correspondence position place;If so, then stop described related data
The service in storehouse, the mark deleted the corresponding file of Relational database or change described Relational database.
According to another aspect of the invention, there is provided recover the device from storehouse in a kind of Database Systems in master-slave mode, bag
Include:
Receiving unit, is suitable to receive the backup instruction from specified database;
Backup units, are suitable to MDL be backed up to generate Backup Data, wherein, the Backup Data of MDL
Include the data base configuration file of MDL;
Transmission unit, is suitable to the Backup Data of MDL is transferred to the correspondence position of specified database, so that described
Specified database according to described Backup Data become MDL from storehouse.
Alternatively, described transmission unit, is further adapted for determining whether that enough spaces MDL has been carried out
Reorganize and outfit part;If there are enough spaces, then after described backup units carry out full backup to MDL, open Rsync clothes
The completed Backup Data of MDL is transferred to the correspondence position of specified database by business using Rsync mode;If not yet
There are enough spaces, in described backup units when i.e. for backing up to MDL by the way of passing, by Backup Data
It is transferred to the correspondence position of specified database.
Alternatively, described backup units, are suitable to backup to MDL using dbbackup utility xtrabackup
Locally.
Alternatively, described backup units, are further adapted for during MDL is backed up, by MDL
Master-slave synchronisation information output and described specified database between is in specified synchronizing information file;
Described transmission unit, be further adapted for using the described synchronizing information file specified as MDL Backup Data
A part be transferred to the correspondence position of described specified database.
According to another aspect of the invention, there is provided recover the system from storehouse in a kind of Database Systems in master-slave mode, its
In, this system includes:Device as described in any of the above-described and the device as described in any of the above-described.
From the foregoing, technical scheme, first send backup instruction and MDL side is entered to MDL
Row backup, the Backup Data containing the data base configuration file of MDL is saved in the right of specified database to be restored
Answer position, by change data base configuration file make specified database become MDL from storehouse and start this database.Should
Technical scheme need backup when from backing up to master library, thus ensure that the ageing of Backup Data;Using this backup number
Can be used from storehouse directly as master library according to the database recovering, compared with prior art, be obviously improved recovery
Availability from storehouse.
Described above is only the general introduction of technical solution of the present invention, in order to better understand the technological means of the present invention,
And can be practiced according to the content of specification, and in order to allow the above and other objects of the present invention, feature and advantage can
Become apparent, below especially exemplified by the specific embodiment of the present invention.
Brief description
By reading the detailed description of hereafter preferred embodiment, various other advantages and benefit are common for this area
Technical staff will be clear from understanding.Accompanying drawing is only used for illustrating the purpose of preferred embodiment, and is not considered as to the present invention
Restriction.And in whole accompanying drawing, it is denoted by the same reference numerals identical part.In the accompanying drawings:
Fig. 1 shows the method recovered in a kind of Database Systems in master-slave mode according to an embodiment of the invention from storehouse
Schematic flow sheet;
Fig. 2 shows that another kind according to an embodiment of the invention recovers the side from storehouse in master-slave mode Database Systems
The schematic flow sheet of method;
Fig. 3 shows the device recovering in a kind of Database Systems in master-slave mode according to an embodiment of the invention from storehouse
Structural representation;
Fig. 4 shows that another kind according to an embodiment of the invention recovers the dress from storehouse in master-slave mode Database Systems
The structural representation put;And
Fig. 5 shows the system recovered in a kind of Database Systems in master-slave mode according to an embodiment of the invention from storehouse
Structural representation.
Specific embodiment
It is more fully described the exemplary embodiment of the disclosure below with reference to accompanying drawings.Although showing the disclosure in accompanying drawing
Exemplary embodiment it being understood, however, that may be realized in various forms the disclosure and should not be by embodiments set forth here
Limited.On the contrary, these embodiments are provided to be able to be best understood from the disclosure, and can be by the scope of the present disclosure
Complete conveys to those skilled in the art.
In the present invention, master library refers to MDL, refers to from database from storehouse.Fig. 1 shows according to the present invention one
Recover the schematic flow sheet of the method from storehouse in a kind of Database Systems in master-slave mode of embodiment, as shown in figure 1, the method bag
Include:
Step S110, sends backup instruction so that MDL side is backed up to MDL to MDL side.
It is to realize using to the Backup Data carrying out from storehouse from the recovery in storehouse in prior art, the shortcoming of this mode
Point out in background section, will not be described here.In the present embodiment, when needing to carry out recovering from storehouse, then to master
Database side sends backup instruction to back up master library it is ensured that being used for recovering the ageing and available of the Backup Data from storehouse
Property.Specifically MDL can be backed up using dbbackup utilitys such as xtrabackup.
Step S120, obtains the Backup Data of MDL and is saved in the correspondence position of specified database to be restored,
The Backup Data of MDL includes the data base configuration file of MDL.
Step S130, modification preserve data base configuration file so that specified database become MDL from storehouse.
Data base configuration file in MDL with differ from wide area information server configuration file, for example,
Typically, the data permission of MDL is access limit, and is read-only from the data permission of database.In addition, principal and subordinate's number
Port according to storehouse is also different, and these contents are all saved in data base configuration file, therefore will modify.
Step S140, starts specified database.Database after startup can be used from storehouse directly as master library.
It can be seen that, the method shown in Fig. 1, first send backup instruction and MDL side is backed up to MDL, will
The Backup Data containing the data base configuration file of MDL is saved in the correspondence position of specified database to be restored, leads to
Cross modification data base configuration file make specified database become MDL from storehouse and start this database.This technical scheme exists
Need during backup from backing up to master library, thus ensure that the ageing of Backup Data;The number being recovered using this Backup Data
Can be used from storehouse directly as master library according to storehouse, compared with prior art, be obviously improved can use from storehouse recovered
Property.
In one embodiment of the invention, send backup instruction to MDL side to include:Obtain the IP of MDL
Address and port numbers;IP address according to MDL and port numbers send backup instruction to MDL side.
In the present embodiment, other performed operations can be realized in the way of script, and user only needs to provide
IP address from the corresponding master library in storehouse to be restored and port numbers.For example, the IP of user input is obtained by front end page
Address and port numbers, script is assured that MDL to be backed up according to IP address and port numbers.
In one embodiment of the invention, in the method shown in Fig. 1, obtain the Backup Data of MDL and be saved in
The correspondence position of specified database to be restored includes:Using Rsync mode, the completed Backup Data of MDL is passed
Correspondence position to specified database is preserved;Or, using i.e. standby pass by the way of the Backup Data of MDL is passed
The defeated correspondence position to specified database is preserved.
It may be considered which kind of side the current capacities of MDL to select using when to MDL execution backup operation
Formula is backed up, and is saved in MDL locally including by backup, or, directly will back up the correspondence being saved in specified database
Position, that is, i.e. standby pass.In actual applications, master data can first be carried out after MDL receives backup instruction
The Backup Data of MDL, if capacity is sufficient, can be saved in MDL locally, work as backup by checking of storage capacity
After the completion of, then by Rsync mode, the correspondence position that the completed Backup Data of MDL passes to specified database is entered
Row preserves;If off-capacity, then just take the i.e. standby mode passing, when executing backup operation, directly by MDL
Backup Data be transferred to the correspondence position of specified database and preserved (for example, using xtrabackup instrument to master data
Storehouse carries out Backup Data, and is preserved using the correspondence position that ssh order is transmitted to specified database).Now permissible
The process that the Backup Data of MDL is transferred to the correspondence position of specified database by cycle criterion whether there is, if existing,
Do not start Rsync process, and after judging that this process no longer exists, determine that backup completes, follow-up modification can be executed
The operation of data base configuration file.
In one embodiment of the invention, the method shown in Fig. 1 further includes:Judge to be saved in specified database
Whether there is the master-slave synchronisation information as other databases from storehouse for the MDL in the data of correspondence position;If it has, then deleting
Except master-slave synchronisation information.
In the master-slave database of tandem type, the master library of backup can also be as other master libraries from storehouse.At this moment right
Master library carries out just comprising the master-slave synchronisation information as other master libraries from storehouse for this master library in the Backup Data back up generation.If
Do not delete this synchronizing information, that newly recovers just cannot be as the master library of this backup from storehouse from storehouse.
In one embodiment of the invention, the method shown in Fig. 1 further includes:Obtain MDL and specified data
Master-slave synchronisation information between storehouse;After starting specified database, according to master-slave synchronisation information, the data of MDL is same
Walk as from the specified database of database.
After recovering to complete and start from storehouse, if can not synchronize with master library, then this is still from storehouse can not
Normal service is provided.Therefore, the master-slave synchronisation information in the middle of storehouse of MDL and this recovery will also be obtained further.
Specifically, in one embodiment of the invention, the master-slave synchronisation information obtaining between MDL and specified database includes:
Find out the synchronizing information file specified from being saved in the data of correspondence position of specified database;From specified synchronizing information
The master-slave synchronisation information between MDL and specified database is obtained in file.
For example using xtrabackup instrument come when backing up MDL it is possible to by the IP of master library, port numbers,
The information outputs such as binlog, master_log_pos, in synchronizing information file, so, are obtaining MDL and specified data
It is possible to find out synchronizing information file therefrom from the Backup Data in storehouse from being saved in during master-slave synchronisation information between storehouse
Get MDL and this recovery master-slave synchronisation information between storehouse.
In one embodiment of the invention, it is intended that database is mysql database in said method, the method enters one
Step includes:Judge to whether there is GTID in the synchronizing information file specified;If it is present principal and subordinate's number is carried out using first method
According to synchronization process;If it does not exist, then principal and subordinate's data synchronization processing is carried out using second method.
GTID (Global Transaction Identification, global transaction identification identifier), is in mysql
Newly-increased content in data 5.6 version.In whole master-slave synchronisation framework, No. GTID of every any two affairs is all without identical.
Therefore when the mysql database of 5.6 versions carries out data backup, in synchronizing information file, GTID will be comprised, and at 5.5 editions
When this mysql database carries out data backup, in synchronizing information file, do not comprise GTID.Therefore using 5.5 versions
Mysql MDL carries out when storehouse is recovered, can be with the master-slave synchronisation information in direct access synchronizing information file from storehouse
Execution;And carrying out when storehouse is recovered using the mysql MDL of 5.6 versions, needs carry out same first with the GTID getting
Step setting, then other master-slave synchronisation information in synchronizing information are being executed from storehouse.
In one embodiment of the invention, the method shown in Fig. 1 further includes:By the Backup Data of MDL
Before being saved in the correspondence position of specified database to be restored, check whether there is dependency number on the machine of correspondence position place
According to storehouse;If so, then stop the service of Relational database, delete the corresponding file of Relational database or the mark of change Relational database
Know.
For example, a machine is provided with originally certain master library from storehouse, can not should continue for some reason from storehouse
Continuous use, need again to recover one corresponding with this master library from storehouse.Now existed on this machine one related to master library
From storehouse, if do not processed to it, the normal use from storehouse newly recovering can be affected, therefore in this embodiment, needing
Check when there is Relational database on machine, stop the service of Relational database, delete Relational database corresponding
File or the mark of change Relational database.
Fig. 2 shows that another kind according to an embodiment of the invention recovers the side from storehouse in master-slave mode Database Systems
The schematic flow sheet of method, as shown in Fig. 2 the method includes:
Step S210, receives the backup instruction from specified database.
Step S220, is backed up to MDL to generate Backup Data, wherein, wraps in the Backup Data of MDL
Include the data base configuration file of MDL.
Step S230, the Backup Data of MDL is transferred to the correspondence position of specified database, so that specifying data
Storehouse according to Backup Data become MDL from storehouse.
Method shown in Fig. 2 can apply to MDL side.In the present embodiment after receiving backup instruction, to master
Database is backed up and Backup Data is transferred to the correspondence position of specified database.
In one embodiment of the invention, in the method shown in Fig. 2, before database is backed up, the method is entered
One step includes:Determine whether that enough spaces to carry out full backup to MDL;If there are enough spaces, then right
After MDL carries out full backup, open Rsync service, using Rsync mode by the completed backup number of MDL
According to the correspondence position being transferred to specified database;Without enough spaces, using i.e. standby pass by the way of to MDL
Backed up and Backup Data is transferred to the correspondence position of specified database (for example, using xtrabackup instrument to main number
Carry out Backup Data according to storehouse, and preserved using the correspondence position that ssh order is transmitted to specified database).
Judge to be backed up using which kind of mode according to the free space of MDL in the present embodiment, work as MDL
Capacity sufficient when, the full backup of MDL can be saved in MDL local, be then turned on Rsync service, adopt
The completed Backup Data of MDL is transferred to the correspondence position of specified database by Rsync mode;If MDL
Off-capacity, then using i.e. standby pass by the way of MDL backed up and Backup Data is transferred to specified database
Correspondence position (for example, using xtrabackup instrument, Backup Data is carried out to MDL, and is passed using ssh order
The defeated correspondence position to specified database is preserved).
In one embodiment of the invention, in the method shown in Fig. 2, MDL is carried out with backup and includes:Using number
According to library backup instrument xtrabackup, MDL is backuped to locally.
In one embodiment of the invention, the method shown in Fig. 2 further includes:Backed up to MDL
During, by the master-slave synchronisation information output between MDL and specified database in specified synchronizing information file;Will
The synchronizing information file specified is transferred to the correspondence position of specified database as a part for the Backup Data of MDL.Main
Can also be realized using dbbackup utility xtrabackup from the output of synchronizing information, master-slave synchronisation information includes
Following one or more:The IP of MDL, port numbers, binlog, master_log_pos, gitd.
Fig. 3 shows the device recovering in a kind of Database Systems in master-slave mode according to an embodiment of the invention from storehouse
Structural representation, as shown in figure 3, recovering to include from the device 300 in storehouse in master-slave mode Database Systems:
Transmitting element 310, is suitable to send backup instruction so that MDL side is carried out to MDL to MDL side
Backup.
Acquiring unit 320, is suitable to obtain the Backup Data of MDL and be saved in the right of specified database to be restored
Answer position, the Backup Data of MDL includes the data base configuration file of MDL.
Modification unit 330, is suitably modified to the data base configuration file preserving, so that specified database becomes MDL
From storehouse.
Start unit 340, is suitable to start specified database.
It can be seen that, the device shown in Fig. 3, cooperating by each unit, first send backup instruction and make MDL side
MDL is backed up, the Backup Data containing the data base configuration file of MDL is saved in finger to be restored
Determine the correspondence position of database, by change data base configuration file make specified database become MDL from storehouse and start
This database.This technical scheme need backup when from backing up to master library, thus ensure that the ageing of Backup Data;Profit
Can be used from storehouse directly as master library with the database that this Backup Data recovers, compared with prior art, significantly be carried
Rise the availability from storehouse recovered.
In one embodiment of the invention, in the device shown in Fig. 3, transmitting element 310, it is suitable to obtain MDL
IP address and port numbers;IP address according to MDL and port numbers send backup instruction to MDL side.
In one embodiment of the invention, in the device shown in Fig. 3, acquiring unit 320, it is suitable for use with Rsync mode
The correspondence position that the completed Backup Data of MDL is passed to specified database is preserved;Or, be suitable for use be
The correspondence position that the Backup Data of MDL is transferred to specified database is preserved by the standby mode passing.
In one embodiment of the invention, in the device shown in Fig. 3, change unit 330, be further adapted for judging to preserve
Whether there is the master-slave synchronisation letter as other databases from storehouse for the MDL in the data of the correspondence position of specified database
Breath;If it has, then deleting master-slave synchronisation information.
In one embodiment of the invention, the device shown in Fig. 3 further includes:Lock unit, is suitable to obtain main number
According to the master-slave synchronisation information between storehouse and specified database;After specified database starts, will be led according to master-slave synchronisation information
The data syn-chronization of database is to as from the specified database of database.
In one embodiment of the invention, in said apparatus, lock unit, it is suitable to from being saved in the right of specified database
The synchronizing information file specified is found out in the data answering position;Obtain MDL and refer to from specified synchronizing information file
Determine the master-slave synchronisation information between database.
In one embodiment of the invention, it is intended that database is mysql database in said apparatus, lock unit, enters
One step is suitable to judge to whether there is GTID in the synchronizing information file specified;If it is present principal and subordinate is carried out using first method
Data synchronization processing;If it does not exist, then principal and subordinate's data synchronization processing is carried out using second method.
In one embodiment of the invention, the device shown in Fig. 3 further includes:Pretreatment unit, is suitable to lead
Before the Backup Data of database is saved in the correspondence position of specified database to be restored, check on the machine of correspondence position place
Whether there is Relational database;If so, then stop the service of Relational database, delete the corresponding file of Relational database or more
Change the mark of Relational database.
Fig. 4 shows that another kind according to an embodiment of the invention recovers the dress from storehouse in master-slave mode Database Systems
The structural representation put, as shown in figure 4, recover to include from the device 400 in storehouse in master-slave mode Database Systems:
Receiving unit 410, is suitable to receive the backup instruction from specified database.
Backup units 420, are suitable to MDL be backed up to generate Backup Data, wherein, the backup of MDL
Data includes the data base configuration file of MDL.
Transmission unit 430, is suitable to the Backup Data of MDL be transferred to the correspondence position of specified database, so that referring to
Determine database according to Backup Data become MDL from storehouse.
In one embodiment of the invention, in the device shown in Fig. 4, transmission unit 430, it is further adapted for judging whether
Enough spaces are had to carry out full backup to MDL;If there are enough spaces, then in backup units 420 to master data
After storehouse carries out full backup, open Rsync service, using Rsync mode, the completed Backup Data of MDL is transmitted
Correspondence position to specified database;Without enough spaces, backup units 420 using i.e. standby pass by the way of to master
When database is backed up, Backup Data is transferred to the correspondence position of specified database.
In one embodiment of the invention, in the device shown in Fig. 4, backup units 420, it is suitable to utilize DB Backup
MDL is backuped to locally by instrument xtrabackup.
In one embodiment of the invention, in the device shown in Fig. 4, backup units 420, it is further adapted for main number
During being backed up according to storehouse, by the master-slave synchronisation information output between MDL and specified database to the synchronization specified
In message file;Transmission unit 430, is further adapted for specified synchronizing information file as the Backup Data of MDL
A part is transferred to the correspondence position of specified database.
It should be noted that the specific embodiment of above-mentioned each device embodiment and aforementioned corresponding method embodiment is concrete
Embodiment is identical, will not be described here.
Fig. 5 shows the system recovered in a kind of Database Systems in master-slave mode according to an embodiment of the invention from storehouse
Structural representation, as shown in figure 5, recovering to include from the system 500 in storehouse in master-slave mode Database Systems:As any of the above-described reality
Apply and recover device 300 from storehouse in the master-slave mode Database Systems in example and as the master-slave mode number above-mentioned any embodiment
According to the device 400 recovering in the system of storehouse from storehouse.Wherein recover can apply from the device 300 in storehouse in master-slave mode Database Systems
In to be restored from database side, recover in master-slave mode Database Systems from the device 400 in storehouse can apply to be restored
From database corresponding MDL side,
In sum, technical scheme, first sends backup instruction and MDL side is carried out to MDL
Backup, the Backup Data containing the data base configuration file of MDL is saved in the correspondence of specified database to be restored
Position, by change data base configuration file make specified database become MDL from storehouse and start this database.This skill
Art scheme need backup when from backing up to master library, thus ensure that the ageing of Backup Data;Using this Backup Data
Recover database can be used from storehouse directly as master library, compared with prior art, be obviously improved recover from
The availability in storehouse.
It should be noted that:
Algorithm and display be not inherently related to any certain computer, virtual bench or miscellaneous equipment provided herein.
Various fexible units can also be used together with based on teaching in this.As described above, construct required by this kind of device
Structure be obvious.Additionally, the present invention is also not for any certain programmed language.It is understood that, it is possible to use various
Programming language realizes the content of invention described herein, and the description above language-specific done is to disclose this
Bright preferred forms.
In specification mentioned herein, illustrate a large amount of details.It is to be appreciated, however, that the enforcement of the present invention
Example can be put into practice in the case of not having these details.In some instances, known method, structure are not been shown in detail
And technology, so as not to obscure the understanding of this description.
Similarly it will be appreciated that in order to simplify the disclosure and help understand one or more of each inventive aspect,
Above in the description to the exemplary embodiment of the present invention, each feature of the present invention is grouped together into single enforcement sometimes
In example, figure or descriptions thereof.However, the method for the disclosure should be construed to reflect following intention:I.e. required guarantor
The application claims of shield more features than the feature being expressly recited in each claim.More precisely, it is such as following
Claims reflected as, inventive aspect is all features less than single embodiment disclosed above.Therefore,
The claims following specific embodiment are thus expressly incorporated in this specific embodiment, wherein each claim itself
All as the separate embodiments of the present invention.
Those skilled in the art are appreciated that and the module in the equipment in embodiment can be carried out adaptively
Change and they are arranged in one or more equipment different from this embodiment.Can be the module in embodiment or list
Unit or assembly be combined into a module or unit or assembly, and can be divided in addition multiple submodule or subelement or
Sub-component.In addition to such feature and/or at least some of process or unit exclude each other, can adopt any
Combination is to all features disclosed in this specification (including adjoint claim, summary and accompanying drawing) and so disclosed
Where method or all processes of equipment or unit are combined.Unless expressly stated otherwise, this specification (includes adjoint power
Profit requires, summary and accompanying drawing) disclosed in each feature can carry out generation by the alternative features providing identical, equivalent or similar purpose
Replace.
Although additionally, it will be appreciated by those of skill in the art that some embodiments described herein include other embodiments
In included some features rather than further feature, but the combination of the feature of different embodiment means to be in the present invention's
Within the scope of and form different embodiments.For example, in the following claims, embodiment required for protection appoint
One of meaning can in any combination mode using.
The all parts embodiment of the present invention can be realized with hardware, or to run on one or more processor
Software module realize, or with combinations thereof realize.It will be understood by those of skill in the art that can use in practice
Microprocessor or digital signal processor (DSP) are according to embodiments of the present invention extensive in master-slave mode Database Systems to realize
The some or all functions of multiple some or all parts from the device and system in storehouse.The present invention is also implemented as using
In some or all equipment executing method as described herein or program of device (for example, computer program and meter
Calculation machine program product).Such program realizing the present invention can store on a computer-readable medium, or can have one
The form of individual or multiple signal.Such signal can be downloaded from internet website and obtain, or above carries in carrier signal
For, or provided with any other form.
It should be noted that above-described embodiment the present invention will be described rather than limits the invention, and ability
Field technique personnel can design alternative embodiment without departing from the scope of the appended claims.In the claims,
Any reference symbol between bracket should not be configured to limitations on claims.Word "comprising" does not exclude the presence of not
Element listed in the claims or step.Word "a" or "an" before element does not exclude the presence of multiple such
Element.The present invention can come real by means of the hardware including some different elements and by means of properly programmed computer
Existing.If in the unit claim listing equipment for drying, several in these devices can be by same hardware branch
To embody.The use of word first, second, and third does not indicate that any order.These words can be explained and run after fame
Claim.
Embodiment of the invention discloses that recovering the method from storehouse in A1, a kind of Database Systems in master-slave mode, wherein, should
Method includes:
Send backup instruction to MDL side so that MDL side is backed up to MDL;
Obtain the Backup Data of MDL and be saved in the correspondence position of specified database to be restored, MDL
Backup Data includes the data base configuration file of MDL;
Modification preserve described data base configuration file so that described specified database become described MDL from
Storehouse;
Start described specified database.
A2, the method as described in A1, wherein, send backup instruction to MDL side and include:
Obtain IP address and the port numbers of MDL;
IP address according to MDL and port numbers send backup instruction to MDL side.
A3, the method as described in A1, wherein, the Backup Data of described acquisition MDL is simultaneously saved in be restored specifying
The correspondence position of database includes:
Using Rsync mode, the correspondence position that the completed Backup Data of MDL passes to specified database is carried out
Preserve;
Or,
Using i.e. standby pass by the way of the Backup Data of MDL is transferred to specified database correspondence position carry out
Preserve.
A4, the method as described in A1, wherein, the method further includes:
Judge whether there is described MDL as other in the data of correspondence position being saved in described specified database
The master-slave synchronisation information from storehouse of database;
If it has, then deleting described master-slave synchronisation information.
A5, the method as described in A1, wherein, the method further includes:
Obtain the master-slave synchronisation information between MDL and described specified database;
After starting described specified database, according to described master-slave synchronisation information by the data syn-chronization of MDL to work
It is from the described specified database of database.
A6, the method as described in A5, wherein, the described master-slave synchronisation obtaining between MDL and described specified database
Information includes:
Find out the synchronizing information file specified from being saved in the data of correspondence position of described specified database;
The master-slave synchronisation between MDL and described specified database is obtained from the described synchronizing information file specified
Information.
A7, the method as described in A6, wherein, described specified database is mysql database, and the method further includes:
Judge to whether there is GTID in the described synchronizing information file specified;
If it is present principal and subordinate's data synchronization processing is carried out using first method;
If it does not exist, then principal and subordinate's data synchronization processing is carried out using second method.
A8, the method as described in A1, wherein, the method further includes:
Before the Backup Data of MDL is saved in the correspondence position of specified database to be restored, check described
Whether there is Relational database on the machine of correspondence position place;
If so, then stop the service of described Relational database, delete the corresponding file of Relational database or change described phase
Close the mark of database.
A kind of method that embodiments of the invention also disclose B9, recover in Database Systems in master-slave mode from storehouse, wherein,
The method includes:
Receive the backup instruction from specified database;
MDL is backed up to generate Backup Data, wherein, the Backup Data of MDL includes master data
The data base configuration file in storehouse;
The Backup Data of MDL is transferred to the correspondence position of specified database so that described specified database according to
Described Backup Data become MDL from storehouse.
B10, the method as described in B9, wherein, before database is backed up, the method further includes:
Determine whether that enough spaces to carry out full backup to MDL;
If there are enough spaces, then after full backup is carried out to MDL, open Rsync service, using Rsync
The completed Backup Data of MDL is transferred to the correspondence position of specified database by mode;
Without enough spaces, using i.e. standby pass by the way of MDL backed up and Backup Data passed
The defeated correspondence position to specified database.
B11, the method as described in B9, wherein, described MDL is carried out backup include:
Using dbbackup utility xtrabackup, MDL is backuped to locally.
B12, the method as described in B9, wherein, the method further includes:
During MDL is backed up, by the master-slave synchronisation between MDL and described specified database
Information output is in specified synchronizing information file;
The described synchronizing information file specified is transferred to described specifying as a part for the Backup Data of MDL
The correspondence position of database.
The device that embodiments of the invention also disclose C13, recover in a kind of Database Systems in master-slave mode from storehouse, its
In, this device includes:
Transmitting element, be suitable to MDL side send backup instruction so that MDL side MDL is carried out standby
Part;
Acquiring unit, is suitable to the corresponding position obtaining the Backup Data of MDL and being saved in specified database to be restored
Put, the Backup Data of MDL includes the data base configuration file of MDL;
Modification unit, is suitably modified to the described data base configuration file preserving, so that described specified database becomes described
MDL from storehouse;
Start unit, is suitable to start described specified database.
C14, the device as described in C13, wherein,
Described transmitting element, is suitable to obtain IP address and the port numbers of MDL;IP address according to MDL and
Port numbers send backup instruction to MDL side.
C15, the device as described in C13, wherein,
Acquiring unit, is suitable for use with Rsync mode and the completed Backup Data of MDL is passed to specified database
Correspondence position preserved;Or, the Backup Data of MDL is transferred to specified by the i.e. standby mode passing that is suitable for use with
The correspondence position of database is preserved.
C16, the device as described in C13, wherein,
Whether modification unit, be further adapted in the data judge the correspondence position being saved in described specified database
State the master-slave synchronisation information as other databases from storehouse for the MDL;If it has, then deleting described master-slave synchronisation information.
C17, the device as described in C13, wherein, this device further includes:
Lock unit, is suitable to obtain the master-slave synchronisation information between MDL and described specified database;In described finger
Determine database start after, according to described master-slave synchronisation information using the data syn-chronization of MDL to as from database described in
In specified database.
C18, the device as described in C17, wherein,
Described lock unit, is suitable to specify from being saved in find out the data of correspondence position of described specified database
Synchronizing information file;The principal and subordinate between MDL and described specified database is obtained from the described synchronizing information file specified
Synchronizing information.
C19, the device as described in C18, wherein, described specified database is mysql database,
Described lock unit, is further adapted for judging to whether there is GTID in the described synchronizing information file specified;If
Exist, then principal and subordinate's data synchronization processing is carried out using first method;If it does not exist, then principal and subordinate's data is carried out using second method
Synchronization process.
C20, the device as described in C12, wherein, this device further includes:
Pretreatment unit, is suitable in the corresponding position that the Backup Data of MDL is saved in specified database to be restored
Before putting, check whether there is Relational database on the machine of described correspondence position place;If so, then stop described related data
The service in storehouse, the mark deleted the corresponding file of Relational database or change described Relational database.
The device that embodiments of the invention also disclose D21, recover in a kind of Database Systems in master-slave mode from storehouse, its
In, this device includes:
Receiving unit, is suitable to receive the backup instruction from specified database;
Backup units, are suitable to MDL be backed up to generate Backup Data, wherein, the Backup Data of MDL
Include the data base configuration file of MDL;
Transmission unit, is suitable to the Backup Data of MDL is transferred to the correspondence position of specified database, so that described
Specified database according to described Backup Data become MDL from storehouse.
D22, the device as described in D21, wherein,
Described transmission unit, is further adapted for determining whether that enough spaces to carry out full backup to MDL;
If there are enough spaces, then after described backup units carry out full backup to MDL, open Rsync service, adopt
The completed Backup Data of MDL is transferred to the correspondence position of specified database by Rsync mode;Without enough
Space, described backup units using i.e. standby pass by the way of MDL is backed up when, Backup Data is transferred to
The correspondence position of specified database.
D23, the device as described in D21, wherein,
Described backup units, are suitable to backup to locally MDL using dbbackup utility xtrabackup.
D24, the device as described in D21, wherein,
Described backup units, are further adapted for during MDL is backed up, by MDL and described
Master-slave synchronisation information output between specified database is in specified synchronizing information file;
Described transmission unit, be further adapted for using the described synchronizing information file specified as MDL Backup Data
A part be transferred to the correspondence position of described specified database.
The system that embodiments of the invention also disclose E25, recover in a kind of Database Systems in master-slave mode from storehouse, its
In, this system includes:Device as any one of C13-C20 and the device as any one of D21-2D4.
Claims (10)
1. recover the method from storehouse in a kind of Database Systems in master-slave mode, wherein, the method includes:
Send backup instruction to MDL side so that MDL side is backed up to MDL;
Obtain the Backup Data of MDL and be saved in the correspondence position of specified database to be restored, the backup of MDL
Data includes the data base configuration file of MDL;
Modification preserve described data base configuration file so that described specified database become described MDL from storehouse;
Start described specified database.
2. the method for claim 1, wherein send backup instruction to MDL side to include:
Obtain IP address and the port numbers of MDL;
IP address according to MDL and port numbers send backup instruction to MDL side.
3. the method for claim 1, wherein described obtain the Backup Data of MDL and be saved in finger to be restored
The correspondence position determining database includes:
Using Rsync mode, the correspondence position that the completed Backup Data of MDL passes to specified database is protected
Deposit;
Or,
Using i.e. standby pass by the way of the Backup Data of MDL is transferred to specified database correspondence position preserved.
4. recover the method from storehouse in a kind of Database Systems in master-slave mode, wherein, the method includes:
Receive the backup instruction from specified database;
MDL is backed up to generate Backup Data, wherein, the Backup Data of MDL includes MDL
Data base configuration file;
The Backup Data of MDL is transferred to the correspondence position of specified database, so that described specified database is according to described
Backup Data become MDL from storehouse.
5. method as claimed in claim 4, wherein, before database is backed up, the method further includes:
Determine whether that enough spaces to carry out full backup to MDL;
If there are enough spaces, then after full backup is carried out to MDL, open Rsync service, using Rsync mode
The completed Backup Data of MDL is transferred to the correspondence position of specified database;
Without enough spaces, using i.e. standby pass by the way of MDL backed up and Backup Data is transferred to
The correspondence position of specified database.
6. recover the device from storehouse in a kind of Database Systems in master-slave mode, wherein, this device includes:
Transmitting element, is suitable to send backup instruction so that MDL side is backed up to MDL to MDL side;
Acquiring unit, is suitable to the correspondence position obtaining the Backup Data of MDL and being saved in specified database to be restored,
The Backup Data of MDL includes the data base configuration file of MDL;
Modification unit, is suitably modified to the described data base configuration file preserving, so that described specified database becomes described main number
According to storehouse from storehouse;
Start unit, is suitable to start described specified database.
7. device as claimed in claim 6, wherein,
Described transmitting element, is suitable to obtain IP address and the port numbers of MDL;IP address according to MDL and port
Number to MDL side send backup instruction.
8. recover the device from storehouse in a kind of Database Systems in master-slave mode, wherein, this device includes:
Receiving unit, is suitable to receive the backup instruction from specified database;
Backup units, are suitable to MDL be backed up to generate Backup Data, wherein, wrap in the Backup Data of MDL
Include the data base configuration file of MDL;
Transmission unit, is suitable to the Backup Data of MDL is transferred to the correspondence position of specified database, so that described specify
Database root according to described Backup Data become MDL from storehouse.
9. device as claimed in claim 8, wherein,
Described transmission unit, is further adapted for determining whether that enough spaces to carry out full backup to MDL;If
There are enough spaces, then, after described backup units carry out full backup to MDL, open Rsync service, using Rsync
The completed Backup Data of MDL is transferred to the correspondence position of specified database by mode;Without enough skies
Between, in described backup units when i.e. for backing up to MDL by the way of passing, Backup Data is transferred to specified
The correspondence position of database.
10. recover the system from storehouse in a kind of Database Systems in master-slave mode, wherein, this system includes:In claim 6-7
Device described in any one and the device as any one of claim 8-9.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610848284.9A CN106383755A (en) | 2016-09-23 | 2016-09-23 | Method, apparatus and system for recovering slave database from master-slave database system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610848284.9A CN106383755A (en) | 2016-09-23 | 2016-09-23 | Method, apparatus and system for recovering slave database from master-slave database system |
Publications (1)
Publication Number | Publication Date |
---|---|
CN106383755A true CN106383755A (en) | 2017-02-08 |
Family
ID=57937343
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201610848284.9A Pending CN106383755A (en) | 2016-09-23 | 2016-09-23 | Method, apparatus and system for recovering slave database from master-slave database system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106383755A (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107861838A (en) * | 2017-10-18 | 2018-03-30 | 福建中金在线信息科技有限公司 | Method and device of the automated back-up MySQL database from storehouse |
CN108733699A (en) * | 2017-04-19 | 2018-11-02 | 北京京东尚科信息技术有限公司 | Database leader follower replication system, method and apparatus |
CN110955719A (en) * | 2018-09-27 | 2020-04-03 | 阿里巴巴集团控股有限公司 | Data access processing equipment, system and method |
CN113761075A (en) * | 2020-09-01 | 2021-12-07 | 北京沃东天骏信息技术有限公司 | Method, device, equipment and computer readable medium for switching databases |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102194009A (en) * | 2011-06-09 | 2011-09-21 | 北京新媒传信科技有限公司 | Database hosting method and database hosting platform system |
CN104391873A (en) * | 2014-10-29 | 2015-03-04 | 上海达梦数据库有限公司 | Database operation separation method and database operation separation system |
CN105468475A (en) * | 2015-11-16 | 2016-04-06 | 北京奇虎科技有限公司 | Backup method and backup device of database |
-
2016
- 2016-09-23 CN CN201610848284.9A patent/CN106383755A/en active Pending
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102194009A (en) * | 2011-06-09 | 2011-09-21 | 北京新媒传信科技有限公司 | Database hosting method and database hosting platform system |
CN104391873A (en) * | 2014-10-29 | 2015-03-04 | 上海达梦数据库有限公司 | Database operation separation method and database operation separation system |
CN105468475A (en) * | 2015-11-16 | 2016-04-06 | 北京奇虎科技有限公司 | Backup method and backup device of database |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108733699A (en) * | 2017-04-19 | 2018-11-02 | 北京京东尚科信息技术有限公司 | Database leader follower replication system, method and apparatus |
CN107861838A (en) * | 2017-10-18 | 2018-03-30 | 福建中金在线信息科技有限公司 | Method and device of the automated back-up MySQL database from storehouse |
CN110955719A (en) * | 2018-09-27 | 2020-04-03 | 阿里巴巴集团控股有限公司 | Data access processing equipment, system and method |
CN113761075A (en) * | 2020-09-01 | 2021-12-07 | 北京沃东天骏信息技术有限公司 | Method, device, equipment and computer readable medium for switching databases |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111124755B (en) | Fault recovery method and device for cluster nodes, electronic equipment and storage medium | |
US9367598B2 (en) | Merging an out of synchronization indicator and a change recording indicator in response to a failure in consistency group formation | |
US8645323B2 (en) | Large volume data replication using job replication | |
CN105550229A (en) | Method and device for repairing data of distributed storage system | |
CN106383755A (en) | Method, apparatus and system for recovering slave database from master-slave database system | |
CN107992537B (en) | Service attribute transmission method, device, computer equipment and storage medium | |
CN107193607B (en) | Method and apparatus for updating code file, storage medium, processor, and terminal | |
US20130166505A1 (en) | Monitoring replication lag between geographically dispersed sites | |
CN110659256A (en) | Multi-computer room synchronization method, computing device and computer storage medium | |
CN108123851A (en) | The lifetime detection method and device of main and subordinate node synchronization link in distributed system | |
CN105468373A (en) | Branch merging method and device | |
US10423625B2 (en) | Exactly-once semantics for streaming analytics in non-idempotent output operations | |
CN107943617B (en) | Data restoration method and device and server cluster | |
CN104462342B (en) | database snapshot synchronization processing method and device | |
CN106790378A (en) | The full synchronous method of data of equipment room, apparatus and system | |
CN105550230B (en) | The method for detecting and device of distributed memory system node failure | |
CN114117111A (en) | Information retrieval method, device and system | |
US9015116B2 (en) | Consistent replication of transactional updates | |
CN110825758B (en) | Transaction processing method and device | |
US9342512B1 (en) | System and method for repairing data synchronization links | |
CN113806309A (en) | Metadata deleting method, system, terminal and storage medium based on distributed lock | |
CN103379167A (en) | Multipoint synchronous storing file downloading exception handling system and method | |
CN113407629A (en) | Data synchronization method and device, electronic equipment and storage medium | |
CN112948494A (en) | Data synchronization method and device, electronic equipment and computer readable medium | |
CN111651189A (en) | Product delivery method and device of continuous integration system and electronic equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20170208 |
|
RJ01 | Rejection of invention patent application after publication |