CN113742376A - Data synchronization method, first server and data synchronization system - Google Patents

Data synchronization method, first server and data synchronization system Download PDF

Info

Publication number
CN113742376A
CN113742376A CN202011173528.0A CN202011173528A CN113742376A CN 113742376 A CN113742376 A CN 113742376A CN 202011173528 A CN202011173528 A CN 202011173528A CN 113742376 A CN113742376 A CN 113742376A
Authority
CN
China
Prior art keywords
data
pointer
server
synchronized
synchronizing
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
CN202011173528.0A
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 Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Century Trading Co Ltd, Beijing Wodong Tianjun Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN202011173528.0A priority Critical patent/CN113742376A/en
Publication of CN113742376A publication Critical patent/CN113742376A/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/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24552Database cache management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • 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/24Querying
    • G06F16/245Query processing
    • G06F16/2457Query processing with adaptation to user needs
    • G06F16/24578Query processing with adaptation to user needs using ranking
    • 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Computing Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a data synchronization method, a first server and a data synchronization system, and relates to the technical field of computers. One embodiment of the method is applied to a first server, wherein the first server comprises first data and a first pointer, and the first pointer is used for indicating the last updated data in the first data; the method comprises the following steps: monitoring a second pointer on the second server in real time, wherein the second pointer is used for indicating the last updated data in the second data on the second server; judging whether the first pointer and the second pointer are the same; if not, determining the data to be synchronized on the second server according to the second pointer; and synchronizing the first data and the second data according to the data to be synchronized. According to the embodiment, the first server can synchronize the first data in time and can synchronize only the determined data to be synchronized, so that the operation resource of the first server is saved, and the performance of the first server can be more effectively exerted.

Description

Data synchronization method, first server and data synchronization system
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method for synchronizing data, a first server, and a system for synchronizing data.
Background
With the advent of the big data era, the processing capacity of a single server cannot meet the increasing data processing requirement, so that the distributed system is generated, and the pressure of processing data by each server can be relieved by deploying the application system on a plurality of servers.
In the process of implementing the invention, the inventor finds that at least the following problems exist in the prior art:
the distributed system needs to ensure that the data stored on each server is consistent, and the current method for keeping the data consistent is to update the data regularly, that is, to read the data from the database again every certain time. However, this method may cause that data cannot be updated in time, and the database needs to be traversed each time data is re-read, and when there is more data, more resources of the server are occupied, and the performance of the server is affected.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method for synchronizing data, a first server, and a system for synchronizing data, where a first server monitors a second pointer on a second server in real time, and when it is determined that the second pointer is different from a first pointer of the first server, the first server can determine data to be synchronized on the second server according to the second pointer in time, so as to implement an effect of synchronizing first data of the first server in time. In addition, the first server can only synchronize the determined data to be synchronized on the second server without traversing all data of the second server, so that the operation resources of the first server are saved, and the performance of the first server is more effectively exerted.
To achieve the above object, according to an aspect of an embodiment of the present invention, there is provided a method of synchronizing data.
The method for synchronizing the data is applied to a first server, wherein the first server comprises first data and a first pointer, and the first pointer is used for indicating the last updated data in the first data; the method comprises the following steps:
monitoring a second pointer on the second server in real time, wherein the second pointer is used for indicating the last updated data in the second data on the second server;
judging whether the first pointer and the second pointer are the same; if not, determining the data to be synchronized on the second server according to the second pointer;
and synchronizing the first data and the second data according to the data to be synchronized.
Alternatively,
according to the data to be synchronized, synchronizing the first data and the second data comprises:
and updating the first data according to the data to be synchronized so as to realize the synchronization of the first data and the second data.
Alternatively,
updating the first data according to the data to be synchronized, comprising:
determining a buffer queue for storing data to be synchronized, wherein the buffer queue comprises: the data to be synchronized and a second pointer identification corresponding to the data to be synchronized;
and circularly executing the following steps until the first pointer and the second pointer are the same:
and incrementing the first pointer, determining a second pointer identifier which is the same as the incremented first pointer from the buffer queue, and updating the first data according to the data to be synchronized corresponding to the determined second pointer identifier.
Alternatively,
judging whether the first pointer and the second pointer are the same comprises the following steps:
and determining whether the first pointer and the second pointer are the same by receiving a data update broadcast sent by the central server or monitoring the second pointer in real time.
Alternatively,
the method further comprises the following steps:
and starting timing after the first data are synchronized, and when the recorded duration reaches a first preset duration threshold and the first data are not newly synchronized within the recorded duration, acquiring second data from the second server, and replacing the first data according to the acquired second data.
Alternatively,
the first data comprises any one or more of: an item identification, an inventory quantity of the item, and a storage location of the item.
To achieve the above object, according to still another aspect of an embodiment of the present invention, there is provided a first server.
The first server of the embodiment of the invention comprises a monitoring module, a judging module and a synchronizing module; wherein:
the monitoring module is used for monitoring a second pointer on the second server in real time, and the second pointer is used for indicating the last updated data in the second data on the second server;
the judging module is used for judging whether the first pointer is the same as the second pointer acquired by the monitoring module; if not, determining the data to be synchronized on the second server according to the second pointer;
and the synchronization module is used for synchronizing the first data and the second data according to the data to be synchronized determined by the judgment module.
To achieve the above object, according to still another aspect of an embodiment of the present invention, there is provided a system for synchronizing data.
The system for synchronizing data of the embodiment of the invention comprises: the first server and the second server provided in the above embodiment of the invention; wherein:
the second server includes second data and a second pointer, the second pointer is used for indicating the last updated data in the second data, and when the second data is updated, the second pointer is updated.
Alternatively,
the second server is further configured to: circularly executing the following steps until the updated data is completely stored in the second data:
the second pointer is incremented and the updated data is saved to the second data.
Alternatively,
the second server is further configured to: and storing the updated data and the corresponding second pointer identification into a buffer queue, and taking the updated data as the data to be synchronized, so that the first server updates the first data according to the data to be synchronized corresponding to the second pointer identification.
Alternatively,
the second server is further configured to: and when the data to be synchronized in the buffer queue is not read within a second preset time threshold, deleting the data to be synchronized and the second pointer identification in the buffer queue.
To achieve the above object, according to still another aspect of an embodiment of the present invention, there is provided a server for synchronizing data.
The server for synchronizing data of the embodiment of the invention comprises: one or more processors; the storage device is used for storing one or more programs which, when executed by one or more processors, cause the one or more processors to implement a method for synchronizing data according to an embodiment of the present invention.
To achieve the above object, according to still another aspect of embodiments of the present invention, there is provided a computer-readable storage medium.
A computer-readable storage medium of an embodiment of the present invention has a computer program stored thereon, and when the program is executed by a processor, the program implements a method of synchronizing data of an embodiment of the present invention.
One embodiment of the above invention has the following advantages or benefits: when the data on the second server is changed, the corresponding data on the first server can be updated synchronously in time, and the first server only updates the changed data on the second server synchronously without traversing all the data of the second server, so that the operation resource of the first server is saved, and the performance of the first server can be more effectively exerted.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a schematic diagram of the main steps of a method of synchronizing data according to an embodiment of the invention;
FIG. 2 is a schematic diagram of the main steps of a method for updating first data according to data to be synchronized according to an embodiment of the present invention;
FIG. 3 is a diagram illustrating major blocks of a first server according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of the major modules of a system for synchronizing data according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of the main steps of another method of synchronizing data according to an embodiment of the invention;
FIG. 6 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;
fig. 7 is a schematic block diagram of a computer system suitable for use in implementing a terminal device or server of an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
It should be noted that the embodiments of the present invention and the technical features of the embodiments may be combined with each other without conflict.
Fig. 1 is a schematic diagram of the main steps of a method of synchronizing data according to an embodiment of the present invention.
As shown in fig. 1, a method for synchronizing data according to an embodiment of the present invention mainly includes the following steps:
step S101: and monitoring a second pointer on the second server in real time, wherein the second pointer is used for indicating the last updated data in the second data on the second server.
The method for synchronizing data provided by the embodiment of the invention is applied to a first server, in the related technology of a distributed system, the first server is a server configured locally, and in the related technology of a virtual machine, the first server is a virtual machine configured locally. The first server stores first data and a first pointer, the first data refers to cache data on the first server, and the first pointer is used for indicating data which is updated last in the first data.
In an embodiment of the present invention, the first data may include any one or more of: an item identification, an inventory quantity of the item, and a storage location of the item.
In the embodiment of the invention, the first server monitors the second pointer on the second server in real time to ensure that whether the second data on the second server is updated or not is known in time. The second server is a central server in the distributed system related technology or the virtual machine related technology, and can be deployed on the line or in the cloud. The second server stores second data and a second pointer, and the second pointer is used for indicating the last updated data in the second data.
In the embodiment of the invention, when the second data on the second server is not updated or the second data is updated and the synchronization data of the first server is completed, the first data and the second data are the same; and when the second data on the second server changes and the first server is synchronizing the data, the first data is different from the second data. However, the first server monitors the second pointer on the second server in real time, when the second data on the second server is updated, the process of synchronizing the data by the first server can be started in time, and the time consumed by the synchronization process under the current network transmission technology is very short, so that the first data on the first server is kept consistent with the second data on the second server in most of the time, and the problem that the data cannot be synchronized in time among different servers at present, and further the data on different servers are inconsistent is solved to a great extent.
Step S102: judging whether the first pointer and the second pointer are the same; and if not, determining the data to be synchronized on the second server according to the second pointer.
In the embodiment of the present invention, the first pointer and the second pointer may respectively store the amount of the first data and the amount of the second data, where the first pointer and the second pointer correspond to a counter, the second pointer is circularly increased by 1 when there is an update of the data, and the first pointer is circularly increased by 1 when the data is synchronized, so that the first pointer and the second pointer respectively indicate the last updated data of the first data and the second data. For example, at a certain time, the first pointer is "182", which indicates that there are 182 data in the first data, and the 182 th data is the last updated data of the first server, and at this time, the first server knows that the second pointer is "184" by monitoring, which indicates that there are 184 data in the second data, and the 184 th data is the last updated data of the second server, so the first server can determine that: the first pointer and the second pointer are different, and the data to be synchronized on the second server is determined according to the second pointer.
In the embodiment of the present invention, when the physical start address of the first data on the first server is the same as the physical start address of the second data on the second server, the first pointer and the second pointer may further store the physical address of the last updated data in the first data and the second data, respectively, when there is an update of data, the second pointer cyclically adds a step size, and when the data is synchronized, the first pointer cyclically adds a step size. For example, at a certain time, the first pointer points to "11230H", which indicates that the last updated data in the first data is stored at "11230H", and at this time, the first server monitors that the second pointer points to "1123 AH", which indicates that the last updated data in the second data is stored at "1123 AH", so that the first server can determine that: the first pointer and the second pointer are different, and the data to be synchronized on the second server is determined according to the second pointer.
In the embodiment of the present invention, the first server may further monitor second data pointed by the second pointer in real time, and determine whether the second data is updated by determining whether the first data pointed by the first pointer is the same as the second data pointed by the second pointer. And when the first data pointed by the first pointer is different from the second data pointed by the second pointer, the second data is changed, and the first server determines the data to be synchronized on the second server according to the second pointer.
In the embodiment of the invention, the data to be synchronized is the data which is updated on the second server but not synchronized by the first server. And when the first pointer and the second pointer are judged to be different, the first server can determine the data to be synchronized on the second server according to the second pointer. Therefore, the first server can only execute the synchronization operation on the data to be synchronized, the second data on the second server does not need to be traversed to determine the data to be synchronized, and the function of synchronizing the data does not need to be realized by acquiring all the second data on the second server. As can be seen from the above description, the embodiment of the present invention can implement the function of synchronizing data under the condition of occupying few server resources, and does not affect the normal performance of the server.
In the embodiment of the present invention, the first server may determine whether the first pointer and the second pointer are the same by monitoring the second pointer in real time; it may also be determined whether the first pointer and the second pointer are the same by receiving a data update broadcast from a second server.
Step S103: and synchronizing the first data and the second data according to the data to be synchronized.
In the embodiment of the present invention, after the first server determines the data to be synchronized on the second server according to the second pointer, the first server updates the first data according to the data to be synchronized, so as to synchronize the first data with the second data. Fig. 2 is a schematic diagram illustrating main steps of a method for updating first data according to data to be synchronized according to an embodiment of the present invention.
As shown in fig. 2, a method for updating first data according to data to be synchronized according to an embodiment of the present invention mainly includes the following steps:
step S201: determining a buffer queue for storing data to be synchronized, wherein the buffer queue comprises: the data to be synchronized and a second pointer identification corresponding to the data to be synchronized;
step S202: the first pointer is increased in an increment mode, and a second pointer identification which is the same as the increased first pointer is determined from the cache queue;
step S203: updating the first data according to the data to be synchronized corresponding to the determined second pointer identification;
step S204: judging whether the first pointer and the second pointer are the same, if not, returning to the step S202, and if so, executing the step S205;
step S205: the current flow is ended.
In the embodiment of the present invention, the updating of the second data includes operations such as adding, deleting, and modifying, and the data amount in the second data is increased: when new data exist, the second server directly writes the new data into second data; when the original data is deleted or modified, the second server adds a deletion or modification identifier based on the original second data to generate new second data. And the second pointer records the position of the second data change in an incremental mode.
The synchronization of the first data by the first server is similar to the update of the second data by the second server, specifically: when the second data contains newly added data, the first server directly writes the newly added data into the first data; when the second data has deletion or modification operation, the first server adds a deletion or modification identifier based on the original first data to generate new first data. At this time, the data amount in the first data is increased, and the first pointer records the position of the first data changed in an incremental manner.
In the embodiment of the present invention, the cache queue is used for storing the change track of the second data. The buffer queue may include data to be synchronized and a second pointer identifier corresponding to the data to be synchronized, where the second pointer identifier is used to store a value of the second pointer when the corresponding data to be synchronized is indicated by the second pointer. And at the moment, the first server directly determines corresponding data to be synchronized according to the second pointer identification which is the same as the increased first pointer, and updates the first data according to the data to be synchronized.
In this embodiment of the present invention, the buffer queue may also include a data id to be synchronized and a second pointer identifier corresponding to the data id to be synchronized, where the second pointer identifier is used to store a value of the second pointer when the corresponding data id to be synchronized is indicated by the second pointer. At this time, the first server firstly determines a corresponding data id to be synchronized according to a second pointer identification which is the same as the increased first pointer, then determines corresponding data to be synchronized from the second data according to the data id to be synchronized, and updates the first data according to the data to be synchronized.
In the embodiment of the present invention, the increments of the first pointer and the second pointer may be from 1, and the first pointer and the second pointer increase by one step each time the first data and the second data change.
In the embodiment of the invention, when the first server is not synchronized with the second server for a long time, all the second data can be pulled from the second server once and the first data can be replaced, so that accidental errors existing in the data transmission process can be avoided. Specifically, the method comprises the following steps: the first server starts timing after updating the first data, and when the recorded duration reaches a first preset duration threshold and new data updating does not occur within the recorded duration, the first server acquires all second data from the second server and replaces the first data according to the acquired all second data. And if the first server carries out synchronous operation in the timing process, clearing the recorded duration and timing again. In a preferred embodiment of the present invention, the first preset time threshold may be 30 minutes.
According to the method for synchronizing data, provided by the embodiment of the invention, the first server monitors the second pointer on the second server in real time, and when the second pointer is judged to be different from the first pointer of the first server, the data to be synchronized on the second server can be determined in time according to the second pointer, so that the effect of synchronizing the first data of the first server in time is realized. In addition, the first server can only synchronize the determined data to be synchronized on the second server without traversing all data of the second server, so that the operation resources of the first server are saved, and the performance of the first server is more effectively exerted.
Fig. 3 is a schematic diagram of main modules of a first server according to an embodiment of the present invention.
As shown in fig. 3, a first server 300 according to an embodiment of the present invention includes: a monitoring module 301, a judging module 302 and a synchronizing module 303; wherein:
the monitoring module 301 is configured to monitor a second pointer on the second server in real time, where the second pointer is used to indicate a last updated data in second data on the second server;
a judging module 302, configured to judge whether the first pointer is the same as the second pointer obtained by the monitoring module 301; if not, determining the data to be synchronized on the second server according to the second pointer;
the synchronization module 303 is configured to synchronize the first data and the second data according to the data to be synchronized determined by the determination module 302.
In this embodiment of the present invention, the synchronization module 303 may further be configured to: and updating the first data according to the data to be synchronized so as to realize the synchronization of the first data and the second data.
In this embodiment of the present invention, the synchronization module 303 may further be configured to: determining a buffer queue for storing data to be synchronized, wherein the buffer queue comprises: the data to be synchronized and a second pointer identification corresponding to the data to be synchronized; and circularly executing the following steps until the first pointer and the second pointer are the same: and incrementing the first pointer, determining a second pointer identifier which is the same as the incremented first pointer from the buffer queue, and updating the first data according to the data to be synchronized corresponding to the determined second pointer identifier.
In this embodiment of the present invention, the determining module 302 may further be configured to: and determining whether the first pointer and the second pointer are the same by receiving a data update broadcast sent by the central server or monitoring the second pointer in real time.
In this embodiment of the present invention, the synchronization module 303 may further be configured to: and starting timing after the first data is updated, acquiring second data from the second server when the recorded duration reaches a preset duration threshold and no new data update occurs in the recorded duration, and replacing the first data according to the acquired second data.
In an embodiment of the invention, the first data comprises any one or more of: an item identification, an inventory quantity of the item, and a storage location of the item.
According to the first server provided by the embodiment of the invention, the first server monitors the second pointer on the second server in real time, and when the second pointer is judged to be different from the first pointer of the first server, the data to be synchronized on the second server can be determined in time according to the second pointer, so that the effect of synchronizing the first data of the first server in time is realized. In addition, the first server can only synchronize the determined data to be synchronized on the second server without traversing all data of the second server, so that the operation resources of the first server are saved, and the performance of the first server is more effectively exerted.
FIG. 4 is a schematic diagram of the main modules of a system for synchronizing data according to an embodiment of the present invention.
As shown in fig. 4, a system 400 for synchronizing data according to an embodiment of the present invention includes: the first server 300 and the second server 401 provided in the above embodiment of the present invention; wherein:
the second server 401 includes second data and a second pointer for indicating data that is last updated in the second data, and updates the second pointer when the second data is updated.
In this embodiment of the present invention, the second server 401 may further be configured to perform the following steps in a loop until all the updated data is stored in the second data: the second pointer is incremented and the updated data is saved to the second data.
In this embodiment of the present invention, the second server 401 may further be configured to: and storing the updated data and the corresponding second pointer identification into a buffer queue, and taking the updated data as the data to be synchronized, so that the first server updates the first data according to the data to be synchronized corresponding to the second pointer identification.
In this embodiment of the present invention, the second server 401 may further be configured to: setting an expiration policy, namely: and when the data to be synchronized in the buffer queue is not read within a second preset time threshold, deleting the data to be synchronized and the second pointer identification in the buffer queue to avoid error data.
In this embodiment of the present invention, the cache queue may also include a data id to be synchronized and a second pointer identifier corresponding to the data id to be synchronized, and at this time, the second server 401 may further be configured to: and when the data id to be synchronized in the buffer queue is not read within a second preset time threshold, deleting the data id to be synchronized and the second pointer identification in the buffer queue. In a preferred embodiment of the present invention, the second preset time threshold may be 30 minutes.
According to the system for synchronizing data, provided by the embodiment of the invention, the first server monitors the second pointer on the second server in real time, and when the second pointer is judged to be different from the first pointer of the first server, the data to be synchronized on the second server can be determined in time according to the second pointer, so that the effect of synchronizing the first data of the first server in time is realized. In addition, the first server can only synchronize the determined data to be synchronized on the second server without traversing all data of the second server, so that the operation resources of the first server are saved, and the performance of the first server is more effectively exerted.
The following describes a method for synchronizing data according to this embodiment.
Fig. 5 is a schematic diagram of the main steps of another method of synchronizing data according to an embodiment of the present invention.
As shown in fig. 5, another method for synchronizing data according to an embodiment of the present invention mainly includes the following steps:
step S501: the first server monitors a second pointer on the second server in real time, and the second pointer is used for indicating the last updated data in the second data on the second server.
Step S502: the second server receives the updated data, increments the second pointer by 1 cyclically, and saves the updated data in the second data.
Step S503: and the second server takes the updated data as the data to be synchronized, stores the id of the data to be synchronized and the corresponding second pointer identification in the cache queue, and sets an expiration policy.
In the embodiment of the invention, the purpose of setting the expiration policy is to save space of the buffer queue, because when the data in the buffer queue is read by all the first servers, the data is useless, and error data may also occur, and the data id to be synchronized and the second pointer in the buffer queue are deleted after the expiration.
Step S504: and the first server judges whether the first pointer and the second pointer are the same or not, and when the first pointer and the second pointer are different, the first server reads the data to be synchronized from the cache queue of the second server.
Step S505: and the first server adds 1 to the first pointer in a circulating manner, determines a corresponding data id to be synchronized according to a second pointer identification which is the same as the first pointer, and determines corresponding data to be synchronized from second data according to the data id to be synchronized.
Step S506: and the first server synchronizes the first data according to the data to be synchronized.
Fig. 6 illustrates an exemplary system architecture 600 of a first server or a method of synchronizing data to which embodiments of the present invention may be applied.
As shown in fig. 6, the system architecture 600 may include terminal devices 601, 602, 603, a network 604, and a server 605. The network 604 serves to provide a medium for communication links between the terminal devices 601, 602, 603 and the server 605. Network 604 may include various types of connections, such as wire, wireless communication links, or fiber optic cables, to name a few.
A user may use the terminal devices 601, 602, 603 to interact with the server 605 via the network 604 to receive or send messages or the like. Various communication client applications, such as shopping applications, web browser applications, search applications, instant messaging tools, mailbox clients, social platform software, and the like, may be installed on the terminal devices 601, 602, and 603.
The terminal devices 601, 602, 603 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 605 may be a server that provides various services, such as a background management server that supports shopping websites browsed by users using the terminal devices 601, 602, and 603. The background management server may analyze and perform other processing on the received data such as the product information query request, and feed back a processing result (e.g., target push information and product information) to the terminal device.
It should be understood that the number of terminal devices, networks, and servers in fig. 6 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 7, shown is a block diagram of a computer system 700 suitable for use with a terminal device implementing an embodiment of the present invention. The terminal device shown in fig. 7 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 7, the computer system 700 includes a Central Processing Unit (CPU)701, which can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)702 or a program loaded from a storage section 708 into a Random Access Memory (RAM) 703. In the RAM 703, various programs and data necessary for the operation of the system 700 are also stored. The CPU 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input/output (I/O) interface 705 is also connected to bus 704.
The following components are connected to the I/O interface 705: an input portion 706 including a keyboard, a mouse, and the like; an output section 707 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 708 including a hard disk and the like; and a communication section 709 including a network interface card such as a LAN card, a modem, or the like. The communication section 709 performs communication processing via a network such as the internet. A drive 710 is also connected to the I/O interface 705 as needed. A removable medium 711 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 710 as necessary, so that a computer program read out therefrom is mounted into the storage section 708 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program can be downloaded and installed from a network through the communication section 709, and/or installed from the removable medium 711. The computer program performs the above-described functions defined in the system of the present invention when executed by the Central Processing Unit (CPU) 701.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present invention may be implemented by software or hardware. The described modules may also be provided in a processor, which may be described as: a processor includes a monitoring module, a determination module, and a synchronization module. Where the names of these modules do not in some cases constitute a limitation of the module itself, for example, the monitoring module may also be described as a "module monitoring the second pointer on the second server in real time".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise: monitoring a second pointer on the second server in real time, wherein the second pointer is used for indicating the last updated data in the second data on the second server; judging whether the first pointer and the second pointer are the same; if not, determining the data to be synchronized on the second server according to the second pointer; and synchronizing the first data and the second data according to the data to be synchronized.
According to the technical scheme of the embodiment of the invention, the first server monitors the second pointer on the second server in real time, and when the second pointer is judged to be different from the first pointer of the first server, the data to be synchronized on the second server can be determined in time according to the second pointer, so that the effect of synchronizing the first data of the first server in time is realized. In addition, the first server can only synchronize the determined data to be synchronized on the second server without traversing all data of the second server, so that the operation resources of the first server are saved, and the performance of the first server is more effectively exerted.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (13)

1. A method for synchronizing data is applied to a first server, wherein the first server comprises first data and a first pointer, and the first pointer is used for indicating the last updated data in the first data; the method comprises the following steps:
monitoring a second pointer on a second server in real time, wherein the second pointer is used for indicating the last updated data in second data on the second server;
judging whether the first pointer and the second pointer are the same; if not, determining the data to be synchronized on the second server according to the second pointer;
and synchronizing the first data and the second data according to the data to be synchronized.
2. The method of claim 1, wherein the synchronizing the first data and the second data according to the data to be synchronized comprises:
and updating the first data according to the data to be synchronized so as to realize the synchronization of the first data and the second data.
3. The method of claim 2, wherein the updating the first data according to the data to be synchronized comprises:
determining a buffer queue for storing the data to be synchronized, wherein the buffer queue comprises: the data to be synchronized and a second pointer identification corresponding to the data to be synchronized;
circularly executing the following steps until the first pointer and the second pointer are the same:
and incrementing the first pointer, determining a second pointer identifier which is the same as the incremented first pointer from the cache queue, and updating the first data according to the data to be synchronized corresponding to the determined second pointer identifier.
4. The method of claim 1, wherein said determining whether the first pointer and the second pointer are the same comprises:
and determining whether the first pointer and the second pointer are the same by receiving a data updating broadcast sent by a central server or monitoring the second pointer in real time.
5. The method of claim 1, further comprising:
and starting timing after the first data are synchronized, acquiring second data from the second server when the recorded duration reaches a first preset duration threshold and the first data are not newly synchronized within the recorded duration, and replacing the first data according to the acquired second data.
6. The method of claim 1, wherein the first data comprises any one or more of: an item identification, an inventory quantity of the item, and a storage location of the item.
7. A first server is characterized by comprising a monitoring module, a judging module and a synchronizing module; wherein:
the monitoring module is used for monitoring a second pointer on a second server in real time, and the second pointer is used for indicating the last updated data in second data on the second server;
the judging module is used for judging whether the first pointer is the same as the second pointer acquired by the monitoring module; if not, determining the data to be synchronized on the second server according to the second pointer;
and the synchronization module is used for synchronizing the first data and the second data according to the data to be synchronized determined by the judgment module.
8. A system for synchronizing data, comprising: the first server and the second server of claim 7; wherein:
the second server comprises second data and a second pointer, wherein the second pointer is used for indicating the last updated data in the second data, and when the second data is updated, the second pointer is updated.
9. The system of claim 8,
the second server is further configured to: circularly executing the following steps until the updated data is completely stored in the second data:
and incrementing the second pointer and saving the updated data into the second data.
10. The system of claim 8,
the second server is further configured to: and storing the updated data and the corresponding second pointer identification into a buffer queue, and using the updated data as data to be synchronized, so that the first server updates the first data according to the data to be synchronized corresponding to the second pointer identification.
11. The system of claim 10,
the second server is further configured to: and when the data to be synchronized in the cache queue is not read within a second preset time threshold, deleting the data to be synchronized and the second pointer identification in the cache queue.
12. A server for synchronizing data, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-6.
13. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-6.
CN202011173528.0A 2020-10-28 2020-10-28 Data synchronization method, first server and data synchronization system Pending CN113742376A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011173528.0A CN113742376A (en) 2020-10-28 2020-10-28 Data synchronization method, first server and data synchronization system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011173528.0A CN113742376A (en) 2020-10-28 2020-10-28 Data synchronization method, first server and data synchronization system

Publications (1)

Publication Number Publication Date
CN113742376A true CN113742376A (en) 2021-12-03

Family

ID=78728131

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011173528.0A Pending CN113742376A (en) 2020-10-28 2020-10-28 Data synchronization method, first server and data synchronization system

Country Status (1)

Country Link
CN (1) CN113742376A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115037612A (en) * 2022-03-10 2022-09-09 广东统信软件有限公司 Server configuration method, computing device and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110198331A (en) * 2018-03-28 2019-09-03 腾讯科技(上海)有限公司 A kind of method and system of synchrodata
CN111241203A (en) * 2020-02-10 2020-06-05 江苏满运软件科技有限公司 Hive data warehouse synchronization method, system, equipment and storage medium
CN111552735A (en) * 2020-03-27 2020-08-18 深圳壹账通智能科技有限公司 Data link-based data synchronization method, apparatus, computer device and medium
CN111813707A (en) * 2020-07-17 2020-10-23 济南浪潮数据技术有限公司 Data synchronization method, device, equipment and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110198331A (en) * 2018-03-28 2019-09-03 腾讯科技(上海)有限公司 A kind of method and system of synchrodata
CN111241203A (en) * 2020-02-10 2020-06-05 江苏满运软件科技有限公司 Hive data warehouse synchronization method, system, equipment and storage medium
CN111552735A (en) * 2020-03-27 2020-08-18 深圳壹账通智能科技有限公司 Data link-based data synchronization method, apparatus, computer device and medium
CN111813707A (en) * 2020-07-17 2020-10-23 济南浪潮数据技术有限公司 Data synchronization method, device, equipment and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115037612A (en) * 2022-03-10 2022-09-09 广东统信软件有限公司 Server configuration method, computing device and storage medium
CN115037612B (en) * 2022-03-10 2024-03-26 广东统信软件有限公司 Server configuration method, computing device and storage medium

Similar Documents

Publication Publication Date Title
CN111309747A (en) Data synchronization method, system and device
US20230153211A1 (en) Method, electronic device and computer program product for storage management
CN111338834A (en) Data storage method and device
CN107818027B (en) Method and device for switching main name node and standby name node and distributed system
CN113783916B (en) Information synchronization method and device
CN113050890A (en) Data migration method and device
CN113742376A (en) Data synchronization method, first server and data synchronization system
CN112084254A (en) Data synchronization method and system
CN112395337A (en) Data export method and device
CN115454666A (en) Data synchronization method and device among message queue clusters
CN112711572B (en) Online capacity expansion method and device suitable for database and table division
CN112181470B (en) Patch deployment method and device
CN112732728A (en) Data synchronization method and system
CN110851192A (en) Method and device for responding to configuration of degraded switch
CN112688982A (en) User request processing method and device
CN117478535B (en) Log storage method and device
CN117632885B (en) Resource synchronization method, device, equipment and medium in backtracking system
CN113760965B (en) Data query method and device
CN110019671B (en) Method and system for processing real-time message
CN113138975A (en) Data migration method and device
CN115167769A (en) Method, device and system for writing data
CN113064669A (en) Loading control method and device
CN117389475A (en) Data processing method and device
CN117667307A (en) Virtual machine starting method, device, equipment and storage medium
CN112068848A (en) Method and device for managing software version

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