The present invention relates to the field of databases, and specifically provides a
database cluster master-slave method, which has the following steps: S1, after opening a transaction, a unique transaction ID is obtained and returned to the
client; S2, the user sends an
SQL sql1 to the connection node, and the connection node forwards the received
sql1 to the corresponding coordinator node for execution, responds to the connection node after the execution is completed and returns to the
client, and at the same time sends the
SQL statement or the Key-Value data corresponding to the
SQL statement and the dependency relationship between transactions to the Merge module of the
backup site; S3, the user sends a second SQL
sql1, and the process is the same as the above step S2; S4, the user sends a
commit / abort statement, and the transaction enters the
commit stage; S5, after receiving the
commit, the Merge module of the
backup site verifies whether the transaction is complete through the key span recorded in the transaction and the last version number of each range. Compared with the prior art, the present invention can quickly switch to the
backup database after the main
database fails, thereby improving the disaster tolerance capability of the database.