CN107229541B - Backup method, standby system and the server of Transaction Information - Google Patents

Backup method, standby system and the server of Transaction Information Download PDF

Info

Publication number
CN107229541B
CN107229541B CN201710477551.0A CN201710477551A CN107229541B CN 107229541 B CN107229541 B CN 107229541B CN 201710477551 A CN201710477551 A CN 201710477551A CN 107229541 B CN107229541 B CN 107229541B
Authority
CN
China
Prior art keywords
server
identification code
database
transaction information
standby
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.)
Active
Application number
CN201710477551.0A
Other languages
Chinese (zh)
Other versions
CN107229541A (en
Inventor
姜宇祥
俞榕刚
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ctrip Travel Information Technology Shanghai Co Ltd
Original Assignee
Ctrip Travel Information Technology Shanghai Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ctrip Travel Information Technology Shanghai Co Ltd filed Critical Ctrip Travel Information Technology Shanghai Co Ltd
Priority to CN201710477551.0A priority Critical patent/CN107229541B/en
Publication of CN107229541A publication Critical patent/CN107229541A/en
Application granted granted Critical
Publication of CN107229541B publication Critical patent/CN107229541B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1474Saving, restoring, recovering or retrying in transactions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Quality & Reliability (AREA)
  • Databases & Information Systems (AREA)
  • Computing Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Hardware Redundancy (AREA)

Abstract

The present invention provides a kind of backup method of Transaction Information, standby system and server, the standby system includes the server where server and one or more standby databases where a primary database, the backup method transmits an identification code while including: the server transport Transaction Information where server and the standby database where the primary database, and respectively according to the transmission situation of Transaction Information, indicate the state of the corresponding backup operation of the identification code, when the server where the server or the standby database where the primary database is in either step failure, it is synchronous with the standby database that the server of the failure completes the primary database according to the inquiry of the identification code and its flag states.Backup method, standby system and the server of Transaction Information provided by the invention can realize that primary database is synchronous with standby database in any server failure.

Description

Backup method, standby system and the server of Transaction Information
Technical field
The present invention relates to computer application technology more particularly to a kind of backup methods of Transaction Information, standby system And server.
Background technique
In data storage and the technology of data backup, usual single machine database only can guarantee the integrality of data, once Delay machine occurs, offer service can not be provided.
In order to keep the continuity of service, partial database provides the service mode of master slave mode in high reliability, when Service is switched to standby database and continues to provide on the server after server delay machine where primary database.For example, MySQL Database is exactly that master slave mode mode is used to provide reliability of service.The high reliability that master slave mode provides passes through host data Change data are sent to slave, same operation is completed on slave.To be consistent in data with host.
Then, the leader follower replication of existing MySQL will appear the inconsistent situation of data in certain extreme cases.For example, main Submit delta data to local with server where database, but the delta data takes where being not sent to standby database It is engaged in delay machine occur when device.After completing failover, server where standby database lacks the data of the part, because , there is the inconsistent situation of data in this.
Summary of the invention
The present invention provides backup method, the backup of a kind of Transaction Information to overcome the problems of the above-mentioned prior art System and server can realize that primary database is synchronous with standby database in any server failure.
According to an aspect of the present invention, a kind of backup method of standby system for Transaction Information is provided, it is described standby Part system includes the server where server and one or more standby databases where a primary database, the backup Method includes following backup-step: the server where the primary database generates an identification code, institute according to a Transaction Information The backup operation for stating Transaction Information described in identification code unique identification defines the flag states of the corresponding backup operation of the identification code It is unfinished;The Transaction Information and the identification code are sent at least one institute by the server where the primary database State the server where standby database;Server where the standby database is by the identification code and the Transaction Information Persistence, and the identification code described in the server mark where the standby database make the corresponding backup behaviour of the identification code The flag states of work are to be completed;The server where server to the primary database where the standby database returns A multiple return information, the return information indicate that the Transaction Information completes backup;Server where the primary database According to the return information by the identification code and the Transaction Information persistence and in the service where the primary database Identification code described in device mark is completed the flag states of the corresponding backup operation of the identification code, wherein when described primary The server where server or the standby database where database is in any of the above-described backup-step failure, the event The server of barrier completes the primary database and the preliminary data according to the inquiry of the identification code and its flag states The synchronization in library.
It optionally, will be in one or more of standby databases when the server failure where the primary database A standby database as the primary database;Using the primary database as a standby database.
Optionally, when any server failure is restarted, inquiry is with the presence or absence of mark in the server restarted State is the unfinished identification code of the backup operation of Transaction Information, and if it exists, then the server restarted is to current primary data Server where library sends a query information to inquire the identification code in the mark of the server where current primary database Will state, the server restarted are completed synchronous with current primary database according to the result of the query information.
Optionally, if the result of the query information indicates the identification code in the server where current primary database Flag states indicate that the backup operation of the Transaction Information is completed, then where the server restarted to current primary database Server request the Transaction Information.
Optionally, if the result of the query information indicates the identification code in the server where current primary database Flag states indicate that the backup operation of the Transaction Information does not complete, then the server restarted is deleted in corresponding database The Transaction Information and the identification code of the corresponding identification code.
Optionally, when the server failure where the primary database, the service where each standby database Device inquires the identification code of the primary database, and the identification code is not complete in the flag states of the primary database At, using the identification code the backup database flag states be completed standby database as primary data Library.
Optionally, the flag states of the identification code are as the first mark of the server where being located at the primary database It position and is indicated positioned at the second flag bit of the server where the standby database, first flag bit and described second The different value of flag bit indicates whether the backup operation of the corresponding Transaction Information of associated identification code is completed.
Optionally, the flag states of the identification code are as the first queue of the server where being located at the primary database It is indicated with the second queue positioned at the server where the standby database, the server where the primary database When generating the identification code, the identification code is put into the first queue, when the server where the primary database is complete After the Transaction Information and the persistence of the identification code, the identification code is removed from the first queue;When described When server where standby database receives the identification code, the identification code is put into the second queue, when described standby After completing the Transaction Information and the persistence of the identification code with the server where database, by the identification code from described It is removed in second queue.
Optionally, the server where the primary database has a primary mark.
Optionally, the identification code are as follows: the server where Universally Unique Identifier or the primary database generates Random number.
According to another aspect of the invention, a kind of standby system of Transaction Information is also provided, comprising: a primary database institute Server, comprising: first processor;First computer readable storage medium stores the first computer program, institute thereon It states and realizes following primary DB Backup step: the primary data when the first computer program is executed by the first processor Server where library generates an identification code, the backup of Transaction Information described in the identification code unique identification according to a Transaction Information Operation, it is unfinished for defining the flag states of the corresponding backup operation of the identification code;Service where the primary database The Transaction Information and the identification code are sent to the server where at least one standby database by device;The primary data The return information that server where library is replied according to the server where the standby database is by the identification code and described Transaction Information persistence and the identification code described in the server mark where the primary database, keep the identification code corresponding The flag states of backup operation are to be completed;Server where one or more standby databases, each standby database The server at place includes: second processor;Second computer readable storage medium storing program for executing stores second computer program thereon, The second computer program realizes following standby database backup-step when being executed by the second processor: the spare number The identification code and the Transaction Information are received according to the server where library, the identification code and the Transaction Information is lasting Change, and the identification code described in the server mark where the standby database, makes the corresponding backup operation of the identification code Flag states are to be completed;Server where server to the primary database where the standby database replys one Return information, the return information indicate that the Transaction Information completes backup;Wherein, when the service where the primary database Server where device or the standby database is in any of the above-described primary DB Backup step or preliminary data library backup When step failure, the server of the failure completes the primary data according to the inquiry of the identification code and its flag states Library is synchronous with the standby database.
Optionally, the server where the primary database has a primary mark, when the primary mark is replaced extremely When another server, first computer program realizes the preliminary data library backup step when being executed by the first processor Suddenly, the primary DB Backup step is realized when the second computer program is executed by the second processor.
Optionally, when restarting after any server failure, inquiry is with the presence or absence of mark in the server restarted Will state is the unfinished identification code of the backup operation of Transaction Information, and if it exists, then the server restarted is to current primary number A query information is sent according to the server where library to inquire the identification code in the server where current primary database Flag states, the server restarted are completed synchronous with current primary database according to the result of the query information.
According to another aspect of the invention, a kind of server is provided, also for realizing primary database and standby database Between data backup, comprising: processor;Computer readable storage medium stores computer program, the computer thereon Program realizes following steps when being executed by the processor: if the server is as the server where a primary database When, the server generates an identification code, the backup of Transaction Information described in the identification code unique identification according to a Transaction Information Operation, it is unfinished for defining the flag states of the corresponding backup operation of the identification code;The server is by the Transaction Information And the identification code is sent to the server where at least one standby database;The server is according to the standby database The return information that the server at place is replied is by the identification code and the Transaction Information persistence and in the server mark The flag states of the corresponding backup operation of the identification code are completed in the identification code;If the server is standby as one When with server where database, the server receives the identification code and the Transaction Information, by the identification code and The Transaction Information persistence, and the identification code described in the server mark, make the corresponding backup operation of the identification code Flag states are to be completed;Server where from the server to primary database replys a return information, the reply letter Breath indicates that the Transaction Information completes backup;Wherein, when the server is in any of the above-described step failure, the clothes of the failure Business device completes the same of the primary database and the standby database according to the inquiry of the identification code and its flag states Step.
Compared with prior art, advantage of the invention is that passing through server where primary database and standby database institute Server transport Transaction Information while transmit an identification code, and respectively according to the transmission situation of Transaction Information, mark with The state of the backup operation of the corresponding Transaction Information of the identification code, when where primary database server or standby database institute Server in either step failure, the server of the failure according to the identification code and its flag states inquiry with It is synchronous with the standby database to complete the primary database, realizes that primary database is consistent with the data of standby database Property.
Detailed description of the invention
Its example embodiment is described in detail by referring to accompanying drawing, above and other feature of the invention and advantage will become It is more obvious.
Fig. 1 shows the structural schematic diagram of the standby system of Transaction Information according to an embodiment of the present invention.
Fig. 2 shows server events where database primary in the standby system of Transaction Information according to an embodiment of the present invention Structural schematic diagram after barrier.
Fig. 3 shows the schematic diagram of the standby system of Transaction Information according to an embodiment of the present invention.
Fig. 4 shows the timing diagram of the backup method of Transaction Information according to an embodiment of the present invention.
Fig. 5 shows the backup method after primary database place server failure according to an embodiment of the present invention is restarted Timing diagram.
Fig. 6 shows the backup method after primary database place server failure according to an embodiment of the present invention is restarted Timing diagram.
Fig. 7 shows the backup method after standby database place according to an embodiment of the present invention server failure is restarted Timing diagram.
Fig. 8 shows the backup method after standby database place according to an embodiment of the present invention server failure is restarted Timing diagram.
Specific embodiment
Example embodiment is described more fully with reference to the drawings.However, example embodiment can be with a variety of shapes Formula is implemented, and is not understood as limited to embodiment set forth herein;On the contrary, thesing embodiments are provided so that the present invention will Fully and completely, and by the design of example embodiment comprehensively it is communicated to those skilled in the art.It is identical attached in figure Icon note indicates same or similar structure, thus will omit repetition thereof.
Described feature, structure or characteristic can be incorporated in one or more embodiments in any suitable manner In.In the following description, many details are provided to provide and fully understand to embodiments of the present invention.However, One of ordinary skill in the art would recognize that without one or more in the specific detail, or using other methods, group Member, material etc. can also practice technical solution of the present invention.In other cases, it is not shown in detail or describes known features, material Material operates to avoid the fuzzy present invention.
Block diagram shown in the drawings is only functional entity, not necessarily must be corresponding with physically separate entity. I.e., it is possible to realize these functional entitys using software form, or these functions reality is realized in one or more integrated circuits Body, or these functional entitys are realized in heterogeneous networks and/or processor device and/or microcontroller device.
The ordinal numbers such as heretofore described " first ", " second " are only to name to distinguish, and are not intended to limit different set Standby or different structure.
In order to solve the defects of prior art, the data consistency of standby database and primary database, the present invention are realized The backup method and standby system of a kind of Transaction Information are provided.Standby system includes the server and one where a primary database Server where a or multiple standby databases.The backup method includes following backup-step: the primary database institute Server one identification code is generated according to a Transaction Information, the backup behaviour of Transaction Information described in the identification code unique identification Make, it is unfinished for defining the corresponding flag states of the identification code;Server where the primary database is by the affairs Data and the identification code are sent to the server where at least one described standby database;Where the standby database Server makes described by the identification code and the Transaction Information persistence, and in the server where the standby database The flag states of the corresponding backup operation of identification code are to be completed;Server where the standby database is to the primary number A return information is replied according to the server where library, the return information indicates that the Transaction Information completes backup;It is described primary Server where database is according to the return information by the identification code and the Transaction Information persistence and in the master The identification code described in the server mark where database keeps the flag states of the corresponding backup operation of the identification code complete At, wherein when the server where the server or the standby database where the primary database is any of the above-described standby When part step failure, the server of the failure completes the primary number according to the inquiry of the identification code and its flag states It is synchronous with the standby database according to library.
Illustrate multiple embodiments provided by the invention with reference to the accompanying drawing.It shows referring first to Fig. 1, Fig. 1 according to this hair The structural schematic diagram of the standby system of the Transaction Information of bright embodiment.Standby system includes the server where a primary database 110 and one or more standby database where server 120.The service where a primary database is shown in Fig. 1 Server 120 where device 110 and four standby databases, but the quantity of the server where standby database not as Limit.Server 110 where primary database communicates with the server 120 where each standby database.In some embodiments In, the server 120 where server 110 and each standby database where primary database is located in same local area network, and Wirelessly it is connected with each other.Server 110 where primary database and each preliminary data in yet other embodiments, Server 120 where library is located in internet, and is wirelessly connected with each other.In other embodiments, primary number It can also be connected by wired mode with the server 120 where each standby database according to the server 110 where library.Ability Different connecting communication modes may be implemented in field technique personnel, and it will not be described here.
In some embodiments, the server 110 where primary database and the server where standby database 120 are Identical equipment, operation needed for executing primary database when server is as server 110 where primary database, when Operation needed for executing standby database when server is as server 120 where standby database.In other embodiment In, above-mentioned each server is also possible to different equipment, but can execute identical operation.
In the embodiment shown in fig. 1, when generating Transaction Information, as the server 110 where primary database by thing Business data are sent to the server 120 where multiple standby databases, and at the server 120 where multiple standby databases Persistence is to complete the backup of Transaction Information.Further, in the present invention, the server 110 where primary database with it is standby An identification code, and the clothes where primary database are transmitted while with the 120 transmission transaction data of server where database Server 120 where business device 110 and standby database indicates that the identification code is corresponding respectively according to the transmission situation of Transaction Information Transaction Information backup operation Status of Backups.
Specifically, in the standby system of Transaction Information, if the 120 failure (example of server where a standby database Such as delay machine) when, the server 110 where primary database continues offer service.120 weight of server where the standby database Qi Hou continues to use as the server 120 where standby database, and is continued according to the inquiry of identification code and its flag states Consistency of the backup operation to realize primary database and standby database before 120 failure of server.In other words, in this way Embodiment in, 120 failure of server where standby database restart after system structure and the standby database where It is identical before 120 failure of server.
In conjunction with Fig. 1 and Fig. 2, Fig. 2 shows primary data in the standby system of Transaction Information according to an embodiment of the present invention Structural schematic diagram after server failure where library.If when 110 failure of server (such as delay machine) where a primary database, Continue offer service as the server 210 where primary database as the server 120 where a standby database.In addition, In a preferred embodiment, as the current Transaction Information backup of 110 failure of server where one completes primary database Standby database where server 120 continue offer service as the server 210 where primary database.The failure After server 110 where primary database is restarted, used as the server 220 where standby database.The master of the failure Before continuing 220 failure of server according to the inquiry of identification code and its flag states after being restarted with the server 220 where database Backup operation to realize the consistency of primary database and standby database.In other words, in such embodiments, primary number System structure after restarting according to 110 failure of server where library will be as shown in Figure 2.
Further, when relating to server failure in the above description, the friendship of primary database and standby database For use, specific alternation method may refer to Fig. 3, and Fig. 3 shows the standby system of Transaction Information according to an embodiment of the present invention Schematic diagram.For the sake of clarity, Fig. 3 shows two servers 810 and 820.Server 810 includes processor 811 and meter Calculation machine readable storage medium storing program for executing 812.Server 820 includes processor 821 and computer readable storage medium 822.
When a primary mark 830 is located at server 810, server 810 is the server where primary database, service Device 820 is the server where standby database.Accordingly, the computer program on computer readable storage medium 812 is located Reason device 811 can realize the primary DB Backup step of corresponding primary database when executing;On computer readable storage medium 822 Computer program can realize the standby database backup-step of corresponding standby database when being executed by processor 821.
When 810 failure of server, a primary mark 830 is set first at server 820, and works as 810 weight of server Qi Shi deletes its primary mark.At this point, server 810 is the server where standby database, server 820 is primary number According to the server where library.Accordingly, when the computer program on computer readable storage medium 812 is executed by processor 811 The standby database backup-step of corresponding standby database can be achieved;Computer program on computer readable storage medium 822 The primary DB Backup step of corresponding primary database can be realized when being executed by processor 821.
The timing diagram of the backup method of Transaction Information according to an embodiment of the present invention is shown referring to Fig. 4, Fig. 4.For For the sake of clear, Fig. 4 only shows the server where server 110 and a standby database where a primary database 120.It is appreciated that identical step timing and other standby databases can be used in the server 110 where the primary database The server at place carries out data backup.
Step S301 is first carried out in server 110 where primary database, generates an identification code according to a Transaction Information. The backup operation of identification code unique identification Transaction Information.The identification code can be Universally Unique Identifier (UUID) or by primary The random number that server 110 where database generates.Identification code association corresponding with one first flag bit, the first flag bit Whether the corresponding backup operation of flag states sign code is completed.In some embodiments, which can identification code Associatedly it is arranged in a file.In yet other embodiments, first flag bit may also be arranged on the identification code front side or Rear side, for example, 0000000 (identification code) 0 (the first flag bit, for example, 0 indicates that backup operation does not complete, 1 expression backup operation It is completed).
Then, the server 110 where primary database executes step S302, Transaction Information and identification code is sent to standby With the server 120 where database.
Later, server 120 where standby database executes step S303, by identification code and Transaction Information persistence, And associated second flag bit of identification code is set in the server 120 where standby database.
Specifically, in some embodiments, when the server 120 where standby database receives identification code and affairs After data, in the memory of the server 120 where being stored in standby database in identification code and Transaction Information, standby database institute Server 120 need to carry out persistence operation to identification code and Transaction Information, be to deposit by the data model translation in memory Model is stored up, to realize the storage of persistence.Further, in some embodiments, same with associated first flag bit of identification code Identification code is sent to the server 120 where standby database and together as the second flag bit, and where standby database After 120 persistence identification code of server and Transaction Information, the associated second flag bit (example of identification code is set at server 120 1 such as is set by the second flag bit, to indicate that backup operation is completed).In other change case, where standby database After 120 persistence identification code of server and Transaction Information, is generated at server 120 and associated second mark of the identification code is set Will position.Second flag bit can be associatedly stored in a file of server 120 with identification code, or by second flag bit After persistence together with identification code storage.More variation patterns may be implemented in those skilled in the art, and it will not be described here.
Then, the server 120 where standby database executes step S304, the server to where primary database 110 reply a return information.Return information indicates that Transaction Information completes backup.
Then, server 110 where primary database executes step S305, according to return information by identification code and affairs Simultaneously associated first flag bit of identification code is arranged in the server 110 where primary database in data persistence.
It is as the server 120 where standby database that identification code and Transaction Information persistence is identical, primary database institute Server 110 persistence operation is carried out to identification code and Transaction Information, be storage mould by the data model translation in memory Type.After 110 persistence identification code of server and Transaction Information where primary database, identification code is set at server 110 Associated first flag bit (such as 1 being set by the first flag bit, to indicate that backup operation is completed).
In the above-described embodiments, if the server where server or standby database where primary database is above-mentioned Failure in the arbitrary steps of step S301 to S305, then the server of failure can according to identification code and flag bit inquiry with complete It is synchronous with standby database at primary database, it will be described as follows in conjunction with Fig. 5 to Fig. 8.
Fig. 5 shows the backup method after primary database place server failure according to an embodiment of the present invention is restarted Timing diagram.In such embodiments, as where a standby database after the server failure where primary database is restarted Server 220 use, and the server where standby database when failure that server where primary database is non- It is used as the server 210 where current primary database.As described above, being completed in a preferred embodiment by one Server 120 where the standby database of the current Transaction Information backup of 110 failure of server where primary database is made Continue to provide service for the server 210 where primary database.For example, can looking by the second flag bit of identification code It askes, will not have identification code to be associated with the second flag bit is that the server 120 where unfinished standby database is used as primary data Server 210 where library continues offer service, and other are not complete spare number there are associated second flag bit of identification code It interacts according to the server 120 where library with the server 210 where primary database to complete these unfinished Transaction Informations Backup operation.
At this point, step S401 is first carried out in the server 220 restarted, judge exist in the server restarted 220 First flag bit is (backup operation of corresponding Transaction Information) unfinished identification code.Specifically, the server 220 restarted can To read the file containing the first flag bit Yu identification code incidence relation, to judge the state of the first flag bit.Further, since weight The server as primary database before 220 failure of server opened, the setting of the first flag bit is in preliminary data service Device is arranged after the setting of the second flag bit, therefore, if it is not complete that the first flag bit is not present in the server restarted 220 At identification code, then it represents that the backup operation of the Transaction Information of all identification codes mark is completed, subsequent same without carrying out Step operation, details are not described herein.
After step S401, the server 220 restarted executes step S402, the server to where current primary database 210 send a query information.Server 220 in the query information comprising restarting inquires the first flag bit in step S401 Flag states be unfinished identification code.
Later, the server 210 where current primary database executes step S403, according to the mark in the query information Code inquiry is in the server 210 where current primary database, the corresponding deputy state of the identification code.In the present embodiment In, the server 210 where current primary database inquires the mark in the server 210 where current primary database Corresponding second flag bit of code indicates that the backup of corresponding Transaction Information is completed.
After inquiry, the server 210 where current primary database executes step S404, and the server 220 of Xiang Chongqi returns Multiple query result.
The server 220 restarted receives the query result in step S405.According to the query result, the first flag bit is in weight The server 220 opened is unfinished identification code, is in the second flag bit of the server 210 where current primary database It is completed, illustrates the corresponding Transaction Information of the identification code persistence in the server 210 where current primary database, and The not persistence in the server 220 restarted.
Therefore, the server 220 restarted is in 210 request transaction of server where step S406 to current primary database Data (there may be the partial data persistence in the server 220 restarted, it can be only to the service where current primary database Device 210 requests the Transaction Information of remainder).Later, the server 210 where current primary database is to the server restarted 220 send the Transaction Information (optionally, while sending corresponding identification code).After the server 220 restarted receives Transaction Information In step S408, it is set as by the corresponding identification code persistence of Transaction Information, and by associated first flag bit of identification code The backup operation of Transaction Information is completed.
In a change case of Fig. 5, Fig. 6 may refer to, Fig. 6 shows primary database according to an embodiment of the present invention Place server failure restart after backup method timing diagram.
In Fig. 6, step S501 to step S502 is identical as step S401 and step S402.
Later, the server 210 where current primary database executes step S503, the clothes where current primary database Business device 210 is inquired according to the identification code in the query information of step S502 in the service where current primary database Corresponding second flag bit of the identification code indicates that the backup of corresponding Transaction Information does not complete in device 210.
After inquiry, the server 210 where current primary database executes step S504, and the server 220 of Xiang Chongqi returns Multiple query result.
The server 220 restarted receives the query result in step S505.According to the query result, the first flag bit is in weight The server 220 opened is unfinished identification code, is in the second flag bit of the server 210 where current primary database It does not complete, illustrates the corresponding Transaction Information of the identification code not persistence in the server 210 where current primary database, The not persistence in the server 220 restarted.
Therefore, the server 220 restarted understands that the Transaction Information of corresponding identification code (may have partial transaction in step S506 Data persistence in the server 220 restarted, understands the partial data) and while understand the identification code, to be returned to data State before backup.
By above-mentioned Fig. 5 and timing shown in fig. 6, the primary database after completion is restarted is synchronous with standby database, So that data are consistent.
Specifically, if server (server 220 restarted) step S301 shown in Fig. 4 where primary database or It breaks down at S302, then it is appreciated that data are not sent, and handles affairs in the server 220 restarted and be engaged in failing, and is standby With server (server 210 where current primary database) no data where database, state is consistent.
If being sent out at server (server 220 restarted) step S304 or S305 shown in Fig. 4 where primary database Raw failure, then the persistence of Transaction Information and identification code, and the preliminary data is completed in the server where standby database Server where library will be used as the current primary server 210 where database.Service where primary database The current primary server 210 where database is connected when device (server 220 restarted) is restarted, and is identified the second mark of code The inquiry of will position, current primary backup operation of the server 210 for the Transaction Information of the identification code where database of judgement Whether (inquiry flag bit) is completed.
In other words, if the second flag bit of the association identification code of inquiry is completed for backup operation, illustrate Transaction Information In the current primary server 210 where database persistence, need to complete the backup of unfinished Transaction Information, to the portion Point Transaction Information is restored.If the second flag bit of the association identification code of inquiry does not complete for backup operation, illustrate current The Transaction Information of the corresponding identification code is not present in the primary server 210 where database, needs on the server 220 restarted The state that the Transaction Information and corresponding identification code are removed to be restored to before Transaction Information backup.
Backup timing after restarting the foregoing describe the server failure where original primary database, separately below root Server failure where describing standby database according to Fig. 7 and Fig. 8 restart after backup timing.Fig. 7 is shown according to the present invention Server failure where the standby database of embodiment restart after backup method timing diagram.Fig. 8 is shown according to the present invention Server failure where the standby database of embodiment restart after backup method timing diagram.
As shown the server 120 restarted (server where the standby database of script) and current primary in Fig. 7 Server 110 (server where the primary database of script) where database, timing is similar with shown in Fig. 5.
Step S601 is first carried out in the server 120 restarted, and judges that there are the second marks in the server restarted 120 Will position is (backup operation of corresponding Transaction Information) unfinished identification code.If there is no the in the server restarted 120 Two flag bits are unfinished identification code, then it represents that without carrying out subsequent simultaneously operating.
After step S601, the server 120 restarted executes step S602, the server to where current primary database 110 send a query information.Server 120 in the query information comprising restarting inquires the second flag bit in step s 601 For unfinished identification code.Later, the server 110 where current primary database executes step S603, is believed according to the inquiry Identification code in breath inquires corresponding first flag bit of the identification code in the server 110 where current primary database and refers to Show that the backup of corresponding Transaction Information is completed.After inquiry, the server 110 where current primary database executes step The server 120 of S604, Xiang Chongqi reply query result.
The server 120 restarted receives the query result in step S605.According to the query result, the second flag bit is in weight The server 120 opened is unfinished identification code, is in the first flag bit of the server 110 where current primary database It is completed, illustrates the corresponding Transaction Information of the identification code persistence in the server 110 where current primary database, and The not persistence in the server 120 restarted.
Therefore, the server 120 restarted is associated in the backup of step S606 to S608 completion Transaction Information and identification code The setting of second flag bit operates.In some embodiments, above situation may be not present, therefore, in these embodiments without Above-mentioned steps need to be executed.
Referring to Fig. 8, in Fig. 8, step S701 to step S702 is identical as step S601 and step S602.
Later, the server 110 where current primary database executes step S703, is believed according to the inquiry of step S702 Identification code in breath inquires corresponding first mark of the identification code in the server 110 where current primary database Position indicates that the backup of corresponding Transaction Information does not complete.After inquiry, the server 110 where current primary database executes step The server 720 of S704, Xiang Chongqi reply query result.
The server 120 restarted receives the query result in step S705.According to the query result, the second flag bit is in weight The server 120 opened is unfinished identification code, is in the first flag bit of the server 110 where current primary database It does not complete, illustrates the corresponding Transaction Information of the identification code not persistence in the server 110 where current primary database, The not persistence in the server 120 restarted.
Therefore, the server 120 restarted understands that the Transaction Information of corresponding identification code (may have partial transaction in step S706 Data persistence in the server 120 restarted, understands the partial data) and while understand the identification code, to be returned to data State before backup.
In order to guarantee that Fig. 5 is gone on smoothly to timing diagram shown in Fig. 8, the setting of identification code, Transaction Information and flag bit is suitable Preferably, for persistence identification code first, then persistence Transaction Information, it is corresponding for association identification code to be finally arranged flag bit to sequence The backup of Transaction Information be completed.
Figure 5 above merely depicts the mark that the backup operation of the corresponding Transaction Information of identification code is indicated with flag bit to Fig. 8 The embodiment of will state.In some change case of the invention, it can also be indicated in the form of queue.
For example, the flag states of identification code are as the first queue of the server where being located at primary database and are located at spare The second queue of server where database indicates.When the server where primary database generates identification code, will mark Knowledge is piled up into first queue.After the server where primary database completes the persistence of Transaction Information and identification code, it will mark Know code to remove from first queue.When the server where standby database receives identification code, identification code is put into the second team Column, after the server where standby database completes the persistence of Transaction Information and identification code, by identification code from second queue Middle removal.According to aforesaid way, the backup operation of the corresponding Transaction Information of identification code in first queue is in primary data Server where library does not complete, and the backup operation for the corresponding Transaction Information of identification code not occurred in first queue is in master It is completed with the server where database;The backup operation of the corresponding Transaction Information of identification code in second queue is standby It is not completed with the server where database, and the backup for the corresponding Transaction Information of identification code not occurred in second queue is grasped Work is completed in the server where standby database.After consequent malfunction is restarted, it is only necessary to the identification code in query request Determine the flag states of the backup operation of the corresponding Transaction Information of identification code.
Compared with prior art, advantage of the invention is that passing through server where primary database and standby database institute Server transport Transaction Information while transmit an identification code, and respectively according to the transmission situation of Transaction Information, mark with The state of the backup operation of the corresponding Transaction Information of the identification code, when where primary database server or standby database institute Server in either step failure, the server of the failure according to the identification code and its flag states inquiry with It is synchronous with the standby database to complete the primary database, realizes that primary database is consistent with the data of standby database Property.
Through the above description of the embodiments, those skilled in the art is it can be readily appreciated that the embodiment of the present disclosure can lead to Hardware realization is crossed, can also be realized in such a way that software is in conjunction with necessary hardware.Therefore, the technical side of the embodiment of the present disclosure Case can be embodied in the form of software products, which can store (can be in a non-volatile memory medium CD-ROM, USB flash disk, mobile hard disk etc.) in, including some instructions are used so that calculating equipment (can be personal computer, Server, mobile terminal or network equipment etc.) it executes according to the method for disclosure embodiment.
It will be understood by those skilled in the art that attached drawing is the schematic diagram of example embodiment, module or stream in attached drawing Necessary to journey not necessarily implements the disclosure, therefore it cannot be used for the protection scope of the limitation disclosure.
It will be appreciated by those skilled in the art that above-mentioned each module can be distributed in device according to the description of embodiment, it can also It is located in one or more devices different from the present embodiment with carrying out corresponding change.The module of above-described embodiment can be merged into One module, can also be further split into multiple submodule.
It is particularly shown and described exemplary embodiments of the present invention above.It should be understood that the present invention is not limited to institute Disclosed embodiment, on the contrary, it is intended to cover comprising various modifications within the scope of the appended claims and equivalent set It changes.

Claims (14)

1. a kind of backup method of the standby system for Transaction Information, which is characterized in that the standby system includes one primary The server where server and one or more standby databases where database, the backup method includes following backup Step:
Server where the primary database generates an identification code, the identification code unique identification institute according to a Transaction Information The backup operation for stating Transaction Information, it is unfinished for defining the flag states of the corresponding backup operation of the identification code;
It is described standby that the Transaction Information and the identification code are sent at least one by server where the primary database With the server where database;
Server where the standby database is by the identification code and the Transaction Information persistence, and in the spare number According to identification code described in the server mark where library, the flag states of the corresponding backup operation of the identification code are completed;
Server where server to the primary database where the standby database replys a return information, described Return information indicates that the Transaction Information completes backup;
Server where the primary database is lasting by the identification code and the Transaction Information according to the return information Change and the identification code described in the server mark where the primary database, make the mark of the corresponding backup operation of the identification code Will state is to be completed,
Wherein, when the server where the server or the standby database where the primary database is any of the above-described standby When part step failure, the server of failure completes the primary database according to the inquiry of the identification code and its flag states It is synchronous with the standby database.
2. backup method as described in claim 1, which is characterized in that
Server failure where the primary database, by a spare number in one or more of standby databases According to library as the primary database;Using the primary database as a standby database.
3. backup method as claimed in claim 2, which is characterized in that when any server failure is restarted, Yu Chongqi Server in the inquiry identification code unfinished with the presence or absence of the backup operation that flag states are Transaction Information, and if it exists, then should Server where from the server restarted to current primary database sends a query information to inquire the identification code current The flag states of server where primary database, the server restarted completed according to the result of the query information with The synchronization of current primary database.
4. backup method as claimed in claim 3, which is characterized in that
If the result of the query information indicates that the identification code refers in the flag states of the server where current primary database Show that the backup operation of the Transaction Information is completed, then the server where the server restarted to current primary database is asked Seek the Transaction Information.
5. backup method as claimed in claim 3, which is characterized in that
If the result of the query information indicates that the identification code refers in the flag states of the server where current primary database Show that the backup operation of the Transaction Information does not complete, then the server restarted deletes the corresponding mark in corresponding database The Transaction Information and the identification code of code.
6. backup method as claimed in claim 2, which is characterized in that the server failure where the primary database When, the identification code of the primary database is inquired in server where each standby database, the identification code is in institute State the flag states of primary database be it is unfinished, by the identification code the standby database flag states be it is complete At standby database as primary database.
7. such as backup method as claimed in any one of claims 1 to 6, which is characterized in that
The flag states of the identification code are as the first flag bit of the server where being located at the primary database and are located at institute The second flag bit of the server where standby database is stated to indicate, first flag bit and second flag bit are different Value indicate whether the backup operation of the corresponding Transaction Information of associated identification code is completed.
8. such as backup method as claimed in any one of claims 1 to 6, which is characterized in that
The flag states of the identification code are as the first queue of the server where being located at the primary database and are located at described The second queue of server where standby database indicates,
When the server where the primary database generates the identification code, the identification code is put into the first team Column will be described after the server where the primary database completes the persistence of the Transaction Information and the identification code Identification code is removed from the first queue;
When the server where the standby database receives the identification code, the identification code is put into second team Column will be described after the server where the standby database completes the persistence of the Transaction Information and the identification code Identification code is removed from the second queue.
9. such as backup method as claimed in any one of claims 1 to 6, which is characterized in that the service where the primary database Device has a primary mark.
10. such as backup method as claimed in any one of claims 1 to 6, which is characterized in that the identification code are as follows: general unique knowledge The random number that server where other code or the primary database generates.
11. a kind of standby system of Transaction Information characterized by comprising
Server where one primary database, comprising:
First processor;
First computer readable storage medium, stores the first computer program thereon, and first computer program is described Following primary DB Backup step is realized when first processor executes:
Server where the primary database generates an identification code, the identification code unique identification institute according to a Transaction Information The backup operation for stating Transaction Information, it is unfinished for defining the flag states of the corresponding backup operation of the identification code;
The Transaction Information and the identification code are sent at least one spare number by the server where the primary database According to the server where library;
The return information that server where the primary database is replied according to the server where the standby database will The identification code and the Transaction Information persistence and the identification code described in the server mark where the primary database, make The flag states of the corresponding backup operation of the identification code are to be completed;
Server where one or more standby databases, the server where each standby database include:
Second processor;
Second computer readable storage medium storing program for executing, stores second computer program thereon, and the second computer program is described Second processor realizes following standby database backup-step when executing:
Server where the standby database receives the identification code and the Transaction Information, by the identification code and described Transaction Information persistence, and the identification code described in the server mark where the standby database keep the identification code corresponding Backup operation flag states be completed;
Server where server to the primary database where the standby database replys a return information, described Return information indicates that the Transaction Information completes backup;Wherein, when server where the primary database or described spare Server where database in any of the above-described primary DB Backup step or standby database backup-step failure, therefore The server of barrier completes the primary database and the preliminary data according to the inquiry of the identification code and its flag states The synchronization in library.
12. the standby system of Transaction Information as claimed in claim 11, which is characterized in that the clothes where the primary database Business device has a primary mark,
When the primary mark replacement to another server, when first computer program is executed by the first processor Realize that the standby database backup-step, the second computer program realize the master when being executed by the second processor With DB Backup step.
13. the standby system of Transaction Information as claimed in claim 12, which is characterized in that after any server failure When restarting, the inquiry mark unfinished with the presence or absence of the backup operation that flag states are Transaction Information in the server of Yu Chongqi Code, and if it exists, then the server where the server restarted to current primary database sends a query information to inquire Identification code is stated in the flag states of the server where current primary database, the server restarted is according to the query information Result it is synchronous with current primary database to complete.
14. a kind of server, for realizing the data backup between primary database and standby database, which is characterized in that packet It includes:
Processor;
Computer readable storage medium stores computer program, when the computer program is executed by the processor thereon Realize following steps:
If the server is as server where a primary database,
The server generates an identification code, the backup of Transaction Information described in the identification code unique identification according to a Transaction Information Operation, it is unfinished for defining the flag states of the corresponding backup operation of the identification code;
The Transaction Information and the identification code are sent to the server where at least one standby database by the server;
The return information that the server is replied according to the server where the standby database is by the identification code and described Transaction Information persistence and the identification code described in the server mark, make the mark shape of the corresponding backup operation of the identification code State is to be completed;If the server is as server where a standby database,
The server receives the identification code and the Transaction Information, by the identification code and the Transaction Information persistence, And the identification code described in the server mark, the flag states of the corresponding backup operation of the identification code are completed;
Server where from the server to primary database replys a return information, and the return information indicates the affairs Data complete backup;
Wherein, when the server is in any of the above-described step failure, the server of failure indicates according to the identification code with it The inquiry of state is synchronous with the standby database to complete the primary database.
CN201710477551.0A 2017-06-20 2017-06-20 Backup method, standby system and the server of Transaction Information Active CN107229541B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710477551.0A CN107229541B (en) 2017-06-20 2017-06-20 Backup method, standby system and the server of Transaction Information

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710477551.0A CN107229541B (en) 2017-06-20 2017-06-20 Backup method, standby system and the server of Transaction Information

Publications (2)

Publication Number Publication Date
CN107229541A CN107229541A (en) 2017-10-03
CN107229541B true CN107229541B (en) 2019-11-26

Family

ID=59935070

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710477551.0A Active CN107229541B (en) 2017-06-20 2017-06-20 Backup method, standby system and the server of Transaction Information

Country Status (1)

Country Link
CN (1) CN107229541B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109213631A (en) * 2018-08-22 2019-01-15 郑州云海信息技术有限公司 A kind of transaction methods, device, equipment and readable storage medium storing program for executing
CN111106947B (en) * 2018-10-29 2023-02-07 北京金山云网络技术有限公司 Node downtime repairing method and device, electronic equipment and readable storage medium

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1851658A (en) * 2005-08-02 2006-10-25 上海华为技术有限公司 Data management system and method
CN101038591A (en) * 2007-04-11 2007-09-19 华为技术有限公司 Method and system for synchronizing data base
WO2007134008A3 (en) * 2006-05-08 2008-10-09 Firestar Software Inc System and method for exchanging transaction information using images
CN101706795A (en) * 2009-11-30 2010-05-12 上海世范软件技术有限公司 Method for synchronizing data of database in active/standby server
CN102662793A (en) * 2012-03-07 2012-09-12 江苏引跑网络科技有限公司 Hot backup and recovery method of distributed database with guarantee of data consistency
CN103077242A (en) * 2013-01-11 2013-05-01 北京佳讯飞鸿电气股份有限公司 Method for hot standby of dual database servers
US8554727B2 (en) * 2006-05-19 2013-10-08 Inmage Systems, Inc. Method and system of tiered quiescing
CN103902617A (en) * 2012-12-28 2014-07-02 华为技术有限公司 Distributed database synchronization method and system

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020029200A1 (en) * 1999-09-10 2002-03-07 Charles Dulin System and method for providing certificate validation and other services

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1851658A (en) * 2005-08-02 2006-10-25 上海华为技术有限公司 Data management system and method
WO2007134008A3 (en) * 2006-05-08 2008-10-09 Firestar Software Inc System and method for exchanging transaction information using images
US8554727B2 (en) * 2006-05-19 2013-10-08 Inmage Systems, Inc. Method and system of tiered quiescing
CN101038591A (en) * 2007-04-11 2007-09-19 华为技术有限公司 Method and system for synchronizing data base
CN101706795A (en) * 2009-11-30 2010-05-12 上海世范软件技术有限公司 Method for synchronizing data of database in active/standby server
CN102662793A (en) * 2012-03-07 2012-09-12 江苏引跑网络科技有限公司 Hot backup and recovery method of distributed database with guarantee of data consistency
CN103902617A (en) * 2012-12-28 2014-07-02 华为技术有限公司 Distributed database synchronization method and system
CN103077242A (en) * 2013-01-11 2013-05-01 北京佳讯飞鸿电气股份有限公司 Method for hot standby of dual database servers

Also Published As

Publication number Publication date
CN107229541A (en) 2017-10-03

Similar Documents

Publication Publication Date Title
JP4648447B2 (en) Failure recovery method, program, and management server
CN103548010B (en) Synchronization replication in distributed storage environment
KR101602312B1 (en) Data sending method, data receiving method, and storage device
US9251233B2 (en) Merging an out of synchronization indicator and a change recording indicator in response to a failure in consistency group formation
CN103312624B (en) A kind of Message Queuing Services system and method
CN108351860A (en) The distributed storage devices based on RDMA of low latency
CN103593266A (en) ot standby method based on arbitration disk mechanism
CN105229591A (en) Overall situation polymerization NameSpace is created in order to storage administration
JP2005528684A5 (en)
EP2976714B1 (en) Method and system for byzantine fault tolerant data replication
CN106802892B (en) Method and equipment for checking consistency of main and standby data
CN107329859B (en) Data protection method and storage device
CN104765661A (en) Multiple-node hot standby method of metadata service nodes in cloud storage service
CN107229541B (en) Backup method, standby system and the server of Transaction Information
WO2021004256A1 (en) Node switching method in node failure and related device
CN105357042A (en) High-availability cluster system, master node and slave node
WO2018136760A1 (en) Systems and methods for reconstructing cache loss
CN110121694B (en) Log management method, server and database system
WO2021082925A1 (en) Transaction processing method and apparatus
CN110121712B (en) Log management method, server and database system
Pankowski Consistency and availability of Data in replicated NoSQL databases
CN114168636A (en) Data processing method, device and equipment based on cache consistency and storage medium
CN108243209A (en) A kind of method of data synchronization and device
EP4088195A1 (en) Processing delete requests based on change feed of updates
CN104220982A (en) Transaction processing method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant