The invention relates to the field of databases, and particularly provides a main and standby method between
database clusters, which comprises the following steps: S1, after a transaction is started, obtaining a unique transaction ID and returning the transaction ID to a
client; s2, a user sends an
SQL (Structured
Query Language)
sql1 to a connection node, the connection node forwards the received
sql1 to a corresponding coordinator node for execution, responds to the connection node after execution is completed and returns the
sql1 to the
client, and meanwhile, an
SQL statement or a dependency relationship between Key-Value data corresponding to the
SQL statement and transactions is sent to a Merge module of a standby site; s3, the user sends a second SQL sql1, and the process is the same as that of the step S2; s4, the user sends
commit / abort statements, and the transaction enters a submission stage; and S5, after receiving the
commit, the Merge module of the standby site verifies whether the transaction is complete or not through the key span of the transaction
record and the
final version number of each range. Compared with the prior art, when the main
database breaks down, the main
database can be rapidly switched to the standby database, and the
disaster recovery capacity of the database is improved.