CN110287187B - Method, system and storage medium for synchronously updating data tables in multiple servers - Google Patents

Method, system and storage medium for synchronously updating data tables in multiple servers Download PDF

Info

Publication number
CN110287187B
CN110287187B CN201910479620.0A CN201910479620A CN110287187B CN 110287187 B CN110287187 B CN 110287187B CN 201910479620 A CN201910479620 A CN 201910479620A CN 110287187 B CN110287187 B CN 110287187B
Authority
CN
China
Prior art keywords
server
data table
data
updating
virtual
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910479620.0A
Other languages
Chinese (zh)
Other versions
CN110287187A (en
Inventor
胡峰
陈晓
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
HNAC Technology Co Ltd
Original Assignee
HNAC Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by HNAC Technology Co Ltd filed Critical HNAC Technology Co Ltd
Priority to CN201910479620.0A priority Critical patent/CN110287187B/en
Publication of CN110287187A publication Critical patent/CN110287187A/en
Application granted granted Critical
Publication of CN110287187B publication Critical patent/CN110287187B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2282Tablespace storage structures; Management thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2365Ensuring data consistency and integrity
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • G06F16/273Asynchronous replication or reconciliation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1095Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes

Abstract

The application relates to a method, a system, a computer device and a storage medium for synchronously updating data tables in a plurality of servers. The method comprises the following steps: the first server responds to user operation, updates the data content of the built-in first data table and the updating identification of the built-in virtual recording table, and sends the updating identification and the updating content to the second server in sequence, the second server updates the built-in recording table according to the updating identification, interrupts the one-way synchronization thread of the second data table to the first data table according to the updated recording table, and updates the built-in second data table according to the updating content in the state of interruption of the one-way synchronization thread. The bidirectional synchronization process of the data tables is realized by triggering and updating the built-in data tables, the built-in record tables and the virtual tables with mapping relation with the record tables, no external synchronization tool needs to be additionally developed, and the convenient and efficient bidirectional synchronization of the data tables in a plurality of servers is realized.

Description

Method, system and storage medium for synchronously updating data tables in multiple servers
Technical Field
The present application relates to the field of data processing technologies, and in particular, to a method, a system, a computer device, and a storage medium for synchronously updating data tables in multiple servers.
Background
With the rapid development of information technology, in different application environments, a server a is often required to remotely operate a server B to achieve data synchronization.
For remote synchronization operation of a mysql (relational database management system) database, the conventional method generally implements detection update and synchronization through an sql command after connecting the mysql database by other external programs.
When the number of data tables to be synchronized is small and the amount of data to be synchronized is small, more technical cost and time cost are needed to develop an external program to obtain a synchronization tool, so that serious development resource waste is caused, the data table synchronization process is complicated, and the efficiency is influenced.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a method, a system, a computer device, and a storage medium for implementing synchronous update of data tables in multiple servers, which is convenient and efficient.
A synchronous updating method for a data table in a plurality of servers, wherein the plurality of servers comprise a first server and a second server, and the synchronous updating method for the data table comprises the following steps:
the first server responds to user operation, and updates data content of a built-in first data table and an update identifier of a built-in virtual record table, wherein the first data table is associated with the virtual record table;
the first server sends the updating identification of the virtual record table and the updating content of the first data table to the second server;
the second server updates a built-in record table which has a mapping relation with the virtual record table according to the updating identification;
and the second server interrupts the one-way synchronous thread for synchronizing the second data table to the first data table according to the updated record table, and updates the built-in second data table according to the updated content in the state of interruption of the one-way synchronous thread.
In one embodiment, the first server sending the updated identifier of the virtual record table and the updated content of the first data table to the second server includes:
the first server sends the update identification of the virtual record table to the second server according to a first mapping relation between the virtual record table and the record table which is constructed in advance;
the first server updates the updating content of the first data table to a built-in virtual data table;
and the first server sends the updated content of the second data table to the second server according to a second mapping relation between the virtual data table and the second data table which is constructed in advance.
In one embodiment, before the first server sends the update identifier of the virtual record table and the update content of the first data table to the second server, the method further includes:
the first server sends a mapping request link to the second server based on a Federated engine;
and the second server constructs a first mapping relation between the virtual record table and the record table and a second mapping relation between the virtual data table and the second data table according to mapping object information carried by the mapping request link.
In one embodiment, the updating, by the first server, the data content of the built-in first data table and the update identifier of the built-in virtual record table in response to the user operation includes:
the first server responds to user operation, updates the data content of a built-in first data table, and sends first trigger information to a virtual record table associated with the first data table;
and updating the virtual record table according to the data operation source information carried by the first trigger information, wherein the updated virtual record table carries an update identifier, the update identifier corresponds to the data operation source information, and the update identifier comprises user operation and mapping synchronization completion.
In one embodiment, the interrupting, by the second server, the synchronization of the second data table to the unidirectional synchronization thread of the first data table according to the updated record table includes:
the second server sends a second trigger message to a second data table according to the updated record table;
and when the updating mark carried by the second trigger message is user operation, interrupting the one-way synchronization thread for synchronizing the second data table to the first data table.
In one embodiment, after the first server sends the update identifier of the virtual record table and the update content of the first data table to the second server, the method further includes:
the first server updates the updating identification of the virtual record table for the second time and sends the updating identification for the second time to the second server;
the second server interrupts a unidirectional synchronous thread for synchronizing the second data table to the first data table according to the updated record table, and after updating the built-in second data table according to the updated content in the state of the unidirectional synchronous thread interruption, the method further includes:
and the second server updates the record table for the second time according to the secondary updating identification, and awakens the unidirectional synchronous thread of the second data table to be synchronized to the first data table again when the updating identification of the record table updated for the second time is mapping synchronization completion.
A synchronous updating system for data tables in a plurality of servers comprises a first server and a second server;
the first server is used for responding to user operation, updating the data content of a built-in first data table and the updating identification of a built-in virtual record table, and sending the updating identification of the virtual record table and the updating content of the first data table to the second server, wherein the first data table is associated with the virtual record table;
the second server is used for updating a built-in record table which has a mapping relation with the virtual record table according to the updating identification, interrupting the unidirectional synchronous thread for synchronizing the second data table to the first data table according to the updated record table, and updating the built-in second data table according to the updating content in the state of the unidirectional synchronous thread interruption.
In one embodiment, the first server is further configured to update the update identifier of the virtual record table for the second time, and send the update identifier for the second time to the second server;
and the second server is also used for updating the record table for the second time according to the secondary updating identification, and awakening the unidirectional synchronization thread for synchronizing the second data table to the first data table again when the updating identification of the record table updated for the second time is the end of mapping synchronization.
A computer device comprising a memory and a processor, the memory storing a computer program, the processor implementing the following steps when executing the computer program:
the first server responds to user operation, and updates data content of a built-in first data table and an update identifier of a built-in virtual record table, wherein the first data table is associated with the virtual record table;
the first server sends the updating identification of the virtual record table and the updating content of the first data table to the second server;
the second server updates a built-in record table which has a mapping relation with the virtual record table according to the updating identification;
and the second server interrupts the one-way synchronous thread for synchronizing the second data table to the first data table according to the updated record table, and updates the built-in second data table according to the updated content in the state of interruption of the one-way synchronous thread.
A computer-readable storage medium, on which a computer program is stored which, when executed by a processor, carries out the steps of:
the first server responds to user operation, and updates data content of a built-in first data table and an update identifier of a built-in virtual record table, wherein the first data table is associated with the virtual record table;
the first server sends the updating identification of the virtual record table and the updating content of the first data table to the second server;
the second server updates a built-in record table which has a mapping relation with the virtual record table according to the updating identification;
and the second server interrupts the one-way synchronous thread for synchronizing the second data table to the first data table according to the updated record table, and updates the built-in second data table according to the updated content in the state of interruption of the one-way synchronous thread.
According to the method, the system, the computer device and the storage medium for synchronously updating the data tables in the multiple servers, the first server updates the data content of the first data table in the first server and the update identifier of the virtual record table associated with the first data table according to the operation of the response user and sends the update identifier and the update content to the second server, the second server updates the built-in record table which has a mapping relation with the virtual record table according to the update identifier, the second server interrupts the one-way synchronization thread for synchronizing the second data table to the first data table according to the updated record table, and updates the built-in second data table according to the update content in the interruption state of the one-way synchronization thread. Compared with the traditional data table updating method, the scheme sends the updating content corresponding to the first data table and the updating identifier of the virtual recording table, which are updated when the first server responds to the user operation, to the second server, updates the built-in recording table with the mapping relation with the virtual recording table through the updating identifier of the virtual recording table, further synchronizes the first data table in the first server and the second data table in the second server through interrupting the unidirectional synchronization thread of the second data table to the first data table, on one hand, by interrupting the unidirectional synchronization thread of the second data table, the situation that the second data table automatically sends the corresponding updating content to the first server when the data content is updated synchronously can be avoided, so that dead cycle of the data table synchronization process occurs, and bidirectional synchronous updating of the data tables among different servers is realized, on the other hand, the bidirectional synchronization process of the data tables is realized through the triggering update of the built-in data tables, the built-in record tables and the virtual tables with the mapping relation, no external tool needs to be additionally developed, and the convenient and efficient synchronization of the data tables in the servers is realized.
Drawings
FIG. 1 is a diagram illustrating an exemplary implementation of a method for synchronously updating data tables in multiple servers;
FIG. 2 is a flowchart illustrating a method for synchronously updating data tables in multiple servers according to an embodiment;
FIG. 3 is a flowchart illustrating a method for synchronously updating data tables in multiple servers according to another embodiment;
FIG. 4 is a flowchart illustrating a method for synchronously updating data tables in multiple servers according to another embodiment;
FIG. 5 is a flowchart illustrating a method for synchronously updating data tables in multiple servers according to yet another embodiment;
FIG. 6 is a flowchart illustrating a method for synchronously updating data tables in multiple servers in yet another embodiment;
FIG. 7 is a flowchart illustrating a method for synchronously updating data tables in multiple servers in one embodiment;
FIG. 8 is a block diagram of a system for synchronized updating of data tables in multiple servers, according to one embodiment;
FIG. 9 is a block diagram of a system for synchronously updating data tables in multiple servers in an exemplary application;
FIG. 10 is a diagram showing an internal structure of a computer device according to an embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application. The first server and the second server are relative concepts, and the first server and the second server can be replaced with each other in the application process.
The method for synchronously updating the data tables in the multiple servers can be applied to the application environment shown in fig. 1. The method can be particularly used for bidirectional synchronization between a small number of data tables of mysql databases of two servers, and is a lightweight implementation scheme. In which the terminal 100 communicates with the first server 200 through a network, and the first server 200 communicates with the second server 300 through a network. The first server 200 updates the data content of the built-in first data table and the update identifier of the virtual record table associated with the first data table according to the user operation instruction sent by the terminal 100, and sends the update identifier and the update content to the second server 300, the second server 300 updates the record table in the second server 300, which has a mapping relation with the virtual record table according to the update identifier, when the second server 300 interrupts the unidirectional synchronization thread for synchronizing the second data table of the second server 300 to the first data table according to the updated record table, the second server 300 updates the second data table in the second server 300 according to the update content, performs synchronization between the first data table in the first server 200 and the second data table in the second server 300, and performs the unidirectional synchronization thread for synchronizing the second data table to the first data table by interrupting the unidirectional synchronization thread, the method and the device avoid dead circulation of a synchronization process caused by the fact that the second data table automatically sends the corresponding updated content to the first server 200 when data are synchronized, thereby realizing bidirectional synchronization of the data tables among different servers, avoiding the need that a user synchronizes part of data in a mode of using other external programs, expanding the use range and improving the applicability, and can be used for multi-machine synchronization of a rights management data table and a user information data table and the like. The terminal 100 may be, but not limited to, various personal computers, notebook computers, smart phones, tablet computers, and portable wearable devices, and the first server 200 and the second server 300 may be implemented by independent servers or a server cluster formed by a plurality of servers.
In other embodiments, the user may also directly operate the first server 200, so that the first server 200 responds to the user operation.
In one embodiment, as shown in fig. 2, a method for synchronously updating a data table in a plurality of servers is provided, the plurality of servers includes a first server and a second server, and the method for synchronously updating the data table includes the following steps:
step S100, the first server responds to a user operation, and updates a data content of a built-in first data table and an update identifier of a built-in virtual record table, where the first data table is associated with the virtual record table.
The first server responding to the user operation may be a response process in which the user operates the data table in the server through the terminal, or a response process in which the user directly operates the data table in the server, and the user operation includes writing, deleting, updating, and the like of the data table. The first server responds to user operation, corresponding data updating is carried out on a first data table in the first server, an updated first data table is obtained, the virtual record table is used for recording data operation source information, the data operation source information comprises user operation and mapping updating, the user operation means that a user sends a user operation instruction to the first server through a terminal or directly sends the user operation instruction to the first server, so that the server updates the data table according to the user operation instruction, and the mapping updating means that updated content corresponding to updating is sent to a second server when the first data table is updated through a preset mapping relation, so that the second server synchronously updates the second data table according to the updated content.
Step S200, the first server sends the update identifier of the virtual record table and the update content of the first data table to the second server.
The updating mark corresponding to the virtual record table refers to a mark corresponding to data operation source information, and includes user operation and mapping updating, and the updating content corresponding to the first data table includes data writing, data deletion, data updating and the like. In an embodiment, when a first server responds to a user operation, data content of a first data table is updated, trigger information is generated, a virtual record table and a virtual data table associated with the first data table are sequentially sent to the virtual record table and the virtual data table, the virtual data table is a middle channel connecting the first data table of the first server and a second data table of a second server, the virtual data table and the first data table have an association relation and a mapping relation with the second data table, when the virtual data table is triggered through the association relation with the first data table, updated content of the first data table is sent to the second server, the virtual data table cannot be directly operated by the user, and the operation on the virtual data table is directly reflected on the second data table through the mapping relation.
And step S300, the second server updates the built-in record table which has a mapping relation with the virtual record table according to the updating identification.
The second server is internally provided with a record table, a mapping relation is pre-constructed between the virtual record table and the record table, and when the virtual record table in the first server is updated, the record table in the second server is also correspondingly updated according to the mapping relation. In an embodiment, when the virtual record table is updated, the first server sends the update identifier of the virtual record table to the second server according to the mapping relationship, and the second server updates the record table according to the update identifier.
And step S400, the second server interrupts the second data table to be synchronized to the unidirectional synchronous thread of the first data table according to the updated record table, and updates the built-in second data table according to the updating content in the state of the unidirectional synchronous thread interruption.
In the second server, the built-in recording table is associated with a built-in second data table, and when the recording table is updated, the second data table is triggered according to the updating identifier, so that the second server controls the second data table to be synchronized to the interruption and re-awakening of the unidirectional synchronization thread of the first data table. In an embodiment, when the update identifier is a user operation, the second data table is synchronized with the first data table, and the unidirectional synchronization thread controlling the second data table to be synchronized with the first data table is triggered to be interrupted, so that the situation that when the second data table is modified, the unidirectional synchronization thread synchronizing the second data table with the first data table sends the update content corresponding to the second data table to the first server is avoided, and data synchronization is prevented from being in a dead cycle. And when the updating identifier is that the mapping synchronization is completed, controlling to awaken the one-way synchronization thread for synchronizing the second data table to the first data table again, so that when a user operates the second data table through the terminal, the second server sends the corresponding updating content to the first data table of the first server, and reverse data synchronization updating is realized. The user operation and the mapping synchronization completion both correspond to the operation of the first server, the user operation refers to corresponding information when the first server responds to the user operation, and the mapping synchronization completion refers to corresponding information after the first server synchronizes the updated content of the first data table to the second server.
According to the synchronous updating method for the data tables in the multiple servers, the first server updates the data content of the first data table in the first server and the updating identifier of the virtual record table associated with the first data table according to the response user operation and sends the updating identifier and the updating content to the second server, the second server updates the built-in record table which has a mapping relation with the virtual record table according to the updating identifier, the second server interrupts the one-way synchronous thread for synchronizing the second data table to the first data table according to the updated record table, and the built-in second data table is updated according to the updating content in the state of interruption of the one-way synchronous thread. Compared with the traditional data table updating method, the scheme sends the updating content corresponding to the first data table and the updating identifier of the virtual recording table, which are updated when the first server responds to the user operation, to the second server, updates the built-in recording table with the mapping relation with the virtual recording table through the updating identifier of the virtual recording table, further synchronizes the first data table in the first server and the second data table in the second server through interrupting the unidirectional synchronization thread of the second data table to the first data table, on one hand, by interrupting the unidirectional synchronization thread of the second data table, the situation that the second data table automatically sends the corresponding updating content to the first server when the data content is updated synchronously can be avoided, so that dead cycle of the data table synchronization process occurs, and bidirectional synchronous updating of the data tables among different servers is realized, on the other hand, the bidirectional synchronization process of the data tables is realized through the triggering update of the built-in data tables, the built-in record tables and the virtual tables with the mapping relation, no external tool needs to be additionally developed, and the convenient and efficient synchronization of the data tables in the servers is realized.
In one embodiment, as shown in fig. 3, the step S200 of sending, by the first server, the update identifier of the virtual record table and the update content of the first data table to the second server includes:
in step S220, the first server sends the update identifier of the virtual record table to the second server according to the first mapping relationship between the virtual record table and the record table that is constructed in advance.
In step S240, the first server updates the update content of the first data table to the built-in virtual data table.
Step S260, the first server sends the updated content of the second data table to the second server according to the second mapping relationship between the pre-constructed virtual data table and the second data table.
The virtual data table is used for realizing remote operation on another server, when the virtual table of the server A is operated, the virtual data table of the server A cannot be changed, and the corresponding updated content can be embodied in the data table which has a mapping relation with the virtual data table in another server B. In the scheme, a user operates the first data table, the first data table updates the updating content corresponding to the first data table to the virtual data table by sending the trigger information to the virtual record table, so that the second data table is updated through the mapping relation between the virtual data table and the second data table, and the first data table and the second data table are synchronized.
In an embodiment, as shown in fig. 4, before the step S200, before the sending, by the first server, the update identifier of the virtual record table and the update content of the first data table to the second server, the method further includes:
step S180, the first server sends a mapping request link to the second server based on the Federated engine;
step S190, the second server constructs a first mapping relationship between the virtual record table and the record table and a second mapping relationship between the virtual data table and the second data table according to the mapping object information carried by the mapping request link.
The Federated engine is a storage engine of the mysql data table, can be connected to a data table with the same structure of another server to establish a mapping relation, is a virtual data table, is only one mapping of a connected remote table, does not occupy a memory locally, and operates the Federated table, which is equivalent to operating a table with a mapping relation in another remote server. Based on the Federated engine, the first server sends a mapping request link to the second server, the mapping request link carries mapping object information, a first mapping relation between the virtual record table and the record table is constructed according to the mapping object information carried by the mapping request link, and a second mapping relation between the virtual data table and the second data table is constructed. Similarly, the second server may also send the mapping request link to the first server to construct a reverse mapping relationship.
In one embodiment, as shown in fig. 5, in step S100, the updating, by the first server, the data content of the built-in first data table and the update identifier of the built-in virtual record table in response to the user operation include:
step S110, the first server responds to the user operation, updates the data content of the built-in first data table, and sends the first trigger information to the virtual record table associated with the first data table.
Step S120, updating the virtual record table according to the data operation source information carried by the first trigger information, wherein the updated virtual record table carries an update identifier, the update identifier corresponds to the data operation source information, and the update identifier comprises user operation and mapping synchronization completion.
The first server responds to the user operation, updates the first data table in the first server, and sends out the trigger information when the data in the first data table is operated, namely the first data table is updated. In an application example, in one data synchronization, when the data content of a first data table is updated, trigger information a, trigger information B and trigger information C are sequentially sent out three times, taking trigger information a, trigger information B and trigger information C as an example, when the data content in the first data table is updated, the trigger information a is sent to a virtual record table first, according to the mapping relation between the virtual record table and the record table, so that a second server interrupts the synchronization of the second data table to a unidirectional synchronization thread of the first data table according to the updated record table, then the trigger information B is sent to a built-in virtual data table, according to the mapping relation between the virtual data table and the second data table, so that the second data table in the second server obtains corresponding updated content, updates the second data table, finally, the trigger information C is sent to the virtual record table, and the update identifier of the virtual record table is updated again, so that the second server wakes up the one-way synchronization thread of the second data table synchronized to the first data table again. The updating mark carried by the triggering information A is user operation, and the updating mark carried by the triggering information C is mapping synchronization completion.
In one application example, each table in the mysql database is embedded with a trigger program (hereinafter referred to as a trigger), and when the first server responds to a user operation, the trigger in the first data table is triggered to sequentially send trigger information to the virtual record table, the virtual data table, and the virtual record table.
In one embodiment, as shown in fig. 6, the interrupting, by the second server, the one-way synchronization thread for synchronizing the second data table to the first data table according to the updated record table includes:
step S410, the second server sends a second trigger message to the second data table according to the updated record table.
Step S420, when the update identifier carried in the second trigger message is a user operation, the one-way synchronization thread for synchronizing the second data table to the first data table is interrupted.
And step S430, updating the built-in second data table according to the updating content in the one-way synchronous thread interruption state.
When the record table built in the second server is correspondingly updated according to the update identifier of the virtual record table built in the first server, the state of the one-way synchronization thread for synchronizing the second data table to the first data table needs to be controlled. In an embodiment, when the record table receives that the update identifier of the virtual record table is the user operation, the update identifier of the record table is synchronously updated to the user operation, and the second server interrupts the one-way synchronization thread for synchronizing the second data table to the first data table according to the update identifier of the record table. And when the second data table acquires the trigger information, the one-way synchronization thread for synchronizing the second data table to the first data table is interrupted.
In one embodiment, as shown in fig. 7, after the step S200, the first server sends the update identifier of the virtual record table and the update content of the first data table to the second server, the method further includes:
step S270, the first server updates the update identifier of the virtual record table for the second time, and sends the update identifier for the second time to the second server.
Step S400, the second server interrupts the unidirectional synchronization thread for synchronizing the second data table to the first data table according to the updated record table, and after updating the built-in second data table according to the update content in the state of the unidirectional synchronization thread interruption, the method further includes:
step S470 is that the second server updates the record table for the second time according to the second update identifier, and when the update identifier of the record table updated for the second time is the end of the mapping synchronization, wakes up the unidirectional synchronization thread of the second data table synchronized to the first data table again.
When the second data table is updated, the one-way synchronization thread synchronized to the first data table by the second data table belongs to an interrupt state, and needs to be awakened again so that the one-way synchronization thread synchronized to the first data table by the second data table is in a ready-to-work state.
It should be understood that although the various steps in the flow charts of fig. 2-7 are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least some of the steps in fig. 2-7 may include multiple sub-steps or multiple stages that are not necessarily performed at the same time, but may be performed at different times, and the order of performance of the sub-steps or stages is not necessarily sequential, but may be performed in turn or alternating with other steps or at least some of the sub-steps or stages of other steps.
In one embodiment, as shown in fig. 8, there is provided a system for synchronously updating data tables in multiple servers, including: a first server 200 and a second server 300;
the first server 200 is configured to update the data content of the built-in first data table 220 and the update identifier of the built-in virtual record table 260 in response to a user operation, and sequentially send the update identifier of the virtual record table 260 and the update content of the first data table 220 to the second server 300, where the first data table 220 is associated with the virtual record table 260;
the second server 300 is configured to update the record table 360 in the second server 300, which has a mapping relationship with the virtual record table 260, according to the update identifier, and when the second server 300 interrupts the unidirectional synchronization thread from the second data table 320 to the first data table 220 according to the updated record table 360, update the built-in second data table 320 according to the update content.
In one embodiment, the first server 200 is further configured to update the update identifier of the virtual record table 260 for the second time, and send the update identifier for the second time to the second server 300;
the second server 300 is further configured to update the record table 360 for the second time according to the second update identifier, and when the update identifier of the record table 360 for the second time update is that the mapping synchronization is finished, re-awaken the unidirectional synchronization thread of the second data table 320 synchronized to the first data table 220.
In one embodiment, the first server 200 is further configured to send the update identifier of the virtual record table 260 to the second server 300 according to a first mapping relationship between the pre-constructed first data table 220 and the second data table 320, then update the update content of the first data table 220 to the built-in virtual data table 240, and send the update content of the second data table 320 to the second server 300 according to a second mapping relationship between the pre-constructed virtual data table 240 and the second data table 320.
In one embodiment, the first server 200 is further configured to send a mapping request link to the second server 300 based on a fed engine, and the second server 300 is further configured to construct a first mapping relationship between the virtual record table 260 and the record table 360 and a second mapping relationship between the virtual data table 240 and the second data table 320 according to mapping object information carried by the mapping request link.
In an embodiment, the first server 200 is further configured to update the data content of the built-in first data table 220 in response to a user operation, send first trigger information to the virtual record table 260 associated with the first data table 220, update the virtual record table 260 according to data operation source information carried in the first trigger information, where the updated virtual record table 260 carries an update identifier, the update identifier corresponds to the data operation source information, and the update identifier includes an end of synchronization between the user operation and the mapping.
In one embodiment, the second server 300 is further configured to send a second trigger message to the second data table 320 according to the updated record table 360, and interrupt the unidirectional synchronization thread from the second data table 320 to the first data table 220 when the update identifier carried in the second trigger message is a user operation.
In an application example, as shown in fig. 9, a first data table, a first virtual record table, and a first record table are built in a first server, a second data table, a second virtual record table, and a second record table are built in a second server, and a trigger program is built in each table to implement a trigger function. The virtual data table and the data table have a mapping relationship, that is, the first virtual data table and the second data table have a mapping relationship, the second virtual data table and the first data table have a mapping relationship, and similarly, the virtual record table and the record table have a mapping relationship. In the figure, data shown by a solid line is a data processing flow for a user to operate the first data table through the terminal and synchronously update the second data table, and data shown by a dotted line is a data processing flow for a user to operate the second data table through the terminal and synchronously update the first data table. In other application examples, a server operated by a user can be directly used as a first server, and a server for realizing synchronous updating of the data table can be used as a second server. Taking the solid-line data processing procedure as an example, when a user operates the first data table through the terminal, the trigger of the first data table is triggered, the trigger information a1 is sequentially sent to the first virtual record table, the trigger information a2 is sent to the first virtual data table, and the trigger information a3 is sent to the first virtual record table. In the figures, a1, a2, a3 represent corresponding data streams after the trigger message is sent, where data operation source information carried by the trigger information a1 is a user operation, and is used to update the update identifier of the first virtual record table to the user operation, the first virtual record table synchronizes the update identifier to the second record table through a mapping relationship with the second record table, and the second record table interrupts the unidirectional synchronization thread for synchronizing the second data table to the first data table according to the update identifier of the user operation. The trigger information a2 carries update content, which is used to update the first virtual data table, the first virtual data table sends the update content to the second data table through the mapping relation with the second data table, and the update content is updated according to the update content under the condition that the unidirectional synchronous thread that the second data table is synchronized to the first data table is interrupted. The data operation source information carried by the trigger information a3 is mapping update, and is used for performing secondary update on the update identifier of the first virtual record table, so as to synchronously implement secondary update on the second record table, and the second record table re-awakens the unidirectional synchronization thread where the second data table is synchronized to the first data table according to the update identifier of the mapping update. The dashed data processing in fig. 9 is also possible. In other application examples, the one-way synchronization thread for synchronizing the second data table to the first data table may be implemented by a trigger program. The scheme can directly realize the double-machine synchronization of a single table in the mysql database, completely does not influence the performance of a user for operating other tables, and does not occupy the service resources of the mysql database when the synchronous table is not updated.
In the system for synchronously updating the data tables in the multiple servers, the first server updates the data content of the first data table in the first server and the update identifier of the virtual record table associated with the first data table according to the response user operation, and sends the update identifier and the update content to the second server, the second server updates the built-in record table which has a mapping relation with the virtual record table according to the update identifier, the second server interrupts the unidirectional synchronous thread for synchronizing the second data table to the first data table according to the updated record table, and updates the built-in second data table according to the update content in the state of the interrupted unidirectional synchronous thread. Compared with the traditional data table updating method, the scheme sends the updating content corresponding to the first data table and the updating identifier of the virtual recording table, which are updated when the first server responds to the user operation, to the second server, updates the built-in recording table with the mapping relation with the virtual recording table through the updating identifier of the virtual recording table, further synchronizes the first data table in the first server and the second data table in the second server through interrupting the unidirectional synchronization thread of the second data table to the first data table, on one hand, by interrupting the unidirectional synchronization thread of the second data table, the situation that the second data table automatically sends the corresponding updating content to the first server when the data content is updated synchronously can be avoided, so that dead cycle of the data table synchronization process occurs, and bidirectional synchronous updating of the data tables among different servers is realized, on the other hand, the bidirectional synchronization process of the data tables is realized through the triggering update of the built-in data tables, the built-in record tables and the virtual tables with the mapping relation, no external tool needs to be additionally developed, and the convenient and efficient synchronization of the data tables in the servers is realized.
For specific limitations of the system for synchronously updating data tables in multiple servers, reference may be made to the above limitations on the method for synchronously updating data tables in multiple servers, and details are not described here.
In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as shown in fig. 10. The computer device includes a processor, a memory, a network interface, and a database connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The database of the computer device is used for storing data table synchronization updating data. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a method for synchronous updating of data tables in multiple servers.
Those skilled in the art will appreciate that the architecture shown in fig. 10 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, there is provided a computer device comprising a memory storing a computer program and a processor implementing the following steps when the processor executes the computer program:
the first server responds to user operation, and updates the data content of a built-in first data table and the updating identification of a built-in virtual record table, wherein the first data table is associated with the virtual record table;
the first server sends the update identification of the virtual record table and the update content of the first data table to the second server;
the second server updates a built-in record table which has a mapping relation with the virtual record table according to the updating identification;
and the second server interrupts the one-way synchronous thread for synchronizing the second data table to the first data table according to the updated record table, and updates the built-in second data table according to the updated content in the state of interruption of the one-way synchronous thread.
In other embodiments, the processor, when executing the computer program, further implements the steps of the method for synchronously updating the data tables in the plurality of servers in the above embodiments.
The computer device for implementing the method for synchronously updating the data tables in the multiple servers updates the data content of the first data table in the first server and the update identifier of the virtual record table associated with the first data table by controlling the first server according to the operation of the response user, sends the update identifier and the update content to the second server, controls the second server to update the built-in record table which has a mapping relation with the virtual record table according to the update identifier, interrupts the unidirectional synchronization thread for synchronizing the second data table to the first data table according to the updated record table by the second server, and updates the built-in second data table according to the update content in the interrupted state of the unidirectional synchronization thread. Compared with the traditional data table updating method, the scheme sends the updating content corresponding to the first data table and the updating identifier of the virtual recording table, which are updated when the first server responds to the user operation, to the second server, updates the built-in recording table with the mapping relation with the virtual recording table through the updating identifier of the virtual recording table, further synchronizes the first data table in the first server and the second data table in the second server through interrupting the unidirectional synchronization thread of the second data table to the first data table, on one hand, by interrupting the unidirectional synchronization thread of the second data table, the situation that the second data table automatically sends the corresponding updating content to the first server when the data content is updated synchronously can be avoided, so that dead cycle of the data table synchronization process occurs, and bidirectional synchronous updating of the data tables among different servers is realized, on the other hand, the bidirectional synchronization process of the data tables is realized through the triggering update of the built-in data tables, the built-in record tables and the virtual tables with the mapping relation, no external tool needs to be additionally developed, and the convenient and efficient synchronization of the data tables in the servers is realized.
In one embodiment, a computer-readable storage medium is provided, having a computer program stored thereon, which when executed by a processor, performs the steps of:
the first server responds to user operation, and updates the data content of a built-in first data table and the updating identification of a built-in virtual record table, wherein the first data table is associated with the virtual record table;
the first server sends the update identification of the virtual record table and the update content of the first data table to the second server;
the second server updates a built-in record table which has a mapping relation with the virtual record table according to the updating identification;
and the second server interrupts the one-way synchronous thread for synchronizing the second data table to the first data table according to the updated record table, and updates the built-in second data table according to the updated content in the state of interruption of the one-way synchronous thread.
In other embodiments, the computer program, when executed by a processor, further implements the steps of the method for synchronously updating data tables in multiple servers in the above embodiments.
The computer-readable storage medium for implementing the method for synchronously updating the data tables in the multiple servers updates the data content of the first data table in the first server and the update identifier of the virtual record table associated with the first data table by controlling the first server according to the response user operation, and sends the update identifier and the update content to the second server, controls the second server to update the built-in record table which has a mapping relation with the virtual record table according to the update identifier, and interrupts the unidirectional synchronization thread for synchronizing the second data table to the first data table according to the updated record table by the second server, and updates the built-in second data table according to the update content in the interrupted state of the unidirectional synchronization thread. Compared with the traditional data table updating method, the scheme sends the updating content corresponding to the first data table and the updating identifier of the virtual recording table, which are updated when the first server responds to the user operation, to the second server, updates the built-in recording table with the mapping relation with the virtual recording table through the updating identifier of the virtual recording table, further synchronizes the first data table in the first server and the second data table in the second server through interrupting the unidirectional synchronization thread of the second data table to the first data table, on one hand, by interrupting the unidirectional synchronization thread of the second data table, the situation that the second data table automatically sends the corresponding updating content to the first server when the data content is updated synchronously can be avoided, so that dead cycle of the data table synchronization process occurs, and bidirectional synchronous updating of the data tables among different servers is realized, on the other hand, the bidirectional synchronization process of the data tables is realized through the triggering update of the built-in data tables, the built-in record tables and the virtual tables with the mapping relation, no external tool needs to be additionally developed, and the convenient and efficient synchronization of the data tables in the servers is realized.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware related to instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above examples only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (10)

1. A synchronous updating method for a data table in a plurality of servers, wherein the plurality of servers comprise a first server and a second server, and the synchronous updating method for the data table comprises the following steps:
the first server responds to user operation, and updates data content of a built-in first data table and an update identifier of a built-in virtual record table, wherein the first data table is associated with the virtual record table;
the first server sends the updating identification of the virtual record table and the updating content of the first data table to the second server;
the second server updates a built-in record table which has a mapping relation with the virtual record table according to the updating identification;
and the second server interrupts the one-way synchronous thread for synchronizing the second data table to the first data table according to the updated record table, and updates the built-in second data table according to the updated content in the state of interruption of the one-way synchronous thread.
2. The method of claim 1, wherein the first server sending the updated identification of the virtual record table and the updated content of the first data table to the second server comprises:
the first server sends the update identification of the virtual record table to the second server according to a first mapping relation between the virtual record table and the record table which is constructed in advance;
the first server updates the updating content of the first data table to a built-in virtual data table;
and the first server sends the updated content of the virtual data table to the second server according to a second mapping relation between the virtual data table and the second data table which is constructed in advance.
3. The method of claim 2, wherein before the first server sends the updated identifier of the virtual record table and the updated content of the first data table to the second server, further comprising:
the first server sends a mapping request link to the second server based on a Federated engine;
and the second server constructs a first mapping relation between the virtual record table and the record table and a second mapping relation between the virtual data table and the second data table according to mapping object information carried by the mapping request link.
4. The method of claim 1, wherein the first server updating the data content of the built-in first data table and the update identifier of the built-in virtual record table in response to the user operation comprises:
the first server responds to user operation, updates the data content of a built-in first data table, and sends first trigger information to a virtual record table associated with the first data table;
and updating the virtual record table according to the data operation source information carried by the first trigger information, wherein the updated virtual record table carries an update identifier, the update identifier corresponds to the data operation source information, and the update identifier comprises user operation and mapping synchronization completion.
5. The method of claim 4, wherein the second server interrupting the one-way synchronization thread of the second data table to the first data table based on the updated record table comprises:
the second server sends a second trigger message to a second data table according to the updated record table;
and when the updating mark carried by the second trigger message is user operation, interrupting the one-way synchronization thread for synchronizing the second data table to the first data table.
6. The method of claim 5, wherein after the first server sends the updated identifier of the virtual record table and the updated content of the first data table to the second server, further comprising:
the first server updates the updating identification of the virtual record table for the second time and sends the updating identification for the second time to the second server;
the second server interrupts a unidirectional synchronous thread for synchronizing the second data table to the first data table according to the updated record table, and after updating the built-in second data table according to the updated content in the state of the unidirectional synchronous thread interruption, the method further includes:
and the second server updates the record table for the second time according to the secondary updating identification, and awakens the unidirectional synchronous thread of the second data table to be synchronized to the first data table again when the updating identification of the record table updated for the second time is mapping synchronization completion.
7. A synchronous updating system for data tables in a plurality of servers is characterized by comprising a first server and a second server;
the first server is used for responding to user operation, updating the data content of a built-in first data table and the updating identification of a built-in virtual record table, and sending the updating identification of the virtual record table and the updating content of the first data table to the second server, wherein the first data table is associated with the virtual record table;
the second server is used for updating a built-in record table which has a mapping relation with the virtual record table according to the updating identification, interrupting the unidirectional synchronous thread for synchronizing the second data table to the first data table according to the updated record table, and updating the built-in second data table according to the updating content in the state of the unidirectional synchronous thread interruption.
8. The system of claim 7, wherein the first server is further configured to update the update identifier of the virtual record table for the second time, and send the update identifier for the second time to the second server;
and the second server is also used for updating the record table for the second time according to the secondary updating identification, and awakening the unidirectional synchronization thread for synchronizing the second data table to the first data table again when the updating identification of the record table updated for the second time is the end of mapping synchronization.
9. A computer device comprising a memory and a processor, the memory storing a computer program, wherein the processor implements the steps of the method of any one of claims 1 to 6 when executing the computer program.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 6.
CN201910479620.0A 2019-06-04 2019-06-04 Method, system and storage medium for synchronously updating data tables in multiple servers Active CN110287187B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910479620.0A CN110287187B (en) 2019-06-04 2019-06-04 Method, system and storage medium for synchronously updating data tables in multiple servers

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910479620.0A CN110287187B (en) 2019-06-04 2019-06-04 Method, system and storage medium for synchronously updating data tables in multiple servers

Publications (2)

Publication Number Publication Date
CN110287187A CN110287187A (en) 2019-09-27
CN110287187B true CN110287187B (en) 2021-06-08

Family

ID=68003124

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910479620.0A Active CN110287187B (en) 2019-06-04 2019-06-04 Method, system and storage medium for synchronously updating data tables in multiple servers

Country Status (1)

Country Link
CN (1) CN110287187B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112817988B (en) * 2021-01-06 2022-11-15 贵阳迅游网络科技有限公司 Synchronous acceleration method for enterprise business

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104239439A (en) * 2008-12-22 2014-12-24 岩星比德科有限公司 Selective database replication
WO2018093094A1 (en) * 2016-11-16 2018-05-24 주식회사 실크로드소프트 Data replacation technique in database management system
CN109271444A (en) * 2018-08-10 2019-01-25 武汉达梦数据库有限公司 A kind of table level bi-directional synchronization method and system based on trigger

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104239439A (en) * 2008-12-22 2014-12-24 岩星比德科有限公司 Selective database replication
WO2018093094A1 (en) * 2016-11-16 2018-05-24 주식회사 실크로드소프트 Data replacation technique in database management system
CN109271444A (en) * 2018-08-10 2019-01-25 武汉达梦数据库有限公司 A kind of table level bi-directional synchronization method and system based on trigger

Also Published As

Publication number Publication date
CN110287187A (en) 2019-09-27

Similar Documents

Publication Publication Date Title
US10719260B2 (en) Techniques for storing and retrieving data from a computing device
WO2020140683A1 (en) Task scheduling method and apparatus, computer device, and storage medium
CN110750506A (en) Data object identification generation method and device, computer equipment and storage medium
WO2017162032A1 (en) Method and device for executing data recovery operation
US10114848B2 (en) Ensuring the same completion status for transactions after recovery in a synchronous replication environment
MX2014007678A (en) Application consistent snapshots of a shared volume.
CN109445845B (en) Interface calling method and device, computer equipment and storage medium
CN110213392B (en) Data distribution method and device, computer equipment and storage medium
CN110781214A (en) Database reading and writing method and device, computer equipment and storage medium
CN110716989A (en) Dimension data processing method and device, computer equipment and storage medium
CN109389299B (en) Workflow process deployment method, workflow process deployment device, computer equipment and storage medium
CN110602165A (en) Government affair data synchronization method, device, system, computer equipment and storage medium
CN110287187B (en) Method, system and storage medium for synchronously updating data tables in multiple servers
CN111158959A (en) Virtual machine backup method and device and virtual machine recovery method and device
CN113810433A (en) File uploading method and device and computer equipment
CN112866339B (en) Data transmission method and device, computer equipment and storage medium
CN109634140B (en) Method, device, unit and computer equipment for updating running environment data
WO2019201248A1 (en) Re-bootstrap method and device in lightweight machine to machine system
CN108965450B (en) Service request response method, device, computer equipment and storage medium
CN112232902B (en) Order data processing method, device and system, computer equipment and storage medium
CN111966530A (en) Disaster recovery switching method and device for application system, computer equipment and storage medium
CN111159271A (en) Data processing method and device, computer equipment and storage medium
CN109325057B (en) Middleware management method, device, computer equipment and storage medium
CN110866011B (en) Data table synchronization method and device, computer equipment and storage medium
CN112783866A (en) Data reading method and device, computer equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant