Data synchronization method and device for double-center structure database, equipment and medium

By establishing a row identification mapping relationship between the first database and the second database of the dual-center structure database, the problem of the inability to accurately locate the updated rows during data synchronization is solved, and more accurate data synchronization is achieved and data inconsistency is avoided.

CN119862239AInactive Publication Date: 2025-04-22DISJIE (BEIJING) DATA MANAGEMENT TECH CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202510344302.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-24
Publication Date
2025-04-22
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The dual-center structure database cannot accurately locate the rows that need to be updated when data synchronization, resulting in incorrect data updates and data inconsistencies.

Method used

By establishing a mapping relationship between the first row identification and the second row identification between the first database and the second database, during the data change operation, the second database uses the second row identification to accurately locate the row that needs to be updated, and performs the corresponding data change operation.

Benefits of technology

Improve the data synchronization accuracy of the dual-center structure database, avoiding the problems of incorrect data updates and data inconsistencies.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119862239A_ABST
    Figure CN119862239A_ABST
Patent Text Reader

Abstract

The invention discloses a data synchronization method and device for a double-center structure database, equipment and a medium, and belongs to the technical field of data processing. The method comprises the steps that after a data change instruction of a user is executed in a first database, change data content and a first line identifier corresponding to the data change instruction are acquired from an operation log; sending a first data synchronization instruction including the changed data content and the first line identifier to a second database, so that the second database searches a second line identifier having a mapping relationship with the first line identifier, and executing the first data synchronization instruction based on the second line identifier; the first row identifier is used for indicating the position where the inserted data content contained in the data insertion instruction is inserted into the first database after the first database executes the data insertion instruction of the user; the second row identifier is used for indicating the position where the inserted data content is inserted into the second database after the second database executes the second data synchronization instruction. The accuracy of data synchronization can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing technology, and in particular to a data synchronization method, device, equipment and medium for a dual-center structure database. Background Art

[0002] A dual-center database is a distributed database architecture that aims to achieve high availability, disaster tolerance, and load balancing of data through two data centers. This architecture is usually used in scenarios with extremely high requirements for data reliability and system availability, such as finance, telecommunications, e-commerce, and other fields. For database A and database B in a dual-center database, the two need to achieve real-time data synchronization. After database A obtains the data entered by the user, the operation log of database A records the data input operation and synchronizes the data to database B according to the policy. After database B saves the data, the operation log of database B records the operation of saving the data.

[0003] In a dual-center database system, in order to reduce the content of operation log records, improve the efficiency of operation log writing, and thus improve the overall performance of the database, the operation log mainly records data changes (i.e., "what was modified"), rather than complete SQL statements or operation logic. For example, when database A executes UPDATE t SET name='xxx' WHEREid=100, when database B is synchronized, its operation log only records UPDATE t SET name='xxx', and does not record the columns involved in the WHERE condition. Therefore, when database A subsequently updates the row with id=100, database B will update the name field of all rows to 'xxx', not just the row with id=100, because it does not record the columns involved in the WHERE condition.

[0004] Therefore, when synchronizing data, the databases of the current dual-center database system may not be able to accurately locate the rows that need to be updated, which may lead to erroneous data updates and cause data inconsistency problems in the two databases. Summary of the invention

[0005] In order to solve the above problems existing in the prior art, the present invention provides a data synchronization method, device, equipment and medium for a dual-center structure database. The technical problem to be solved by the present invention is achieved through the following technical solutions: A first aspect of the present invention provides a data synchronization method for a dual-center structure database, which is applied to a first database, and the method comprises: After the first database executes the user's data change instruction, acquiring change instruction information corresponding to the data change instruction from the operation log of the first database; wherein the change instruction information includes the change data content and the first row identifier; Sending a first data synchronization instruction including the changed data content and the first row identifier to a second database, so that the second database parses the first data synchronization instruction to obtain the first row identifier, searches for a second row identifier that has a mapping relationship with the first row identifier, and executes the first data synchronization instruction based on the second row identifier; The first row identifier is identification information for indicating the position where the insert data content contained in the data insert instruction is inserted into the first database after the first database executes the user's data insert instruction; The second row identifier is identification information for indicating a position where the insert data content contained in the second data synchronization instruction is inserted into the second database after the second database executes the second data synchronization instruction sent by the first database.

[0006] The method provided by the present invention establishes a mapping relationship between the first row identifier and the second row identifier generated when the first database and the second database perform data insertion operations. During subsequent data change operations, the second database matches the first row identifier sent by the first database with the mapping relationship stored locally, matches the second row identifier, and accurately locates the row that requires data change based on the second row identifier, thereby effectively improving the accuracy of data synchronization in a dual-center structure database.

[0007] In a possible implementation, the method further includes: After the first database executes the data insertion instruction of the user, first insertion instruction information corresponding to the data insertion instruction is obtained from the operation log of the first database; wherein the first insertion instruction information includes the insertion data content and the first row identifier; The second data synchronization instruction including the insert data content and the first row identifier is sent to the second database, so that after executing the second data synchronization instruction, the second database obtains the second insert instruction information including the insert data content and the second row identifier corresponding to the second data synchronization instruction from the operation log of the second database, and generates and stores the mapping relationship between the second row identifier and the first row identifier. A second aspect of the present invention provides a data synchronization method for a dual-center structure database, which is applied to a second database, and the method comprises: receiving and parsing a first data synchronization instruction including a changed data content and a first row identifier sent by the first database, and obtaining the first row identifier; wherein the changed data content is data content corresponding to the data change instruction obtained from the operation log of the first database after the first database executes the user's data change instruction; Searching for a second row identifier that has a mapping relationship with the first row identifier; wherein the first row identifier is identifier information used to indicate the position where the insert data content contained in the data insert instruction is inserted into the first database after the first database executes the user's data insert instruction; the second row identifier is identifier information used to indicate the position where the insert data content contained in the second data synchronization instruction is inserted into the second database after the second database executes the second data synchronization instruction sent by the first database; The first data synchronization instruction is executed based on the second row identifier.

[0008] The method provided by the present invention establishes a mapping relationship between the first row identifier and the second row identifier generated when the first database and the second database perform data insertion operations. During subsequent data change operations, the second database matches the first row identifier sent by the first database with the mapping relationship stored locally, matches the second row identifier, and accurately locates the row that requires data change based on the second row identifier, thereby effectively improving the accuracy of data synchronization in a dual-center structure database.

[0009] In a possible implementation, the method further includes: receiving and parsing a second data synchronization instruction including the insert data content and the first row identifier sent by the first database, and obtaining the first row identifier; wherein the insert data content is data content corresponding to the data insert instruction obtained from the operation log of the first database after the first database executes the user's data insert instruction; After the second database executes the second data synchronization instruction, second insertion instruction information corresponding to the second data synchronization instruction, including the inserted data content and the second row identifier, is obtained from the operation log of the second database, and a mapping relationship between the second row identifier and the first row identifier is generated and stored.

[0010] In a possible implementation manner, after executing the first data synchronization instruction based on the second row identifier, the method further includes: Generate first filter tag information, and store the first filter tag information in the operation log of the second database, so that the log analysis program of the second database obtains the first filter tag information when monitoring that the operation log of the second database changes due to the second database executing the first data synchronization instruction; The first filter tag information is used to instruct the second database not to send a first reverse data synchronization instruction to the first database.

[0011] In a possible implementation, the second insertion instruction information further includes second filtering tag information; after the second database executes the second data synchronization instruction, the method further includes: Generate the second filter tag information, and store the second filter tag information in the operation log of the second database, so that the log analysis program of the second database obtains the second filter tag information when monitoring that the operation log of the second database changes due to the second database executing the second data synchronization instruction; The second filter tag information is used to instruct the second database not to send a second reverse data synchronization instruction to the first database.

[0012] A third aspect of the present invention provides a data synchronization device for a dual-center structure database, which is applied to a first database, and the device comprises: A first acquisition module, configured to acquire, after the first database executes the user's data change instruction, change instruction information corresponding to the data change instruction from the operation log of the first database; wherein the change instruction information includes the change data content and the first row identifier; A first sending module is used to send a first data synchronization instruction including the changed data content and the first row identifier to a second database, so that the second database parses the first data synchronization instruction to obtain the first row identifier, searches for a second row identifier that has a mapping relationship with the first row identifier, and executes the first data synchronization instruction based on the second row identifier; The first row identifier is identification information for indicating the position where the insert data content contained in the data insert instruction is inserted into the first database after the first database executes the user's data insert instruction; The second row identifier is identification information for indicating a position where the insert data content contained in the second data synchronization instruction is inserted into the second database after the second database executes the second data synchronization instruction sent by the first database.

[0013] A fourth aspect of the present invention provides a data synchronization device for a dual-center structure database, comprising: applied to a second database, the device comprising: a first receiving and parsing module, configured to receive and parse a first data synchronization instruction including a changed data content and a first row identifier sent by the first database, and obtain the first row identifier; wherein the changed data content is data content corresponding to the data change instruction obtained from an operation log of the first database after the first database executes the data change instruction of the user; A search module, used to search for a second row identifier that has a mapping relationship with the first row identifier; wherein the first row identifier is identification information used to indicate the position where the insert data content contained in the data insert instruction is inserted into the first database after the first database executes the user's data insert instruction; the second row identifier is identification information used to indicate the position where the insert data content contained in the second data synchronization instruction is inserted into the second database after the second database executes the second data synchronization instruction sent by the first database; An instruction execution module is used to execute the first data synchronization instruction based on the second row identifier.

[0014] The fifth aspect of the present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, a data synchronization method for a dual-center structure database provided in the first aspect of the present invention is implemented.

[0015] A sixth aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a data synchronization method for a dual-center structure database provided in the first aspect of the present invention.

[0016] For the specific description of the third to sixth aspects of the present invention and their various implementations, reference can be made to the detailed description in the first aspect, the second aspect and their various implementations; and for the beneficial effects of the third to sixth aspects and their various implementations, reference can be made to the analysis of the beneficial effects in the first aspect, the second aspect and their various implementations, which will not be repeated here.

[0017] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] Figure 1 It is a flow chart of a data synchronization method of a dual-center structure database applied to a first database according to an embodiment of the present invention; Figure 2It is a flow chart of a data synchronization method of a dual-center structure database applied to a second database according to an embodiment of the present invention; Figure 3 It is a structural block diagram of a data synchronization device for a dual-center structure database applied to a first database according to an embodiment of the present invention; Figure 4 It is a structural block diagram of a data synchronization device of a dual-center structure database applied to a second database according to an embodiment of the present invention; Figure 5 It is a block diagram of the internal structure of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0019] The present invention is further described in detail below with reference to specific embodiments, but the embodiments of the present invention are not limited thereto.

[0020] The dual-center structure database involved in this embodiment is composed of a first database and a second database. The first database and the second database can be deployed on different electronic devices or on the same electronic device.

[0021] The following specifically describes the data synchronization method of the dual-center structure database starting from the first database and the second database respectively.

[0022] It should be noted that the data synchronization method of the dual-center structure database provided in the embodiment of the present invention is executed by an electronic device, which can be a server or a terminal device. The server can be an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server providing cloud computing services; the terminal device can be a smart phone, a tablet computer, a desktop computer, a wearable device, etc., but is not limited thereto.

[0023] Figure 1 The following is a flow chart of a data synchronization method for a dual-center structure database applied to a first database provided in this embodiment. Figure 1 As shown, the main process of the method is described as follows (steps S101-S102): Step S101, after executing the user's data change instruction in the first database, obtaining change instruction information corresponding to the data change instruction from the operation log of the first database; wherein the change instruction information includes the change data content and the first row identifier; Step S102, sending the first data synchronization instruction including the changed data content and the first row identifier to the second database, so that the second database parses the first data synchronization instruction to obtain the first row identifier, searches for the second row identifier that has a mapping relationship with the first row identifier, and executes the first data synchronization instruction based on the second row identifier.

[0024] In this embodiment, the data change instruction includes instructions such as data deletion and data update. When the first database receives the data change instruction input by the user, it parses the data change instruction, obtains the changed data content, and executes the instruction according to the changed data content. For example, the SQL statement corresponding to the data change instruction is UPDATE t SET name='xxx' WHERE id=100, and the keyword UPDATE, table name t, field name name, new value 'xxx', condition field id, and condition value 100 are parsed to obtain the changed data content. Its execution logic is to locate table t, filter out the row with id=100 according to the WHERE condition, and update the name field value of the filtered row to 'xxx'.

[0025] In this embodiment, the first row identifier is identification information used to indicate the position where the insert data content contained in the data insert instruction is inserted into the first database after the first database executes the user's data insert instruction. In other words, the first row identifier is a unique internal identifier automatically generated for the row when a row of data is inserted into the table of the first database. After the first database executes the data insert instruction, the operation log records the insert data content excluding the where condition, and also records the unique internal identifier corresponding to the row where the data insert operation is to be performed, that is, the first row identifier. After the first database executes the user's data insert instruction, the first insert instruction information corresponding to the data insert instruction can be obtained from the operation log of the first database, and the first insert instruction information includes the insert data content and the first row identifier.

[0026] Since the first database and the second database constitute a dual-center structure database, after the first database executes the data insertion instruction, it is necessary to send the corresponding second data synchronization instruction to the second database so that the second database also performs the corresponding data insertion operation to ensure data synchronization between the second database and the first database.

[0027] The first database sends a second data synchronization instruction including the same insert data content and the first row identifier to the second database. After the second database executes the second data synchronization instruction, the operation log of the second database will record the insert data content except the where condition, and will also record the unique internal identifier corresponding to the row where the data insertion operation is to be performed, that is, the second row identifier. In other words, the second row identifier is the identification information used to indicate the position where the insert data content contained in the second data synchronization instruction is inserted into the second database after the second database executes the second data synchronization instruction sent by the first database.

[0028] Then, the second database obtains second insertion instruction information corresponding to the second data synchronization instruction from the operation log, including the inserted data content and the second row identifier, and generates and stores a mapping relationship between the second row identifier and the first row identifier.

[0029] Since the second database does not record the where condition in the operation log when executing the second data synchronization instruction, when the first database executes the data change operation and sends the corresponding first data synchronization instruction to the second database, the second database cannot accurately locate the row to be updated in the table, resulting in erroneous data updates and causing data inconsistency between the two databases.

[0030] To solve this problem, the first database will send the first row identifier along with the first data synchronization instruction to the second database. The second database will search for the second row identifier corresponding to the first row identifier based on the mapping relationship between the second row identifier and the first row identifier stored locally, and then perform the corresponding data change operation based on the second row identifier.

[0031] It should be noted that the first row identifier and the second row identifier may use RowID to directly point to the physical storage location of the data row.

[0032] Figure 2 The following is a flow chart of a data synchronization method for a dual-center structure database applied to a second database provided in this embodiment. Figure 2 As shown, the main process of the method is described as follows (steps S201 to S203): Step S201, receiving and parsing a first data synchronization instruction including a changed data content and a first row identifier sent by a first database, and obtaining a first row identifier; wherein the changed data content is data content corresponding to the data change instruction obtained from the operation log of the first database after the first database executes the user's data change instruction; Step S202, searching for a second row identifier that has a mapping relationship with the first row identifier; wherein the first row identifier is identifier information used to indicate the position where the insert data content contained in the data insert instruction is inserted into the first database after the first database executes the user's data insert instruction; the second row identifier is identifier information used to indicate the position where the insert data content contained in the second data synchronization instruction is inserted into the second database after the second database executes the second data synchronization instruction sent by the first database; Step S203: execute the first data synchronization instruction based on the second row identifier.

[0033] In this embodiment, the second database receives and parses the second data synchronization instruction sent by the first database, including the insert data content and the first row identifier, to obtain the first row identifier; wherein the insert data content is the data content corresponding to the data insertion instruction obtained from the operation log of the first database after the first database executes the user's data insertion instruction; after the second database executes the second data synchronization instruction, the second insert instruction information corresponding to the second data synchronization instruction, including the insert data content and the second row identifier, is obtained from the operation log of the second database, and a mapping relationship between the second row identifier and the first row identifier is generated and stored.

[0034] The above steps S201 to S203 may be implemented by referring to the specific solutions of steps S101 to S102, which will not be described in detail here.

[0035] After the second database executes the first data synchronization instruction, its operation log will change due to the execution of the instruction, and the log analysis program of the second database will automatically monitor the log changes and analyze the existence of data change operations in the second database. According to the synchronization mechanism of the dual-center structure database, when a data change operation occurs in one database, the same data change operation will be actively sent to the other database. However, for the second database, its execution of the first data synchronization instruction is triggered by the execution of the data change instruction by the first database. If the data change operation of the first database is triggered by the data change operation of the second database at this time, this will cause the first and second databases to repeat the data change operation indefinitely, which will waste computing resources, storage resources and network bandwidth, increase the load of the replication link, and may cause replication delays, affecting the real-time nature of the data.

[0036] Therefore, in some optional embodiments, after executing the first data synchronization instruction based on the second row identifier, first filter tag information is generated, and the first filter tag information is stored in the operation log of the second database, so that the log analysis program of the second database obtains the first filter tag information when it monitors that the operation log of the second database has changed due to the second database executing the first data synchronization instruction.

[0037] The first filter tag information is used to instruct the second database not to send the first reverse data synchronization instruction to the first database. The first reverse data synchronization instruction is the same as the data change operation corresponding to the first data synchronization instruction, but the synchronization direction is opposite, that is, the first reverse data synchronization instruction is to synchronize data from the second database to the first database, while the first data synchronization instruction is to synchronize data from the first database to the second database.

[0038] Similarly, after the second database executes the second data synchronization instruction, second filter tag information can also be generated and stored in the operation log of the second database, so that the log analysis program of the second database can obtain the second filter tag information when it monitors that the operation log of the second database has changed due to the second database executing the second data synchronization instruction.

[0039] The second filter tag information is used to instruct the second database not to send the second reverse data synchronization instruction to the first database. The second reverse data synchronization instruction is the same as the data insertion operation corresponding to the second data synchronization instruction, but the synchronization direction is opposite, that is, the second reverse data synchronization instruction is to synchronize data from the second database to the first database, while the second data synchronization instruction is to synchronize data from the first database to the second database.

[0040] Based on the same inventive concept, an embodiment of the present invention provides a data synchronization device for a dual-center structure database applied to a first database. Figure 3 FIG. 3 is a structural block diagram of a data synchronization device 300 for a dual-center structure database provided by an embodiment of the present invention. Figure 3 As shown, the data synchronization device 300 of the dual-center structure database mainly includes: The first acquisition module 301 is used to acquire change instruction information corresponding to the data change instruction from the operation log of the first database after the first database executes the user's data change instruction; wherein the change instruction information includes the change data content and the first row identifier; The first sending module 302 is used to send the first data synchronization instruction including the changed data content and the first row identifier to the second database, so that the second database parses the first data synchronization instruction to obtain the first row identifier, searches for the second row identifier that has a mapping relationship with the first row identifier, and executes the first data synchronization instruction based on the second row identifier; The first row is identified as identification information for indicating the position where the insert data content contained in the data insert instruction is inserted into the first database after the first database executes the user's data insert instruction; The second row is identified as identification information for indicating the position where the insert data content contained in the second data synchronization instruction is inserted into the second database after the second database executes the second data synchronization instruction sent by the first database.

[0041] In some optional embodiments, the data synchronization device 300 of the dual-center structure database further includes: A second acquisition model is used to acquire first insertion instruction information corresponding to the data insertion instruction from the operation log of the first database after the first database executes the user's data insertion instruction; wherein the first insertion instruction information includes the insertion data content and the first row identifier; The second sending module is used to send a second data synchronization instruction including the inserted data content and the first row identifier to the second database, so that after executing the second data synchronization instruction, the second database obtains the second insert instruction information including the inserted data content and the second row identifier corresponding to the second data synchronization instruction from the operation log of the second database, and generates and stores the mapping relationship between the second row identifier and the first row identifier. Based on the same inventive concept, an embodiment of the present invention provides a data synchronization device for a dual-center structure database applied to a second database. Figure 4 FIG. 4 is a structural block diagram of a data synchronization device 400 for a dual-center structure database provided by an embodiment of the present invention. Figure 4 As shown, the data synchronization device 400 of the dual-center structure database mainly includes: The first receiving and parsing module 401 is used to receive and parse the first data synchronization instruction including the changed data content and the first row identifier sent by the first database, and obtain the first row identifier; wherein the changed data content is the data content corresponding to the data change instruction obtained from the operation log of the first database after the first database executes the user's data change instruction; The search module 402 is used to search for a second row identifier that has a mapping relationship with the first row identifier; wherein the first row identifier is identifier information used to indicate the position where the insert data content contained in the data insert instruction is inserted into the first database after the first database executes the user's data insert instruction; the second row identifier is identifier information used to indicate the position where the insert data content contained in the second data synchronization instruction is inserted into the second database after the second database executes the second data synchronization instruction sent by the first database; The instruction execution module 403 is used to execute the first data synchronization instruction based on the second row identifier.

[0042] In some optional embodiments, the data synchronization device 400 of the dual-center structure database further includes: A second receiving and parsing module is used to receive and parse the second data synchronization instruction including the insert data content and the first row identifier sent by the first database to obtain the first row identifier; wherein the insert data content is the data content corresponding to the data insert instruction obtained from the operation log of the first database after the first database executes the user's data insert instruction; The first generation and storage module is used to obtain second insertion instruction information corresponding to the second data synchronization instruction including the inserted data content and the second row identifier from the operation log of the second database after the second data synchronization instruction is executed in the second database, and generate and store a mapping relationship between the second row identifier and the first row identifier.

[0043] In some optional embodiments, the data synchronization device 400 of the dual-center structure database further includes: A second generation and storage module is used to generate first filter tag information after executing the first data synchronization instruction based on the second row identifier, and store the first filter tag information in the operation log of the second database, so that the log analysis program of the second database obtains the first filter tag information when monitoring that the operation log of the second database changes due to the second database executing the first data synchronization instruction; The first filtering tag information is used to instruct the second database not to send the first reverse data synchronization instruction to the first database.

[0044] In some optional embodiments, the second insertion instruction information further includes second filtering tag information; the data synchronization device 400 for the dual-center structure database further includes: A third generation storage module is used to generate second filter tag information after the second database executes the second data synchronization instruction, and store the second filter tag information in the operation log of the second database, so that the log analysis program of the second database obtains the second filter tag information when monitoring that the operation log of the second database changes due to the second database executing the second data synchronization instruction; The second filtering tag information is used to instruct the second database not to send the second reverse data synchronization instruction to the first database.

[0045] The functional modules in the above embodiments can be integrated together to form an independent unit, for example, integrated in a processing unit, or each module can exist physically separately, or two or more modules can be integrated to form an independent unit. The above integrated unit can be implemented in the form of hardware or in the form of a software functional unit. If the function is implemented in the form of a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or part of the contribution to the prior art or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium, including several instructions to enable an electronic device (which can be a personal computer, a server or a network device, etc.) or a processor (processor) to perform all or part of the steps of the methods of each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory, a random access memory, a disk or an optical disk.

[0046] The various variations and specific examples in the method provided in the embodiment of the present invention are also applicable to the data synchronization device for the dual-center structure database provided in this embodiment. Through the above detailed description of the data synchronization method for the dual-center structure database, those skilled in the art can clearly know the implementation method of the data synchronization device for the dual-center structure database in this embodiment. For the sake of brevity of the specification, it will not be described in detail here.

[0047] Figure 5 FIG. 5 is a structural block diagram of an electronic device 500 provided in an embodiment of the present invention. Figure 5 As shown, the electronic device 500 includes a memory 501 , a processor 502 , and a communication bus 503 ; the memory 501 and the processor 502 are connected via the communication bus 503 .

[0048] The memory 501 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 501 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function, and instructions for implementing the data synchronization method for a dual-center structure database provided in the above embodiment, etc.; the data storage area may store data involved in the data synchronization method for a dual-center structure database provided in the above embodiment, etc.

[0049] The processor 502 may include one or more processing cores. The processor 502 executes various functions and processes data of the present application by running or executing instructions, programs, code sets or instruction sets stored in the memory 501, calling the data stored in the memory 501. The processor 502 may be at least one of an application-specific integrated circuit (ASIC), a digital signal processor (DSP), a digital signal processing device (DSPD), a programmable logic device (PLD), a field programmable gate array (FPGA), a central processing unit (CPU), a controller, a microcontroller and a microprocessor. It is understandable that for different devices, the electronic device used to implement the above-mentioned processor 502 function may also be other, and the embodiment of the present invention is not specifically limited.

[0050] The communication bus 503 may include a path to transmit information between the above components. The communication bus 503 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The communication bus 503 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 Only one double arrow is used in the diagram, but it does not mean that there is only one bus or one type of bus. Figure 5 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0051] An embodiment of the present invention further provides a computer-readable storage medium storing a computer program that can be loaded by a processor and execute the data synchronization method of the dual-center structure database provided in the above embodiment.

[0052] In this embodiment, the computer-readable storage medium may be a tangible device that holds and stores instructions used by the instruction execution device. The computer-readable storage medium may be, but is not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any combination thereof. Specifically, the computer-readable storage medium may be a portable computer disk, a hard disk, a USB flash drive, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a podium random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, an optical disk, a magnetic disk, a mechanical encoding device, and any combination thereof.

[0053] The computer program in this embodiment includes a computer program for executing Figure 1 , Figure 2 The program code of the method shown in the embodiment may include instructions corresponding to the steps of the method provided in the above embodiment. The computer program may be downloaded from a computer-readable storage medium to various computing / processing devices, or downloaded to an external computer or external storage device via a network (such as the Internet, a local area network, a wide area network and / or a wireless network). The computer program may be executed entirely on the user's computer or as an independent software package.

[0054] In the embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0055] In addition, it is to be understood that relational terms such as first and second are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. The terms "comprises," "comprising," or any other variation thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device that includes a series of elements includes not only those elements, but also other elements that are not explicitly listed, or elements that are inherent to such process, method, article, or device.

[0056] The above are only preferred embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A data synchronization method for a dual-center structure database, characterized in that: Applied to the first database, the method comprises: After the first database executes the user's data change instruction, acquiring change instruction information corresponding to the data change instruction from the operation log of the first database; wherein the change instruction information includes the change data content and the first row identifier; Sending a first data synchronization instruction including the changed data content and the first row identifier to a second database, so that the second database parses the first data synchronization instruction to obtain the first row identifier, searches for a second row identifier that has a mapping relationship with the first row identifier, and executes the first data synchronization instruction based on the second row identifier; The first row identifier is identification information for indicating the position where the insert data content contained in the data insert instruction is inserted into the first database after the first database executes the user's data insert instruction; The second row identifier is identification information for indicating a position where the insert data content contained in the second data synchronization instruction is inserted into the second database after the second database executes the second data synchronization instruction sent by the first database.

2. The data synchronization method of the dual-center structure database according to claim 1, characterized in that: The method further comprises: After the first database executes the data insertion instruction of the user, first insertion instruction information corresponding to the data insertion instruction is obtained from the operation log of the first database; wherein the first insertion instruction information includes the insertion data content and the first row identifier; The second data synchronization instruction including the insert data content and the first row identifier is sent to the second database, so that after executing the second data synchronization instruction, the second database obtains the second insert instruction information including the insert data content and the second row identifier corresponding to the second data synchronization instruction from the operation log of the second database, and generates and stores the mapping relationship between the second row identifier and the first row identifier.

3. A data synchronization method for a dual-center structure database, characterized in that: Applied to the second database, the method comprises: receiving and parsing a first data synchronization instruction including a changed data content and a first row identifier sent by the first database, and obtaining the first row identifier; wherein the changed data content is data content corresponding to the data change instruction obtained from the operation log of the first database after the first database executes the data change instruction of the user; Searching for a second row identifier that has a mapping relationship with the first row identifier; wherein the first row identifier is identifier information used to indicate the position where the insert data content contained in the data insert instruction is inserted into the first database after the first database executes the user's data insert instruction; the second row identifier is identifier information used to indicate the position where the insert data content contained in the second data synchronization instruction is inserted into the second database after the second database executes the second data synchronization instruction sent by the first database; The first data synchronization instruction is executed based on the second row identifier.

4. The data synchronization method of the dual-center structure database as claimed in claim 3, characterized in that: The method further comprises: receiving and parsing a second data synchronization instruction including the insert data content and the first row identifier sent by the first database, and obtaining the first row identifier; wherein the insert data content is data content corresponding to the data insert instruction obtained from the operation log of the first database after the first database executes the user's data insert instruction; After the second database executes the second data synchronization instruction, second insertion instruction information corresponding to the second data synchronization instruction, including the inserted data content and the second row identifier, is obtained from the operation log of the second database, and a mapping relationship between the second row identifier and the first row identifier is generated and stored.

5. The data synchronization method of the dual-center structure database according to claim 3 or 4, characterized in that: After executing the first data synchronization instruction based on the second row identifier, the method further includes: Generate first filter tag information, and store the first filter tag information in the operation log of the second database, so that the log analysis program of the second database obtains the first filter tag information when monitoring that the operation log of the second database changes due to the second database executing the first data synchronization instruction; The first filter tag information is used to instruct the second database not to send a first reverse data synchronization instruction to the first database.

6. The data synchronization method of the dual-center structure database according to claim 4, characterized in that: The second insertion instruction information further includes second filtering tag information; after the second database executes the second data synchronization instruction, the method further includes: Generate the second filter tag information, and store the second filter tag information in the operation log of the second database, so that the log analysis program of the second database obtains the second filter tag information when monitoring that the operation log of the second database changes due to the second database executing the second data synchronization instruction; The second filter tag information is used to instruct the second database not to send a second reverse data synchronization instruction to the first database.

7. A data synchronization device for a dual-center structure database, characterized in that: Applied to a first database, the device comprises: A first acquisition module, configured to acquire, after the first database executes the user's data change instruction, change instruction information corresponding to the data change instruction from the operation log of the first database; wherein the change instruction information includes the change data content and the first row identifier; A first sending module is used to send a first data synchronization instruction including the changed data content and the first row identifier to a second database, so that the second database parses the first data synchronization instruction to obtain the first row identifier, searches for a second row identifier that has a mapping relationship with the first row identifier, and executes the first data synchronization instruction based on the second row identifier; The first row identifier is identification information for indicating the position where the insert data content contained in the data insert instruction is inserted into the first database after the first database executes the user's data insert instruction; The second row identifier is identification information for indicating a position where the insert data content contained in the second data synchronization instruction is inserted into the second database after the second database executes the second data synchronization instruction sent by the first database.

8. A data synchronization device for a dual-center structure database, characterized in that: Applied to the second database, the device comprises: a first receiving and parsing module, configured to receive and parse a first data synchronization instruction including a changed data content and a first row identifier sent by the first database, and obtain the first row identifier; wherein the changed data content is data content corresponding to the data change instruction obtained from an operation log of the first database after the first database executes the data change instruction of the user; A search module, used to search for a second row identifier that has a mapping relationship with the first row identifier; wherein the first row identifier is identification information used to indicate the position where the insert data content contained in the data insert instruction is inserted into the first database after the first database executes the user's data insert instruction; the second row identifier is identification information used to indicate the position where the insert data content contained in the second data synchronization instruction is inserted into the second database after the second database executes the second data synchronization instruction sent by the first database; An instruction execution module is used to execute the first data synchronization instruction based on the second row identifier.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the data synchronization method of the dual-center structure database as described in any one of claims 1 to 6 is implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the data synchronization method of the dual-center structure database as described in any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Cross-domain backup method and device in cloud computing system

    CN109976952A

  • Data backup method, device and system and computer readable storage medium

    CN111400097A

  • Data synchronization method and device, equipment and storage medium

    CN116303796A

  • Data synchronization method and device, equipment and storage medium

    CN116303798A

  • Data real-time synchronization method and device, electronic equipment, medium and program product

    CN117971974A