Search

CN-122019660-A - MySQL data detection and synchronization method and electronic equipment

CN122019660ACN 122019660 ACN122019660 ACN 122019660ACN-122019660-A

Abstract

The application discloses a MySQL data detection and synchronization method and electronic equipment, and belongs to the technical field of software development. The method comprises the steps of starting a global transaction function of MySQL nodes, wherein each transaction corresponding to each MySQL node comprises a unique identifier of each transaction, determining a monitoring period of the MySQL nodes, monitoring the MySQL nodes in the monitoring period, automatically determining a target monitoring period, acquiring updated transactions corresponding to the MySQL nodes in the target monitoring period, determining a master-slave relationship of the MySQL nodes based on information related to the updated transactions, detecting data synchronization integrity among the MySQL nodes according to the master-slave relationship, and executing a data synchronization integrity restoration step. The application ensures the integrity and data consistency of the data synchronization between the MySQL master node and the MySQL slave node, improves the synchronization efficiency and reduces the synchronization difficulty.

Inventors

  • XU XIAOWEI
  • Bian Shuangwei
  • LIN FENG
  • WU YUNXIA
  • HUANG YE

Assignees

  • 北京首信科技股份有限公司

Dates

Publication Date
20260512
Application Date
20241111

Claims (10)

  1. 1. A MySQL data detection and synchronization method, the method comprising: Starting a global transaction function of MySQL nodes, wherein the transaction corresponding to each MySQL node comprises a unique identifier of each transaction; determining a monitoring period of the MySQL node, and monitoring the MySQL node in the monitoring period; automatically determining a target monitoring period, and acquiring an update transaction corresponding to a MySQL node in the target monitoring period; based on the information related to the update transaction, determining a master-slave relationship of MySQL nodes; detecting the data synchronization integrity between MySQL nodes according to the master-slave relationship; and performing a data synchronization integrity repair step.
  2. 2. The MySQL data detection and synchronization method of claim 1, wherein the MySQL node comprises a master node and a slave node.
  3. 3. The method for detecting and synchronizing MySQL data according to claim 1 or 2, wherein determining the master-slave relationship of MySQL nodes based on the related information of the update transaction comprises analyzing a master node corresponding to the transaction according to a format of a transaction record of the MySQL nodes in a target monitoring period, and determining the master-slave relationship of the MySQL nodes, wherein the master-slave relationship represents the corresponding relationship between the master node and the slave node.
  4. 4. A MySQL data detection and synchronization method according to claim 3, wherein detecting the integrity of data synchronization between MySQL nodes according to the master-slave relationship comprises: The method comprises the steps of respectively obtaining unique identifiers of transactions in a record file of a master node and unique identifiers of transactions in a record file of a slave node in a monitoring period, wherein the record file of the master node contains unique identifiers of all transactions, and the record file of the slave node contains unique identifiers of all synchronized transactions; Judging whether the transaction loss occurs in the synchronization process, and if the transaction loss is determined to occur, indicating that the data synchronization is incomplete.
  5. 5. The MySQL data detection and synchronization method of claim 4, wherein the performing a data synchronization integrity repair step comprises: Acquiring a unique identifier of a lost transaction in the synchronization process; Acquiring a corresponding update statement through the unique identifier of the lost transaction; acquiring corresponding update data from the master node according to the update statement; and updating the update data to the slave node.
  6. 6. The method for detecting and synchronizing MySQL data according to claim 5, wherein the operation corresponding to the update statement comprises adding, deleting and modifying.
  7. 7. The MySQL data detection and synchronization method of claim 4, wherein determining if a transaction loss occurred in the synchronization process is accomplished by way of an operating system compare command.
  8. 8. The method of claim 5, further comprising excluding transactions in the master node that do not require synchronization before the unique identification of transactions is lost during synchronization is obtained.
  9. 9. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the method according to any one of claims 1 to 8 when executing the computer program.
  10. 10. A computer-readable storage medium, characterized in that the computer-readable storage medium stores one or more programs, the one or more programs may be executed by one or more processors to implement the method of any of claims 1 to 8.

Description

MySQL data detection and synchronization method and electronic equipment Technical Field The application belongs to the technical field of software development, and particularly relates to a MySQL data detection and synchronization method and electronic equipment. Background With the rapid development of information technology and network technology, the requirements on high availability, data integrity and stability of software are higher and higher, and with the development of business and technology, multiple machine rooms/different places and multiple activities become a necessary deployment mode for most software service providers. Data is transmitted across a machine room, and there are a number of unstable factors such as network, machine room failure, etc. As an open source relational database which is widely applied at present, an asynchronous synchronous mode of MySQL is widely applied, and when data is synchronized across a machine room, the unstable factors increase the risk of asynchronous synchronous data loss, and the lost data is difficult to resynchronize and has low synchronization efficiency. Aiming at the problems, the application provides a MySQL data detection and synchronization method and electronic equipment. Disclosure of Invention In order to solve the defects of the prior art, the application provides a MySQL data detection and synchronization method and electronic equipment, and solves the problems that after data synchronization between MySQL nodes is lost, the difficulty of resynchronization of the lost data is high, the synchronization efficiency is low and the like in the prior art. The technical effects to be achieved by the application are realized by the following scheme: in a first aspect, the present application provides a MySQL data detection and synchronization method, the method comprising: Starting a global transaction function of MySQL nodes, wherein the transaction corresponding to each MySQL node comprises a unique identifier of each transaction; determining a monitoring period of the MySQL node, and monitoring the MySQL node in the monitoring period; automatically determining a target monitoring period, and acquiring an update transaction corresponding to a MySQL node in the target monitoring period; based on the information related to the update transaction, determining a master-slave relationship of MySQL nodes; detecting the data synchronization integrity between MySQL nodes according to the master-slave relationship; and performing a data synchronization integrity repair step. In some embodiments, the MySQL node includes a master node and a slave node. In some embodiments, determining the master-slave relationship of the MySQL node based on the related information of the update transaction comprises analyzing a master node corresponding to the transaction according to the format of a transaction record of the MySQL node in a target monitoring period, and determining the master-slave relationship of the MySQL node, wherein the master-slave relationship represents the corresponding relationship between the master node and the slave node. In some embodiments, detecting data synchronization integrity between MySQL nodes according to the master-slave relationship comprises: The method comprises the steps of respectively obtaining unique identifiers of transactions in a record file of a master node and unique identifiers of transactions in a record file of a slave node in a monitoring period, wherein the record file of the master node contains unique identifiers of all transactions, and the record file of the slave node contains unique identifiers of all synchronized transactions; Judging whether the transaction loss occurs in the synchronization process, and if the transaction loss is determined to occur, indicating that the data synchronization is incomplete. In some embodiments, the performing a data synchronization integrity repair step includes: Acquiring a unique identifier of a lost transaction in the synchronization process; Acquiring a corresponding update statement through the unique identifier of the lost transaction; acquiring corresponding update data from the master node according to the update statement; and updating the update data to the slave node. In some embodiments, the operations corresponding to the update statement include adding, deleting, and modifying. In some embodiments, the determining whether the synchronization process has a transaction loss is accomplished by way of an operating system compare command. In some embodiments, excluding transactions in the master node that do not require synchronization is also included before the unique identification of transactions is lost during the synchronization process is obtained. In a second aspect, the application provides an electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the method of