P
US10045397B2ActiveUtilityPatentIndex 42

Data complementing method and apparatus

Assignee: BEIJING QIHOO TECHNOLOGY COPriority: Dec 24, 2014Filed: Nov 9, 2015Granted: Aug 7, 2018
Est. expiryDec 24, 2034(~8.5 yrs left)· nominal 20-yr term from priority
Inventors:YANG TING
G06F 16/275H04W 84/20G06F 16/25G06F 16/27G06F 17/30581
42
PatentIndex Score
0
Cited by
7
References
13
Claims

Abstract

Embodiments of the invention provide a data complementing method and apparatus, which relate to the field of computer. In the method provided by the invention, in the process of master database switching in a master-slave database cluster, a slave database is selected from the database cluster to act as a new master database; first connections between the new master database and all the other slave databases are established successively; the data of the new master database is compared with the data of all the other slave databases, respectively, to synchronize new data in all the other slave databases into the new master database, to accomplish data complementing of the new master database, which causes the new master database to have the latest data in the database cluster, guarantees smooth switching of the master database, and therefore will not influence normal running of database services.

Claims

exact text as granted — not AI-modified
The invention claimed is: 
     
       1. A data complementing method applied in master database switching in a master-slave database cluster, the method comprising:
 selecting a slave database from the database cluster to act as a new master database; 
 establishing first connections between the new master database and all the other slave databases successively; 
 comparing data of the new master database with data of all the other slave databases, respectively, to synchronize new data in all the other slave databases into the new master database; and 
 finishing data complementing of the new master database when data comparison and synchronization of all the other slave databases is accomplished, 
 wherein selecting a slave database from the database cluster to act as a new master database comprises:
 obtaining a list of all the slave databases of the database cluster before the establishing connections between the new master database and all the slave databases successively; and 
 from all the slave databases recorded by the list, screening out and obtaining a slave database that meets a preset condition to act as the new master database, and wherein the preset condition comprises at least one of:
 the state of the slave database being identified as alive; and 
 the number of delayed transactions of the slave database being less than a preset number. 
 
 
 
     
     
       2. The method as claimed in  claim 1 , wherein the first connections are master-slave connections, and the other slave databases and the new master database have the master and slave statuses, respectively. 
     
     
       3. The method as claimed in  claim 1 , wherein the step of comparing the data of the new master database with the data of all the other slave databases, respectively, to synchronize new data in all the other slave databases into the new master database, further comprises: after data comparison and synchronization is accomplished between the new master database and one other slave database, disconnecting the first connection between them. 
     
     
       4. The method as claimed in  claim 1 , wherein the method further comprises: establishing second connections between the new master database and all the other slave databases successively after data complementing of the new master database is finished; and synchronizing data of the new master database to all the other slave databases. 
     
     
       5. The method as claimed in  claim 4 , wherein the second connections are master-slave connections, and the new master database and the other slave databases have the master and slave statuses, respectively. 
     
     
       6. The method as claimed in  claim 1 , wherein the database cluster is a MYSQL database cluster. 
     
     
       7. A data complementing apparatus applied in master database switching in a master-slave database cluster, the apparatus comprising:
 a memory having instructions stored thereon: 
 a processor configured to execute the instructions to perform the following operations: 
 selecting a slave database from the database cluster to act as a new master database; 
 establishing first connections between the new master database and all the other slave databases successively; 
 comparing data of the new master database with data of all the other slave databases, respectively, to synchronize new data in all the other slave databases into the new master database; and 
 finishing data complementing of the new master database when the data comparison and synchronization of all the other slave databases is accomplished, 
 wherein selecting a slave database from the database cluster to act as a new master database comprises:
 obtaining a list of all the slave databases of the database cluster before the establishing connections between the new master database and all the slave databases successively; and 
 from all the slave databases recorded by the list, screening out and obtaining a slave database that meets a preset condition to act as the new master database, and wherein the preset condition comprises at least one of:
 the state of the slave database being identified as alive; and 
 the number of delayed transactions of the slave database being less than a preset number. 
 
 
 
     
     
       8. The apparatus as claimed in  claim 7 , wherein the first connections are master-slave connections, and the other slave databases and the new master database have the master and slave statuses, respectively. 
     
     
       9. The apparatus as claimed in  claim 7 , wherein the comparing the data of the new master database with the data of all the other slave databases, respectively, to synchronize new data in all the other slave databases into the new master database, further comprises: after data comparison and synchronization is accomplished between the new master database and one other slave database, disconnecting the first connection between them. 
     
     
       10. The apparatus as claimed in  claim 7 , wherein the operations further comprises:
 establishing second connections between the new master database and all the other slave databases successively after data complementing of the new master database is finished; and 
 synchronizing data of the new master database to all the other slave databases. 
 
     
     
       11. The apparatus as claimed in  claim 10 , wherein the second connections are master-slave connections, and the new master database and the other slave databases have the master and slave statuses, respectively. 
     
     
       12. The apparatus as claimed in  claim 7 , wherein the database cluster is a MYSQL database cluster. 
     
     
       13. A non-transitory computer readable medium having instructions stored thereon that when executed by at least one processor, cause the at least one processor to perform following operations:
 selecting a slave database from the database cluster to act as a new master database: 
 establishing first connections between the new master database and all the other slave databases successively: 
 comparing data of the new master database with data of all the other slave databases, respectively, to synchronize new data in all the other slave databases into the new master database; and 
 finishing data complementing of the new master database when data comparison and synchronization of all the other slave databases is accomplished, 
 wherein selecting a slave database from the database cluster to act as a new master database comprises:
 obtaining a list of all the slave databases of the database cluster before the establishing connections between the new master database and all the slave databases successively; and 
 from all the slave databases recorded by the list, screening out and obtaining a slave database that meets a preset condition to act as the new master database, and wherein the preset condition comprises at least one of:
 the state of the slave database being identified as alive; and 
 the number of delayed transactions of the slave database being less than a preset number.

Cited by (0)

No later patents cite this yet.

References (0)

No backward citations on record.