Movatterモバイル変換


[0]ホーム

URL:


CN113672604A - User data synchronization method, device and system and electronic equipment - Google Patents

User data synchronization method, device and system and electronic equipment
Download PDF

Info

Publication number
CN113672604A
CN113672604ACN202110935970.0ACN202110935970ACN113672604ACN 113672604 ACN113672604 ACN 113672604ACN 202110935970 ACN202110935970 ACN 202110935970ACN 113672604 ACN113672604 ACN 113672604A
Authority
CN
China
Prior art keywords
user
database
user data
data
user identification
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
CN202110935970.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.)
Zhejiang Dahua Technology Co Ltd
Original Assignee
Zhejiang Dahua 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 Zhejiang Dahua Technology Co LtdfiledCriticalZhejiang Dahua Technology Co Ltd
Priority to CN202110935970.0ApriorityCriticalpatent/CN113672604A/en
Publication of CN113672604ApublicationCriticalpatent/CN113672604A/en
Pendinglegal-statusCriticalCurrent

Links

Images

Classifications

Landscapes

Abstract

The application discloses a user data synchronization method, a device, a system and electronic equipment, wherein the method comprises the following steps: the method comprises the steps that a change request containing a user identifier and user data corresponding to the user identifier are obtained by a main device, then whether the user data same as the change data exist in a main device database or not is judged, if not, the user data corresponding to the user identifier are changed according to the change data, and all slave devices are informed to change according to the change data. Based on the method, the user data in the multiple equipment databases can be synchronously updated when the central server is absent.

Description

User data synchronization method, device and system and electronic equipment
Technical Field
The application relates to the technical field of computers, in particular to a user data synchronization method, device and system and electronic equipment.
Background
With the improvement of the overall security awareness of the society, the management of cell user data is more and more emphasized, and a cell usually has a plurality of access control devices, and when certain user data is changed, the user data is usually required to be updated on the plurality of access control devices. If the user data of the cell is managed under the condition that the central server exists, the change data of the user can be synchronously updated to the plurality of access control devices through the central server, but when the user data of the cell is managed under the condition that the central server does not exist, the change data of the user needs to be recorded into the plurality of access control devices one by one, the workload is relatively large, and the user data management is inconvenient.
In the prior art, synchronous change of user data in a plurality of access control equipment databases is usually realized based on a central server, and under the condition of no central server, user change data needs to be independently input into a plurality of access control equipment, so that the workload is large, and the user data management is inconvenient.
Disclosure of Invention
The application provides a user data synchronization method, a device, a system and electronic equipment, which can be used for realizing synchronous updating of user data in a plurality of equipment databases.
In a first aspect, the present application provides a user data synchronization method, where the method includes:
acquiring a change request containing a user identifier and change data corresponding to the user identifier;
determining whether user data identical to the changed data exists in a first database;
if not, changing the user data corresponding to the user identification according to the changed data, and informing each slave device to change according to the changed data;
if so, ignoring the change request.
By the user data synchronization method, when the existing user data needs to be updated or new user data needs to be added, the user data in the multiple equipment databases can be changed simultaneously under the condition of no central server.
In one possible design, before the obtaining the change request including the user identifier, the method further includes:
receiving an acquisition request of a newly online slave device, wherein the acquisition request is used for requesting all user data;
and pushing all user data to the slave equipment according to the acquisition request.
By the method, all the user data in the database of the master device can be pushed to the newly online slave device, and the newly online slave device updates the database of the slave device according to the user data pushed by the master device.
The application provides a user data synchronization method, which comprises the following steps:
acquiring a deletion request containing a user identifier;
judging whether user data corresponding to the user identification exists in a second database or not;
if so, deleting the user data corresponding to the user identification, and informing each slave device to delete the user data corresponding to the user identification;
if not, the delete request is ignored.
By the user data synchronization method, when the existing user data needs to be deleted, the user data in the multiple equipment databases can be deleted simultaneously under the condition of no central server.
In one possible design, before the obtaining the deletion request including the user identifier, the method further includes:
receiving a request for acquiring all user data from the newly online slave device;
and pushing all user data to the slave equipment according to the request for acquiring all user data.
By the method, all the user data in the database of the master device can be pushed to the newly online slave device, and the newly online slave device updates the database of the slave device according to the user data pushed by the master device.
The application provides a data updating method, which comprises the following steps:
when the first parameter sent by the main equipment is inconsistent with the stored second parameter, sequentially matching the user identification in a third database with the user identification in the main equipment database, wherein the third database is a newly online slave equipment database;
if the inconsistent user identification exists, requesting to obtain user data corresponding to the user identification from the main equipment;
if the consistent user identification exists, comparing the user parameters corresponding to the same user identification in the third database and the main equipment database;
if the user parameters corresponding to the same user identification are consistent, no processing is performed;
and if the user parameters corresponding to the same user identification are not consistent, replacing the user data in the third database with the user data corresponding to the same user identification in the main equipment database until all the user data in the third database are consistent with all the user data in the main equipment data.
By the data updating method, the user data in the newly online slave equipment database can be updated to be consistent with the user data in the master equipment database.
In a possible design, when it is obtained that the first parameter sent by the host device is inconsistent with the stored second parameter, sequentially matching the user identifier in the third database with the user identifier in the host device database includes:
requesting to obtain a first parameter from a main device, wherein the first parameter is obtained by calculation according to all user data in a main device database;
comparing the first parameter with a stored second parameter, wherein the second parameter is obtained by calculation according to all user data which is pushed by a main device and stored in the third database;
if the two are the same, no treatment is carried out;
and if not, matching the user identification in the third database with the user identification in the main equipment database in sequence.
By the method, whether the user data in the newly online slave equipment database is inconsistent with the user data in the master equipment database can be integrally judged, and if the user data is inconsistent, the user identification in the newly online slave equipment database is continuously matched with the user identification in the master equipment.
In a second aspect, the present application provides a user data synchronization apparatus, including:
the first acquisition module is used for acquiring a change request containing a user identifier and change data corresponding to the user identifier;
the first judging module is used for judging whether user data same as the changed data exists in the first database or not;
the first change module is used for changing the user data corresponding to the user identification according to the change data and informing each slave device to change according to the change data if the first change module does not exist;
and the first processing module is used for ignoring the change request if the change request exists.
In one possible design, the apparatus further includes:
the device comprises a first receiving module, a second receiving module and a sending module, wherein the first receiving module is used for receiving an acquisition request of a newly online slave device, and the acquisition request is used for requesting all user data;
and the first pushing module is used for pushing all user data to the slave equipment according to the acquisition request.
The application provides a user data synchronization device, the device includes:
the second acquisition module is used for acquiring a deletion request containing the user identifier;
the second judging module is used for judging whether user data corresponding to the user identification exists in a second database or not;
the second changing module is used for deleting the user data corresponding to the user identification if the user data exists, and informing each slave device of deleting the user data corresponding to the user identification;
and the second processing module is used for ignoring the deletion request if the deletion request does not exist.
The present application provides a data update apparatus, the apparatus including:
the matching module is used for sequentially matching the user identification in a third database with the user identification in the main equipment database when the first parameter sent by the main equipment is inconsistent with the stored second parameter, wherein the third database is a newly on-line slave equipment database;
a third obtaining module, configured to request the master device to obtain user data corresponding to the user identifier if the inconsistent user identifiers exist;
the comparison module is used for comparing the user parameters corresponding to the same user identifier in the third database and the main equipment database if the consistent user identifier exists;
the third processing module is used for not performing any processing if the user parameters corresponding to the same user identification are consistent;
and the replacing module is used for replacing the user data in the third database with the user data corresponding to the same user identification in the main equipment database until all the user data in the third database is consistent with all the user data in the main equipment data if the user parameters corresponding to the same user identification are inconsistent.
In one possible design, the matching module includes:
the request unit is used for requesting the main equipment to acquire a first parameter, wherein the first parameter is obtained by calculation according to all user data in a main equipment database;
the comparison unit is used for comparing the first parameter with a stored second parameter, wherein the second parameter is obtained by calculation according to all user data which is pushed by the main equipment and stored in the third database;
the processing unit is used for not performing any processing if the processing units are the same;
and the matching unit is used for matching the user identification in the third database with the user identification in the main equipment database in sequence if the user identifications are different.
In a third aspect, the present application provides a user data synchronization system, where the system includes a master device and a slave device, where the master device is configured to obtain a change request including a user identifier and change data corresponding to the user identifier; determining whether user data identical to the changed data exists in a first database; if not, changing the user data corresponding to the user identification according to the changed data, and informing each slave device to change according to the changed data; if yes, ignoring the change request;
the slave device is used for receiving the change data pushed by the master device; and changing the user data corresponding to the user identification according to the changed data.
In a possible design, the master device is further configured to receive an acquisition request of a newly online slave device, where the acquisition request is used to request all user data; and pushing all user data to the slave equipment according to the acquisition request.
In a possible design, the slave device is further configured to, when it is acquired that the first parameter sent by the master device is inconsistent with the stored second parameter, sequentially match the user identifier in the third database with the user identifier in the master device database, where the third database is a newly online slave device database; if the inconsistent user identification exists, requesting to obtain user data corresponding to the user identification from the main equipment; if the consistent user identification exists, comparing the user parameters corresponding to the same user identification in the third database and the main equipment database; if the user parameters corresponding to the same user identification are consistent, no processing is performed; and if the user parameters corresponding to the same user identification are not consistent, replacing the user data in the third database with the user data corresponding to the same user identification in the main equipment database until all the user data in the third database are consistent with all the user data in the main equipment data.
In a possible design, the slave device is further configured to request the master device to obtain a first parameter, where the first parameter is calculated according to all user data in the master device database; comparing the first parameter with a stored second parameter, wherein the second parameter is obtained by calculation according to all user data which is pushed by a main device and stored in the third database; if the two are the same, no treatment is carried out; and if not, matching the user identification in the third database with the user identification in the main equipment database in sequence.
The application provides a user data synchronization system, which comprises a master device and a slave device, wherein the master device is used for acquiring a deletion request containing a user identifier; judging whether user data corresponding to the user identification exists in a second database or not; if so, deleting the user data corresponding to the user identification, and informing each slave device to delete the user data corresponding to the user identification; if not, the delete request is ignored.
The slave device is used for receiving a deletion notification of the master device; and deleting the user data corresponding to the user identification according to the deletion notification.
In a fourth aspect, the present application provides an electronic device, comprising:
a memory for storing a computer program;
and the processor is used for realizing the method steps of the user data synchronization when executing the computer program stored in the memory.
In a fifth aspect, the present application provides a computer-readable storage medium having stored thereon a computer program which, when being executed by a processor, carries out the above-mentioned method steps for user data synchronization.
Based on the method provided by the application, when user data in a plurality of devices are updated, the master device updates the user data corresponding to the user identifier in the master device database according to the acquired change request containing the user identifier and the change data corresponding to the user identifier, and notifies all slave devices to change according to the change data, and the slave devices update the user data corresponding to the user identifier in the slave device database according to the notification of the master device, so that the user data in all slave device databases are synchronized.
When deleting the existing users in the multiple device databases, the master device deletes the user data corresponding to the user identifier in the master device database according to the obtained deletion request containing the user identifier, and then notifies each slave device to delete the user data corresponding to the user identifier, and the slave devices delete the user data corresponding to the user identifier in the slave device database according to the notification of the master device, so that the user data in all the slave device databases are synchronized.
When the master device needs to be replaced, a master device is determined from the original slave devices, and the newly online device is used as the slave device, or when the slave devices need to be added and the original slave devices need to be replaced, the user data in the database of the newly online slave device can be updated to be consistent with the user data in the database of the master device.
For each of the second aspect to the fifth aspect and possible technical effects of each aspect, please refer to the above description of the possible technical effects of the first aspect or various possible schemes of the first aspect, and no repeated description is given here.
Drawings
Fig. 1 is a flowchart of a user data synchronization method provided in the present application;
FIG. 2 is a flow chart of another user data synchronization method provided herein;
fig. 3 is a flowchart of a method for a master device to notify a newly online slave device to update data according to the present application;
FIG. 4 is a flowchart of a method for updating a database of a slave device according to the present application;
FIG. 5 is a diagram illustrating a master-slave device according to the present disclosure;
fig. 6 is a schematic structural diagram of a user data synchronization apparatus provided in the present application;
fig. 7 is a schematic structural diagram of another user data synchronization apparatus provided in the present application;
FIG. 8 is a schematic structural diagram of a data updating apparatus provided in the present application;
fig. 9 is a schematic structural diagram of a matching module provided in the present application;
FIG. 10 is a schematic diagram of a user data synchronization system according to the present application;
FIG. 11 is a schematic diagram of another embodiment of a user data synchronization system provided herein;
fig. 12 is a schematic structural diagram of an electronic device provided in the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more clear, the present application will be further described in detail with reference to the accompanying drawings. The particular methods of operation in the method embodiments may also be applied to apparatus embodiments or system embodiments. It should be noted that "a plurality" is understood as "at least two" in the description of the present application. "and/or" describes the association relationship of the associated objects, meaning that there may be three relationships, e.g., a and/or B, which may mean: a exists alone, A and B exist simultaneously, and B exists alone. A is connected with B and can represent: a and B are directly connected and A and B are connected through C. In addition, in the description of the present application, the terms "first," "second," and the like are used for descriptive purposes only and are not intended to indicate or imply relative importance nor order to be construed.
The embodiments of the present application will be described in detail below with reference to the accompanying drawings.
The user data synchronization method provided by the embodiment of the application is used for synchronizing the user data in a plurality of equipment databases under the condition of no central server. The method and the device in the embodiment of the application are based on the same technical concept, and because the principles of the problems solved by the method and the device are similar, the device and the embodiment of the method can be mutually referred, and repeated parts are not repeated.
When the user data management of the cell is performed without a central server, if the user data is changed, the changed data needs to be entered one by one on a plurality of access control devices, which is inconvenient for the user data management.
In order to realize that user data change is carried out on a plurality of access control devices simultaneously under the condition without a central server, one main device is determined from the plurality of access control devices, and the rest are slave devices.
The first embodiment is as follows:
specifically, as shown in fig. 1, a specific flow of a user data synchronization method provided by the present application is as follows:
s11, obtaining a change request containing a user identification and change data corresponding to the user identification;
in an embodiment of the present application, the user data includes a user identifier, user information, and a user parameter, where the user information includes:
the method comprises the steps of user card information, wherein the card information comprises specific card information and authority acquired through the card information;
user password information, wherein the password information comprises specific password information and authority acquired through the password information;
user fingerprint information, wherein the fingerprint information comprises binary data obtained through fingerprint calculation and authority obtained through the fingerprint;
and the face information of the user comprises face characteristics, a face base map and authority acquired through the face information.
And calculating the user information according to a preset algorithm to obtain corresponding user parameters, wherein the preset algorithm can be a Hash algorithm, and the obtained user parameters are Hash codes.
In the embodiment of the present application, the change request includes two types: one is to request the addition of new user data and the other is to update existing user data.
The primary device has two ways to obtain the change request: the method comprises the steps that a change request containing a user identifier is directly obtained by a master device, and a change request containing the user identifier transmitted by a slave device is obtained by the other device, wherein the transmission can be in a transparent transmission mode, namely the slave device directly transmits the obtained user change information to the master device without any processing.
S12, determining whether the same user data as the changed data exists in the first database;
in this embodiment of the present application, the first database is a master device database, and the user data in the first database is compared with the changed data to determine whether the user data identical to the changed data exists in the database, and if not, step S13 is executed; if so, go to step S14.
S13, changing the user data corresponding to the user identification according to the changed data, and informing each slave device to change according to the changed data;
in this embodiment, if the first database does not have the same user data as the changed data, indicating that the changed data is new user data, or updating the existing user data, the master device needs to change the user data in the first database corresponding to the user identifier according to the changed data, and notify each slave device of changing according to the changed data, so as to implement synchronous updating of the user data in each slave device database.
S14, ignoring the change request.
In the embodiment of the present application, if the same user data as the change data does not exist in the first database, it indicates that the change data is already stored in the database, and therefore no processing is required and the change request is ignored.
Based on the above manner, after acquiring the change request including the user identifier and the change data corresponding to the user identifier, the master device compares the change data with the user data in the first database to determine whether the first database includes the change data, if not, updates the user data in the first database corresponding to the user identifier according to the change data, and notifies each slave device to change according to the change data, thereby realizing synchronous update of the user data in each slave device database.
The user data synchronization method only aims at two application scenes of adding new user data and updating the existing user data, and the other application scene is the processing of a request for deleting the existing user data, and in this case, the user data synchronization method is as shown in fig. 2:
s21, acquiring a deletion request containing a user identifier;
in the embodiment of the present application, obtaining a deletion request including a user identifier may be implemented in two ways: one is that the master device directly obtains a delete request containing the user identifier, and the other is that a change request containing the user identifier transmitted from the slave device is obtained.
S22, judging whether the second database has user data corresponding to the user identification;
in an embodiment of the application, the second database indicates a master device database. If the user identifier exists in the second database, it indicates that the user data corresponding to the user identifier exists in the main device database, and then step S23 is executed; otherwise, it indicates that the user data corresponding to the user identifier does not exist in the master device database, and step S24 is executed.
S23, deleting the user data corresponding to the user identification, and informing each slave device to delete the user data corresponding to the user identification;
s24, the delete request is ignored.
Based on the steps, when the main device obtains the request for deleting the existing user data, whether the user data requested to be deleted exists or not is judged, if yes, the user data are deleted, then all the slave devices are informed to delete the user data, and synchronous updating of the user data in all the slave device databases is achieved.
According to the user data synchronization method in each scene, the master device database can be updated under the condition that the slave device requests to add new user data, update the existing data or delete the existing data, and the slave device is informed to update the slave device database according to different requests, so that the user data in the slave device database can be updated synchronously.
Example two:
in a possible application scenario, when it is detected that the slave device is abnormal or a new slave device needs to be added, before the master device obtains a change request including a user identifier or obtains a deletion request including a user identifier, all user data in the master device database needs to be pushed to the newly online slave device, and a specific flow is shown in fig. 3:
s31, receiving a request of all user data acquisition of the newly on-line slave device;
in this embodiment of the present application, before sending a request for acquiring all user data to a master device, a slave device further needs to configure relevant information of the master device, where the relevant information refers to an IP, a port, a password, and the like.
S32, pushing all user data to the slave device according to the request for acquiring all user data;
in the embodiment of the application, all user data is pushed to the slave device to inform the slave device to update the database of the slave device according to the pushed all user data. The user data comprises a user identifier, and user information and user parameters corresponding to the user identifier, wherein the user information is formed by the following steps:
and (3) user identification: user information;
calculating the user information according to a preset algorithm to obtain corresponding user parameters, wherein the user parameters are composed of the following steps:
and (3) user identification: a user parameter;
the user identification of each user is unique, and for the same user, the user identification, the user information and the user parameters are in one-to-one correspondence, and the user identification, the user information and the user parameters jointly form user data.
Based on the above steps, when it is detected that the slave device is abnormal or a new slave device needs to be added, before the master device acquires the user change information, all user data in the master device database needs to be pushed to the newly online slave device, so that the newly online slave device acquires all user data in the master device database.
In another application scenario, if it is detected that the master device is abnormal and the master device needs to be replaced, a new master device needs to be determined from the original slave devices, wherein the determination of the new master device can be implemented manually. And then, the newly online equipment is used as slave equipment to execute the process, so that the newly online slave equipment acquires all user data in the main equipment database.
Further, when new user data is added or existing user data is updated, the method steps shown in fig. 1 in the first embodiment are executed on all slave devices including the slave device which is newly online, and when existing user data is deleted, the method steps shown in fig. 2 in the first embodiment are executed on all slave devices including the slave device which is newly online, so that synchronous updating of user data in a database of all slave devices including the slave device which is newly online is realized.
Example three:
when the master device notifies the newly online slave device to update the newly online slave device database according to the pushed user data, the newly online slave device needs to update the newly online slave device database according to the user data pushed by the master device, and the specific updating method is as shown in fig. 4:
s41, acquiring a first parameter pushed by the main equipment;
in this embodiment of the application, the first parameter is calculated according to a preset algorithm based on all user data in the primary device database, where the preset algorithm may be a hash algorithm, and then the obtained first parameter is a global hash value calculated based on all user data.
S42, comparing the second parameter with the first parameter;
in this embodiment, the second parameter is calculated according to all user data in a third database, where the third database indicates a newly online slave device database, and all user data in the third database is pushed by the master device.
And comparing the second parameter with the first parameter to judge whether the third database is inconsistent with the main equipment database in user data.
If the second parameter is consistent with the first parameter, which indicates that all the user data in the third database is consistent with all the user data in the master device database, performing step S43; if the third database is not consistent with the user data stored in the master database, step S44 is executed.
S43, ending the updating process;
s44, matching the user identification in the third database with the user identification in the main equipment database in sequence;
in the embodiment of the present application, the user data lacking in the third database may be found by matching the user identifier in the third database with the user identifier in the main device database. Specifically, if there is an inconsistent user identifier between the third database and the master device database, indicating that there is no user data corresponding to the user identifier in the third database, step S45 is executed; if the consistent user identifier exists, it indicates that the user data corresponding to the user identifier exists in the third database, but it cannot be guaranteed that the user parameter corresponding to the user identifier is correct, so step S46 is executed.
S45, requesting the main device to acquire the user data corresponding to the user identification;
in this embodiment of the application, if the same user identifier as that in the database of the master device is not found in the third database, it indicates that the user data corresponding to the user identifier is absent in the third database, and therefore, the newly online slave device requests the master device to acquire the user data corresponding to the user identifier.
S46, comparing the third database with the user parameter corresponding to the same user identifier in the main equipment data;
in the embodiment of the application, the user identifier has uniqueness, and the user parameters corresponding to the same user identifier in the third database and the main device data are compared to find out which specific user data in the third database are inconsistent with the user data in the main device database. Specifically, if the user parameters corresponding to the same user identifier in the third database are consistent with the user parameters corresponding to the same user identifier in the master device data, indicating that the user data corresponding to the same user identifier is consistent, step S47 is executed; if the user parameters corresponding to the same user identifier in the third database and the master device data are not consistent, it indicates that the user data corresponding to the same user identifier are not consistent, then step S48 is executed.
S47, not performing any treatment;
and S48, replacing the user data in the third database with the user data corresponding to the same user identification in the main equipment database.
If the user data corresponding to the same user identifier in the third database is inconsistent with the user data corresponding to the same user identifier in the main device data, it indicates that the user data corresponding to the same user identifier in the third database is wrong, and therefore the user data corresponding to the same user identifier in the main device database needs to be replaced.
Based on the steps, the second parameter is compared with the first parameter, and whether inconsistent user data exists in the third database and the main equipment database is judged on the whole. In case of inconsistent user data, matching the user identification in the third database with the user identification in the master device to find out the missing user data in the third database, thereby requesting the data from the master device for the missing user data. Further, the user parameters corresponding to the same user identifier in the third database and the main device database are matched to find out which specific user data are different, so that the different user data in the third database are replaced by the user data corresponding to the same user identifier in the main device. By the method, the consistency of the user data in the newly online slave equipment database and the user data in the master equipment database is finally realized.
According to the user data synchronization method provided by the application, when user data in a plurality of devices are updated, the master device updates the user data corresponding to the user identification in the master device database according to the acquired change request containing the user identification and the change data corresponding to the user identification, and notifies all slave devices to change according to the change data, and the slave devices update the user data corresponding to the user identification in the slave device database according to the notification of the master device, so that the user data in all slave device databases are synchronized.
When deleting the existing users in the multiple device databases, the master device deletes the user data corresponding to the user identifier in the master device database according to the obtained deletion request containing the user identifier, and then notifies each slave device to delete the user data corresponding to the user identifier, and the slave devices delete the user data corresponding to the user identifier in the slave device database according to the notification of the master device, so that the user data in all the slave device databases are synchronized.
When the master device needs to be replaced, a master device is determined from the original slave devices, and the newly online device is used as the slave device, or when the slave devices need to be added and the original slave devices need to be replaced, the user data in the newly online slave device database can be updated to be consistent with the user data in the master device database through the data updating method provided by the application.
Further, in order to explain the user data synchronization method provided by the present application in more detail, the method provided by the present application is explained in detail in a specific application scenario.
Referring to fig. 5, there are 1 master device and 3 slave devices, and a black bold line in fig. 5 represents an information link between the master device and the slave device. When the master equipment needs to be replaced, the equipment management personnel sets the slave equipment 1 as the master equipment, and the newly-on-line equipment is used as new slave equipment 1;
the slave device 1 sends an instruction for acquiring all user data to the master device;
after receiving the instruction, the master device pushes all user data in a master device database to the slave device 1;
the slave device 1 stores all user data pushed by the master device in a database of the slave device and requests the master device to push a first global hash value;
after receiving the request, the master device pushes the first global hash value to the slave device;
after receiving the first hash value pushed by the master device, the slave device 1 compares the second hash value with the first hash value;
if the second hash value is consistent with the first hash value, indicating that the user data in the slave device 1 database is consistent with the user data in the master device database, and ending the updating of the data in the slave device 1 database;
if the second hash value is not consistent with the first hash value, matching the user identifier in the slave device 1 database with the user identifier in the master device database;
if the inconsistent user identifications exist, the slave equipment 1 requests the master equipment to acquire user data corresponding to the user identifications;
if the consistent user identification exists, comparing user parameters corresponding to the same user identification in the slave equipment 1 database and the master equipment database;
if the user parameters corresponding to the same user identification are consistent, all the main equipment and the slave equipment are not processed;
and if the user parameters corresponding to the same user identification are not consistent, replacing the user data in the slave equipment 1 database with the user data corresponding to the same user identification in the master equipment database until all the user data in the slave equipment 1 database is consistent with all the user data in the master equipment data.
Based on the steps, the user data in the newly online slave equipment database can be updated to be consistent with the user data in the master equipment database. In this case:
the slave device 2 acquires a change request containing a user identifier and change data corresponding to the user identifier, and transmits the acquired change request and change data to the master device;
the main equipment acquires the change request containing the user identification and the change data corresponding to the user identification, and judges whether user data same as the change data exists in a main equipment database or not;
if not, the master device changes the user data corresponding to the user identification according to the change data and informs each slave device to change according to the change data;
if not, ignoring the change request;
and each slave device receives a notification change instruction of the master device and updates the user parameters in the slave device database.
Based on the above steps, when the slave device 2 obtains a data change instruction, the change instruction is transmitted to the master device, the master device updates the master device database according to the change instruction, and notifies the slave devices to change according to the change data, and after the slave devices update the slave device database according to the notification of the master device, the slave devices achieve user data synchronization in the slave device databases.
Based on the same inventive concept, an embodiment of the present application further provides a user data synchronization apparatus, as shown in fig. 6, which is a schematic structural diagram of the user data synchronization apparatus in the present application, and the apparatus includes:
a first obtainingmodule 61, configured to obtain a change request including a user identifier and change data corresponding to the user identifier;
afirst determination module 62, configured to determine whether user data identical to the changed data exists in the first database;
a first changingmodule 63, configured to change, according to the changed data, user data corresponding to the user identifier and notify each slave device of changing according to the changed data if the user data does not exist;
thefirst processing module 64, if present, is configured to ignore the change request.
In one possible design, the apparatus further includes:
the device comprises a first receiving module, a second receiving module and a sending module, wherein the first receiving module is used for receiving an acquisition request of a newly online slave device, and the acquisition request is used for requesting all user data;
and the first pushing module is used for pushing all user data to the slave equipment according to the acquisition request.
The present application provides a user data synchronization apparatus, as shown in fig. 7, the apparatus includes:
a second obtainingmodule 71, configured to obtain a deletion request including a user identifier;
a second determiningmodule 72, configured to determine whether user data corresponding to the user identifier exists in a second database;
a second changingmodule 73, configured to delete the user data corresponding to the user identifier if the user data exists, and notify each slave device to delete the user data corresponding to the user identifier;
thesecond processing module 74, if not present, is configured to ignore the delete request.
The present application provides a data updating apparatus, as shown in fig. 8, the apparatus including:
thematching module 81 is configured to, when it is obtained that the first parameter sent by the master device is inconsistent with the stored second parameter, sequentially match the user identifier in the third database with the user identifier in the master device database, where the third database is a newly online slave device database;
a third obtainingmodule 82, configured to request the master device to obtain user data corresponding to the user identifier if the inconsistent user identifiers exist;
thecomparison module 83 compares the user parameters corresponding to the same user identifier in the third database and the main device database if the consistent user identifier exists;
athird processing module 84, if the user parameters corresponding to the same user identifier are consistent, no processing is performed;
if the user parameters corresponding to the same user identifier are not consistent, thereplacement module 85 replaces the user data in the third database with the user data corresponding to the same user identifier in the main device database until all the user data in the third database is consistent with all the user data in the main device data.
In one possible design, as shown in fig. 9, the matching module includes:
a requestingunit 91, configured to request the master device to obtain a first parameter, where the first parameter is calculated according to all user data in the master device database;
a comparingunit 92, configured to compare the first parameter with a stored second parameter, where the second parameter is obtained by calculation according to all user data pushed by a master device and stored in the third database;
aprocessing unit 93, if the same, configured to not perform any processing;
and if the user identifiers are different, the matchingunit 94 is configured to match the user identifiers in the third database with the user identifiers in the main device database in sequence.
According to the user data synchronization device provided by the application, when user data in a plurality of devices are updated, the master device updates the user data corresponding to the user identification in the master device database according to the acquired change request containing the user identification and the change data corresponding to the user identification, and notifies all slave devices to change according to the change data, and the slave devices update the user data corresponding to the user identification in the slave device database according to the notification of the master device, so that the user data in all slave device databases are synchronized.
When deleting the existing users in the multiple device databases, the master device deletes the user data corresponding to the user identifier in the master device database according to the obtained deletion request containing the user identifier, and then notifies each slave device to delete the user data corresponding to the user identifier, and the slave devices delete the user data corresponding to the user identifier in the slave device database according to the notification of the master device, so that the user data in all the slave device databases are synchronized.
When the master device needs to be replaced, a master device is determined from the original slave devices, and the newly online device serves as the slave device, or when the slave devices need to be added and the original slave devices need to be replaced, the user data in the newly online slave device database can be updated to be consistent with the user data in the master device database through the data updating device provided by the application.
Based on the same inventive concept, an embodiment of the present application further provides a user data synchronization system, as shown in fig. 10, which is a schematic structural diagram of the user data synchronization system in the present application: the system comprises a master device 101 and a slave device 102.
The master device 101 is configured to obtain a change request including a user identifier and change data corresponding to the user identifier; determining whether user data identical to the changed data exists in a first database; if not, changing the user data corresponding to the user identifier according to the changed data, and notifying each slave device 102 to change according to the changed data; if so, ignoring the change request.
The slave device 102 is configured to receive change data pushed by the master device 101; and changing the user data corresponding to the user identification according to the changed data.
In a possible design, the master device 101 is further configured to receive an acquisition request of the newly online slave device 103, where the acquisition request is used to request all user data; and pushing all user data to the slave device 103 according to the acquisition request.
In a possible design, the slave device 102 is further configured to, when it is obtained that the first parameter sent by the master device 101 is inconsistent with the stored second parameter, sequentially match the user identifier in the third database with the user identifier in the master device 101 database, where the third database is a newly online slave device 103 database; if the inconsistent user identifiers exist, requesting the main equipment 101 to acquire user data corresponding to the user identifiers; if the consistent user identification exists, comparing the user parameters corresponding to the same user identification in the third database and the main equipment 101 database; if the user parameters corresponding to the same user identification are consistent, no processing is performed; and if the user parameters corresponding to the same user identification are not consistent, replacing the user data in the third database with the user data corresponding to the same user identification in the main equipment 101 database until all the user data in the third database is consistent with all the user data in the main equipment 101 data.
In a possible design, the slave device 102 is further configured to request the master device 101 to obtain a first parameter, where the first parameter is calculated according to all user data in the database of the master device 101; comparing the first parameter with a stored second parameter, wherein the second parameter is obtained by calculation according to all user data which is pushed by the main device 101 and stored in the third database; if the two are the same, no treatment is carried out; and if not, matching the user identification in the third database with the user identification in the database of the main equipment 101 in sequence.
The present application provides a user data synchronization system, as shown in fig. 11, which is a schematic structural diagram of a user data synchronization system in the present application: the system comprises a master device 111 and a slave device 112.
The master device 111 is configured to obtain a deletion request including a user identifier; judging whether user data corresponding to the user identification exists in a second database or not; if yes, deleting the user data corresponding to the user identifier, and notifying each slave device 112 to delete the user data corresponding to the user identifier; if not, the delete request is ignored.
The slave device 112, configured to receive a deletion notification of the master device 111; and deleting the user data corresponding to the user identification according to the deletion notification.
Based on the same inventive concept, an embodiment of the present application further provides an electronic device, where the electronic device can implement the function of the foregoing user data synchronization apparatus, and with reference to fig. 12, the electronic device includes:
at least oneprocessor 121, and amemory 122 connected to the at least oneprocessor 121, in this embodiment, a specific connection medium between theprocessor 121 and thememory 122 is not limited in this application, and fig. 12 illustrates an example where theprocessor 121 and thememory 122 are connected through abus 120. Thebus 120 is shown in fig. 12 by a thick line, and the connection between other components is merely illustrative and not limited thereto. Thebus 120 may be divided into an address bus, a data bus, a control bus, etc., and is shown in fig. 12 with only one thick line for ease of illustration, but does not represent only one bus or one type of bus. Alternatively, theprocessor 121 may also be referred to as a controller, without limitation to name a few.
In the embodiment of the present application, thememory 122 stores instructions executable by the at least oneprocessor 121, and the at least oneprocessor 121 can execute the user data synchronization method discussed above by executing the instructions stored in thememory 122. Theprocessor 121 may implement the functions of the respective modules in the apparatuses shown in fig. 6, 8, and 9.
Theprocessor 121 is a control center of the apparatus, and may connect various parts of the entire control device by using various interfaces and lines, and perform various functions of the apparatus and process data by operating or executing instructions stored in thememory 122 and calling data stored in thememory 122, thereby performing overall monitoring of the apparatus.
In one possible design,processor 121 may include one or more processing units, andprocessor 121 may integrate an application processor that handles primarily the operating system, user interfaces, application programs, and the like, and a modem processor that handles primarily wireless communications. It will be appreciated that the modem processor described above may not be integrated into theprocessor 121. In some embodiments, theprocessor 121 and thememory 122 may be implemented on the same chip, or in some embodiments, they may be implemented separately on separate chips.
Theprocessor 121 may be a general-purpose processor, such as a Central Processing Unit (CPU), a digital signal processor, an application specific integrated circuit, a field programmable gate array or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination thereof, that may implement or perform the methods, steps, and logic blocks disclosed in the embodiments of the present application. A general purpose processor may be a microprocessor or any conventional processor or the like. The steps of the user data synchronization method disclosed in the embodiments of the present application may be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules in the processor.
Memory 122, which is a non-volatile computer-readable storage medium, may be used to store non-volatile software programs, non-volatile computer-executable programs, and modules. TheMemory 122 may include at least one type of storage medium, and may include, for example, a flash Memory, a hard disk, a multimedia card, a card-type Memory, a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a Programmable Read Only Memory (PROM), a Read Only Memory (ROM), a charge Erasable Programmable Read Only Memory (EEPROM), a magnetic Memory, a magnetic disk, an optical disk, and the like. Thememory 122 is any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer, but is not limited to such. Thememory 122 in the embodiments of the present application may also be circuitry or any other device capable of performing a storage function for storing program instructions and/or data.
Theprocessor 121 is programmed to solidify the codes corresponding to the user data synchronization method described in the foregoing embodiments into the chip, so that the chip can execute the steps of the user data synchronization method of the embodiments shown in fig. 1, fig. 2, fig. 3, and fig. 4 when running. How to program theprocessor 121 is well known to those skilled in the art and will not be described herein.
Based on the same inventive concept, the present application also provides a storage medium storing computer instructions, which when executed on a computer, cause the computer to perform the user data synchronization method discussed above.
In some possible embodiments, the various aspects of the user data synchronization method provided in the present application may also be implemented in the form of a program product comprising program code means for causing a control device to carry out the steps of the user data synchronization method according to various exemplary embodiments of the present application described above in this specification, when the program product is run on an apparatus.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present application without departing from the spirit and scope of the application. Thus, if such modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is intended to include such modifications and variations as well.

Claims (12)

CN202110935970.0A2021-08-162021-08-16User data synchronization method, device and system and electronic equipmentPendingCN113672604A (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN202110935970.0ACN113672604A (en)2021-08-162021-08-16User data synchronization method, device and system and electronic equipment

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN202110935970.0ACN113672604A (en)2021-08-162021-08-16User data synchronization method, device and system and electronic equipment

Publications (1)

Publication NumberPublication Date
CN113672604Atrue CN113672604A (en)2021-11-19

Family

ID=78542920

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN202110935970.0APendingCN113672604A (en)2021-08-162021-08-16User data synchronization method, device and system and electronic equipment

Country Status (1)

CountryLink
CN (1)CN113672604A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN114153924A (en)*2021-12-072022-03-08深圳市丛文安全电子有限公司Information synchronization method and system for terminal equipment and host

Citations (10)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN102426611A (en)*2012-01-132012-04-25广州从兴电子开发有限公司Database synchronization method and device
US20140108334A1 (en)*2012-10-162014-04-17ESC Services, Inc.Providing procedures
CN105989044A (en)*2015-02-042016-10-05阿里巴巴集团控股有限公司Database verification method and system
CN106855869A (en)*2015-12-092017-06-16中国移动通信集团公司A kind of methods, devices and systems for realizing database High Availabitity
CN108243209A (en)*2016-12-232018-07-03深圳市优朋普乐传媒发展有限公司A kind of method of data synchronization and device
CN111241198A (en)*2020-01-022020-06-05广州虎牙科技有限公司Data synchronization method and device and data processing equipment
CN111625540A (en)*2020-05-112020-09-04福建慧政通信息科技有限公司Method and device for verifying data synchronization integrity of relational database
CN112003943A (en)*2020-08-252020-11-27苏州思必驰信息科技有限公司 Voice data synchronization method and device
CN112307119A (en)*2020-10-272021-02-02广州市网星信息技术有限公司Data synchronization method, device, equipment and storage medium
CN112968921A (en)*2021-01-182021-06-15浙江大华技术股份有限公司Data updating method, device and computer readable storage medium

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN102426611A (en)*2012-01-132012-04-25广州从兴电子开发有限公司Database synchronization method and device
US20140108334A1 (en)*2012-10-162014-04-17ESC Services, Inc.Providing procedures
CN105989044A (en)*2015-02-042016-10-05阿里巴巴集团控股有限公司Database verification method and system
CN106855869A (en)*2015-12-092017-06-16中国移动通信集团公司A kind of methods, devices and systems for realizing database High Availabitity
CN108243209A (en)*2016-12-232018-07-03深圳市优朋普乐传媒发展有限公司A kind of method of data synchronization and device
CN111241198A (en)*2020-01-022020-06-05广州虎牙科技有限公司Data synchronization method and device and data processing equipment
CN111625540A (en)*2020-05-112020-09-04福建慧政通信息科技有限公司Method and device for verifying data synchronization integrity of relational database
CN112003943A (en)*2020-08-252020-11-27苏州思必驰信息科技有限公司 Voice data synchronization method and device
CN112307119A (en)*2020-10-272021-02-02广州市网星信息技术有限公司Data synchronization method, device, equipment and storage medium
CN112968921A (en)*2021-01-182021-06-15浙江大华技术股份有限公司Data updating method, device and computer readable storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN114153924A (en)*2021-12-072022-03-08深圳市丛文安全电子有限公司Information synchronization method and system for terminal equipment and host

Similar Documents

PublicationPublication DateTitle
CN102202087B (en)Method for identifying storage equipment and system thereof
CN111291000B (en) Blockchain-based file acquisition methods, equipment and storage media
CN111800468B (en)Multi-cluster management method and device based on cloud, medium and electronic equipment
CN110557452B (en)Node management method and device of block chain, storage medium and computer equipment
CN108183971B (en)Node election method in distributed system
CN110619226A (en)Platform-based data processing method, system, equipment and storage medium
CN113672692B (en)Data processing method, data processing device, computer equipment and storage medium
CN111399764B (en)Data storage method, data reading device, data storage equipment and data storage medium
CN111262822B (en)File storage method, device, block link point and system
CN109542841B (en)Method for creating data snapshot in cluster and terminal equipment
CN112256930A (en)Method, device and system for batch generation of identification codes for distributed services
CN113760519B (en)Distributed transaction processing method, device, system and electronic equipment
CN108039960B (en)Configuration information issuing method and server
CN113672604A (en)User data synchronization method, device and system and electronic equipment
CN113641649B (en)Data acquisition method, device, equipment and storage medium
CN117708210A (en)Data importing method and device, electronic equipment and nonvolatile storage medium
CN111049689B (en)Data center switching method and device
CN111385613B (en)Television system repairing method, storage medium and application server
CN110363515B (en)Rights and interests card account information inquiry method, system, server and readable storage medium
CN117650937A (en)Task permission verification method and device, nonvolatile storage medium and electronic equipment
CN116894010A (en)Resource state processing method and device, electronic equipment and storage medium
CN111443934B (en)Gray scale user determination method, device, equipment and storage medium
CN112685064A (en)Device identification processing method and device, storage medium and electronic device
CN107666495B (en)Disaster recovery method and terminal for application
CN112733210B (en)Equipment identifier obtaining method and device and computer readable storage medium

Legal Events

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

[8]ページ先頭

©2009-2025 Movatter.jp