Encryption-based data synchronization method and device, computer device and storage medium

By generating reference digest information and encrypted information during the master-slave database synchronization process, the problem of data synchronization anomalies caused by the failure of the second database to execute operation statements is solved, and higher data synchronization accuracy is achieved.

CN115203322BActive Publication Date: 2026-04-28PING AN BANK CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
PING AN BANK CO LTD
Filing Date
2022-06-25
Publication Date
2026-04-28

AI Technical Summary

Technical Problem

In existing technologies, during the master-slave database synchronization process, the failure of the second database to execute operation statements can lead to data synchronization anomalies, affecting the accuracy of data synchronization.

Method used

By obtaining the operation statements from the first database, executing them and generating reference digest information and encrypted information, and then processing the data in the second database based on this information, data synchronization can be achieved.

Benefits of technology

This avoids data synchronization anomalies caused by the failure of operation statements in the second database, and improves the accuracy of data synchronization between the first and second databases.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115203322B_ABST
    Figure CN115203322B_ABST
Patent Text Reader

Abstract

The application discloses a kind of based on encryption data synchronization method, device, computer equipment and storage medium, comprising: obtaining the operation statement of first database;Operation statement is executed to first database, and first data information is obtained;According to the preset summary algorithm, first data information is handled, and first reference summary information is obtained;According to first reference summary information, the data change information of first database after executing operation statement is determined;When data change information matches with preset reference information, according to the preset encryption algorithm, first data information is handled, and reference encryption information is obtained;Operation statement is executed to the second database corresponding to first database, and second data information is obtained;According to second data information, first reference summary information and reference encryption information, data processing is carried out to second database.The application can avoid data synchronization exception, and improve the accuracy of first database and second database data synchronization.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, specifically to an encryption-based data synchronization method, apparatus, computer device, and storage medium. Background Technology

[0002] With the rapid development of computer technology, the amount of data stored in databases is increasing. In a master-slave database server deployment architecture, the data in the master and slave databases should be consistent. To maintain data synchronization between the master and slave databases, the current technology generally employs the following method: after executing operation statements on the master database, these statements are written to the master database's binary log, and then the operation statements in the master database's binary log are used to process the slave database. This data synchronization method can lead to synchronization anomalies if the slave database fails to execute operation statements. Summary of the Invention

[0003] This application provides an encrypted data synchronization method, apparatus, computer device, and storage medium, which can avoid data synchronization anomalies caused by the failure of the second database to execute operation statements, and improve the accuracy of data synchronization between the first and second databases.

[0004] On the one hand, this application provides an encrypted data synchronization method, including:

[0005] Retrieve the operation statements from the first database;

[0006] The operation statement is executed on the first database to obtain the first data information;

[0007] The first data information is processed according to a preset digest algorithm to obtain the first reference digest information;

[0008] Based on the first reference digest information, determine the data change information of the first database after executing the operation statement;

[0009] When the data change information matches the preset benchmark information, the first data information is processed according to the preset encryption algorithm to obtain reference encrypted information;

[0010] The operation statement is executed on the second database corresponding to the first database to obtain the second data information;

[0011] The second database is processed based on the second data information, the first reference digest information, and the reference encryption information to achieve data synchronization between the first database and the second database.

[0012] In some embodiments of this application, the step of processing the second database based on the second data information, the first reference digest information, and the reference encryption information includes:

[0013] The second data information is processed according to the aforementioned digest algorithm to obtain the target digest information;

[0014] The second database is processed based on the target digest information, the first reference digest information, and the reference encryption information.

[0015] In some embodiments of this application, the step of processing the second database based on the target digest information, the first reference digest information, and the reference encryption information includes:

[0016] The target summary information is compared with the first reference summary information;

[0017] When the target digest information is inconsistent with the first reference digest information, the second database is processed according to the reference encryption information.

[0018] In some embodiments of this application, the data processing of the second database based on the reference encryption information includes:

[0019] The reference encrypted information is processed according to the decryption algorithm corresponding to the encryption algorithm to obtain the third data information;

[0020] Based on the third data information, the second database is processed.

[0021] In some embodiments of this application, determining the data change information of the first database after executing the operation statement based on the first reference digest information includes:

[0022] Obtain fourth data information, which is the data information of the first database before the operation statement is executed on the first database;

[0023] The fourth data information is processed according to the digest algorithm to obtain the second reference digest information;

[0024] Based on the first reference digest information and the second reference digest information, determine the data change information of the first database after executing the operation statement.

[0025] In some embodiments of this application, before executing the operation statement on the second database corresponding to the first database to obtain the second data information, the method further includes:

[0026] Write the operation statement, the first reference digest information, and the reference encryption information into the binary log of the first database;

[0027] The operation statements, the first reference digest information, and the reference encryption information in the binary log are synchronized to the target log file of the second database.

[0028] In some embodiments of this application, the operation statement includes multiple statements, and executing the operation statement on the first database to obtain the first data information includes:

[0029] Obtain the attribute fields of each of the multiple operation statements, and determine the execution order of the multiple operation statements based on the attribute fields;

[0030] The plurality of operation statements are executed on the first database according to the execution order to obtain the first data information.

[0031] On the other hand, this application provides an encrypted data synchronization device, comprising:

[0032] The data acquisition unit is used to acquire operation statements from the first database;

[0033] The first execution unit is configured to execute the operation statement on the first database to obtain first data information;

[0034] An information processing unit is used to process the first data information according to a preset digest algorithm to obtain first reference digest information;

[0035] An information determination unit is configured to determine, based on the first reference digest information, the data change information of the first database after executing the operation statement;

[0036] An information encryption unit is used to process the first data information according to a preset encryption algorithm to obtain reference encrypted information when the data change information matches the preset reference information.

[0037] The second execution unit is used to execute the operation statement on the second database corresponding to the first database to obtain the second data information;

[0038] The data synchronization unit is used to process the second database according to the second data information, the first reference digest information and the reference encryption information, so as to realize the data synchronization between the first database and the second database.

[0039] On the other hand, this application also provides a computer device, the computer device comprising:

[0040] One or more processors;

[0041] Memory; and

[0042] One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the processor to implement the steps in the encryption-based data synchronization method described in any one of the first aspects.

[0043] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, the computer program being loaded by a processor to perform the steps of the encryption-based data synchronization method described in any of the first aspects.

[0044] After executing operation statements on the second database corresponding to the first database, this application processes the data of the second database based on the second data information, the first reference digest information, and the reference encryption information. This can avoid data synchronization anomalies caused by the failure of the second database to execute operation statements, and improve the accuracy of data synchronization between the first and second databases. Attached Figure Description

[0045] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0046] Figure 1 This is a schematic diagram of a scenario for an encrypted data synchronization system provided in an embodiment of this application;

[0047] Figure 2 This is a schematic flowchart of an embodiment of the encrypted data synchronization method provided in this application.

[0048] Figure 3 This is a schematic diagram of an embodiment of the encrypted data synchronization device provided in this application.

[0049] Figure 4 This is a schematic diagram of an embodiment of the computer device provided in this application. Detailed Implementation

[0050] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0051] In the description of this application, it should be understood that the terms "center," "longitudinal," "lateral," "length," "width," "thickness," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," and "outer," etc., indicating orientation or positional relationships based on the orientation or positional relationships shown in the accompanying drawings, are used only for the convenience of describing this application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of this application. Furthermore, the terms "first," "second," "third," and "fourth" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined with "first," "second," "third," and "fourth" may explicitly or implicitly include one or more of the stated features. In the description of this application, "a plurality of" means two or more, unless otherwise explicitly specified.

[0052] In this application, the term "exemplary" is used to mean "used as an example, illustration, or description." Any embodiment described as "exemplary" in this application is not necessarily to be construed as being more preferred or advantageous than other embodiments. The following description is provided to enable any person skilled in the art to make and use this application. Details are set forth in the following description for purposes of explanation. It should be understood that those skilled in the art will recognize that this application can be made without using these specific details. In other instances, well-known structures and processes are not described in detail to avoid obscuring the description of this application with unnecessary detail. Therefore, this application is not intended to be limited to the embodiments shown, but is consistent with the broadest scope of the principles and features disclosed in this application.

[0053] It should be noted that since the method in this application embodiment is executed in a computer device, the processing objects of each computer device exist in the form of data or information, such as time, which is essentially time information. It is understood that if size, quantity, position, etc. are mentioned in subsequent embodiments, they are all corresponding data that exist so that the computer device can process them. Specific details will not be elaborated here.

[0054] This application provides an encrypted data synchronization method, apparatus, computer device, and storage medium, which will be described in detail below.

[0055] Please see Figure 1 , Figure 1 This is a schematic diagram of a scenario for an encrypted data synchronization system provided in an embodiment of this application. The encrypted data synchronization system may include a computer device 100, which integrates an encrypted data synchronization device, such as... Figure 1 Computer equipment in the country.

[0056] In this embodiment, the computer device 100 is mainly used to obtain operation statements for a first database; execute the operation statements on the first database to obtain first data information; process the first data information according to a preset digest algorithm to obtain first reference digest information; determine the data change information of the first database after executing the operation statements based on the first reference digest information; when the data change information matches preset benchmark information, process the first data information according to a preset encryption algorithm to obtain reference encryption information; execute the operation statements on the second database corresponding to the first database to obtain second data information; process the second database according to the second data information, the first reference digest information, and the reference encryption information to achieve data synchronization between the first database and the second database, which can avoid data synchronization anomalies caused by the failure of the second database to execute the operation statements, and improve the accuracy of data synchronization between the first database and the second database.

[0057] In this embodiment, the computer device 100 can be a standalone server, a server network, or a server cluster. For example, the computer device 100 described in this embodiment includes, but is not limited to, a computer, a network host, a single network server, a set of multiple network servers, or a cloud server composed of multiple servers. The cloud server is composed of a large number of computers or network servers based on cloud computing.

[0058] It is understood that the computer device 100 used in the embodiments of this application can be a device that includes both receiving and transmitting hardware, that is, a device having receiving and transmitting hardware capable of performing bidirectional communication on a bidirectional communication link. Such a device may include: cellular or other communication devices having a single-line display, a multi-line display, or a cellular or other communication device without a multi-line display. Specifically, the computer device 100 may be a desktop terminal or a mobile terminal, and may also be one of a mobile phone, tablet computer, laptop computer, etc.

[0059] Those skilled in the art will understand that Figure 1 The application environment shown is merely one application scenario of the solution in this application and does not constitute a limitation on the application scenario of the solution in this application. Other application environments may include those that are more specific to this application. Figure 1 The number of computer devices shown is more or less, for example Figure 1 Only one computer device is shown in the diagram. It is understood that the encrypted data synchronization system may also include one or more other services, which are not specified here.

[0060] In addition, such as Figure 1 As shown, the encryption-based data synchronization system may also include a memory 200 for storing data, such as operation statements of the first database, such as operation statement A, operation statement B, operation statement C, etc., and data information, such as first data information, second data information, third data information, fourth data information, etc.

[0061] It should be noted that, Figure 1 The schematic diagram of the encrypted data synchronization system shown is merely an example. The encrypted data synchronization system and scenario described in this application are for the purpose of more clearly illustrating the technical solutions of this application and do not constitute a limitation on the technical solutions provided in this application. As those skilled in the art will know, with the evolution of encrypted data synchronization systems and the emergence of new business scenarios, the technical solutions provided in this application are also applicable to similar technical problems.

[0062] First, this application provides an encryption-based data synchronization method. The execution subject of this encryption-based data synchronization method is an encryption-based data synchronization device applied to a computer device. The encryption-based data synchronization method includes: obtaining an operation statement for a first database; executing the operation statement on the first database to obtain first data information; processing the first data information according to a preset digest algorithm to obtain first reference digest information; determining data change information of the first database after executing the operation statement based on the first reference digest information; when the data change information matches preset benchmark information, processing the first data information according to a preset encryption algorithm to obtain reference encrypted information; executing the operation statement on a second database corresponding to the first database to obtain second data information; and processing the second database according to the second data information, the first reference digest information, and the reference encrypted information to achieve data synchronization between the first database and the second database.

[0063] like Figure 2 The diagram shown is a flowchart of an embodiment of the encrypted data synchronization method in this application. The encrypted data synchronization method includes:

[0064] S100, Obtain the operation statements for the first database.

[0065] Operation statements are database operation instructions initiated by the user to the first database. Operation statements include, but are not limited to, Structured Query Language (SQL) statements. Operation statements can include deletion operations, write operations, operations that overwrite data in the original database, moving data in the database, changing the data storage location, etc. After executing an operation statement on the first database, the data in the first database may or may not change. For example, after performing a deletion operation on some data in the first database, that data is removed from the first database; after moving some data in the first database, the position of that data in the first database may change, but the data in the first database remains unchanged. After receiving the operation statement for the first database from the user, the computer device retrieves the operation statement for subsequent steps to execute the operation statement on the first database and to synchronize the data between the first and second databases based on the operation statement.

[0066] S200: Execute the operation statement on the first database to obtain the first data information.

[0067] The first data information refers to the data information of the first database after executing operation statements on it. As mentioned in the preceding steps, the data in the first database may or may not change after executing operation statements on it. In this embodiment, after obtaining the operation statements for the first database, the operation statements are executed on the first database to obtain the first data information, so that data synchronization can be performed based on the first data information in subsequent steps.

[0068] In one specific embodiment, step S200 includes:

[0069] S210. Obtain the attribute field of each operation statement in the multiple operation statements, and determine the execution order of the multiple operation statements based on the attribute field;

[0070] S220. Execute the multiple operation statements on the first database according to the execution order to obtain the first data information.

[0071] The attribute fields of the operation statements include, but are not limited to, operation type, operation initiator, and operation keywords. The first database can contain one or more operation statements. When multiple operation statements are obtained, the attribute fields of each operation statement are further retrieved. Based on these attribute fields, the execution order of the multiple operation statements is determined. Then, the multiple operation statements are executed on the first database according to the execution order to obtain the first data information corresponding to each operation statement. For example, if the execution order of the multiple operation statements is determined to be operation statement A, operation statement B, and operation statement C based on the attribute fields of each operation statement, then when executing multiple operation statements on the first database, operation statement A is executed first to obtain first data information A, then operation statement B is executed to obtain first data information B, and finally operation statement C is executed to obtain first data information C.

[0072] In a specific implementation of this application, the attribute fields of the operation statements include operation type, operation initiator, and operation keyword. The correspondence between operation type and first score, operation initiator and second score, and operation keyword and third score can be pre-defined. For example, operation type A, operation type B, and operation type C correspond to score values ​​A, B, and C, respectively. After obtaining the attribute fields of the operation statements, the first score, second score, and third score corresponding to each operation statement can be determined based on the operation type, operation initiator, operation keyword, and the pre-defined correspondence. Then, the execution order of multiple operation statements is determined based on the first, second, and third scores. Specifically, when determining the execution order of multiple operation statements based on the first, second, and third scores, the total score corresponding to each operation statement can be determined based on the first, second, and third scores, and then the execution order of multiple operation statements is determined based on the total score corresponding to each operation statement. When determining the total score, you can sum the first, second, and third scores, or perform a weighted sum of the first, second, and third scores, or sum the first, second, and third scores and then average them, etc.

[0073] S300. The first data information is processed according to a preset digest algorithm to obtain the first reference digest information.

[0074] The first reference digest information is obtained by processing the first data information according to a preset digest algorithm. The preset digest algorithm includes, but is not limited to, Message Digest (MD) algorithm, Security Hash Algorithm (SHA) algorithm, and Message Authentication Code (MAC) algorithm. In this embodiment, after obtaining the first data information, it is processed according to the preset digest algorithm to obtain the first reference digest information, so that data synchronization can be performed based on the first reference digest information in subsequent steps.

[0075] S400. Based on the first reference digest information, determine the data change information of the first database after executing the operation statement.

[0076] Data change information is used to characterize the data change status of the first database after the execution of the operation statement. As mentioned in the preceding steps, after executing the operation statement on the first database, the data in the first database may or may not change. Considering that when the data in the first database does not change after executing the operation statement, the data in the first database and the second database are already in a synchronized state, and there is no need to synchronize the data in the first database and the second database, this embodiment, after obtaining the first reference digest information, determines the data change information of the first database after executing the operation statement based on the first reference digest information, so that data synchronization can be performed based on the data change information in subsequent steps.

[0077] In one specific embodiment, step S400 includes:

[0078] S410. Obtain fourth data information, wherein the fourth data information is the data information of the first database before the operation statement is executed on the first database;

[0079] S420. Process the fourth data information according to the digest algorithm to obtain the second reference digest information;

[0080] S430. Based on the first reference digest information and the second reference digest information, determine the data change information of the first database after executing the operation statement.

[0081] The fourth data information is the data information of the first database before the operation instruction is executed on the first database. The second reference digest information is the digest information obtained by processing the fourth data information according to a digest algorithm. The digest algorithm used to process the fourth data information is the same as the digest algorithm used to process the first data information. In this embodiment, when determining the data change information of the first database based on the first reference digest information, the fourth data information is first obtained, then processed according to the digest algorithm to obtain the second reference digest information, and finally the first and second reference digest information are compared. Based on the comparison result, the data change information of the first database after executing the operation statement is determined. For example, when the first and second reference digest information are inconsistent, the data change information is determined to be "data has changed"; when the first and second reference digest information are consistent, the data change information is determined to be "data has not changed".

[0082] S500: When the data change information matches the preset reference information, the first data information is processed according to the preset encryption algorithm to obtain reference encryption information.

[0083] The baseline information is a pre-set baseline state information used to measure the data change status of the first database after executing the operation statement. Based on the baseline information, the data change status of the first database after executing the operation statement can be determined. The reference encryption information is the encrypted information obtained by encrypting the second data information according to a preset encryption algorithm. The preset encryption algorithm includes, but is not limited to, RSA, Digital Signature Algorithm (DSA), and DSS algorithms. In this embodiment, after obtaining the data change information of the first database, the data change information is compared with the baseline information. When the data change information matches the preset baseline information, it indicates that the data in the first database has changed after executing the operation statement. Then, the first data information is processed according to the preset encryption algorithm to obtain the reference encryption information. Conversely, if the data change information does not match, it indicates that the data in the first database has not changed after executing the operation statement, and the data in the first and second databases are already in a synchronized state, so there is no need to continue synchronizing the data in the first and second databases. Here, "matching" means that the data change information is the same as the baseline information, or the data change information has a similar meaning to the baseline information. For example, the data change information is "data has changed," and the baseline information is "change," meaning the data change information matches the baseline information.

[0084] S600: Execute the operation statement on the second database corresponding to the first database to obtain the second data information.

[0085] In one implementation of this application, the first database can be a master database, and the second database corresponding to the first database can be a slave database of the first database. The second data information is the data information of the second database after an operation statement is executed on the second database. In this embodiment, the first data information is processed according to a preset encryption algorithm, and then an operation statement is executed on the second database corresponding to the first database to obtain the second data information, so that data synchronization can be performed based on the second data information and reference encryption information in subsequent steps.

[0086] In one specific embodiment, prior to step S600, the method further includes:

[0087] M610. Write the operation statement, the first reference digest information, and the reference encryption information into the binary log of the first database;

[0088] M620. Synchronize the operation statement, the first reference digest information, and the reference encryption information in the binary log to the target log file of the second database.

[0089] The binary log is a file that records the operation statements executed by the first database, and the target log file is a file that records the operation statements executed by the second database. In this embodiment, before executing operation statements on the second database corresponding to the first database, the operation statements, the first reference digest information, and the reference encryption information are written into the binary log of the first database. Then, the operation statements, the first reference digest information, and the reference encryption information in the binary log are synchronized to the target log file of the second database. Then, the operation statements are executed and the data is synchronized on the second database according to the operation statements, the first reference digest information, and the reference encryption information in the target log file. This can improve the real-time performance of data synchronization between the first database and the second database.

[0090] S700: The second database is processed according to the second data information, the first reference digest information and the reference encryption information to achieve data synchronization between the first database and the second database.

[0091] After obtaining the second data information, this embodiment processes the second database based on the second data information, the first reference digest information, and the reference encryption information. This enables data synchronization between the first and second databases, avoids data synchronization anomalies caused by the failure of the second database to execute operation statements, and improves the accuracy of data synchronization between the first and second databases.

[0092] In one specific embodiment, step S700 includes:

[0093] S710. Process the second data information according to the digest algorithm to obtain target digest information;

[0094] S720. Perform data processing on the second database based on the target digest information, the first reference digest information, and the reference encryption information.

[0095] The target digest information is a digest obtained by processing the third data information according to a preset digest algorithm. The digest algorithm used to generate the target digest information is the same as the digest algorithm used to generate the first reference digest information. In this embodiment, when processing the second database based on the second data information, the first reference digest information, and the reference encryption information, the second data information is first processed according to the digest algorithm to obtain the target digest information. Then, the second database is processed based on the target digest information, the first reference digest information, and the reference encryption information.

[0096] In one specific embodiment, step S720 includes:

[0097] S721. Compare the target summary information with the first reference summary information;

[0098] S722. When the target digest information is inconsistent with the first reference digest information, the second database is processed according to the reference encryption information.

[0099] In this embodiment, when processing data in the second database based on the target digest information, the first reference digest information, and the reference encryption information, the target digest information is compared with the first reference digest information. If the target digest information is inconsistent with the first reference digest information, it indicates that the second database failed to execute the operation statement in the target operation log, and there is a synchronization anomaly between the data in the first database and the second database. Then, the second database is processed based on the reference encryption information to achieve data synchronization between the first database and the second database.

[0100] In one specific embodiment, the step of processing the second database according to the reference encryption information in step S722 includes:

[0101] S7221. Process the reference encrypted information according to the decryption algorithm corresponding to the encryption algorithm to obtain third data information;

[0102] S7222. Based on the third data information, perform data processing on the second database.

[0103] In one specific implementation of this application, when processing data in the second database based on the reference encrypted information, the reference encrypted information is first processed using the decryption algorithm corresponding to the aforementioned encryption algorithm to obtain third data information. Then, data processing is performed on the second database based on the third data information to achieve data synchronization between the first and second databases. Specifically, when processing data in the second database based on the third data information, the third data information can be directly used to overwrite the data in the second database.

[0104] To better implement the encryption-based data synchronization method in the embodiments of this application, an encryption-based data synchronization device is also provided in the embodiments of this application, such as... Figure 3 As shown, the encryption-based data synchronization device 600 includes:

[0105] Data acquisition unit 601 is used to acquire operation statements from the first database;

[0106] The first execution unit 602 is used to execute the operation statement on the first database to obtain first data information;

[0107] The information processing unit 603 is used to process the first data information according to a preset digest algorithm to obtain the first reference digest information;

[0108] Information determination unit 604 is used to determine, based on the first reference digest information, the data change information of the first database after executing the operation statement;

[0109] The information encryption unit 605 is used to process the first data information according to a preset encryption algorithm to obtain reference encrypted information when the data change information matches the preset reference information.

[0110] The second execution unit 606 is used to execute the operation statement on the second database corresponding to the first database to obtain the second data information;

[0111] The data synchronization unit 607 is used to process the second database according to the second data information, the first reference digest information and the reference encryption information, so as to realize the data synchronization between the first database and the second database.

[0112] In this embodiment of the application, after executing the operation statement on the second database corresponding to the first database, the second database is processed according to the second data information, the first reference digest information and the reference encryption information. This can avoid data synchronization anomalies caused by the failure of the second database to execute the operation statement, and improve the accuracy of data synchronization between the first database and the second database.

[0113] In some embodiments of this application, the first execution unit 602 is specifically used for:

[0114] Obtain the attribute fields of each of the multiple operation statements, and determine the execution order of the multiple operation statements based on the attribute fields;

[0115] The plurality of operation statements are executed on the first database according to the execution order to obtain the first data information.

[0116] In some embodiments of this application, the information determination unit 604 is specifically used for:

[0117] Obtain fourth data information, which is the data information of the first database before the operation statement is executed on the first database;

[0118] The fourth data information is processed according to the digest algorithm to obtain the second reference digest information;

[0119] Based on the first reference digest information and the second reference digest information, determine the data change information of the first database after executing the operation statement.

[0120] In some embodiments of this application, the data synchronization unit 607 is specifically used for:

[0121] The second data information is processed according to the aforementioned digest algorithm to obtain the target digest information;

[0122] The second database is processed based on the target digest information, the first reference digest information, and the reference encryption information.

[0123] In some embodiments of this application, the data synchronization unit 607 is further configured to:

[0124] The target summary information is compared with the first reference summary information;

[0125] When the target digest information is inconsistent with the first reference digest information, the second database is processed according to the reference encryption information.

[0126] In some embodiments of this application, the data synchronization unit 607 is further configured to:

[0127] The reference encrypted information is processed according to the decryption algorithm corresponding to the encryption algorithm to obtain the third data information;

[0128] Based on the third data information, the second database is processed.

[0129] In some embodiments of this application, the encryption-based data synchronization device 600 further includes:

[0130] An information recording unit is used to write the operation statement, the first reference digest information, and the reference encryption information into the binary log of the first database;

[0131] The information synchronization unit is used to synchronize the operation statement, the first reference digest information and the reference encryption information in the binary log to the target log file of the second database.

[0132] This application also provides a computer device that integrates any of the encryption-based data synchronization devices provided in this application, the computer device comprising:

[0133] One or more processors;

[0134] Memory; and

[0135] One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the processor in the steps of the encrypted data synchronization method described in any of the embodiments of the encrypted data synchronization method described above.

[0136] This application also provides a computer device that integrates any of the encryption-based data synchronization devices provided in this application. For example... Figure 4 As shown, it illustrates a structural schematic diagram of the computer device involved in the embodiments of this application, specifically:

[0137] The computer device may include components such as a processor 701 with one or more processing cores, a memory 702 with one or more computer-readable storage media, a power supply 703, and an input unit 704. Those skilled in the art will understand that... Figure 4 The computer device structure shown does not constitute a limitation on the computer device and may include more or fewer components than shown, or combine certain components, or have different component arrangements. Wherein:

[0138] The processor 701 is the control center of the computer device. It connects various parts of the computer device via various interfaces and lines. By running or executing software programs and / or modules stored in the memory 702, and by calling data stored in the memory 702, it performs various functions of the computer device and processes data, thereby providing overall monitoring of the computer device. Optionally, the processor 701 may include one or more processing cores; preferably, the processor 701 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processor 701.

[0139] The memory 702 can be used to store software programs and modules. The processor 701 executes various functional applications and data processing by running the software programs and modules stored in the memory 702. The memory 702 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, application programs required for at least one function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 702 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory 702 may also include a memory controller to provide the processor 701 with access to the memory 702.

[0140] The computer device also includes a power supply 703 that supplies power to the various components. Preferably, the power supply 703 can be logically connected to the processor 701 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. The power supply 703 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.

[0141] The computer device may also include an input unit 704, which can be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.

[0142] Although not shown, the computer device may also include a display unit, etc., which will not be described in detail here. Specifically, in this embodiment, the processor 701 in the computer device loads the executable files corresponding to the processes of one or more application programs into the memory 702 according to the following instructions, and the processor 701 runs the application programs stored in the memory 702 to realize various functions, as follows:

[0143] Retrieve the operation statements from the first database;

[0144] The operation statement is executed on the first database to obtain the first data information;

[0145] The first data information is processed according to a preset digest algorithm to obtain the first reference digest information;

[0146] Based on the first reference digest information, determine the data change information of the first database after executing the operation statement;

[0147] When the data change information matches the preset benchmark information, the first data information is processed according to the preset encryption algorithm to obtain reference encrypted information;

[0148] The operation statement is executed on the second database corresponding to the first database to obtain the second data information;

[0149] The second database is processed based on the second data information, the first reference digest information, and the reference encryption information to achieve data synchronization between the first database and the second database.

[0150] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by instructions, or by instructions controlling related hardware. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.

[0151] Therefore, embodiments of this application provide a computer-readable storage medium, which may include: read-only memory (ROM), random access memory (RAM), a disk, or an optical disk, etc. A computer program is stored thereon, which is loaded by a processor to execute the steps of any of the encryption-based data synchronization methods provided in embodiments of this application. For example, the computer program loaded by the processor can execute the following steps:

[0152] Retrieve the operation statements from the first database;

[0153] The operation statement is executed on the first database to obtain the first data information;

[0154] The first data information is processed according to a preset digest algorithm to obtain the first reference digest information;

[0155] Based on the first reference digest information, determine the data change information of the first database after executing the operation statement;

[0156] When the data change information matches the preset benchmark information, the first data information is processed according to the preset encryption algorithm to obtain reference encrypted information;

[0157] The operation statement is executed on the second database corresponding to the first database to obtain the second data information;

[0158] The second database is processed based on the second data information, the first reference digest information, and the reference encryption information to achieve data synchronization between the first database and the second database.

[0159] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the detailed descriptions of other embodiments above, which will not be repeated here.

[0160] In practice, each of the above units or structures can be implemented as an independent entity or can be arbitrarily combined to be implemented as the same or several entities. For the specific implementation of each of the above units or structures, please refer to the previous method embodiments, which will not be repeated here.

[0161] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.

[0162] The above provides a detailed description of an encryption-based data synchronization method, apparatus, computer device, and storage medium provided in the embodiments of this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A data synchronization method based on encryption, characterized in that, include: Retrieve the operation statements from the first database; The operation statement is executed on the first database to obtain the first data information; The first data information is processed according to a preset digest algorithm to obtain the first reference digest information; Based on the first reference digest information, determine the data change information of the first database after executing the operation statement; When the data change information matches the preset benchmark information, the first data information is processed according to the preset encryption algorithm to obtain reference encrypted information; The operation statement is executed on the second database corresponding to the first database to obtain the second data information; The second database is processed according to the second data information, the first reference digest information and the reference encryption information to achieve data synchronization between the first database and the second database; Specifically, the operation statement, the first reference digest information, and the reference encryption information are recorded in a log file for use when processing data in the second database; when the operation statement includes multiple operation statements, the attribute fields of each operation statement are obtained, and the execution order of each operation statement is determined according to the attribute fields.

2. The encryption-based data synchronization method according to claim 1, characterized in that, The step of processing the second database based on the second data information, the first reference digest information, and the reference encryption information includes: The second data information is processed according to the aforementioned digest algorithm to obtain the target digest information; The second database is processed based on the target digest information, the first reference digest information, and the reference encryption information.

3. The encryption-based data synchronization method according to claim 2, characterized in that, The step of processing the second database based on the target digest information, the first reference digest information, and the reference encryption information includes: The target summary information is compared with the first reference summary information; When the target digest information is inconsistent with the first reference digest information, the second database is processed according to the reference encryption information.

4. The encryption-based data synchronization method according to claim 3, characterized in that, The step of processing the second database according to the reference encryption information includes: The reference encrypted information is processed according to the decryption algorithm corresponding to the encryption algorithm to obtain the third data information; Based on the third data information, the second database is processed.

5. The encryption-based data synchronization method according to claim 1, characterized in that, The step of determining the data change information of the first database after executing the operation statement based on the first reference digest information includes: Obtain fourth data information, which is the data information of the first database before the operation statement is executed on the first database; The fourth data information is processed according to the digest algorithm to obtain the second reference digest information; Based on the first reference digest information and the second reference digest information, determine the data change information of the first database after executing the operation statement.

6. The encryption-based data synchronization method according to claim 1, characterized in that, Before executing the operation statement on the second database corresponding to the first database to obtain the second data information, the method further includes: Write the operation statement, the first reference digest information, and the reference encryption information into the binary log of the first database; The operation statements, the first reference digest information, and the reference encryption information in the binary log are synchronized to the target log file of the second database.

7. The encryption-based data synchronization method according to claim 1, characterized in that, The operation statement includes multiple statements. Executing the operation statement on the first database to obtain first data information further includes executing the multiple operation statements on the first database according to the execution order to obtain the first data information. The attribute fields include at least one of operation type, operation initiator, and operation keyword; determining the execution order of the multiple operation statements based on the attribute fields includes: determining the score corresponding to each operation statement based on a pre-set correspondence between attribute fields and scores, and determining the execution order based on the total score corresponding to each operation statement.

8. A data synchronization device based on encryption, characterized in that, include: The data acquisition unit is used to acquire operation statements from the first database; The first execution unit is configured to execute the operation statement on the first database to obtain first data information; An information processing unit is used to process the first data information according to a preset digest algorithm to obtain first reference digest information; An information determination unit is configured to determine, based on the first reference digest information, the data change information of the first database after executing the operation statement; An information encryption unit is used to process the first data information according to a preset encryption algorithm to obtain reference encrypted information when the data change information matches the preset reference information. The second execution unit is used to execute the operation statement on the second database corresponding to the first database to obtain the second data information; A data synchronization unit is used to process the second database according to the second data information, the first reference digest information and the reference encryption information, so as to realize data synchronization between the first database and the second database. The information recording unit is used to record the operation statement, the first reference digest information and the reference encryption information to a log file for use when processing data in the second database; The sequence determination unit is used to obtain the attribute fields of each operation statement when the operation statement includes multiple operation statements, and determine the execution order of each operation statement according to the attribute fields.

9. A computer device, characterized in that, The computer device includes: One or more processors; Memory; and One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the processor to implement the steps of the encryption-based data synchronization method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, It stores a computer program, which is loaded by a processor to perform the steps of the encryption-based data synchronization method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Method for monitoring database, management system and storage medium

    CN111723146A

  • Remote data synchronization method and device thereof, equipment and storage medium

    CN114036233A