Movatterモバイル変換


[0]ホーム

URL:


CN113742376B - A method for synchronizing data, a first server, and a system for synchronizing data - Google Patents

A method for synchronizing data, a first server, and a system for synchronizing data
Download PDF

Info

Publication number
CN113742376B
CN113742376BCN202011173528.0ACN202011173528ACN113742376BCN 113742376 BCN113742376 BCN 113742376BCN 202011173528 ACN202011173528 ACN 202011173528ACN 113742376 BCN113742376 BCN 113742376B
Authority
CN
China
Prior art keywords
data
pointer
server
synchronized
updated
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202011173528.0A
Other languages
Chinese (zh)
Other versions
CN113742376A (en
Inventor
晁延杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
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 LtdfiledCriticalBeijing Jingdong Century Trading Co Ltd
Priority to CN202011173528.0ApriorityCriticalpatent/CN113742376B/en
Publication of CN113742376ApublicationCriticalpatent/CN113742376A/en
Application grantedgrantedCritical
Publication of CN113742376BpublicationCriticalpatent/CN113742376B/en
Activelegal-statusCriticalCurrent
Anticipated expirationlegal-statusCritical

Links

Classifications

Landscapes

Abstract

Translated fromChinese

本发明公开了一种同步数据的方法、第一服务器以及同步数据的系统,涉及计算机技术领域。该方法的一具体实施方式应用于第一服务器,第一服务器包括第一数据和第一指针,第一指针用于指示第一数据中最后被更新的数据;包括:实时监控第二服务器上的第二指针,第二指针用于指示第二服务器上的第二数据中最后被更新的数据;判断第一指针和第二指针是否相同;如果否,根据第二指针,确定第二服务器上的待同步数据;根据待同步数据,对第一数据与第二数据进行同步。该实施方式使得第一服务器能够及时对第一数据进行同步,并且能够仅针对确定出的待同步数据进行同步,从而节省了第一服务器的运算资源,使第一服务器的性能得以更有效地发挥。

The present invention discloses a method for synchronizing data, a first server, and a system for synchronizing data, and relates to the field of computer technology. A specific implementation of the method is applied to a first server, the first server includes first data and a first pointer, the first pointer is used to indicate the last updated data in the first data; including: real-time monitoring of a second pointer on a second server, the second pointer is used to indicate 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; synchronizing the first data with the second data according to the data to be synchronized. This implementation enables the first server to synchronize the first data in a timely manner, and can synchronize only the determined data to be synchronized, thereby saving the computing resources of the first server and enabling the performance of the first server to be more effectively utilized.

Description

Method for synchronizing data, first server and system for synchronizing data
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 age, the processing power of a single server has failed to meet the increasing data processing demands, and thus, distributed systems have become available, and deployment of application systems on multiple servers can alleviate the pressure of each server processing data.
In the process of implementing the present invention, the inventor finds that at least the following problems exist in the prior art:
Distributed systems need to ensure that the data stored on the various servers remains consistent, with current practice being to update the data periodically, i.e., re-read the data from the database once per period of time. However, this approach can result in data not being updated in time, and the database is traversed once each time the data is re-read, and when there is more data, more resources of the server are occupied, which affects the performance of the server.
Disclosure of Invention
In view of this, the embodiment of the invention provides a method for synchronizing data, a first server and a system for synchronizing data, wherein the first server monitors a second pointer on a second server in real time, and when judging 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 that the effect of synchronizing the first data of the first server in time is achieved. In addition, the first server can only synchronize the data to be synchronized on the determined second server, and the whole data of the second server does not need to be traversed, so that the operation resources of the first server are saved, and the performance of the first server can be effectively exerted.
To achieve the above object, according to one aspect of an embodiment of the present invention, there is provided a method of synchronizing data.
The method for synchronizing data is applied to a first server, wherein the first server comprises first data and a first pointer, the first pointer is used for indicating the last updated data in the first data, and 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 is the same as the second pointer, if not, determining data to be synchronized on the second server according to the second pointer;
and synchronizing the first data with the second data according to the data to be synchronized.
Alternatively, the process may be carried out in a single-stage,
According to the data to be synchronized, synchronizing the first data with the second data, including:
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, the process may be carried out in a single-stage,
Updating the first data according to the data to be synchronized, including:
determining a cache queue for storing data to be synchronized, wherein the cache queue comprises the data to be synchronized and a second pointer identifier corresponding to the data to be synchronized;
The following steps are circularly executed until the first pointer and the second pointer are the same:
And the first pointer is increased, a second pointer identification which is the same as the increased first pointer is determined from the cache queue, and the first data is updated according to the data to be synchronized corresponding to the determined second pointer identification.
Alternatively, the process may be carried out in a single-stage,
Judging whether the first pointer and the second pointer are the same, comprising:
and determining whether the first pointer and the second pointer are identical by receiving data updating broadcast sent by the central server or monitoring the second pointer in real time.
Alternatively, the process may be carried out in a single-stage,
The method further comprises the steps of:
And starting timing after the first data are synchronized, and acquiring second data from a second server and replacing the first data according to the acquired second data when the recorded duration reaches a first preset duration threshold and new synchronization is not performed on the first data in the recorded duration.
Alternatively, the process may be carried out in a single-stage,
The first data includes any one or more of an item identification, an inventory count of items, and a storage location of the items.
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, a system for synchronizing data is provided.
The system for synchronizing data in the embodiment of the invention comprises a first server and a second server, wherein the first server and the second server are provided in the embodiment of the invention, and the first server comprises:
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.
Alternatively, the process may be carried out in a single-stage,
The second server is further configured to cyclically execute the following steps until the updated data is all saved to the second data:
Increment the second pointer and save the updated data to the second data.
Alternatively, the process may be carried out in a single-stage,
The second server is further used for storing the updated data and the corresponding second pointer identification into a cache queue, and taking 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.
Alternatively, the process may be carried out in a single-stage,
And the second server is further used for deleting the data to be synchronized and the second pointer identification in the cache queue when the data to be synchronized in the cache queue is not read within a second preset duration threshold.
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 according to the embodiment of the invention comprises one or more processors and a storage device, wherein the storage device is used for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors are enabled to realize the method for synchronizing data according to the embodiment of the invention.
To achieve the above object, according to still another aspect of the 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 stored thereon a computer program which, when executed by a processor, implements a method of synchronizing data of an embodiment of the present invention.
The embodiment of the invention has the advantages that when the data on the second server is changed, the corresponding data on the first server can be synchronously updated in time, and the first server only synchronously updates the changed data on the second server without traversing all the 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.
Further effects of the above-described non-conventional alternatives are 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 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 schematic diagram of the primary modules of a first server according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of the main modules of a system for synchronizing data according to an embodiment of the 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 applied;
fig. 7 is a schematic diagram of a computer system suitable for use in implementing an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention will now be described with reference to the accompanying drawings, in which various details of the embodiments of the present invention are included to facilitate understanding, and are to be considered 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 in the embodiments may be combined with each other without collision.
Fig. 1 is a schematic diagram of 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:
and step S101, 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 is applied to a first server, wherein the first server is a server configured locally in a related technology of a distributed system, and the first server is a virtual machine configured locally in a related technology of a virtual machine. The first server stores first data and a first pointer, wherein 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 count of items, and a storage location of the items.
In the embodiment of the invention, the first server monitors the second pointer on the second server in real time so as to ensure that whether the second data on the second server is updated or not is timely known. The second server is a central server in the related technology of the distributed system or the related technology of the virtual machine, and can be deployed on the line or 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 first server is synchronous, the first data and the second data are the same, and when the second data on the second server is changed and the first server is synchronous, the first data and the second data are different. However, the second pointer on the second server is monitored in real time by the first server, 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 consumption of the synchronization process is very short under the current network transmission technology, so that the first data on the first server is consistent with the second data on the second server in most of time, and the problem that the data on different servers cannot be synchronized in time currently is solved to a great extent.
Step S102, 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.
In the embodiment of the invention, the first pointer and the second pointer can respectively store the quantity of the first data and the second data, at this time, the first pointer and the second pointer are equivalent to a counter, when the data is updated, the second pointer is circularly added with 1, and when the data is synchronized, the first pointer is circularly added with 1, so that the first pointer and the second pointer respectively indicate the last updated data in the first data and the second data. For example, the first pointer is 182 at a certain moment, which means that 182 data exists in the first data, the 182 th data is the last updated data of the first server, and the first server monitors 184 second pointers, which means 184 data exists in the second data, and 184 th data is the last updated data of the second server, so that the first server can determine that the first pointer and the second pointer are different, and further determine the data to be synchronized on the second server according to the second pointer.
In the embodiment of the invention, when the physical starting address of the first data on the first server is the same as the physical starting address of the second data on the second server, the first pointer and the second pointer can also respectively store the physical address of the last updated data in the first data and the second data, when the data is updated, the second pointer circularly adds a step length, and when the data is synchronized, the first pointer circularly adds a step length. For example, at a certain moment, the first pointer points to "11230H", which means that the last updated data in the first data is stored in "11230H", and at this moment, the first server monitors to know that the second pointer points to "1123AH", which means that the last updated data in the second data is stored in "1123AH", so that the first server can determine that the first pointer and the second pointer are different, and further determine the data to be synchronized on the second server according to the second pointer.
In the embodiment of the invention, the first server can also monitor the second data pointed by the second pointer in real time, and determine whether the second data is updated by judging whether the first data pointed by the first pointer is the same as the second data pointed by the second pointer. 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. 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. Thus, the first server can only execute the synchronous operation on the data to be synchronized, without traversing the second data on the second server to determine the data to be synchronized, and without realizing the function of synchronizing the data 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 realize the function of synchronizing data under the condition of occupying very few server resources, and does not affect the normal performance of the server.
In the embodiment of the invention, the first server can determine whether the first pointer is identical to the second pointer by monitoring the second pointer in real time, or can determine whether the first pointer is identical to the second pointer by receiving data update broadcast sent by the second server.
Step S103, according to the data to be synchronized, the first data and the second data are synchronized.
In the embodiment of the invention, after the first server determines the data to be synchronized on the second server according to the second pointer, the first data is updated according to the data to be synchronized so as to realize synchronization of the first data and 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 cache queue for storing data to be synchronized, wherein the cache queue comprises the data to be synchronized and a second pointer identifier corresponding to the data to be synchronized;
Step S202, a first pointer is increased, and a second pointer identification which is the same as the increased first pointer is determined from a cache queue;
Step 203, updating the first data according to the determined data to be synchronized corresponding to the 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 205, the current flow is ended.
In the embodiment of the invention, the updating of the second data comprises operations such as adding, deleting and modifying, and the data amount in the second data is increased at the moment, namely, when new data exists, the second server directly writes the new data into the second data, and when the original data is deleted or modified, the second server adds a deleting or modifying identifier based on the original second data so as to generate new second data. The second pointer records the changed position of the second data in an incremental mode.
The first server synchronizes the first data and the second server updates the second data similarly, specifically, when the second data has new data, the first server directly writes the new data into the first data, and when the second data has deleting or modifying operation, the first server adds deleting or modifying identification based on the original first data so as to generate new first data. At this time, the data amount in the first data is increased, and the first pointer records the position where the first data is changed in an incremental manner.
In the embodiment of the invention, the change track of the second data is stored in the cache queue. The cache 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. At this time, the first server directly determines corresponding data to be synchronized according to the second pointer identification which is the same as the first pointer after the increment, and updates the first data according to the data to be synchronized.
In the embodiment of the 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, 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 determines the corresponding data id to be synchronized according to the second pointer identification which is the same as the first pointer after the increment, then determines the corresponding data to be synchronized from the second data according to the data id to be synchronized, and then updates the first data according to the data to be synchronized.
In the embodiment of the present invention, the first pointer and the second pointer may be incremented from 1, and each time the first data and the second data change, the first pointer and the second pointer are respectively incremented by one step.
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 and the first data can be replaced, so that accidental errors in the data transmission process can be avoided. The first server starts timing after updating the first data, and when the recorded duration reaches a first preset duration threshold and no new data update occurs in the recorded duration, the first server acquires all second data from the second server and replaces the first data according to all acquired second data. And if the first server performs synchronous operation in the timing process, resetting the recorded duration and re-timing. In a preferred embodiment of the present invention, the first preset time period threshold may be 30 minutes.
According to the method for synchronizing data, disclosed by the embodiment of the invention, the first server can determine the data to be synchronized on the second server according to the second pointer in time when judging that the second pointer is different from the first pointer of the first server by monitoring the second pointer on the second server in real time, 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 data to be synchronized on the determined second server, and the whole data of the second server does not need to be traversed, so that the operation resources of the first server are saved, and the performance of the first server can be 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, where:
The monitoring module 301 is configured to monitor, in real time, a second pointer on the second server, where the second pointer is used to indicate data that is updated last 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 acquired by the monitoring module 301, if not, determine data to be synchronized on the second server according to the second pointer;
And the synchronizing module 303 is configured to synchronize the first data with the second data according to the data to be synchronized determined by the determining module 302.
In the embodiment of the present invention, the synchronization module 303 may be further configured to update the first data according to the data to be synchronized, so as to achieve synchronization between the first data and the second data.
In the embodiment of the invention, the synchronization module 303 may be further configured to determine a cache queue for storing the data to be synchronized, where the cache queue includes the data to be synchronized and a second pointer identifier corresponding to the data to be synchronized, and circularly execute the following steps until the first pointer is the same as the second pointer, increment the first pointer, determine the second pointer identifier same as the incremented first pointer from the cache queue, and update the first data according to the data to be synchronized corresponding to the determined second pointer identifier.
In an embodiment of the present invention, the determining module 302 may also be configured to determine 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 be further configured to start timing after updating the first data, obtain the second data from the second server when the recorded duration reaches the preset duration threshold and no new data update occurs within the recorded duration, and replace the first data according to the obtained second data.
In an embodiment of the invention, the first data includes any one or more of an item identification, an inventory count of items, and a storage location of the items.
According to the first server, the first server monitors the second pointer on the second server in real time, and when judging that the second pointer is different from the first pointer of the first server, the first server can determine the data to be synchronized on the second server according to the second pointer in time, so that the effect of synchronizing the first data of the first server in time is achieved. In addition, the first server can only synchronize the data to be synchronized on the determined second server, and the whole data of the second server does not need to be traversed, so that the operation resources of the first server are saved, and the performance of the first server can be effectively exerted.
Fig. 4 is a schematic diagram of 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 a first server 300 and a second server 401 provided in the above embodiment of the present invention, where:
the second server 401 includes second data and a second pointer for indicating data that is updated last in the second data, and updates the second pointer when the second data is updated.
In an embodiment of the present invention, the second server 401 may be further configured to perform the steps of cyclically executing the steps of incrementing the second pointer until the updated data is all saved in the second data, and saving the updated data in the second data.
In the embodiment of the present invention, the second server 401 may be further configured to store the updated data and the corresponding second pointer identifier into a cache queue, and use 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 identifier.
In the embodiment of the present invention, the second server 401 may be further configured to set an expiration policy, that is, delete the data to be synchronized and the second pointer identifier in the cache queue when the data to be synchronized in the cache queue is not read within the second preset duration threshold, so as to avoid occurrence of erroneous data.
In the 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, where the second server 401 may be further configured to delete the data id to be synchronized and the second pointer identifier in the cache queue when the data id to be synchronized in the cache queue is not read within a second preset duration threshold. In a preferred embodiment of the present invention, the second preset time period threshold may be 30 minutes.
According to the system for synchronizing data, which is disclosed by the embodiment of the invention, the first server can determine the data to be synchronized on the second server according to the second pointer in time when judging that the second pointer is different from the first pointer of the first server by monitoring the second pointer on the second server in real time, 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 data to be synchronized on the determined second server, and the whole data of the second server does not need to be traversed, so that the operation resources of the first server are saved, and the performance of the first server can be effectively exerted.
A method of synchronizing data provided by the present scheme is described below in accordance with a more complete embodiment.
Fig. 5 is a schematic diagram of 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:
In step S501, the first server monitors, in real time, a second pointer on the second server, where the second pointer is used to indicate data that is updated last in the second data on the second server.
Step S502, the second server receives the updated data, circularly adds 1 to the second pointer, and stores the updated data into the second data.
In step S503, the second server uses the updated data as the data to be synchronized, stores the id of the data to be synchronized and the corresponding second pointer identification into the cache queue, and sets an expiration policy.
In the embodiment of the invention, the purpose of setting the expiration policy is to save the space of the cache queue, because when the data in the cache queue is read by all the first servers, the data is not used, and error data may also occur, the data id to be synchronized and the second pointer identifier in the cache queue are deleted after expiration.
In step S504, the first server judges whether the first pointer and the second pointer are the same, and when the first pointer and the second pointer are different, the first server reads data to be synchronized from a cache queue of the second server.
In step S505, the first server circularly adds 1 to the first pointer, determines the corresponding data id to be synchronized according to the second pointer identification identical to the first pointer, and determines the corresponding data to be synchronized from the second data according to the data id to be synchronized.
In step S506, the first server synchronizes the first data according to the data to be synchronized.
Fig. 6 illustrates an exemplary system architecture 600 of a method of synchronizing data or a first server to which embodiments of the 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 is used as a medium to provide communication links between the terminal devices 601, 602, 603 and the server 605. The network 604 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
A user may interact with the server 605 via the network 604 using the terminal devices 601, 602, 603 to receive or send messages, etc. Various communication client applications, such as shopping class applications, web browser applications, search class applications, instant messaging tools, mailbox clients, social platform software, etc., may be installed on the terminal devices 601, 602, 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 smartphones, tablets, laptop and desktop computers, and the like.
The server 605 may be a server providing various services, such as a background management server providing support for shopping-type websites browsed by the user using the terminal devices 601, 602, 603. The background management server can analyze and other processing on the received data such as the product information inquiry request and the like, and feed back processing results (such as target push information and product information) to the terminal equipment.
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, there is illustrated a schematic diagram of a computer system 700 suitable for use in implementing an embodiment of the present invention. The terminal device shown in fig. 7 is only an example, and should not impose any limitation on the functions and the scope of use of the embodiment 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 according to 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 required for the operation of the system 700 are also stored. The CPU 701, ROM 702, and RAM 703 are connected to each other through a bus 704. An input/output (I/O) interface 705 is also connected to bus 704.
Connected to the I/O interface 705 are an input section 706 including a keyboard, a mouse, and the like, an output section 707 including a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, a speaker, and the like, 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, and the like. The communication section 709 performs communication processing via a network such as the internet. The 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 therefrom is mounted into the storage section 708 as necessary.
In particular, according to embodiments of the present disclosure, the processes described above with reference to 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 shown in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication portion 709, and/or installed from the removable medium 711. The above-described functions defined in the system of the present invention are performed when the computer program is executed by a Central Processing Unit (CPU) 701.
The computer readable medium shown in the present invention may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of a 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 context of this document, 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, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. 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, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
The flowcharts 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 involved in the embodiments of the present invention may be implemented in software or in hardware. The described modules may also be provided in a processor, for example, a processor may be described as comprising a monitoring module, a judging module and a synchronizing module. The names of these modules do not in any way limit the module itself, for example, the monitoring module may also be described as "module for monitoring the second pointer on the second server in real time".
As a further aspect, the invention also provides a computer readable medium which may be comprised in the device described in the above embodiments or may be present alone without being fitted into the device. The computer readable medium carries one or more programs, which when executed by the device, cause the device to include monitoring a second pointer on the second server in real time, the second pointer indicating data that is last updated in second data on the second server, determining whether the first pointer and the second pointer are the same, if not, determining 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 provided by the embodiment of the invention, the first server monitors the second pointer on the second server in real time, and when judging that the second pointer is different from the first pointer of the first server, the first server can timely determine the data to be synchronized on the second server according to the second pointer, so that the effect of timely synchronizing the first data of the first server is realized. In addition, the first server can only synchronize the data to be synchronized on the determined second server, and the whole data of the second server does not need to be traversed, so that the operation resources of the first server are saved, and the performance of the first server can be effectively exerted.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives can occur depending upon design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.

Claims (13)

Translated fromChinese
1.一种同步数据的方法,其特征在于,应用于第一服务器,所述第一服务器包括第一数据和第一指针,所述第一指针用于指示所述第一数据中最后被更新的数据;包括:1. A method for synchronizing data, characterized in that it is applied to a first server, the first server includes first data and a first pointer, the first pointer is used to indicate the last updated data in the first data; comprising:实时监控第二服务器上的第二指针,所述第二指针用于指示所述第二服务器上的第二数据中最后被更新的数据;Real-time monitoring of a second pointer on the second server, where the second pointer is used to indicate the last updated data in the second data on the second server;判断所述第一指针和所述第二指针是否相同;如果否,根据所述第二指针,确定所述第二服务器上的待同步数据;其中,所述第一指针保存所述第一数据的数量;所述第二指针保存所述第二数据的数量;当有数据更新时,所述第二指针循环加1;当同步数据时,第一指针循环加1;Determine whether the first pointer and the second pointer are the same; if not, determine the data to be synchronized on the second server according to the second pointer; wherein the first pointer stores the amount of the first data; the second pointer stores the amount of the second data; when there is data update, the second pointer is cyclically increased by 1; when synchronizing data, the first pointer is cyclically increased by 1;根据所述待同步数据,对所述第一数据与所述第二数据进行同步。The first data and the second data are synchronized according to the data to be synchronized.2.根据权利要求1所述的方法,其特征在于,所述根据所述待同步数据,对所述第一数据与所述第二数据进行同步,包括:2. The method according to claim 1, characterized in that synchronizing the first data with the second data according to the data to be synchronized comprises:根据所述待同步数据,对所述第一数据进行更新,以实现所述第一数据与所述第二数据的同步。The first data is updated according to the data to be synchronized, so as to achieve synchronization between the first data and the second data.3.根据权利要求2所述的方法,其特征在于,所述根据所述待同步数据,对所述第一数据进行更新,包括:3. The method according to claim 2, wherein updating the first data according to the data to be synchronized comprises:确定存储所述待同步数据的缓存队列,所述缓存队列中包括:所述待同步数据以及所述待同步数据对应的第二指针标识;Determine a cache queue for storing the data to be synchronized, wherein the cache queue includes: the data to be synchronized and a second pointer identifier corresponding to the data to be synchronized;循环执行以下步骤,直至所述第一指针和所述第二指针相同:The following steps are executed repeatedly until the first pointer and the second pointer are the same:递增所述第一指针,从所述缓存队列中确定与递增后的第一指针相同的第二指针标识,并根据确定出的所述第二指针标识所对应的待同步数据,对所述第一数据进行更新。The first pointer is incremented, a second pointer identifier that is the same as the incremented first pointer is determined from the cache queue, and the first data is updated according to the to-be-synchronized data corresponding to the determined second pointer identifier.4.根据权利要求1所述的方法,其特征在于,所述判断所述第一指针和所述第二指针是否相同,包括:4. The method according to claim 1, wherein determining whether the first pointer and the second pointer are the same comprises:通过接收中心服务器发出的数据更新广播,或实时监控所述第二指针,确定所述第一指针和所述第二指针是否相同。Whether the first pointer and the second pointer are the same is determined by receiving a data update broadcast from a central server or monitoring the second pointer in real time.5.根据权利要求1所述的方法,其特征在于,该方法还包括:5. The method according to claim 1, characterized in that the method further comprises:在对所述第一数据进行同步后开始计时,当记录的时长达到第一预设时长阈值、且在记录的时长内未对第一数据进行新的同步时,从所述第二服务器获取第二数据,并根据获取的第二数据替换所述第一数据。The timing starts after the first data is synchronized. When the recorded duration reaches a first preset duration threshold and the first data is not newly synchronized within the recorded duration, the second data is obtained from the second server and the first data is replaced according to the obtained second data.6.根据权利要求1所述的方法,其特征在于,所述第一数据包括以下任意一个或多个:物品标识、物品的库存数量和物品的存储位置。6. The method according to claim 1, characterized in that the first data includes any one or more of the following: item identification, item inventory quantity and item storage location.7.一种第一服务器,其特征在于,包括监控模块、判断模块以及同步模块;其中:7. A first server, characterized by comprising a monitoring module, a judgment module and a synchronization module; wherein:所述监控模块,用于实时监控第二服务器上的第二指针,所述第二指针用于指示所述第二服务器上的第二数据中最后被更新的数据;The monitoring module is used to monitor the second pointer on the second server in real time, where the second pointer is used to indicate the last updated data in the second data on the second server;所述判断模块,用于判断第一指针和所述监控模块获取的所述第二指针是否相同;如果否,根据所述第二指针,确定所述第二服务器上的待同步数据;其中,所述第一指针保存第一数据的数量;所述第二指针保存所述第二数据的数量;当有数据更新时,所述第二指针循环加1;当同步数据时,第一指针循环加1;The judging module is used to judge whether the first pointer and the second pointer obtained by the monitoring module are the same; if not, determine the data to be synchronized on the second server according to the second pointer; wherein the first pointer stores the number of the first data; the second pointer stores the number of the second data; when there is data update, the second pointer is cyclically increased by 1; when synchronizing data, the first pointer is cyclically increased by 1;所述同步模块,用于根据所述判断模块确定的所述待同步数据,对所述第一数据与所述第二数据进行同步。The synchronization module is used to synchronize the first data with the second data according to the data to be synchronized determined by the judgment module.8.一种同步数据的系统,其特征在于,包括:权利要求7所述的第一服务器和第二服务器;其中:8. A system for synchronizing data, comprising: the first server and the second server according to claim 7; wherein:所述第二服务器包括第二数据和第二指针,所述第二指针用于指示所述第二数据中最后被更新的数据,当所述第二数据更新时,更新所述第二指针。The second server includes second data and a second pointer, where the second pointer is used to indicate the last updated data in the second data. When the second data is updated, the second pointer is updated.9.根据权利要求8所述的系统,其特征在于,9. The system according to claim 8, characterized in that所述第二服务器还用于:循环执行以下步骤,直至被更新的数据全部保存至第二数据中:The second server is further configured to: loop through the following steps until all updated data is saved in the second database:递增所述第二指针,并将被更新的数据保存至所述第二数据中。The second pointer is incremented, and the updated data is saved in the second data.10.根据权利要求8所述的系统,其特征在于,10. The system according to claim 8, characterized in that所述第二服务器还用于:将所述被更新的数据以及对应的第二指针标识保存至缓存队列中,并将所述被更新的数据作为待同步数据,以使所述第一服务器根据所述第二指针标识所对应的待同步数据,对第一数据进行更新。The second server is also used to: save the updated data and the corresponding second pointer identifier into a cache queue, and use 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 identifier.11.根据权利要求10所述的系统,其特征在于,11. The system according to claim 10, characterized in that所述第二服务器还用于:当所述缓存队列中的所述待同步数据在第二预设时长阈值内未被读取时,删除所述缓存队列中的所述待同步数据和所述第二指针标识。The second server is further configured to: when the to-be-synchronized data in the cache queue is not read within a second preset time threshold, delete the to-be-synchronized data in the cache queue and the second pointer identifier.12.一种同步数据的服务器,其特征在于,包括:12. A server for synchronizing data, comprising:一个或多个处理器;one or more processors;存储装置,用于存储一个或多个程序,a storage device for storing one or more programs,当所述一个或多个程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现如权利要求1-6中任一所述的方法。When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.13.一种计算机可读介质,其上存储有计算机程序,其特征在于,所述程序被处理器执行时实现如权利要求1-6中任一所述的方法。13. A computer-readable medium having a computer program stored thereon, wherein when the program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
CN202011173528.0A2020-10-282020-10-28 A method for synchronizing data, a first server, and a system for synchronizing dataActiveCN113742376B (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN202011173528.0ACN113742376B (en)2020-10-282020-10-28 A method for synchronizing data, a first server, and a system for synchronizing data

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN202011173528.0ACN113742376B (en)2020-10-282020-10-28 A method for synchronizing data, a first server, and a system for synchronizing data

Publications (2)

Publication NumberPublication Date
CN113742376A CN113742376A (en)2021-12-03
CN113742376Btrue CN113742376B (en)2025-03-18

Family

ID=78728131

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN202011173528.0AActiveCN113742376B (en)2020-10-282020-10-28 A method for synchronizing data, a first server, and a system for synchronizing data

Country Status (1)

CountryLink
CN (1)CN113742376B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN115037612B (en)*2022-03-102024-03-26广东统信软件有限公司Server configuration method, computing device and storage medium
CN118394847A (en)*2024-06-242024-07-26深圳市艾晨数字能源有限公司Alarm record synchronization method, device, computer equipment and storage medium

Citations (1)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN111241203A (en)*2020-02-102020-06-05江苏满运软件科技有限公司Hive data warehouse synchronization method, system, equipment and storage medium

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
GB8815978D0 (en)*1988-07-051988-08-10British TelecommMethod & apparatus for encoding decoding & transmitting data in compressed form
JP3721725B2 (en)*1997-07-092005-11-30ソニー株式会社 Information processing method and information processing apparatus
US7113963B1 (en)*2000-11-102006-09-26Palmsource, Inc.Optimized database technique to enable faster data synchronization
CN103581231B (en)*2012-07-252019-03-12腾讯科技(北京)有限公司UGC master/slave data synchronous method and its system
CN110198331B (en)*2018-03-282022-11-25腾讯科技(上海)有限公司 A method and system for synchronizing data
CN111552735A (en)*2020-03-272020-08-18深圳壹账通智能科技有限公司 Data synchronization method, apparatus, computer equipment and medium based on data link
CN111813707B (en)*2020-07-172023-12-22济南浪潮数据技术有限公司Data synchronization method, device, equipment and storage medium

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN111241203A (en)*2020-02-102020-06-05江苏满运软件科技有限公司Hive data warehouse synchronization method, system, equipment and storage medium

Also Published As

Publication numberPublication date
CN113742376A (en)2021-12-03

Similar Documents

PublicationPublication DateTitle
CN110609872B (en)Method and apparatus for synchronizing node data
CN111309747A (en)Data synchronization method, system and device
CN111666134B (en) A distributed task scheduling method and system
CN112948498A (en)Method and device for generating global identification of distributed system
CN110162410B (en) A message processing method and device
CN111338834B (en)Data storage method and device
CN113761001A (en) A cross-system data synchronization method and device
WO2022078243A1 (en)Information synchronization method and apparatus
CN118540319B (en)Method and device for downloading file through browser and electronic equipment
CN113742376B (en) A method for synchronizing data, a first server, and a system for synchronizing data
CN113779082B (en)Method and device for updating data
CN114385570A (en) Method, apparatus, electronic device and readable medium for data synchronization
CN113138975A (en)Data migration method and device
CN111177109A (en)Method and device for deleting overdue key
CN112069137A (en)Method and device for generating information, electronic equipment and computer readable storage medium
CN115167769A (en)Method, device and system for writing data
CN107818027B (en)Method and device for switching main name node and standby name node and distributed system
CN112732728A (en)Data synchronization method and system
CN113347052A (en)Method and device for counting user access data through access log
CN112711572B (en)Online capacity expansion method and device suitable for database and table division
CN110851192B (en)Method and device for responding to degraded switch configuration
CN115454666A (en)Data synchronization method and device among message queue clusters
CN113760383A (en)Configuration information updating method and device
CN116975012A (en)File synchronization method, file updating method, device, electronic equipment and medium
CN113760572A (en)Message processing method and device

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination
GR01Patent grant
GR01Patent grant

[8]ページ先頭

©2009-2025 Movatter.jp