Summary of the invention
Based on this, it is necessary to for traditional embedded database stability and poor reliability, it is difficult to ensure equipment it is reliable,
The problem of stablizing long-term operation provides a kind of data back up method and system, data reconstruction method and system.
A kind of data back up method, includes the following steps:
It is if current first primary database can normally execute read-write operation, the data in first primary database are standby
Part is into target backup database;
If first primary database and the target backup database can normally execute read-write operation, institute is opened
State the external read-write operation of the first primary database;
More new data is obtained, by the update data backup into target backup file.
The data backup by first primary database is to target backup database in one of the embodiments,
In step before, it is further comprising the steps of:
Stop the external read-write operation of first primary database.
The target backup database includes the first backup database and the second backup number in one of the embodiments,
According to library;
Step of the data backup by first primary database into target backup database, including following step
Suddenly:
By the data backup in first primary database to first backup database;
Can first backup database be detected normally execute read-write operation;
If first backup database can normally execute read-write operation, by the number in first backup database
According to backing up to second backup database.
The target backup file includes that first object backup file and the second target are standby in one of the embodiments,
Part file;
The step by the update data backup into target backup file, includes the following steps:
The more new data is successively backed up in the first backup file and the second backup file.
In one of the embodiments, after the step by the update data backup into target backup file,
It is further comprising the steps of:
If updating data failure described in the target backup file backup, again by the update data backup to described
In target backup file.
A kind of data backup system, including:
Database backup module, if can normally execute read-write operation for current first primary database, by described
Data backup in one primary database is into target backup database;
Read-write operation opening module, if can be normal for first primary database and the target backup database
Read-write operation is executed, then opens the external read-write operation of first primary database;
Data backup module is updated, for obtaining more new data, by the update data backup into target backup file.
A kind of computer equipment, including memory and processor, the memory are stored with computer program, the processing
Device realizes following steps when executing the computer program:
It is if current first primary database can normally execute read-write operation, the data in first primary database are standby
Part is into target backup database;
If first primary database and the target backup database can normally execute read-write operation, institute is opened
State the external read-write operation of the first primary database;
More new data is obtained, by the update data backup into target backup file.
A kind of computer readable storage medium, is stored thereon with computer program, and the computer program is held by processor
Following steps are realized when row:
It is if current first primary database can normally execute read-write operation, the data in first primary database are standby
Part is into target backup database;
If first primary database and the target backup database can normally execute read-write operation, institute is opened
State the external read-write operation of the first primary database;
More new data is obtained, by the update data backup into target backup file.
Above-mentioned data back up method, system, computer equipment and storage medium, by the way that the data of the first primary database are standby
Part to target backup database, the data backup that subsequent first primary database is updated to target backup file is realized dynamic in real time
While state backs up, the risk for causing target backup database to damage because of backup operation can be reduced, guarantees target Backup Data
The validity of data in library, reducing embedded database damage leads to the risk of loss of data, to improve embedded data
The reliability in library improves redundancy ability and automatic recovery ability, ensures that equipment is reliable, stablizes long-term operation.
A kind of data reconstruction method carries out data recovery using the Backup Data of the acquisition of above-mentioned data back up method,
Include the following steps:
If current first primary database cannot normally execute read-write operation, cuts off the external of first primary database and adjust
With;
Start target backup database, using the target backup database as the second primary database;
If second primary database can normally execute read-write operation, opens the external of second primary database and adjust
With.
The target backup database includes the first backup database and the second backup number in one of the embodiments,
According to library;
The starting target backup database is wrapped using the target backup database as the step of the second primary database
Include following steps:
Start first backup database, using first backup database as second primary database.
In one of the embodiments, it is described using first backup database as the step of the second primary database it
Afterwards, further comprising the steps of:
If second primary database cannot normally execute read-write operation, start second backup database, by institute
The second backup database is stated as third primary database;
If the third primary database can normally execute read-write operation, opens the external of the third primary database and adjust
With.
If in one of the embodiments, second primary database can normally execute the step of read-write operation it
Afterwards, further comprising the steps of:
Target backup file is read, is directed into the described second main number for the data of the target backup file as source data
According in library.
The target backup file includes the first backup file and the second backup file in one of the embodiments,;
The data of the target backup file are directed into described second as source data by the reading target backup file
Step in primary database, includes the following steps:
Read the first backup file and the second backup file;
From the first backup file and the second backup file, by data renewal time newest backup file
It is directed into second primary database as source data.
In one of the embodiments, before the step of external call of cutting first primary database, also wrap
Include following steps:
Can presently described first primary database of secondary detection normally execute read-write operation;
If first primary database cannot normally execute read-write operation, using first primary database as damage number
It is saved according to library.
A kind of data recovery system carries out data recovery, packet using the Backup Data that above-mentioned data back up method obtains
It includes:
Module is cut off in external call, if cannot normally execute read-write operation for current first primary database, described in cutting
The external call of first primary database;
Backup database starting module, for starting target backup database, using the target backup database as
Two primary databases;
External call opening module, if can normally execute read-write operation for second primary database, described in unlatching
The external call of second primary database.
A kind of computer equipment, including memory and processor, the memory are stored with computer program, the processing
Device realizes following steps when executing the computer program:
If current first primary database cannot normally execute read-write operation, cuts off the external of first primary database and adjust
With;
Start target backup database, using the target backup database as the second primary database;
If second primary database can normally execute read-write operation, opens the external of second primary database and adjust
With.
A kind of computer readable storage medium, is stored thereon with computer program, and the computer program is held by processor
Following steps are realized when row:
If current first primary database cannot normally execute read-write operation, cuts off the external of first primary database and adjust
With;
Start target backup database, using the target backup database as the second primary database;
If second primary database can normally execute read-write operation, opens the external of second primary database and adjust
With.
Above-mentioned data reconstruction method, system, computer equipment and storage medium, when the first primary database is abnormal,
Target backup database is switched to primary database, is then turned on target Backup Data by the external call for cutting off the first primary database
The recovery of data is completed in the external call in library, can be restored data without restarting equipment, the recovery efficiency of data be improved, to mention
The redundancy ability and automatic recovery ability of high embedded database ensure that equipment is reliable, stablize long-term operation.
Specific embodiment
It is with reference to the accompanying drawings and embodiments, right in order to which the objects, technical solutions and advantages of the application are more clearly understood
The application is further elaborated.It should be appreciated that specific embodiment described herein is only used to explain the application, not
For limiting the application.
Data back up method provided by the present application and corresponding data reconstruction method, can be applied to as shown in Figure 1
In application environment.The terminal includes processor, memory, network interface and the database connected by system bus.Wherein, should
Processor is for providing calculating and control ability.The memory includes non-volatile memory medium, built-in storage.This is non-volatile
Storage medium is stored with operating system, further includes a kind of data backup system and corresponding data recovery system.The interior storage
Device provides environment for the operation of operating system and computer program in non-volatile memory medium.The network of the computer equipment
Interface is used to communicate with external terminal by network connection, receives the various data of exterior terminal.Specifically, data backup system
System and corresponding data recovery system realize embedded database by executing data back up method or data reconstruction method
The backup and recovery of middle data.Wherein, terminal includes but is not limited to the smart machines such as computer, laptop computer.
Referring to fig. 2, Fig. 2 is the flow chart of data back up method in one embodiment of the invention.In the present embodiment, data are standby
Part method, includes the following steps:
Step 210:If current first primary database can normally execute read-write operation, by the number in the first primary database
According to backing up in target backup database.
In this step, primary database refers to that the database being currently running in device systems, target backup database refer to use
In backup, the database of storage primary database data.By executing table handling, such as read operation, write operation etc., inspection to database
Can primary database be surveyed work normally;When the first primary database normally can execute table handling, by the number of the first primary database
According to backuping in target backup database, wherein the first primary database and target backup database, which are respectively stored in, different is
In catalogue of uniting.
Specifically, after device Host normal boot-strap powers on, the first primary database of load to memory headroom, and start thread T
Table handling is executed to the first primary database, can the first primary database of detection work normally, when the first primary database can be normal
When executing table handling, the data of the first primary database are backuped into target Backup Data by the file backup mode of copy migration
In library.
Step 220:If the first primary database and target backup database can normally execute read-write operation, is opened
The external read-write operation of one primary database.
First primary database and target backup database are detected, if the first primary database and target backup number
Table handling can be normally executed according to library, opens the external read-write operation function of the first primary database, the first primary database enters work
State.
Specifically, executing table handling to the first primary database and target backup database by thread T, the first main number is detected
It can be worked normally according to library and target backup database, when the first primary database and target backup database can normally be held
When row table handling, the external read-write operation function of the first primary database is opened, the first primary database enters working condition.
Step 230:More new data is obtained, data backup will be updated into target backup file.
While first primary database is normally carried out read-write operation, the data of update are exported to come, preservation backups to target
In backup file, at this point, no longer carrying out any operation to target backup database.
Optionally, the read-write operation for opening the first primary database can pass through abstract API (Application
Programming Interface, application programming interface) mode open.
In the present embodiment, by the way that by the data backup of the first primary database to target backup database, subsequent first is led
The data backup of database update is to target backup file, wherein the first primary database is real-time dynamic when being written and read
State state can be synchronized at once in target backup file, to realize real-time dynamic backup, meanwhile, process of entirely backing up in realtime is kept
Between the first primary database and target backup file, the wind for causing target backup database to damage because of backup operation can be avoided
Danger guarantees the validity of data in target backup database, and reducing embedded database damage leads to the risk of loss of data,
To improve the reliability of embedded database, improves redundancy ability and automatic recovery ability ensures that equipment is reliable, stablizes long-term
Operation.
Further, in one of the embodiments, by the data backup in the first primary database to target Backup Data
It is further comprising the steps of before step in library:Stop the external read-write operation of the first primary database.
In the present embodiment, stop the external read-write operation of first database, to avoid in subsequent data backup procedure,
Since data of the applications to the first primary database operate, leads to the first primary database backup failure, cause what is more
The damage of first primary database.
Target backup database includes the first backup database and the second Backup Data in one of the embodiments,
Library;By step of the data backup in the first primary database into target backup database, include the following steps:By the first main number
According to the data backup in library to the first backup database;Can the first backup database be detected normally execute read-write operation;If the
One backup database can normally execute read-write operation, then by the data backup in the first backup database to the second Backup Data
Library.
Specifically, when the first primary database normally can execute read-write operation, by the data backup of the first primary database
Into the first backup database;Table handling, such as read operation, write operation etc. are carried out to the first backup database, detection first is standby
Can part database work normally, when the first backup database can work normally, by the data backup of the first backup database
Into the second backup database, wherein the first backup database is stored respectively in different system mesh from the second backup database
Under record.
In the present embodiment, by successively by the data backup of the first primary database to the first backup database, the first backup
DB Backup is to the second backup database, after the case where realizing the dual backup of cyclic redundancy, preventing backup file corruption
No valid data source is restored, and whether Test database damages before data backup every time, guarantees the validity of each Backup Data,
Reducing embedded database damage leads to the risk of loss of data.
Likewise, can realize cyclic redundancy for more new data when the first primary database is normally carried out read-write operation
Dual backup, reducing embedded database damage leads to the risk of loss of data, for this purpose, mesh in one of the embodiments,
Marking backup file includes first object backup file and the second target backup file;Data backup to target will be updated and back up text
Step in part, includes the following steps:More new data is successively backed up in the first backup file and the second backup file.
Specifically, the export of more new data is come, is successively saved standby while the first primary database is normally carried out read-write operation
Part is into the first backup file and the second backup file, wherein the first backup file and the second backup file save respectively
Under different system directories.
After step of the data backup into target backup file being updated in one of the embodiments, further include with
Lower step:If target backup file backup updates data failure, data backup will be updated again into target backup file.
When carrying out real-time dynamic backup more new data every time, all target backup file is detected, if target backup text
Part backup failure backups in target backup file from the first primary database by more new data again immediately, primary to avoid certain
Backup failure or read-write operation lead to target backup file corruption, it is ensured that the correctness of target backup file.
It is the flow chart of data back up method in another embodiment of the present invention referring to Fig. 3, Fig. 3.In the present embodiment, data
Backup method includes the following steps:
Step 310:Stop the external read-write operation of the first primary database.
After device Host normal boot-strap powers on, the first primary database A of load to memory headroom, and stop the first primary database
External read-write operation.
Step 320:It is if the first primary database can normally execute read-write operation, the data in the first primary database are standby
Part to the first backup database;Can the first backup database be detected normally execute read-write operation;If the first backup database energy
Enough normal execution read-write operations, then by the data backup in the first backup database to the second backup database.
Start thread T and table handling is executed to the first primary database A, can the first primary database A of detection work normally;Online
In the case that the testing result that journey T detects the first primary database A is normal, by the data backup in the first primary database A to the
In one backup database C1;There is thread T to execute table handling to the first backup database C1 again, detects the first backup database C1 energy
No normal work, when the testing result of the first backup database C1 be it is normal, extremely by the data backup of the first backup database C1
Second backup database C2.Wherein, the first backup database C1 and the second backup database C2 are respectively stored in different systems
Under catalogue, data backup procedure is all file backup, and backup mode is the mode of copy migration.
Step 330:If the first primary database, first object backup database and the second backup database can normally be held
Row read-write operation then opens the external read-write operation of the first primary database.
The first primary database A, the first backup database C1 and the second backup database C2 are examined by thread T again
It surveys, if the first primary database A, the first backup database C1 and the second backup database C2 can normally execute table handling, leads to
It crosses abstract API and opens the external read-write operation function of the first primary database A, the first primary database A enters working condition.
Step 340:More new data is obtained, more new data is successively backed up into the first backup file and the second backup file
In.
After first primary database A enters working condition, when the first primary database A executes write operation, synchronize data successively
It backs up to the first backup file B1 and the second backup file B2, the first backup file B1 and the second backup file B2 is protected respectively
There are different directories.During each backup operation, by thread T detection the first backup file B1's and the second backup file B2
Correctness, it is ensured that backup is correctly to back up every time.If certain backup failure or write operation lead the first backup file B1 with
And second backup file B2 damage, then backed up again from the first primary database A, it is ensured that the first backup file B1 of redundancy backup with
And second backup file B2 be correctly, so far complete a database redundancy backup operation.
In the present embodiment, by the data backup of the first primary database to different by the way of the dual backup of cyclic redundancy
Backup database, the data backup that subsequent first primary database is updated to different target backup files, wherein the first main number
It being written and read is that can be synchronized to file destination at once according to the real-time dynamical state in library, to realize real-time dynamic backup, together
When, entirely the process of backing up in realtime is maintained between the first primary database and target backup file, can be reduced because backup operation is led
The risk of target backup database damage is caused, guarantees the validity of data in target backup database, reduces embedded database
Depositing damage leads to the risk of loss of data, to improve the reliability of embedded database, improves redundancy ability and self- recoverage energy
It tries hard to keep and hinders that equipment is reliable, stablizes long-term operation.
According to above-mentioned data back up method, the present invention also provides a kind of data reconstruction methods, below with regard to data of the invention
The embodiment of restoration methods is described in detail.Referring to fig. 4, Fig. 4 is the stream of data reconstruction method in one embodiment of the invention
Cheng Tu.In the present embodiment, data back up method includes the following steps:
Step 410:If current first primary database cannot normally execute read-write operation, the outside of the first primary database is cut off
It calls.
In this step, when the read-write operation of the first primary database cannot be executed normally, external program is cut off to master data
The call operation in library, so that the external call state of primary database state from normal operating conditions switches to lock, prevents equipment
Lead to equipment entanglement because operation primary database is abnormal.
Step 420:Start target backup database, using target backup database as the second primary database.
Start target backup database, target backup database is loaded into memory, target backup database is switched
For primary database.
Step 430:If the second primary database can normally execute read-write operation, opens the external of the second primary database and adjust
With.
Table handling, such as read operation, write operation etc. are executed to the second primary database, can the second primary database of detection normal
Work opens the external call operation of primary database, makes host data when the second primary database normally can execute table handling
The external call state in library state from lock switches to normal operating conditions.
In the present embodiment, when the read-write operation of the first primary database cannot be executed normally, need to realize that data are restored;?
Data take the fast quick-recovery of not power down when restoring, and the database of damage is hung up by lock mechanism, start backup database, will back up
Database switches to primary database, is externally operated after completing switching by lock mechanism unlatching, completes entire dynamic master/slave data library
The operation of switching, in entire scheme implementation process, the method for active-standby switch operation is not power down, can be real without restarting equipment
The recovery of existing data, can be improved the accurate and realisation of embedded data library backup, the efficiency that data are restored be improved, to reach
To equipment disaster tolerance ability and automatic recovery ability is improved, complicated in net application process, guarantee equipment provides steadily in the long term can
It leans on, sustainable service.
If also being wrapped after the second primary database can normally execute the step of read-write operation in one of the embodiments,
Include following steps:Target backup file is read, the data of target backup file are directed into the second primary database as source data
In.
In data backup procedure, target backup database has not only been backed up, has also backed up target backup file, this reality
Example is applied in data recovery procedure, the source data of target backup file is directed into target database, to guarantee entire target
The data integrity of backup database, so that after primary database damage, when standby database is switched to primary database when data,
Data dynamic updates, and improves data recovering efficiency.
Target backup database includes the first backup database and the second Backup Data in one of the embodiments,
Library;Starting target backup database includes the following steps using target backup database as the step of the second primary database:It opens
Dynamic first backup database, using the first backup database as the second primary database.
In data backup procedure, data realize dual redundant backup, so in data recovery procedure, starting the first
First backup database is loaded into memory, is switched to primary database by one backup database.
Further, when the first backup database damages, when cannot normally execute read-write operation, starting second can be passed through
Backup database is used as primary database.For this purpose, in one of the embodiments, using the first backup database as second
It is further comprising the steps of after the step of primary database:If the second primary database cannot normally execute read-write operation, start
Two backup databases, using the second backup database as third primary database;If third primary database can normally execute read-write
The external call of third primary database is opened in operation.
In above-described embodiment, in data backup procedure, data realize dual redundant backup, and the mechanism of redundancy backup ensures
Equipment is without valid data source after the case where backup database itself also has the characteristic of backup, prevents backup database damage
Restore, so, when finding the damage of the first backup database, starting the second backup database, and will in data recovery procedure
Second backup database is switched to primary database.
Likewise, target backup file also realizes that dual redundant backs up in data backup procedure;For this purpose, wherein one
In a embodiment, target backup file includes the first backup file and the second backup file;Target backup file is read, by mesh
The data of mark backup file are directed into the step in the second primary database as source data, include the following steps:It is standby to read first
Part file and the second backup file;It is from the first backup file and the second backup file, data renewal time is newest
Backup file is directed into the second primary database as source data.
In the present embodiment, by comparing the renewal time of the first backup file and the second backup file, when determining update
Between a newest backup file, be directed into the data for backing up file as source data in target backup database, guarantee it is standby
Primary database and original the primary database indifference in data of part database switching.
It further include following step before the step of cutting off the external call of the first primary database in one of the embodiments,
Suddenly:Can current first primary database of secondary detection normally execute read-write operation;If the first primary database cannot normally execute reading
Write operation is then saved the first primary database as damage database.
In database course of normal operation, enable thread T to the first primary database execute table handling, such as read operation,
Write operation etc., when discovery has table handling failure, again detection confirmation, when secondary detection confirm the first primary database damage or
When unavailable, using the first primary database as damage database, backup is stored into a fixed system directory, in case after
It looks into.
It is the flow chart of data reconstruction method in another embodiment of the present invention referring to Fig. 5, Fig. 5.In the present embodiment, data
Backup method includes the following steps:
Step S501:If the first primary database cannot normally execute read-write operation, current first primary database of secondary detection
Read-write operation can normally be executed.
Device systems work normally, and in the case of the first primary database A normally reads and writes, start thread T, and start T pairs of thread
First primary database A executes table handling, and can the first primary database A of detection work normally, when the table for finding the first primary database A
When operation failure, detection confirmation again.
Step S502:If the first primary database cannot normally execute read-write operation, using the first primary database as damage number
It is saved according to library, and cuts off the external call of the first primary database.
When secondary detection confirms the first primary database A cisco unity malfunction, the first primary database A is named as A_
Error, and stop the use of the read-write operation API of the first primary database A, tune of the cutting external program to the first primary database A
With applications are illustrated as lock state to the calling of the first primary database at this time.
Step S503:Start the first backup database, using the first backup database as the second primary database.
Start the first backup database C1, the first backup database C1 is loaded into memory, by the first backup database
C1 is switched to primary database.
Step S504:Can the second primary database be detected normally execute read-write operation, if the second primary database can be normal
Read-write operation is executed, step S505 is skipped to;If the second primary database cannot normally execute read-write operation, step S507 is skipped to.
Step S505:Read the first backup file and the second backup file;It is backed up from the first backup file and second
In file, it is directed into the second primary database using data renewal time newest backup file as source data.
If the first backup database C1 can normally execute read-write operation, start the backup of the first backup file B1 and second
File B2 compares the new and old of data in the first backup file B1 and the second backup file B2, from the first backup file B1 and
Renewal time newest one is chosen in the two in second backup file B2, is encapsulated as the file that format is xml, and import the
In one backup database C1.
Step S506:Can the second primary database be detected normally execute read-write operation, if the second primary database can be normal
Read-write operation is executed, step S511 is skipped to;If the second primary database cannot normally execute read-write operation, step S507 is skipped to.
Can the first backup database C1 is detected again normally execute read-write operation, avoid causing in importing data procedures
After the damage of first backup database C1, directly using the database of damage as primary database and open external call.
Step S507:Start the second backup database, using the second backup database as third primary database.
If the first backup database C1 cannot normally execute read-write operation, the second backup database of starting C2 is standby by second
Part database C2 is loaded into memory, and the second backup database C2 is switched to primary database.
Step S508:Can detection third primary database normally execute read-write operation, if third primary database can be normal
Read-write operation is executed, step S509 is skipped to;If third primary database cannot normally execute read-write operation, report and alarm is remotely supervised
Control center.
Step S509:Read the first backup file and the second backup file;It is backed up from the first backup file and second
In file, it is directed into third primary database using data renewal time newest backup file as source data.
Likewise, if the second backup database C2 can normally execute read-write operation, start the first backup file B1 and
Second backup file B2 compares the new and old of data in the first backup file B1 and the second backup file B2, from the first backup text
Renewal time newest one is chosen in the two in part B1 and the second backup file B2, and being encapsulated as format is xml
The file of (eXtensible Markup Language, extensible markup language), and import in the second backup database C2.
Step S510:Can detection third primary database normally execute read-write operation, if third primary database can be normal
Read-write operation is executed, step S511 is skipped to;If third primary database cannot normally execute read-write operation, report and alarm is remotely supervised
Control center.
Step S511:Open the external call of the second primary database or third primary database.
After the first backup database C1 (or second backup database C2) is switched to primary database, the first Backup Data
Library C1 (or second backup database C2) is that data are self-healing, are capable of the database of normal use, as current main number
According to library, the use of the read-write operation API of primary database is opened, allows external program to the calling of primary database, external at this time
Calling state state from lock is switched to normal operating conditions.
Above-mentioned data reconstruction method takes the fast quick-recovery of not power down, and the database of damage is hung up by lock mechanism, starts standby
Backup database is switched to primary database by part database, is externally operated, is completed entire by lock mechanism unlatching after completing switching
The operation of dynamic master/slave data library switching.In entire scheme implementation process, whether the current primary database of circular test can be normal
Read-write operation is executed, to guarantee that the database after data are restored can provide service, and the method for active-standby switch operation for equipment
It is not power down, the recovery of data can be realized without restarting equipment, to improves the accurate and real of embedded data library backup
Existing property improves the efficiency that data are restored.
It should be understood that although each step in the flow chart of Fig. 2 to 5 is successively shown according to the instruction of arrow,
It is these steps is not that the inevitable sequence according to arrow instruction successively executes.Unless expressly stating otherwise herein, these steps
There is no stringent sequences to limit for rapid execution, these steps can execute in other order.Moreover, in Fig. 2 to 5 at least
A part of step may include that perhaps these sub-steps of multiple stages or stage are not necessarily in same a period of time to multiple sub-steps
Quarter executes completion, but can execute at different times, the execution in these sub-steps or stage be sequentially also not necessarily according to
Secondary progress, but in turn or can replace at least part of the sub-step or stage of other steps or other steps
Ground executes.
According to above-mentioned data back up method, the present invention also provides a kind of data backup systems, below with regard to data of the invention
The embodiment of standby system is described in detail.
It is the structural schematic diagram of data backup system in one embodiment of the invention referring to Fig. 6, Fig. 6.In the present embodiment, number
Include according to standby system:Database backup module 610, read-write operation opening module 620 and update data backup module 630,
Wherein:
Database backup module 610, if read-write operation can be normally executed for current first primary database, by first
Data backup in primary database is into target backup database;
Read-write operation opening module 620, if can normally be executed for the first primary database and target backup database
Read-write operation then opens the external read-write operation of the first primary database;
Data backup module 630 is updated, for obtaining more new data, data backup will be updated into target backup file.
Above-mentioned data backup system will be subsequent by by the data backup of the first primary database to target backup database
The data backup that first primary database updates while realizing real-time dynamic backup, can be reduced because standby to target backup file
The risk that part operation causes target backup database to damage, guarantees the validity of data in target backup database, reduces and is embedded in
Formula data damaged stock leads to the risk of loss of data, to improve the reliability of embedded database, improve redundancy ability and
Automatic recovery ability ensures that equipment is reliable, stablizes long-term operation.
Database backup module 610 is used to stop the external read-write behaviour of the first primary database in one of the embodiments,
Make.
Target backup database includes the first backup database and the second Backup Data in one of the embodiments,
Library;Database backup module 610 is used for the data backup in the first primary database to the first backup database;It is standby to detect first
Can part database normally execute read-write operation;When the first backup database normally can execute read-write operation, then by first
Data backup in backup database is to the second backup database.
Target backup file includes first object backup file and the second target backup text in one of the embodiments,
Part;Data backup module 630 is updated for successively backing up to more new data in the first backup file and the second backup file.
Data backup module 630 is updated in one of the embodiments, to be used in target backup file backup more new data
When failure, data backup will be updated again into target backup file.
According to above-mentioned data reconstruction method, the present invention also provides a kind of data recovery systems, below with regard to data of the invention
The embodiment of recovery system is described in detail.
It is the structural schematic diagram of data recovery system in one embodiment of the invention referring to Fig. 7, Fig. 7.In the present embodiment, number
Include according to recovery system:Module 710, backup database starting module 720 and external call opening module are cut off in external call
730, wherein:
Module 710 is cut off in external call, if cannot normally execute read-write operation for current first primary database, cutting the
The external call of one primary database;
Backup database starting module 720, for starting target backup database, using target backup database as second
Primary database;
It is main to open second if can normally execute read-write operation for the second primary database for external call opening module 730
The external call of database.
Above-mentioned data recovery system cuts off the external call of the first primary database when the first primary database is abnormal,
Target backup database is switched to primary database, the recovery of data is completed in the external call for being then turned on target backup database,
Can restore data without restarting equipment, improve the recovery efficiency of data, thus improve embedded database redundancy ability and
Automatic recovery ability ensures that equipment is reliable, stablizes long-term operation.
Target backup database includes the first backup database and the second Backup Data in one of the embodiments,
Library;Backup database starting module 720 is for starting the first backup database, using the first backup database as the second master data
Library.
Backup database starting module 720 in the second primary database for cannot normally hold in one of the embodiments,
When row read-write operation, start the second backup database, using the second backup database as third primary database;In third master data
When library can normally execute read-write operation, the external call of third primary database is opened.
It is the structural schematic diagram of data recovery system in another embodiment of the present invention referring to Fig. 8, Fig. 8.In the present embodiment,
Data recovery system further includes updating data recovery module 740, for reading target backup file, by the number of target backup file
It is directed into the second primary database according to as source data.
Target backup file includes the first backup file and the second backup file in one of the embodiments,;It updates
Data recovery module 740 is for reading the first backup file and the second backup file;It is standby from the first backup file and second
In part file, it is directed into the second primary database using data renewal time newest backup file as source data.
External call cutting module 710 is used for the current first primary database energy of secondary detection in one of the embodiments,
No normal execution read-write operation;When the first primary database normally cannot execute read-write operation, then using the first primary database as
Damage database is saved.
Specific restriction about data backup system or data recovery system may refer to above for data backup
Method or data reconstruction method limit accordingly, and details are not described herein.Above-mentioned data backup system or data recovery system
In modules can be realized fully or partially through software, hardware and combinations thereof.Above-mentioned each module can be interior in the form of hardware
It is embedded in or independently of the memory that in the processor in computer equipment, can also be stored in a software form in computer equipment
In, the corresponding operation of the above modules is executed in order to which processor calls.
In one embodiment, a kind of computer equipment is provided, which can be server, internal junction
Composition can be as shown in Figure 9.The computer equipment include by system bus connect processor, memory, network interface and
Database.Wherein, the processor of the computer equipment is for providing calculating and control ability.The memory packet of the computer equipment
Include non-volatile memory medium, built-in storage.The non-volatile memory medium is stored with operating system, computer program and data
Library.The built-in storage provides environment for the operation of operating system and computer program in non-volatile memory medium.The calculating
The database of machine equipment is for storing different data.The network interface of the computer equipment is used to pass through net with external terminal
Network connection communication.To realize a kind of data back up method and data reconstruction method when the computer program is executed by processor.
It will be understood by those skilled in the art that structure shown in Fig. 9, only part relevant to application scheme is tied
The block diagram of structure does not constitute the restriction for the computer equipment being applied thereon to application scheme, specific computer equipment
It may include perhaps combining certain components or with different component layouts than more or fewer components as shown in the figure.
In one embodiment, a kind of computer equipment, including memory and processor are provided, is stored in memory
Computer program, the processor realize following steps when executing computer program:
If current first primary database can normally execute read-write operation, extremely by the data backup in the first primary database
In target backup database;
If the first primary database and target backup database can normally execute read-write operation, the first master data is opened
The external read-write operation in library;
More new data is obtained, data backup will be updated into target backup file.
In one embodiment, following steps are also realized when processor executes computer program:Stop the first primary database
External read-write operation.
In one embodiment, target backup database includes the first backup database and the second backup database;Place
Reason device also realizes following steps when executing computer program:By the data backup in the first primary database to the first Backup Data
Library;Can the first backup database be detected normally execute read-write operation;If the first backup database can normally execute read-write behaviour
Make, then by the data backup in the first backup database to the second backup database.
In one embodiment, target backup file includes first object backup file and the second target backup file;
Processor also realizes following steps when executing computer program:More new data is successively backed up into the first backup file and second
In backup file.
In one embodiment, following steps are also realized when processor executes computer program:If target backup file is standby
Part updates data failure, then will update data backup again into target backup file.
In one embodiment, a kind of computer equipment, including memory and processor are additionally provided, is stored in memory
There is computer program, which realizes following steps when executing computer program:
If current first primary database cannot normally execute read-write operation, the external call of the first primary database is cut off;
Start target backup database, using target backup database as the second primary database;
If the second primary database can normally execute read-write operation, the external call of the second primary database is opened.
In one embodiment, target backup database includes the first backup database and the second backup database;Place
Reason device also realizes following steps when executing computer program:Start the first backup database, using the first backup database as
Two primary databases.
In one embodiment, following steps are also realized when processor executes computer program:If the second primary database is not
Read-write operation can be normally executed, then starts the second backup database, using the second backup database as third primary database;If the
Three primary databases can normally execute read-write operation, open the external call of third primary database.
In one embodiment, following steps are also realized when processor executes computer program:Target backup file is read,
The data of target backup file are directed into the second primary database as source data.
In one embodiment, target backup file includes the first backup file and the second backup file;Processor is held
Following steps are also realized when row computer program:Read the first backup file and the second backup file;From the first backup file
And second in backup file, is directed into the second primary database using data renewal time newest backup file as source data
In.
In one embodiment, following steps are also realized when processor executes computer program:Secondary detection current first
Can primary database normally execute read-write operation;If the first primary database cannot normally execute read-write operation, by the first main number
It is saved according to library as damage database.
In one embodiment, a kind of computer readable storage medium is provided, computer program is stored thereon with, is calculated
Machine program realizes following steps when being executed by processor:
If current first primary database can normally execute read-write operation, extremely by the data backup in the first primary database
In target backup database;
If the first primary database and target backup database can normally execute read-write operation, the first master data is opened
The external read-write operation in library;
More new data is obtained, data backup will be updated into target backup file.
In one embodiment, following steps are also realized when computer program is executed by processor:Stop the first master data
The external read-write operation in library.
In one embodiment, target backup database includes the first backup database and the second backup database;Meter
Calculation machine program also realizes following steps when being executed by processor:By the data backup in the first primary database to the first Backup Data
Library;Can the first backup database be detected normally execute read-write operation;If the first backup database can normally execute read-write behaviour
Make, then by the data backup in the first backup database to the second backup database.
In one embodiment, target backup file includes first object backup file and the second target backup file;
Following steps are also realized when computer program is executed by processor:More new data is successively backed up into the first backup file and
In two backup files.
In one embodiment, following steps are also realized when computer program is executed by processor:If target backup file
Backup updating data failure will then update data backup into target backup file again.
In one embodiment, a kind of computer readable storage medium is additionally provided, computer program is stored thereon with, is counted
Calculation machine program realizes following steps when being executed by processor:
If current first primary database cannot normally execute read-write operation, the external call of the first primary database is cut off;
Start target backup database, using target backup database as the second primary database;
If the second primary database can normally execute read-write operation, the external call of the second primary database is opened.
In one embodiment, target backup database includes the first backup database and the second backup database;Meter
Calculation machine program also realizes following steps when being executed by processor:Start the first backup database, using the first backup database as
Second primary database.
In one embodiment, following steps are also realized when computer program is executed by processor:If the second primary database
Read-write operation cannot be normally executed, then starts the second backup database, using the second backup database as third primary database;If
Third primary database can normally execute read-write operation, open the external call of third primary database.
In one embodiment, following steps are also realized when computer program is executed by processor:Read target backup text
The data of target backup file are directed into the second primary database by part as source data.
In one embodiment, target backup file includes the first backup file and the second backup file;Computer journey
Following steps are also realized when sequence is executed by processor:Read the first backup file and the second backup file;From the first backup text
In part and the second backup file, the second primary database is directed into using data renewal time newest backup file as source data
In.
In one embodiment, following steps are also realized when computer program is executed by processor:Secondary detection current
Can one primary database normally execute read-write operation;It is main by first if the first primary database cannot normally execute read-write operation
Database is saved as damage database.
Those of ordinary skill in the art will appreciate that realizing all or part of the process in above-described embodiment method, being can be with
Relevant hardware is instructed to complete by computer program, the computer program can be stored in a non-volatile computer
In read/write memory medium, the computer program is when being executed, it may include such as the process of the embodiment of above-mentioned each method.Wherein,
To any reference of memory, storage, database or other media used in each embodiment provided herein,
Including non-volatile and/or volatile memory.Nonvolatile memory may include read-only memory (ROM), programming ROM
(PROM), electrically programmable ROM (EPROM), electrically erasable ROM (EEPROM) or flash memory.Volatile memory may include
Random access memory (RAM) or external cache.By way of illustration and not limitation, RAM is available in many forms,
Such as static state RAM (SRAM), dynamic ram (DRAM), synchronous dram (SDRAM), double data rate sdram (DDRSDRAM), enhancing
Type SDRAM (ESDRAM), synchronization link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM
(RDRAM), direct memory bus dynamic ram (DRDRAM) and memory bus dynamic ram (RDRAM) etc..
Each technical characteristic of above embodiments can be combined arbitrarily, for simplicity of description, not to above-described embodiment
In each technical characteristic it is all possible combination be all described, as long as however, the combination of these technical characteristics be not present lance
Shield all should be considered as described in this specification.
The several embodiments of the application above described embodiment only expresses, the description thereof is more specific and detailed, but simultaneously
It cannot therefore be construed as limiting the scope of the patent.It should be pointed out that coming for those of ordinary skill in the art
It says, without departing from the concept of this application, various modifications and improvements can be made, these belong to the protection of the application
Range.Therefore, the scope of protection shall be subject to the appended claims for the application patent.