CN111858744A - Database data synchronization method, server and system - Google Patents

Database data synchronization method, server and system Download PDF

Info

Publication number
CN111858744A
CN111858744A CN201910357440.5A CN201910357440A CN111858744A CN 111858744 A CN111858744 A CN 111858744A CN 201910357440 A CN201910357440 A CN 201910357440A CN 111858744 A CN111858744 A CN 111858744A
Authority
CN
China
Prior art keywords
server
data
written data
slave
slave server
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.)
Pending
Application number
CN201910357440.5A
Other languages
Chinese (zh)
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.)
Beijing Didi Infinity Technology and Development Co Ltd
Original Assignee
Beijing Didi Infinity Technology and Development 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 Beijing Didi Infinity Technology and Development Co Ltd filed Critical Beijing Didi Infinity Technology and Development Co Ltd
Priority to CN201910357440.5A priority Critical patent/CN111858744A/en
Publication of CN111858744A publication Critical patent/CN111858744A/en
Pending legal-status Critical Current

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/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • 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/25Integrating or interfacing systems involving database management systems

Abstract

The application provides a database data synchronization method, a server and a system, which relate to the technical field of databases, and are characterized in that pre-written data are obtained through a master server, first request information corresponding to the pre-written data and an operation command of a thread are generated, and the operation command is sent to a slave server; the slave server receives the operation command and reconstructs second request information according to the operation command, wherein the second request information comprises the first request information of the master server and the information of the thread on the slave server for processing the first request information, and the master server and the slave server can synchronously process the same pre-written data on the same thread, so that the consistency of the pre-written data in the master server and the slave server is ensured.

Description

Database data synchronization method, server and system
Technical Field
The present application relates to the field of database technologies, and in particular, to a database data synchronization method, a server, and a system.
Background
The database is used for storing data, and a user can add, intercept, update, delete and the like to the data stored in the database through the database.
In the prior art, a data synchronization method between a master server and a slave server is generally that the master server receives a message, generates pre-write data according to the message, and the slave server periodically requests the master server to transmit the pre-write data and executes the acquired pre-write data in the slave server.
However, the above method cannot guarantee strong consistency of the pre-written data in the master server and the slave server.
Disclosure of Invention
In view of this, an object of the embodiments of the present application is to provide a database data synchronization method, a server, and a system, which can enable a master server and a slave server to synchronously process the same pre-written data on the same thread, so as to ensure consistency of the pre-written data in the master server and the slave server.
In a first aspect, an embodiment of the present application provides a database data synchronization method, where the method is applied to a master server, and the method includes: the main server acquires pre-written data; the master server generates first request information corresponding to the pre-written data and an operation command of the thread according to the pre-written data, and sends the operation command to the slave server; the operation command is used for indicating the slave server to reconstruct second request information according to the operation command, and processing the pre-written data on the thread synchronously with the master server according to the second request information; the master server processes the pre-write data on the thread synchronously with the slave server according to the first request.
Optionally, before the main server generates, according to the pre-write data, the first request information corresponding to the pre-write data and the operation command of the thread, the method further includes: the method comprises the steps that a main server obtains operation key values of pre-written data; the main server performs hash processing on the operation key value to obtain a corresponding thread number; and the master server confirms that the threads of the pre-written data are synchronously processed by the master server and the slave server according to the thread numbers.
Optionally, before sending the operation command to the slave server, the method further includes: the main server acquires the capacity of the processed pre-written data of the sliding window of the thread; the main server judges whether the capacity is not greater than a preset capacity threshold value or not; if the capacity is smaller than the preset capacity threshold, the master server continues to send the operation command to the slave server; and if the capacity is equal to the preset capacity threshold, the master server suspends sending the operation command to the slave server.
Optionally, the method further includes: the master server checks whether new pre-written data is generated or not at regular time, and if the new pre-written data is generated, the new pre-written data is sent to the slave server through the file transmission interface; the master server receives first feedback information of the slave server for synchronously processing the new pre-written data, wherein the first feedback information is used for indicating that the slave server completes synchronous processing of the new pre-written data.
Optionally, the method further includes: the method comprises the steps that a master server respectively obtains error rates synchronously generated within preset time of the master server and preset time of a slave server; the master server judges whether the error rate is greater than a first preset threshold value or not, and if so, the master server sends the pre-written data corresponding to the error rate to the slave server again through the file transmission interface; and the master server receives second feedback information of the prewritten data corresponding to the error rate of synchronous processing of the slave server, wherein the second feedback information is used for indicating that the prewritten data corresponding to the error rate of synchronous processing of the slave server is completed.
Optionally, the method further includes: the method comprises the steps that a master server respectively obtains data volumes of synchronous prewritten data of the master server and synchronous prewritten data of a slave server within preset time, and the difference value of the data volumes of the synchronous prewritten data of the master server and the synchronous prewritten data of the slave server is obtained through calculation; when the main server judges whether the difference value is not larger than a second preset threshold value, acquiring the label and the time point of the pre-written data corresponding to the difference value in the main server; and the master server synchronously processes the pre-written data with the slave server on the corresponding thread of the pre-written data according to the label and the time point of the pre-written data.
In a second aspect, an embodiment of the present application provides a database data synchronization method, where the method is applied to a slave server, and the method includes: receiving first request information and an operation command of a thread corresponding to processing pre-written data sent by a main server from a slave server; and the slave server reconstructs second request information according to the operation command, and synchronously processes the pre-written data on the thread with the master server according to the second request information.
Optionally, the method further includes: receiving new pre-written data sent by a master server through a file transmission interface from a slave server; the slave server constructs third request information according to the corresponding relation between the new prewritten data and the multiple threads, wherein the third request information comprises the corresponding relation between the new prewritten data and the multiple threads respectively; and the slave server synchronously processes the new pre-written data on the corresponding multiple threads according to the third request information and sends first feedback information to the master server, wherein the first feedback information is used for indicating that the slave server completes synchronous processing of the new pre-written data.
Optionally, the method further includes: receiving pre-written data corresponding to the error rate sent by the master server through the file transmission interface by the slave server; constructing fourth request information according to the prewritten data corresponding to the error rate from the server, wherein the fourth request information comprises corresponding relations between the prewritten data corresponding to the error rate and the multiple threads respectively; and the slave server synchronously processes the pre-written data corresponding to the error rate on the corresponding multiple threads according to the fourth request information and sends second feedback information to the master server, wherein the second feedback information is used for indicating that the slave server completes the pre-written data corresponding to the synchronous processing error rate.
In a third aspect, a server is applied to a main server, and the server includes: the device comprises an acquisition module, a generation module and a first synchronous processing module; the acquisition module is used for acquiring the prewritten data; the generating module is used for generating first request information corresponding to the pre-written data and an operation command of the thread according to the pre-written data and sending the operation command to the slave server; the operation command is used for indicating the slave server to reconstruct second request information according to the operation command, and processing the pre-written data on the thread synchronously with the master server according to the second request information; and the first synchronous processing module is used for processing the pre-written data on the thread synchronously with the slave server according to the first request.
Optionally, the server further includes a first processing module; the acquisition module is also used for acquiring an operation key value of the pre-written data; the first processing module is used for carrying out hash processing on the operation key value to obtain a corresponding thread number, and confirming the thread of the pre-written data synchronously processed by the main server and the slave server according to the thread number.
Optionally, the server further includes a second processing module, and the obtaining module is further configured to obtain a capacity of the sliding window of the thread for processing the pre-written data; the second processing module is used for judging whether the capacity of the processed pre-written data is not larger than a preset capacity threshold value or not, and if the capacity of the processed pre-written data is smaller than the preset capacity threshold value, the master server continues to send the operation command to the slave server; and if the capacity is equal to the preset capacity threshold, the master server suspends sending the operation command to the slave server.
Optionally, the server further includes a third processing module, configured to check whether new pre-write data is generated at regular time, and if so, send the new pre-write data to the slave server through the file transfer interface; the first synchronous processing module is further used for receiving first feedback information of synchronous processing of the new pre-written data from the server, and the first feedback information is used for indicating that the synchronous processing of the new pre-written data has been completed by the server.
Optionally, the server further includes a fourth processing module, configured to obtain error rates synchronously generated within preset time of the master server and the slave server, respectively, determine whether the error rates are greater than a first preset threshold, and if the error rates are greater than the first preset threshold, the master server sends the prewritten data corresponding to the error rates to the slave server through the file transmission interface again; the first synchronous processing module is further configured to receive second feedback information of the prewritten data corresponding to the error rate of the synchronous processing of the slave server, where the second feedback information is used to indicate that the synchronous processing of the prewritten data corresponding to the error rate of the slave server has been completed.
Optionally, the server further includes a fifth processing module, configured to obtain data amounts of synchronized pre-written data in preset time of the master server and the slave server, respectively, calculate a difference between the data amounts of the synchronized pre-written data of the master server and the synchronized pre-written data of the slave server, and obtain a label and a time point of the pre-written data corresponding to the difference in the master server when determining whether the difference is not greater than a second preset threshold; and the first synchronous processing module is also used for synchronously processing the pre-written data on the thread corresponding to the pre-written data and the slave server according to the label and the time point of the pre-written data.
In a fourth aspect, an embodiment of the present application provides a server, which is applied to a slave server, and the server includes: the receiving module and the second synchronous processing module; the receiving module is used for receiving first request information and an operation command of a thread, wherein the first request information corresponds to processing pre-written data and is sent by a main server; and the second synchronous processing module is used for reconstructing second request information according to the operation command and synchronously processing the pre-written data on the thread with the main server according to the second request information.
Optionally, the server further includes a first sending module; the receiving module is also used for receiving new pre-written data sent by the main server through the file transmission interface; the first sending module is used for constructing third request information according to the corresponding relation between the new prewrite data and the multiple threads, wherein the third request information comprises the corresponding relation between the new prewrite data and the multiple threads respectively; and the second synchronous processing module is further configured to synchronously process new pre-write data with the master server on the corresponding multiple threads according to the third request information, and send first feedback information to the master server, where the first feedback information is used to indicate that the slave server has completed synchronous processing of the new pre-write data.
Optionally, the server further includes a second sending module; the receiving module is also used for receiving the prewritten data corresponding to the error rate sent by the main server through the file transmission interface; the second sending module is used for constructing fourth request information according to the prewrite data corresponding to the error rate, wherein the fourth request information comprises corresponding relations between the prewrite data corresponding to the error rate and the multiple threads respectively; and the second synchronous processing module is further configured to synchronously process pre-written data corresponding to the error rate on the corresponding multiple threads according to the fourth request information, and send second feedback information to the master server, where the second feedback information is used to indicate that the slave server has completed the pre-written data corresponding to the synchronous processing error rate.
In a fifth aspect, an embodiment of the present application provides a database data synchronization system, where the system includes: the master server of any one of the above third aspects and the slave server of any one of the above fourth aspects; and the master server is in communication connection with the slave server.
In a sixth aspect, an embodiment of the present application provides an electronic device, including a computer-readable storage medium storing a computer program and a processor, where the computer program is read by the processor and executed to implement the method of any one of the first and second aspects.
In a seventh aspect, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is read and executed by a processor, the method of any one of the first and second aspects is implemented.
Based on the above aspect, the present application has the following beneficial effects:
the embodiment of the application provides a database data synchronization method, a server and a system, wherein pre-written data is acquired through a master server, first request information corresponding to the pre-written data and an operation command of a thread are generated, and the operation command is sent to a slave server; the slave server receives the operation command and reconstructs second request information according to the operation command, wherein the second request information comprises the first request information of the master server and the information of the thread on the slave server for processing the first request information, and the master server and the slave server can synchronously process the same pre-written data on the same thread, so that the consistency of the pre-written data in the master server and the slave server is ensured.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are required to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained from the drawings without inventive effort.
FIG. 1 is a schematic structural diagram of a database data synchronization system according to an embodiment of the present application;
fig. 2 is a schematic flowchart of a database data synchronization method according to an embodiment of the present application;
FIG. 3 is a schematic flow chart diagram illustrating another database data synchronization method according to an embodiment of the present application;
FIG. 4 is a schematic flow chart diagram illustrating another database data synchronization method according to an embodiment of the present application;
FIG. 5 is a schematic flow chart diagram illustrating another database data synchronization method according to an embodiment of the present application;
FIG. 6 is a schematic flow chart diagram illustrating another database data synchronization method according to an embodiment of the present application;
FIG. 7 is a schematic flow chart diagram illustrating another database data synchronization method according to an embodiment of the present application;
FIG. 8 is a schematic flow chart diagram illustrating another database data synchronization method according to an embodiment of the present application;
FIG. 9 is a schematic flow chart diagram illustrating another database data synchronization method according to an embodiment of the present application;
FIG. 10 is a schematic flow chart diagram illustrating another database data synchronization method according to an embodiment of the present application;
FIG. 11 is a schematic flow chart diagram illustrating another database data synchronization method according to an embodiment of the present application;
FIG. 12 is a schematic flow chart diagram illustrating another database data synchronization method according to an embodiment of the present application;
FIG. 13 is a schematic flow chart diagram illustrating another database data synchronization method according to an embodiment of the present application;
FIG. 14 is a block diagram of a server according to an embodiment of the present application;
FIG. 15 is a block diagram of another server provided by an embodiment of the present application;
FIG. 16 is a block diagram of another server provided by an embodiment of the present application;
fig. 17 is a block diagram of another server provided in an embodiment of the present application.
Detailed Description
In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it should be understood that the drawings in the present application are for illustrative and descriptive purposes only and are not used to limit the scope of protection of the present application. Additionally, it should be understood that the schematic drawings are not necessarily drawn to scale. The flowcharts used in this application illustrate operations implemented according to some embodiments of the present application. It should be understood that the operations of the flow diagrams may be performed out of order, and steps without logical context may be performed in reverse order or simultaneously. One skilled in the art, under the guidance of this application, may add one or more other operations to, or remove one or more operations from, the flowchart.
In addition, the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. The components of the embodiments of the present application, generally described and illustrated in the figures herein, can be arranged and designed in a wide variety of different configurations. Thus, the following description of the embodiments of the present application, provided in the accompanying drawings, is not intended to limit the scope of the claimed application, but is merely representative of selected embodiments of the application. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the present application without making any creative effort, shall fall within the protection scope of the present application.
It should also be noted that the term "comprising" will be used in the embodiments of the present application to indicate the presence of the features stated hereinafter, but does not exclude the addition of further features.
Fig. 1 is a schematic structural diagram of a database data synchronization system according to an embodiment of the present application. As shown in fig. 1, the system includes: a master server 110 and a slave server 111, the master server 110 and the slave server 111 being communicatively connected.
In some embodiments, master server 110 and slave server 111 may include processors. In some embodiments, a processor may include one or more processing cores (e.g., a single-core processor (S) or a multi-core processor (S)). Merely by way of example, a Processor may include a Central Processing Unit (CPU), an Application Specific Integrated Circuit (ASIC), an Application Specific Instruction Set Processor (ASIP), a Graphics Processing Unit (GPU), a Physical Processing Unit (PPU), a Digital Signal Processor (DSP), a Field Programmable Gate Array (FPGA), a Programmable Logic Device (PLD), a controller, a microcontroller Unit, a Reduced Instruction Set computer (Reduced Instruction Set Computing, RISC), a microprocessor, or the like, or any combination thereof.
As shown in fig. 1, the system further includes: the system comprises a network 120, a first database 112, a second database 113, a master server 110 and a slave server 111 which are in communication connection through the network 120, wherein the master server 110 is provided with the corresponding first database 112, and the slave server 111 is provided with the corresponding second database 113. Network 120 may be used for the exchange of information and/or data. In some embodiments, one or more components (e.g., server 110, first database 112, and second database 113) in the user behavior analysis system may obtain information and/or data from other components. In some embodiments, the network 120 may be any type of wired or wireless network, or combination thereof. Merely by way of example, Network 120 may include a wired Network, a Wireless Network, a fiber optic Network, a telecommunications Network, an intranet, the internet, a Local Area Network (LAN), a Wide Area Network (WAN), a Wireless Local Area Network (WLAN), a Metropolitan Area Network (MAN), a Wide Area Network (WAN), a Public Switched Telephone Network (PSTN), a bluetooth Network, a ZigBee Network, a Near Field Communication (NFC) Network, or the like, or any combination thereof. In some embodiments, network 120 may include one or more network access points. For example, network 120 may include wired or wireless network access points, such as base stations and/or network switching nodes, through which one or more components of the service data prediction system may connect to network 120 to exchange data and/or information.
The first database 112 and the second database 113 are used to store data and/or instructions of the master server and the slave server, respectively. In some embodiments, the first database 112 and the second database 113 may store the obtained information and/or data. In some embodiments, first database 112 and second database 113 may store data and/or instructions of the exemplary methods described herein. In some embodiments, the first database 112 and the second database 113 may include mass storage, removable storage, volatile Read-write Memory, Read-Only Memory (ROM), or the like, or any combination thereof. By way of example, mass storage may include magnetic disks, optical disks, solid state drives, and the like; removable memory may include flash drives, floppy disks, optical disks, memory cards, zip disks, tapes, and the like; volatile read-write Memory may include Random Access Memory (RAM); the RAM may include Dynamic RAM (DRAM), Double Data Rate Synchronous Dynamic RAM (DDRSDRAM); static RAM (SRAM), Thyristor-based Random Access Memory (T-RAM), Zero-capacitor RAM (Zero-RAM), and the like. By way of example, ROMs may include Mask Read-Only memories (MROMs), Programmable ROMs (PROMs), Erasable Programmable ROMs (PERROMs), Electrically Erasable Programmable ROMs (EEPROMs), compact disk ROMs (CD-ROMs), digital versatile disks (ROMs), and the like. In some embodiments, the first database 112 and the second database 113 may be implemented on a cloud platform. By way of example only, the cloud platform may include a private cloud, a public cloud, a hybrid cloud, a community cloud, a distributed cloud, across clouds, multiple clouds, or the like, or any combination thereof.
In some embodiments, the first database 112 and the second database 113 may be connected to the network 120 to communicate with one or more components in the user behavior analysis system. One or more components in the user behavior analysis system may access data or instructions stored in the first database 112 and the second database 113 via the network 120. In some embodiments, the first database 112 and the second database 113 may be directly connected to one or more components in the user behavior analysis system; alternatively, in some embodiments, the first database 112 and the second database 113 may also be part of the server 110.
Fig. 2 is a schematic flowchart of a database data synchronization method according to an embodiment of the present application. An embodiment of the present application provides a database data synchronization method, which is applied to a primary server, and as shown in fig. 2, the method includes:
s101, the main server acquires pre-written data.
When receiving an instruction of a client to process pre-written data, a main server acquires the pre-written data corresponding to the instruction, where the instruction is used to indicate the pre-written data to be processed and a storage location of the pre-written data to be processed in a first database, where the client may be a computer, a server, a handset, and the like, and is not limited thereto.
It should be noted that, since any database will obtain the corresponding pre-written data in the instruction of receiving data processing, no additional operation will be generated, and no additional resource of the host server will be used.
S102, the main server generates first request information corresponding to the pre-written data and an operation command of the thread according to the pre-written data, and sends the operation command to the slave server.
The operation command is used for indicating the slave server to reconstruct the second request information according to the operation command, and processing the pre-written data on the thread synchronously with the master server according to the second request information.
The master server generates first request information related to processing the prewritten data according to the prewritten data, determines a thread corresponding to the prewritten data, generates an operation command according to the first request information and the thread corresponding to the prewritten data, and sends the operation command to the slave server, where the first request information is used to instruct the master server to process the prewritten data.
S103, processing the pre-written data on the thread synchronously with the slave server according to the first request.
And the main server processes the pre-written data on the thread corresponding to the pre-written data according to the first request information.
The master server processes the pre-write data on the corresponding thread according to the first request information, and sends the operation command to the slave server, the slave server receives the operation command of the master server, reconstructs a second request information according to the first request information in the operation command, and processes the pre-write data on the thread corresponding to the pre-write data in the slave server according to the second request information, the slave server sends a feedback to the master server after the pre-write data processing is completed, if the master server receives the feedback from the slave server, it indicates that the pre-write data synchronization processing corresponding to the first request information is completed, and vice versa.
In the embodiment of the application, the pre-write data is acquired through the master server, the first request information corresponding to the pre-write data and the operation command of the thread are generated, and the operation command is sent to the slave server; the slave server receives the operation command and reconstructs second request information according to the operation command, wherein the second request information comprises the first request information of the master server and the information of the thread on the slave server for processing the first request information, and the master server and the slave server can synchronously process the same pre-written data on the same thread, so that the consistency of the pre-written data in the master server and the slave server is ensured.
Fig. 3 is a schematic flowchart of another database data synchronization method according to an embodiment of the present application. As shown in fig. 3, optionally, before the main server generates the first request information corresponding to the processed pre-write data and the operation command of the thread according to the pre-write data, the method further includes:
s201, the primary server obtains an operation key value of the pre-written data.
The operation key value is a storage position of the prewritten data in the first database, and when the primary server obtains the prewritten data, the primary server obtains position information of the prewritten data stored in the first database, and then obtains the operation key value corresponding to the prewritten data by searching a registry of the first database.
S202, the primary server carries out hash processing on the operation key value to obtain a corresponding thread number.
The main server is preset with a corresponding relation between the operation key value and the thread number, and after the main server obtains the operation key value, the result after hash processing can be used for obtaining the thread number corresponding to the operation key value.
It should be noted that the hash processing is generally also referred to as hashing and hashing, and is to convert an input (also called pre-map pre-image) of an arbitrary length into an output of a fixed length through a hash algorithm, where the output is a hash value, that is, the hash processing is to simplify a complicated operation key value, so as to obtain a thread number corresponding to the operation key value.
S203, the main server confirms that the main server and the slave server synchronously process the thread of the pre-written data according to the thread number.
The master server determines a thread number corresponding to the prewritten data in the master server according to the thread number corresponding to the operation key value of the prewritten data, and the master server and the slave server process the prewritten data on the thread corresponding to the thread number when processing the prewritten data, so that the prewritten data of the master server and the slave server are executed on the same thread, and consistency of the prewritten data of the master server and the slave server is further ensured.
It should be noted that the operation key indicates that the prewrite data is stored in the database storage location corresponding to the master server, that is, indicates that the storage locations in the database are in one-to-one correspondence with the threads in the server, and the data is stored in the fixed location of the database, and the data stored in the storage location is processed by the corresponding threads in the server.
Fig. 4 is a schematic flowchart of another database data synchronization method according to an embodiment of the present application. As shown in fig. 4, optionally, before sending the operation command to the slave server, the method further includes:
s301, the main server obtains the capacity of the preprocessed pre-written data of the sliding window of the thread.
After determining the thread for processing the pre-written data, the main server obtains the capacity of the sliding window processed pre-written data in the thread, and supposing that the capacity of the sliding window is M, the capacity of the sliding window for processing the pre-written data is M, wherein M is less than or equal to M, and M and M are positive integers.
S302, the main server judges whether the capacity of the processed pre-written data is not larger than a preset capacity threshold value.
The main server compares the capacity of the processed pre-written data of the active window with a preset capacity threshold, where the preset capacity threshold is used to indicate the maximum capacity of the sliding window, i.e., M, and if the capacity of the processed pre-written data of the sliding window is not greater than the preset capacity, i.e., M is not greater than M, then the determination of S303 or S304 is performed.
And S303, if the capacity is smaller than the preset capacity threshold, the master server continuously sends the operation command to the slave server.
If the capacity of the pre-written data processed by the sliding window is smaller than the preset capacity threshold, that is, M is smaller than M, the master server continues to send the operation command to the slave server, continues to receive the pre-written data to be processed by the thread of the master server, and executes the processing process of the pre-written data according to the operation command, which is not described herein again.
And S304, if the capacity is equal to the preset capacity threshold, the master server suspends sending the operation command to the slave server.
If the capacity of the pre-written data processed by the sliding window is equal to the preset capacity threshold, that is, M is equal to M, it indicates that the processing space of the sliding window is full, the thread reaches the maximum value capable of processing the pre-written data, the master server suspends sending the operation command to the slave server, the pre-written data on the thread continues to wait in queue until receiving the feedback information corresponding to the pre-written data in the sliding window, if the feedback information is the information that returns success, the operation command corresponding to the pre-written data in the sliding window is deleted, and if the feedback information is the information that returns failure, the operation command corresponding to the pre-written data that waits in queue and the operation commands after the operation command are sent to the slave server again.
It should be noted that, the capacity threshold represents a capacity at which the thread can process prewrite data at most, generally, a sliding window is used for sending prewrite data in a master server to a slave server, the slave server feeds back to the master server after processing the prewrite data on a corresponding thread, the capacity occupied by processing the prewrite data in the sliding window is cleared, if all the sliding windows are occupied by the prewrite data, it indicates that the sliding window cannot process new prewrite data, and the master server suspends sending an operation command to the slave server.
Generally, if the preset capacity threshold of the sliding window on the thread is 6 and the capacity of the sliding window for processing the pre-write data is 5, the sliding window may further continue to receive the pre-write data, and when the capacity of the sliding window for processing the pre-write data is 6 and the master server does not receive the feedback information sent by the slave server, the master server suspends sending the operation command to the slave server, which indicates that the sliding window in the thread reaches the maximum value capable of processing the pre-write data.
Fig. 5 is a schematic flowchart of another database data synchronization method according to an embodiment of the present application. As shown in fig. 5, optionally, the method further includes:
s401, the master server checks whether new pre-written data are generated at regular time, and if the new pre-written data are generated, the new pre-written data are sent to the slave server through the file transmission interface.
The master server checks whether new pre-written data are generated in the first database at regular time, if the new pre-written data are generated, the new pre-written data are sent to the slave server through the file transmission interface, and if a large amount of pre-written data are generated, the master server sends all the pre-written data to the slave server through the file transmission interface, wherein the file transmission interface is a sendfile interface.
S402, the master server receives first feedback information of the slave server for synchronously processing new pre-written data.
Wherein the first feedback information is used for indicating that the slave server has finished synchronously processing the new pre-written data.
Specifically, when the master server receives new pre-write data once, the amount of the new pre-write data is usually large, the thread information corresponding to the new pre-write data can be obtained through hash processing, the new pre-write data is processed in the corresponding threads, after the processing is completed, the new pre-write data is sent to the slave server, the slave server receives the new pre-write data, and a third request message of the corresponding relationship between the new pre-write data and the threads is constructed, according to the third request message, synchronization processing is respectively performed on the threads corresponding to the new pre-write data, after the synchronization processing is completed, first feedback information is sent to the master server, the first feedback information is used for indicating that the slave server has completed the synchronization processing of the new pre-write data, therefore, when the master server receives the first feedback information, it is determined that the slave server has completed the synchronization processing of the new pre-write data, it should be noted that, the process of the hash processing has been described in detail in the foregoing embodiments, and is not described herein again.
Optionally, if the master server does not receive the first feedback information of the slave server within a preset time or the first feedback information indicates that the synchronization processing of the slave server fails, the new pre-write data queued for waiting and the new pre-write data after the new pre-write data are retransmitted to the slave server, and the specific preset time is set according to actual needs and experience of a worker, which is not limited herein.
In this embodiment of the present application, the master server checks new pre-write data at regular time, the master server processes the new pre-write data first, and then sends the new pre-write data to the slave server, the slave server constructs third request information of correspondence between the new pre-write data and the multiple threads, and according to the third request information, the new pre-write data is synchronously processed on the multiple threads, and the completed first feedback information is fed back to the master server, so that the master server can confirm that the slave server synchronizes the new pre-write data, and thus consistency of the new pre-write data in the master server and the slave server can be ensured.
Fig. 6 is a schematic flowchart of another database data synchronization method according to an embodiment of the present application. As shown in fig. 6, optionally, the method further includes:
S501, the master server respectively obtains error rates synchronously generated within preset time of the master server and the slave server.
After the master server sends the prewritten data to the slave server, the number of the asynchronous prewritten data of the master server and the slave server in the preset time is counted according to the feedback information of the prewritten data, then the synchronous error rate of the master server and the slave server in the preset time is calculated, the specific preset time is set according to needs and the experience of workers, and the method is not limited herein.
In addition, the number of the pre-written data which are not received by the slave server in the master server is also counted in the number of the non-synchronous pre-written data when the number of the non-synchronous pre-written data is counted, wherein the feedback of the slave server is not received by the master server in the preset time, namely the pre-written data of the master server and the pre-written data of the slave server are not synchronous.
S502, the master server judges whether the error rate is larger than a first preset threshold value, and if the error rate is larger than the first preset threshold value, the master server sends the pre-written data corresponding to the error rate to the slave server again through the file transmission interface.
The master server compares the calculated error rate with a first preset threshold, if the error rate is greater than the first preset threshold, the master server obtains a time point when the prewritten data corresponding to the error rate are sent to the slave server last time, and the prewritten data after the time point are sent to the slave server again through the file transmission interface; the first preset threshold may be set according to actual needs and experience of workers, and is not limited herein.
S503, the master server receives second feedback information of the pre-written data corresponding to the error rate of the synchronous processing of the slave server, wherein the second feedback information is used for indicating that the pre-written data corresponding to the error rate of the synchronous processing of the slave server is completed.
Specifically, the master server obtains prewrite data corresponding to the error rate, obtains a plurality of thread information corresponding to the prewrite data corresponding to the error rate through hash processing calculation, and from a first prewrite data corresponding to the error rate, sends all the prewrite data corresponding to the error rate to the slave server again through the file transmission interface, receives the prewrite data corresponding to the error rate from the slave server, constructs a fourth request information of the corresponding relationship between the prewrite data corresponding to the error rate and the plurality of threads, performs synchronization processing on the plurality of threads corresponding to the prewrite data corresponding to the error rate according to the fourth request information, and sends second feedback information to the master server after the synchronization processing is finished, wherein the second feedback information is used for indicating that the slave server has completed the synchronization processing of the prewrite data corresponding to the error rate, so that the master server receives the second feedback information, it should be noted that, for the hash process, the foregoing embodiment has been described in detail, and details are not repeated herein.
Optionally, if the master server does not receive the second feedback information of the slave server within the preset time or the second feedback information indicates that the synchronization processing of the slave server fails, the prewrite data corresponding to the error rate of the queue waiting and the prewrite data corresponding to the error rate of the queue waiting are retransmitted to the slave server, and the specific preset time is set according to actual needs and experience of workers, which is not limited herein.
As described above, in the embodiment of the present application, the prewrite data corresponding to the error rate is obtained by the master server, the prewrite data corresponding to the error rate is processed by the master server, then the prewrite data corresponding to the error rate is sent to the slave server, the slave server constructs the fourth request information of the correspondence relationship between the prewrite data corresponding to the error rate and the multiple threads, the prewrite data corresponding to the error rate is synchronously processed on the multiple threads according to the fourth request information, and the completed second feedback information is fed back to the master server, so that the master server can confirm that the prewrite data corresponding to the error rate is synchronized by the slave server, thereby eliminating the error rate of the prewrite data in the master server and the slave server, and further ensuring the consistency of the prewrite data of the master server and the slave server.
Fig. 7 is a schematic flowchart of another database data synchronization method according to an embodiment of the present application. As shown in fig. 7, optionally, the method further includes:
s601, the master server respectively obtains the data quantity of the synchronous prewritten data of the master server and the slave server within the preset time, and the difference value of the data quantity of the synchronous prewritten data of the master server and the slave server is obtained through calculation.
The method comprises the steps that a master server obtains the data volume of synchronous prewrite data in the master server and a slave server within preset time, namely the master server receives a new prewrite data, the data volume of the synchronous prewrite data of the master server is increased by one, the master server receives feedback of the slave server to the prewrite data, the data volume of the synchronous prewrite data of the slave server is increased by one, and then when the preset time is up, the difference value between the data volume of the synchronous prewrite data of the master server and the data volume of the synchronous prewrite data of the slave server is calculated.
And S602, when the main server judges whether the difference is not larger than a second preset threshold, acquiring the label and the time point of the pre-written data corresponding to the difference in the main server.
And if the difference value between the data quantity of the synchronous prewrite data of the master server and the data quantity of the synchronous prewrite data of the slave server is not larger than a second preset threshold value, acquiring the label and the time point of the prewrite data corresponding to the difference value between the data quantity of the synchronous prewrite data of the master server and the data quantity of the synchronous prewrite data of the slave server in the master server.
And S603, the master server synchronously processes the pre-written data with the slave server on the corresponding thread of the pre-written data according to the label and the time point of the pre-written data.
And the master server processes the prewritten data corresponding to the mark and the time point on the corresponding thread according to the mark and the time point of the prewritten data, and retransmits the prewritten data corresponding to the mark and the time point to the slave server, and the slave server also processes the prewritten data on the corresponding thread.
It should be noted that, the specific number of the second preset threshold may be set according to actual needs and experience of a worker, and is not limited herein.
Fig. 8 is a schematic flowchart of another database data synchronization method according to an embodiment of the present application. As shown in fig. 8, an embodiment of the present application provides a database data synchronization method, which is applied to a slave server, and the method includes:
s701, receiving first request information and a thread operation command, corresponding to processing pre-written data, sent by a main server from a slave server.
S702, the slave server reconstructs second request information according to the operation command, and processes the pre-written data on the thread synchronously with the master server according to the second request information.
Receiving the operation command from the server, analyzing the operation command, reconstructing second request information related to processing the pre-write data and the thread corresponding to the pre-write data according to the first request information and the thread corresponding to the pre-write data, processing the pre-write data on the thread corresponding to the pre-write data on the server according to the second request information, and after the processing is completed, sending the processed pre-write data and the processed pre-write data from the server to the client at the corresponding storage location in the second database, where the client may be a computer, a server, a handset, and the like, and is not limited thereto.
The application provides a database data synchronization method, which is applied to a slave server, and comprises the steps of receiving first request information corresponding to pre-written data processing and an operation command of a thread sent by a master server through the slave server, reconstructing second request information according to the operation command by the slave server, and processing the pre-written data on the thread synchronously with the master server according to the second request information.
Fig. 9 is a schematic flowchart of another database data synchronization method according to an embodiment of the present application. As shown in fig. 9, optionally, the method further includes:
s801, receiving new pre-written data sent by the master server through the file transfer interface from the slave server.
S802, the slave server constructs third request information according to the corresponding relation between the new prewrite data and the multiple threads, wherein the third request information comprises the corresponding relation between the new prewrite data and the multiple threads respectively.
And S803, the slave server synchronously processes the new pre-written data on the corresponding multiple threads according to the third request information, and sends first feedback information to the master server, wherein the first feedback information is used for indicating that the slave server has completed the synchronous processing of the new pre-written data.
Specifically, the master server checks whether new pre-written data is generated in a first database corresponding to the master server at regular time, if so, the new pre-written data is sent to the slave server through the file transmission interface, the slave server receives the new pre-written data sent by the master server through the file transmission interface, third request information of corresponding relations between the new pre-written data and the multiple threads is established, according to the third request information, synchronization processing is respectively performed on the multiple threads corresponding to the new pre-written data, and after the synchronization processing is finished, first feedback information is sent to the master server and is used for indicating that the slave server has completed the synchronization processing of the new pre-written data.
The corresponding relationship between the new pre-written data and the multiple threads may be the same thread or different threads, so that a large amount of pre-written data is conveniently distributed to the multiple threads for processing.
Fig. 10 is a schematic flowchart of another database data synchronization method according to an embodiment of the present application. As shown in fig. 10, optionally, the method further includes:
s901, if the slave server receives the pre-written data corresponding to the error rate sent by the master server through the file transmission interface.
S902, the slave server constructs fourth request information according to the prewritten data corresponding to the error rate.
The fourth request information comprises corresponding relations between prewritten data corresponding to the error rate and the multiple threads respectively;
and S903, the slave server synchronously processes the pre-written data corresponding to the error rate on the corresponding multiple threads according to the fourth request information, and sends second feedback information to the master server, wherein the second feedback information is used for indicating that the slave server completes the pre-written data corresponding to the synchronous processing error rate.
Specifically, after the thread of the master server sends the prewrite data to the slave server, the number of the asynchronous prewrite data of the master server and the slave server in the preset time is counted according to the feedback information of the prewrite data, then the synchronous error rate of the master server and the slave server in the preset time is calculated, the slave server receives the prewrite data corresponding to the error rate sent by the master server through the file transmission interface, and constructs fourth request information of the corresponding relation between the prewrite data corresponding to the error rate and the multiple threads, the multiple threads corresponding to the prewrite data corresponding to the error rate are respectively subjected to synchronous processing according to the fourth request information, after the synchronous processing is finished, second feedback information is sent to the master server, and the second feedback information is used for indicating that the slave server has finished the synchronous processing of the prewrite data corresponding to the error rate, therefore, and the master server determines that the slave server completes the synchronous processing of the pre-written data corresponding to the error rate after receiving the second feedback information.
Fig. 11 is a schematic flowchart of another database data synchronization method according to an embodiment of the present application. As shown in fig. 11, the method includes:
s1001, the master server obtains pre-written data.
S1002, the main server generates an operation command.
Specifically, the main server generates first request information and an operation command of the thread corresponding to the pre-written data according to the pre-written data.
S1003, the master server sends the operation command to the slave server.
S1004, receiving an operation command from the server.
S1005, reconstructing the second request information from the server according to the operation command.
Specifically, the slave server constructs the second request information according to the first request information of the operation command and the thread corresponding to the operation command.
And S1006, the slave server synchronously processes the pre-written data with the master server on the corresponding thread according to the second request information.
S1007, the master server synchronously processes the pre-written data with the slave server on the corresponding thread;
s1008, the slave server transmits an instruction to end the processing of the pre-write data information to the master server.
The method comprises the steps that pre-written data are obtained through a master server, first request information corresponding to the pre-written data and an operation command of a thread are generated, and the operation command is sent to a slave server; the slave server receives the operation command and reconstructs second request information according to the operation command, wherein the second request information comprises the first request information of the master server and the information of the thread on the slave server for processing the first request information, and the master server and the slave server can synchronously process the same pre-written data on the same thread, so that the consistency of the pre-written data in the master server and the slave server is ensured.
Fig. 12 is a schematic flowchart of another database data synchronization method according to an embodiment of the present application. As shown in fig. 12, the method includes:
s1101, the main server checks whether new pre-write data is generated.
And S1102, if so, the master server sends the new pre-written data to the slave server.
S1103, the main server processes the new pre-written data on the corresponding thread.
And S1104, receiving new pre-written data of the master server from the slave server.
S1105, the slave server processes the new pre-write data.
Specifically, the slave server processes the new prewrite data on the corresponding thread according to the corresponding relationship between the new prewrite data and the multiple threads.
S1105, the slave server sends the first feedback information to the master server.
Specifically, after the slave server finishes processing the new pre-written data on the corresponding thread, the slave server sends the first feedback information to the master server, and the master server receives the first feedback information and indicates that the slave server has finished the synchronization processing of the new pre-written data.
In this embodiment of the present application, the master server checks new pre-write data at regular time, the master server processes the new pre-write data first, and then sends the new pre-write data to the slave server, the slave server constructs a correspondence between the new pre-write data and the multiple threads, the slave server synchronously processes the new pre-write data on the multiple threads, and feeds back the completed first feedback information to the master server, and the master server can confirm that the slave server synchronizes the new pre-write data, so that the consistency of the new pre-write data in the master server and the slave server can be ensured.
Fig. 13 is a schematic flowchart of another database data synchronization method according to an embodiment of the present application. As shown in fig. 13, the method includes:
s1201, the main server obtains pre-written data corresponding to the asynchronous error rate within the preset time.
Specifically, the master server respectively obtains the number of the pre-written data which are not synchronized within the preset time of the master server and the slave server, calculates the error rate of the non-synchronization within the preset time of the master server and the slave server, and obtains the pre-written data corresponding to the error rate.
And S1202, the main server processes the pre-written data corresponding to the error rate.
And S1203, the master service sends the prewritten data corresponding to the error rate to the slave server.
Specifically, the master server determines whether the error rate is greater than a first preset threshold, and if the error rate is greater than the first preset threshold, the master server sends the prewritten data corresponding to the error rate to the slave server through the file transmission interface again.
And S1204, receiving the prewritten data corresponding to the error rate from the server.
Specifically, the primary server sends the pre-written data corresponding to the error rate through the file transfer interface.
And S1205, the server processes the pre-written data corresponding to the error rate.
Specifically, the server processes the pre-written data corresponding to the error rate on the corresponding thread.
And S1206, the slave server sends the second feedback information to the master server.
Specifically, after the processing of the prewritten data corresponding to the error rate on the corresponding thread is finished, the slave server sends the second feedback information to the master server, and the master server receives the second feedback information and indicates that the slave server has finished the synchronous processing of the prewritten data corresponding to the error rate.
In this embodiment of the application, the prewrite data corresponding to the error rate is obtained by the master server, the prewrite data corresponding to the error rate is processed by the master server, then the prewrite data corresponding to the error rate is sent to the slave server, the slave server constructs a corresponding relationship between the prewrite data corresponding to the error rate and the multiple threads, the slave server synchronously processes the prewrite data corresponding to the error rate on the multiple threads, and feeds back the completed second feedback information to the master server, so that the master server can confirm that the prewrite data corresponding to the error rate is synchronized by the slave server, thereby eliminating the error rate of the prewrite data in the master server and the slave server, and further ensuring consistency of the prewrite data of the master server and the slave server.
Fig. 14 is a block diagram of a server according to an embodiment of the present application. As shown in fig. 14, an embodiment of the present application provides a server, applied to a main server, where the server includes: an obtaining module 1301, a generating module 1302 and a first synchronization processing module 1303;
An obtaining module 1301, configured to obtain pre-written data;
a generating module 1302, configured to generate, according to the prewrite data, a first request information corresponding to the prewrite data and an operation command of the thread, and send the operation command to the slave server; the operation command is used for indicating the slave server to reconstruct second request information according to the operation command, and processing the pre-written data on the thread synchronously with the master server according to the second request information;
and the first synchronous processing module 1303 is configured to process the pre-write data on the thread synchronously with the slave server according to the first request.
Fig. 15 is a block diagram of another server provided in an embodiment of the present application. As shown in fig. 15, optionally, the server further includes a first processing module 1304;
the obtaining module 1301 is further configured to obtain an operation key value of the pre-written data;
the first processing module 1304 is configured to perform hash processing on the operation key value to obtain a corresponding thread number, and determine, according to the thread number, that the primary server and the secondary server synchronously process the thread of the pre-written data.
Optionally, the server further includes a second processing module 1305;
the obtaining module 1301 is further configured to obtain the capacity of the pre-written data processed by the sliding window of the thread;
The second processing module 1305 is configured to determine whether the capacity is not greater than a preset capacity threshold, and if the capacity is smaller than the preset capacity threshold, the master server continues to send the operation command to the slave server; and if the capacity is equal to the preset capacity threshold, the master server suspends sending the operation command to the slave server.
Optionally, the server further includes a third processing module 1306, configured to check whether new pre-write data is generated at regular time, and if so, send the new pre-write data to the slave server through the file transfer interface;
the first synchronization processing module 1303 is further configured to receive first feedback information of the new pre-write data synchronously processed from the server, where the first feedback information is used to indicate that the slave server has completed synchronously processing the new pre-write data.
Optionally, the server further includes a fourth processing module 1307, configured to obtain error rates synchronously generated within preset time periods of the master server and the slave server, respectively, determine whether the error rates are greater than a first preset threshold, and if the error rates are greater than the first preset threshold, the master server sends the prewritten data corresponding to the error rates to the slave server through the file transmission interface again;
the first synchronization processing module 1303 is further configured to receive second feedback information of the pre-written data corresponding to the error rate of the synchronization processing of the slave server, where the second feedback information is used to indicate that the slave server has completed the pre-written data corresponding to the error rate of the synchronization processing.
Optionally, the server further includes a fifth processing module 1308, configured to obtain data amounts of synchronized pre-written data in preset time of the master server and the slave server, respectively, calculate a difference between the data amounts of the synchronized pre-written data of the master server and the synchronized pre-written data of the slave server, and obtain a label and a time point of the pre-written data corresponding to the difference in the master server when determining whether the difference is not greater than a second preset threshold;
the first synchronization processing module 1303 is further configured to synchronously process the pre-write data with the slave server on the thread corresponding to the pre-write data according to the label and the time point of the pre-write data.
Fig. 16 is a block diagram of another server provided in an embodiment of the present application. As shown in fig. 16, an embodiment of the present application provides a server, which is applied to a slave server, and includes: a receiving module 1401 and a second synchronization processing module 1402;
a receiving module 1401, configured to receive first request information and an operation command of a thread, where the first request information corresponds to pre-write data processing and is sent by a host server;
the second synchronous processing module 1402 is configured to reconstruct the second request information according to the operation command, and process the pre-write data on the thread synchronously with the main server according to the second request information.
Fig. 17 is a block diagram of another server provided in an embodiment of the present application. As shown in fig. 17, optionally, the server further includes a first sending module 1403;
a receiving module 1401, further configured to receive new pre-write data sent by the host server through the file transfer interface;
the first sending module 1403, which constructs third request information according to the corresponding relationship between the new prewrite data and the multiple threads, where the third request information includes the corresponding relationship between the new prewrite data and the multiple threads respectively;
the second synchronous processing module 1402 is further configured to process new pre-write data synchronously with the master server on the corresponding multiple threads according to the third request information, and send first feedback information to the master server, where the first feedback information is used to indicate that the slave server has completed synchronous processing of the new pre-write data.
Optionally, the server further includes a second sending module 1404;
the receiving module 1401 is further configured to receive pre-written data corresponding to the error rate sent by the host server through the file transmission interface;
a second sending module 1404, configured to construct fourth request information according to the prewrite data corresponding to the error rate, where the fourth request information includes correspondence between the prewrite data corresponding to the error rate and the multiple threads, respectively;
The second synchronous processing module 1402 is further configured to synchronously process pre-written data corresponding to the error rate on the corresponding multiple threads according to the fourth request information, and send second feedback information to the master server, where the second feedback information is used to indicate that the slave server has completed the pre-written data corresponding to the synchronous processing error rate.
Further, an embodiment of the present application provides a database data synchronization system, including: the main server and the slave server, and the main server and the slave server are connected in communication, and the specific technical effect of the system is similar to that of the server, and is not described herein again.
An embodiment of the present application further provides an electronic device, which includes a computer-readable storage medium storing a computer program and a processor, where the computer program is read by the processor and executed to implement the steps of the method in the foregoing method embodiment.
Embodiments of the present application further provide a storage medium, on which a computer program is stored, where the computer program is executed by a processor to perform the steps of the method in the foregoing method embodiments.
The above description is only for the specific embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present application, and shall be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (21)

1. A database data synchronization method applied to a main server is characterized by comprising the following steps:
the main server acquires pre-written data;
the master server generates first request information and an operation command of a thread corresponding to the pre-written data according to the pre-written data, and sends the operation command to a slave server; the operation command is used for instructing the slave server to reconstruct second request information according to the operation command, and the pre-written data is processed on the thread synchronously with the master server according to the second request information;
and the master server processes the pre-written data on the thread synchronously with the slave server according to the first request.
2. The database data synchronization method according to claim 1, wherein before the main server generates the first request information and the operation command of the thread corresponding to the pre-written data according to the pre-written data, the method further comprises:
the primary server acquires an operation key value of the pre-written data;
the primary server performs hash processing on the operation key value to obtain a corresponding thread number;
and the master server confirms that the master server and the slave server synchronously process the thread of the pre-written data according to the thread number.
3. The database data synchronization method of claim 1, wherein before sending the operation command to the slave server, the method further comprises:
the main server acquires the capacity of the preprocessed pre-written data of the sliding window of the thread;
the main server judges whether the capacity of the processed pre-written data is not greater than a preset capacity threshold value;
if the operation command is smaller than the preset capacity threshold value, the master server continues to send the operation command to the slave server;
and if the operation command is equal to the preset capacity threshold value, the master server suspends sending the operation command to the slave server.
4. The database data synchronization method of claim 1, further comprising:
the master server checks whether new pre-written data are generated at regular time, and if the new pre-written data are generated, the new pre-written data are sent to the slave server through a file transmission interface;
the master server receives first feedback information of the slave server for synchronously processing the new pre-written data, wherein the first feedback information is used for indicating that the slave server completes synchronous processing of the new pre-written data.
5. The database data synchronization method of claim 1, further comprising:
the master server respectively acquires error rates synchronously generated within preset time of the master server and the slave server;
the master server judges whether the error rate is greater than a first preset threshold value, and if the error rate is greater than the first preset threshold value, the master server sends the pre-written data corresponding to the error rate to the slave server again through a file transmission interface;
and the master server receives second feedback information of the prewritten data corresponding to the error rate synchronously processed by the slave server, wherein the second feedback information is used for indicating that the slave server finishes synchronously processing the prewritten data corresponding to the error rate.
6. The database data synchronization method according to any one of claims 1 to 5, wherein the method further comprises:
the master server respectively acquires the data quantity of the synchronized pre-written data within the preset time of the master server and the slave server, and calculates to obtain the difference value of the data quantity of the synchronized pre-written data of the master server and the slave server;
when the main server judges whether the difference value is not larger than a second preset threshold value, acquiring a label and a time point of the pre-written data corresponding to the difference value in the main server;
And the master server synchronously processes the pre-written data with the slave server on the thread corresponding to the pre-written data according to the label and the time point of the pre-written data.
7. A database data synchronization method applied to a slave server is characterized by comprising the following steps:
the method comprises the steps that the slave server receives first request information and an operation command of a thread, wherein the first request information corresponds to processing pre-written data and is sent by a main server;
and the slave server reconstructs second request information according to the operation command, and synchronously processes the pre-written data on the thread with the master server according to the second request information.
8. The database data synchronization method of claim 7, further comprising:
the slave server receives new pre-written data sent by the master server through a file transmission interface;
the slave server constructs third request information according to the corresponding relation between the new prewrite data and the multiple threads, wherein the third request information comprises the corresponding relation between the new prewrite data and the multiple threads respectively;
and the slave server synchronously processes the new pre-written data on a plurality of corresponding threads according to the third request information and sends first feedback information to the master server, wherein the first feedback information is used for indicating that the slave server completes the synchronous processing of the new pre-written data.
9. The database data synchronization method of claim 7, further comprising:
the slave server receives pre-written data corresponding to the error rate sent by the master server through a file transmission interface;
the slave server constructs fourth request information according to the prewritten data corresponding to the error rate, wherein the fourth request information comprises corresponding relations between the prewritten data corresponding to the error rate and the multiple threads respectively;
and the slave server synchronously processes the pre-written data corresponding to the error rate on a plurality of corresponding threads according to the fourth request information and the master server, and sends second feedback information to the master server, wherein the second feedback information is used for indicating that the slave server completes synchronous processing of the pre-written data corresponding to the error rate.
10. A server applied to a main server, the server comprising: the device comprises an acquisition module, a generation module and a first synchronous processing module;
the acquisition module is used for acquiring the pre-written data;
the generating module is used for generating a first request message and a thread operation command corresponding to the pre-written data according to the pre-written data and sending the operation command to a slave server; the operation command is used for instructing the slave server to reconstruct second request information according to the operation command, and the pre-written data is processed on the thread synchronously with the master server according to the second request information;
The first synchronous processing module is used for processing the pre-written data on the thread synchronously with the slave server according to the first request.
11. The server of claim 10, further comprising a first processing module;
the obtaining module is further configured to obtain an operation key value of the pre-write data;
the first processing module is used for performing hash processing on the operation key value to obtain a corresponding thread number, and confirming the thread of the pre-written data synchronously processed by the main server and the slave server according to the thread number.
12. The server of claim 10, further comprising a second processing module,
the obtaining module is further configured to obtain a capacity of the sliding window of the thread for processing the pre-write data;
the second processing module is configured to determine whether the capacity of the processed pre-write data is not greater than a preset capacity threshold, and if the capacity of the processed pre-write data is smaller than the preset capacity threshold, the master server continues to send the operation command to the slave server; and if the operation command is equal to the preset capacity threshold value, the master server suspends sending the operation command to the slave server.
13. The server according to claim 10, wherein the server further comprises a third processing module, configured to periodically check whether new pre-write data is generated, and if so, send the new pre-write data to the slave server through the file transfer interface;
the first synchronous processing module is further configured to receive first feedback information of the slave server synchronously processing the new pre-write data, where the first feedback information is used to indicate that the slave server has completed synchronously processing the new pre-write data.
14. The server according to claim 10, wherein the server further includes a fourth processing module, configured to obtain error rates synchronously generated within preset time of the master server and the slave server, respectively, determine whether the error rates are greater than a first preset threshold, and if the error rates are greater than the first preset threshold, the master server sends the prewritten data corresponding to the error rates to the slave server again through a file transmission interface;
the first synchronous processing module is further configured to receive second feedback information of the prewrite data corresponding to the error rate, where the second feedback information is used to indicate that the slave server has completed synchronous processing of the prewrite data corresponding to the error rate.
15. The server according to any one of claims 10 to 14, wherein the server further includes a fifth processing module, configured to obtain data amounts of the pre-write data synchronized within a preset time by the master server and the slave server, respectively, calculate a difference between the data amounts of the pre-write data synchronized by the master server and the slave server, and obtain a label and a time point of the pre-write data corresponding to the difference in the master server when determining whether the difference is not greater than a second preset threshold;
and the first synchronous processing module is also used for synchronously processing the pre-written data with the slave server on the thread corresponding to the pre-written data according to the label and the time point of the pre-written data.
16. A server for application to a slave server, the server comprising: the receiving module and the second synchronous processing module;
the receiving module is used for receiving first request information and an operation command of a thread, which correspond to the pre-written data processing and are sent by the main server;
and the second synchronous processing module is used for reconstructing second request information according to the operation command and processing the pre-written data on the thread synchronously with the main server according to the second request information.
17. The server of claim 16, further comprising a first sending module;
the receiving module is further configured to receive new pre-write data sent by the host server through a file transfer interface;
the first sending module is configured to construct third request information according to a corresponding relationship between the new prewrite data and the multiple threads, where the third request information includes a corresponding relationship between the new prewrite data and the multiple threads respectively;
the second synchronous processing module is further configured to synchronously process the new pre-write data with the master server on the corresponding multiple threads according to the third request information, and send first feedback information to the master server, where the first feedback information is used to indicate that the slave server has completed synchronous processing of the new pre-write data.
18. The server according to claim 16, wherein the server further comprises a second sending module;
the receiving module is further configured to receive prewritten data corresponding to the error rate sent by the host server through a file transmission interface;
the second sending module is configured to construct fourth request information according to prewritten data corresponding to an error rate, where the fourth request information includes correspondence between the prewritten data corresponding to the error rate and multiple threads, respectively;
The second synchronous processing module is further configured to synchronously process prewritten data corresponding to the error rate on the corresponding multiple threads according to the fourth request information and the master server, and send second feedback information to the master server, where the second feedback information is used to indicate that the slave server has completed synchronous processing of the prewritten data corresponding to the error rate.
19. A database data synchronization system, the system comprising: a master server according to any one of claims 10 to 15 and a slave server according to any one of claims 16 to 18, the master server being communicatively coupled to the slave server.
20. An electronic device, comprising a computer-readable storage medium storing a computer program and a processor, the computer program being read and executed by the processor to implement the method of any of claims 1-9.
21. A computer-readable storage medium, in which a computer program is stored which, when read and executed by a processor, implements the method of any one of claims 1 to 9.
CN201910357440.5A 2019-04-29 2019-04-29 Database data synchronization method, server and system Pending CN111858744A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910357440.5A CN111858744A (en) 2019-04-29 2019-04-29 Database data synchronization method, server and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910357440.5A CN111858744A (en) 2019-04-29 2019-04-29 Database data synchronization method, server and system

Publications (1)

Publication Number Publication Date
CN111858744A true CN111858744A (en) 2020-10-30

Family

ID=72966606

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910357440.5A Pending CN111858744A (en) 2019-04-29 2019-04-29 Database data synchronization method, server and system

Country Status (1)

Country Link
CN (1) CN111858744A (en)

Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101808127A (en) * 2010-03-15 2010-08-18 成都市华为赛门铁克科技有限公司 Data backup method, system and server
JP2013206072A (en) * 2012-03-28 2013-10-07 Nec Corp Data matching system, data matching method, and data matching program
CN103580891A (en) * 2012-07-27 2014-02-12 腾讯科技(深圳)有限公司 Data synchronization method and system and servers
KR20150034006A (en) * 2013-09-25 2015-04-02 삼성에스디에스 주식회사 How to avoid deadlock when use the redundancy of the DB server
CN104978313A (en) * 2014-04-01 2015-10-14 中兴通讯股份有限公司 Data synchronization method and apparatus for database system, and server
CN106874341A (en) * 2016-12-23 2017-06-20 航天星图科技(北京)有限公司 A kind of database synchronization method
CN106933534A (en) * 2015-12-31 2017-07-07 阿里巴巴集团控股有限公司 A kind of method of data synchronization and device
CN107153644A (en) * 2016-03-02 2017-09-12 阿里巴巴集团控股有限公司 A kind of method of data synchronization and device
CN108600008A (en) * 2018-04-24 2018-09-28 成都致云科技有限公司 Server management method, server managing device and distributed system
US20180329630A1 (en) * 2016-09-13 2018-11-15 Tencent Technology (Shenzhen) Company Limited Data synchronization method and system, and synchronization obtaining method and apparatus
CN109254994A (en) * 2018-07-23 2019-01-22 聚好看科技股份有限公司 A kind of method and apparatus that data are synchronous
CN109656934A (en) * 2018-11-19 2019-04-19 武汉达梦数据库有限公司 Source oracle database DDL synchronous method and equipment based on log parsing

Patent Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101808127A (en) * 2010-03-15 2010-08-18 成都市华为赛门铁克科技有限公司 Data backup method, system and server
JP2013206072A (en) * 2012-03-28 2013-10-07 Nec Corp Data matching system, data matching method, and data matching program
CN103580891A (en) * 2012-07-27 2014-02-12 腾讯科技(深圳)有限公司 Data synchronization method and system and servers
KR20150034006A (en) * 2013-09-25 2015-04-02 삼성에스디에스 주식회사 How to avoid deadlock when use the redundancy of the DB server
CN104978313A (en) * 2014-04-01 2015-10-14 中兴通讯股份有限公司 Data synchronization method and apparatus for database system, and server
CN106933534A (en) * 2015-12-31 2017-07-07 阿里巴巴集团控股有限公司 A kind of method of data synchronization and device
CN107153644A (en) * 2016-03-02 2017-09-12 阿里巴巴集团控股有限公司 A kind of method of data synchronization and device
US20180329630A1 (en) * 2016-09-13 2018-11-15 Tencent Technology (Shenzhen) Company Limited Data synchronization method and system, and synchronization obtaining method and apparatus
CN106874341A (en) * 2016-12-23 2017-06-20 航天星图科技(北京)有限公司 A kind of database synchronization method
CN108600008A (en) * 2018-04-24 2018-09-28 成都致云科技有限公司 Server management method, server managing device and distributed system
CN109254994A (en) * 2018-07-23 2019-01-22 聚好看科技股份有限公司 A kind of method and apparatus that data are synchronous
CN109656934A (en) * 2018-11-19 2019-04-19 武汉达梦数据库有限公司 Source oracle database DDL synchronous method and equipment based on log parsing

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
张伟东等: "基于MySQL 数据库复制技术的数据同步分析与实现", 信息与电脑, no. 14, 31 July 2018 (2018-07-31) *

Similar Documents

Publication Publication Date Title
KR102197247B1 (en) Parameter server and method for sharing distributed deep learning parameter using the same
CN109408590B (en) Method, device and equipment for expanding distributed database and storage medium
US11263539B2 (en) Distributed machine learning method and system
US20150160972A1 (en) Virtual machine migration management method, apparatus and system
CN108681900A (en) The method of light node verification transaction
US9749427B2 (en) Systems and methods for consensus protocol selection based on delay analysis
EP2894827A1 (en) Method, apparatus, and system for managing migration of virtual machine
US20220100609A1 (en) Data Replication Method, Apparatus, and System
KR20180125734A (en) Apparatus for sharing parameter and method for using the same
CN107704310B (en) Method, device and equipment for realizing container cluster management
JP2017138780A (en) Parallel calculation processing apparatus and parallel calculation processing method
CN106855834B (en) Data backup method, device and system
CN113094430B (en) Data processing method, device, equipment and storage medium
EP3923186A2 (en) Video recognition method and apparatus, electronic device and storage medium
CN112035266A (en) Resource allocation method, device, equipment and storage medium
CN112163675A (en) Joint training method and device for model and storage medium
CN111291062B (en) Data synchronous writing method and device, computer equipment and storage medium
CN113193947A (en) Method, apparatus, medium, and program product for implementing distributed global ordering
US11172018B2 (en) Method and apparatus for controlling traffic
CN102857333B (en) Device and method for synchronizing data packet from sensor network
JP2013206209A (en) Control program, control method, storage control device and information processing system
CN114489508A (en) Data management method, device, equipment and medium
CN111858744A (en) Database data synchronization method, server and system
JP6755680B2 (en) Data migration system and control method of data migration system
CN112422630A (en) Cloud storage system and object processing method in cloud storage system

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