Data synchronization method, apparatus, device, and storage medium
By leveraging the interaction and encryption of the central service component and the synchronization service component in cross-cloud scenarios, the challenge of cross-cloud database data synchronization is solved, achieving data consistency and security, improving service quality and response speed, and reducing dependence on cloud vendor services.
Patent Information
- Application Number
- CN202411111672.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-13
- Publication Date
- 2026-08-25
- Estimated Expiration
- 2044-08-13
AI Technical Summary
In cross-cloud scenarios, traditional master-slave synchronization methods cannot effectively synchronize data from different cloud databases, and the data synchronization process is vulnerable to attacks or leaks, resulting in limited service quality and response speed. Furthermore, excessive reliance on cloud vendor services leads to high coupling.
By interacting with the central service component of the source database and the synchronization service component of the target database, data synchronization is achieved by encrypting the synchronization data using the task public key, and only the database component is exposed instead of the port in cross-cloud scenarios, thus ensuring data consistency and security and reducing dependence on cloud vendor services.
It enables data synchronization across cloud scenarios, ensuring data consistency and security, improving service quality and response speed globally, and reducing coupling with cloud vendor services.
Smart Images

Figure CN119166713B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a data synchronization method, apparatus, device, and storage medium. Background Technology
[0002] With the rapid development of cloud computing technology, an increasing number of cloud databases are emerging to provide more flexible data storage and backup solutions. Currently, more and more enterprises are choosing to store their data in cloud databases to better meet their business needs. Therefore, in order to fully utilize the resources and advantages of different locations and improve service quality and response speed globally, using different cloud databases as data centers at different nodes around the world is particularly important.
[0003] However, using multiple cloud databases for data storage also brings some problems, the most important of which is the challenge of data synchronization. First, due to differences in network environment, architecture, and security mechanisms among the cloud vendors associated with different cloud databases, traditional master-slave synchronization methods are no longer adequate for data synchronization tasks in cross-cloud scenarios. Second, the different security mechanisms and protocols of the cloud vendors associated with different cloud databases make the data synchronization process vulnerable to attacks or leaks. Furthermore, one should not overly rely on the functions provided by the cloud vendors associated with the cloud databases; business operations should reduce their coupling with cloud vendor services.
[0004] Therefore, how to achieve data synchronization of cloud databases in cross-cloud scenarios, fully utilize the resources and advantages of different cloud databases, and improve service quality and response speed globally is a key challenge. Summary of the Invention
[0005] This application provides a data synchronization method, apparatus, device, and storage medium to achieve data synchronization of cloud databases in cross-cloud scenarios, so as to make full use of the resources and advantages of different cloud databases and improve service quality and response speed globally.
[0006] In a first aspect, embodiments of this application provide a data synchronization method applied to a central service component of a source database, the method comprising:
[0007] Receive synchronization requests sent by the synchronization service component of the target database for the data synchronization task; wherein, the synchronization request carries a synchronization field for indicating the starting query position and the number of query data rows for determining the ending query position;
[0008] Based on the synchronization field, retrieve synchronized data from the source data table that matches the number of data records queried;
[0009] The synchronized data is encrypted using the task's public key, and the encrypted data is returned to the synchronization service component.
[0010] Secondly, embodiments of this application provide a data synchronization method applied to a synchronization service component of a target database, the method comprising:
[0011] For data synchronization tasks, a synchronization request is sent to the central service component of the source database; the synchronization request carries a synchronization field to indicate the starting query position and the number of query data rows to determine the ending query position.
[0012] Receive encrypted data returned by the central service component; the encrypted data is obtained by the central service component through encrypting the synchronization data obtained from the source data table based on the synchronization field, which matches the number of data records queried, using the task public key;
[0013] The encrypted data is decrypted using the task's private key, and the resulting synchronized data is stored in the target database.
[0014] Thirdly, embodiments of this application provide a data synchronization device applied to a central service component of a source database, the device comprising:
[0015] The first receiving module is used to receive a synchronization request sent by the synchronization service component of the target database for the data synchronization task; wherein, the synchronization request carries a synchronization field for indicating the starting query position and the number of query data rows for determining the ending query position.
[0016] The acquisition module is used to retrieve synchronized data from the source data table that matches the number of data records queried, based on the synchronization field.
[0017] The return module is used to encrypt the synchronization data using the task's public key and return the encrypted data to the synchronization service component.
[0018] Fourthly, embodiments of this application provide a data synchronization apparatus for a synchronization service component applied to a target database. The apparatus includes:
[0019] The sending module is used to send a synchronization request to the central service component of the source database for a data synchronization task; the synchronization request carries a synchronization field to indicate the starting query position and the number of query data rows to determine the ending query position.
[0020] The second receiving module is used to receive encrypted data returned by the central service component. The encrypted data is obtained by the central service component through encrypting the synchronization data obtained from the source data table based on the synchronization field, which matches the number of query data records, using the task public key.
[0021] The data storage module is used to decrypt encrypted data using the task's private key and store the obtained synchronized data into the target database.
[0022] Fifthly, embodiments of this application provide an electronic device, including: a memory and a processor, wherein the memory is used to store a computer program; and the processor is used to execute the computer program to implement the steps of the data synchronization method provided in embodiments of this application.
[0023] Sixthly, embodiments of this application provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the data synchronization method provided in embodiments of this application.
[0024] In a seventh aspect, embodiments of this application provide a computer program product, which includes a computer program stored in a computer-readable storage medium; when the processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, causing the electronic device to perform the steps of the data synchronization method provided in embodiments of this application.
[0025] The beneficial effects of this application are as follows:
[0026] This application provides a data synchronization method, apparatus, device, and storage medium. In this application embodiment, the central service component of the source database interacts with the synchronization service component of the target database to achieve data synchronization of cloud databases in a cross-cloud scenario, ensuring data consistency, so as to make full use of the resources and advantages of different cloud databases and improve service quality and response speed globally. Specifically, the central service component receives synchronization requests sent by the synchronization service component for data synchronization tasks. These requests carry a synchronization field indicating the starting query position and the number of query data rows to determine the ending query position. Based on the synchronization field, the central service component retrieves synchronization data from the source data table that matches the number of query data rows, ensuring the accuracy of the synchronized data. Furthermore, the central service component encrypts the synchronization data using the task's public key and returns the encrypted data to the synchronization service component. Encryption of the synchronization data during the synchronization process ensures data security, prevents data loss and leakage, and guarantees the security of business data. Simultaneously, in cross-cloud scenarios, it is not necessary to expose the database port to the public network; only the database components (such as the central service component of the source database and the synchronization service component of the target database) need to be exposed. This avoids excessive reliance on the functions provided by cloud vendors associated with the cloud database and reduces the coupling between the business and cloud vendor services. Attached Figure Description
[0027] 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.
[0028] Figure 1 This is a schematic diagram of an application scenario provided by an embodiment of this application;
[0029] Figure 2 A data synchronization system architecture diagram provided in this application embodiment;
[0030] Figure 3 An interactive flowchart for data synchronization provided in an embodiment of this application;
[0031] Figure 4 This application provides a schematic diagram illustrating the timing of a data synchronization task startup in an embodiment.
[0032] Figure 5 This is a schematic diagram illustrating the timing of another data synchronization task startup provided in an embodiment of this application.
[0033] Figure 6 A detailed flowchart of a data interaction provided in an embodiment of this application;
[0034] Figure 7 A detailed flowchart illustrating another data interaction method provided in this application embodiment;
[0035] Figure 8 A structural diagram of a source data table provided in an embodiment of this application;
[0036] Figure 9 A schematic diagram illustrating the generation of a public / private key pair for a data synchronization task, provided as an embodiment of this application;
[0037] Figure 10 A schematic diagram illustrating a security verification process for a central service component and a synchronization service component, provided as an embodiment of this application.
[0038] Figure 11 A flowchart illustrating a method for performing data synchronization by a central service component, as provided in this application embodiment;
[0039] Figure 12 A flowchart illustrating a method for performing data synchronization using a synchronization service component, as provided in this application embodiment;
[0040] Figure 13 A structural diagram of a data synchronization device provided in an embodiment of this application;
[0041] Figure 14 This is a structural diagram of another data synchronization device provided in an embodiment of this application;
[0042] Figure 15 This is a structural diagram of an electronic device provided in an embodiment of this application. Detailed Implementation
[0043] To make the objectives, technical solutions, and beneficial effects of this application clearer, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the 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.
[0044] The word “exemplary” as used below means “serving as an example, embodiment, or illustration.” Any embodiment illustrated as an “exemplary” need not be construed as superior to or better than other embodiments.
[0045] The terms "first" and "second" used in this document are for descriptive purposes only and should not be construed as indicating relative importance or implying the number of technical features indicated. Therefore, features defined as "first" or "second" may explicitly or implicitly include one or more features. In the description of the embodiments of this application, unless otherwise stated, "multiple" means two or more.
[0046] The design concept of the embodiments of this application is briefly described below:
[0047] With the rapid development of cloud computing technology, an increasing number of cloud databases are emerging to provide more flexible data storage and backup solutions. Currently, more and more enterprises are choosing to store their data in cloud databases to better meet their business needs. Therefore, in order to fully utilize the resources and advantages of different locations and improve service quality and response speed globally, using different cloud databases as data centers at different nodes around the world is particularly important.
[0048] However, using multiple cloud databases for data storage also brings some problems, the most important of which is the challenge of data synchronization. First, due to differences in network environment, architecture, and security mechanisms among the cloud vendors associated with different cloud databases, traditional master-slave synchronization methods are no longer adequate for data synchronization tasks in cross-cloud scenarios. Second, the different security mechanisms and protocols of the cloud vendors associated with different cloud databases make the data synchronization process vulnerable to attacks or leaks. Furthermore, one should not overly rely on the functions provided by the cloud vendors associated with the cloud databases; business operations should reduce their coupling with cloud vendor services.
[0049] In view of this, embodiments of this application provide a data synchronization method, apparatus, device, and storage medium to achieve data synchronization of cloud databases in cross-cloud scenarios, ensuring data consistency and fully utilizing the resources and advantages of different cloud databases to improve service quality and response speed globally. Simultaneously, during data synchronization, the synchronized data is encrypted, and a heartbeat check is maintained between the central service component of the source database and the synchronization service component of the target database. This prevents forged synchronization service components from obtaining data from the central service component, ensuring data security, preventing data loss and leakage, and guaranteeing the security of business data. Furthermore, in cross-cloud scenarios, it is not necessary to expose the database port to the public network; only the database components (such as the central service component of the source database and the synchronization service component of the target database) need to be exposed, avoiding excessive reliance on the functions provided by cloud vendors associated with the cloud database and reducing the coupling between the business and cloud vendor services.
[0050] The application scenarios described below are briefly explained. It should be noted that these scenarios are for illustrative purposes only and are not intended to limit the scope of this application. In actual implementation, the technical solutions provided by the embodiments of this application can be flexibly applied according to actual needs.
[0051] See Figure 1 , Figure 1 This application provides an example of an application scenario, which includes a source database 110 and a target database 120.
[0052] In one possible implementation, the source database 110 and the target database 120 can be connected via a communication network. The communication network can be a wired network or a wireless network. Therefore, the source database 110 and the target database 120 can be directly or indirectly connected via wired or wireless communication. For example, the source database 110 can be indirectly connected to the target database 120 via a wireless access point, or the source database 110 can be directly connected to the target database 120 via the Internet; this application does not impose any limitations on this.
[0053] The source database 110 and the target database 120 can be physical servers, server clusters or distributed systems composed of multiple physical servers, or cloud servers that provide basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms.
[0054] To further illustrate the data synchronization technical solution provided in the embodiments of this application, the following describes the implementation of the data synchronization provided in the exemplary embodiments of this application in conjunction with the accompanying drawings.
[0055] See Figure 2 , Figure 2 This application provides a data synchronization system architecture diagram, which includes a source database 110 and a target database 120. A central service component 1101 is deployed on the source database 110, responsible for data transmission and security assurance. A synchronization service component 1201 is deployed on the target database 120, responsible for making data synchronization requests and storing the requested synchronized data in the target database. Furthermore, in this application embodiment, to reduce reliance on cloud vendor functions and lower coupling with cloud vendor services, in cross-cloud scenarios, it is not necessary to expose the database port to the public network; only the database service components need to be exposed, namely, the central service component of the source database and the synchronization service component of the target database.
[0056] based on Figure 2 The data synchronization system shown in this application provides a data synchronization method, see below. Figure 3 , Figure 3 An interactive flowchart for data synchronization provided in this application embodiment includes the following steps:
[0057] In step S300, the synchronization service component sends a synchronization request to the central service component of the source database for the data synchronization task; wherein the synchronization request carries a synchronization field for indicating the starting query position and the number of query data rows for determining the ending query position.
[0058] In this embodiment of the application, in order to ensure that no data is lost, the synchronization service component starts the data synchronization task in the form of a scheduled task. After starting the data synchronization task, it recursively sends synchronization requests to the midline service component of the source database in sequence until all data of the data synchronization task in the source data table is synchronized, and then the data synchronization task ends.
[0059] In one possible implementation, a detection time interval for the data synchronization task is set, and the start time of the data synchronization task is determined based on the set detection time interval. Taking a detection time interval of 30 minutes as an example, the system checks whether the data synchronization task has ended every 30 minutes. If the data synchronization task has ended, a new data synchronization task is started. If the data synchronization task has not ended, the current data synchronization task continues to be executed until the data synchronization task ends, at which point a new data synchronization task is started.
[0060] For example, see Figure 4 , Figure 4 This is a time-based schematic diagram of a data synchronization task startup provided in an embodiment of this application. Assuming that data synchronization task 1 is started at time T1 for data synchronization, if data synchronization task 1 ends before time T2, then data synchronization task 2 is started at time T2. Similarly, if data synchronization task 2 ends before time T3, then data synchronization task 3 is started at time T3. Here, time T1 to time T2 is a detection time interval, and time T2 to time T3 is a detection time interval.
[0061] Another example, see Figure 5 , Figure 5 This is a schematic diagram illustrating the timing of another data synchronization task startup provided in an embodiment of this application. Assume that data synchronization task 1 is started at time T1 for data synchronization. If data synchronization task 1 has not ended at time T2, then data synchronization task 1 continues to be executed at time T2, and at time T3, it continues to check whether data synchronization task 1 has ended. If data synchronization task 1 has ended, then data synchronization task 2 is started at time T3; otherwise, data synchronization task 1 continues to be executed. Figure 4 Let's take the example of data synchronization task 1 ending at time T3 to illustrate this.
[0062] In another example, suppose data synchronization task 1 is started at time T1 to perform data synchronization, but fails before time T2. In this case, data synchronization task 1 is immediately terminated and restarted at time T2.
[0063] In this embodiment of the application, in order to ensure that complete synchronization data can be obtained for the data synchronization task and to ensure the consistency of data synchronization, at least one synchronization request is sent within a data synchronization task, and each synchronization request carries the synchronization fields MAX_ID (latest identifier) and MAX_LAST_UPD (latest time) used to indicate the starting query position, as well as the number of data records to be queried STEP used to determine the terminal query position; for example, in the first synchronization request message, the synchronization fields can be set to MAX_ID=1, MAX_LAST_UPD=2028-01-0100:00:00, and STEP=100, which means that starting from the record data table with MAX_ID=1, 100 synchronization data records will be queried and obtained from the starting position of MAX_LAST_UPD=2028-01-0100:00:00.
[0064] In one possible implementation, the synchronization field is determined as follows:
[0065] If the synchronization request is the initial request for a data synchronization task, then the synchronization fields are the initially set ones;
[0066] If the synchronization request is a non-initial request of the data synchronization task, and the data synchronization of the previous synchronization request was successful, then the synchronization field is determined based on the synchronization data queried in the previous synchronization request.
[0067] If the synchronization request is a non-initial request of the data synchronization task, and the data synchronization of the previous synchronization request failed, then the synchronization field is the synchronization field carried in the previous synchronization request.
[0068] It should be noted that for cases where the synchronization request is not the initial request for a data synchronization task, the specific implementation method for determining the synchronization field can be found in the following content, which will not be elaborated here.
[0069] In step S301, the central service component receives the synchronization request sent by the synchronization service component for the data synchronization task, and obtains the synchronization data that matches the number of data records queried from the source data table based on the synchronization field.
[0070] In this embodiment of the application, when the central service component receives a synchronization request and retrieves the synchronization data based on the synchronization field and the number of data records queried, it can adopt the following two implementation methods:
[0071] Method 1: The source data table is stored in the source database. After receiving a synchronization request, the central service component sends a request to the source database. The source database, combining the synchronization fields and the number of data rows to be queried, retrieves the synchronized data from the source data table. See the example below. Figure 6 , Figure 6 A specific flowchart of data interaction provided for an embodiment of this application includes the following steps:
[0072] In step S600, the synchronization service component sends a synchronization request to the central service component of the source database for the data synchronization task; wherein, the synchronization request carries a synchronization field for indicating the starting query position and the number of query data rows for determining the ending query position.
[0073] In step S601, after receiving the synchronization request sent by the synchronization service component for the data synchronization task, the central service component sends a data request to the source database. The data request carries a synchronization field to indicate the starting query position and the number of query data records to determine the ending query position.
[0074] Step S602: After receiving the data request, the source database retrieves the synchronized data from the source data table by combining the synchronization fields and the number of data rows queried.
[0075] In step S603, the source database returns the acquired synchronization data to the central service component;
[0076] Step S604: The central service component encrypts the synchronization data using the task public key;
[0077] In step S605, the central service component returns the obtained encrypted data to the synchronization service component;
[0078] In step S606, the synchronization service component receives the encrypted data returned by the central service component, decrypts the encrypted data using the task private key, and obtains the synchronization data.
[0079] In step S607, the synchronization service component stores the obtained synchronization data into the target database.
[0080] from Figure 6 As can be seen, after receiving a synchronization request, the central service component queries the source data table in the source database to obtain the synchronization data. In this approach, the central service component requests synchronization data from the source database for each synchronization request it receives.
[0081] Method 2: The source data table is stored in the source database. Before obtaining the synchronized data, the central service component retrieves the source data table from the source database, and then combines the synchronized fields and the number of data rows queried to obtain the synchronized data from the source data table. For an example, see... Figure 7 , Figure 7 Another specific flowchart of data interaction provided in this application embodiment includes the following steps:
[0082] In step S700, the synchronization service component sends an initial synchronization request to the central service component of the source database for the data synchronization task; wherein, the initial synchronization request carries a synchronization field for indicating the starting query position and the number of query data rows for determining the ending query position.
[0083] Step S701: After receiving the synchronization request sent by the synchronization service component for the data synchronization task, the central service component sends a data table retrieval request to the source database.
[0084] In step S702, after receiving the data table retrieval request, the source database returns the source data table to the central service component;
[0085] Step S703: The central service component retrieves synchronized data from the source data table that matches the number of data records queried, based on the synchronization field.
[0086] Step S704: The central service component determines the synchronization field to be used in the next synchronization request based on the queried synchronization field.
[0087] Step S705: The central service component encrypts the synchronization data and the synchronization field used in the next synchronization request using the task public key;
[0088] In step S706, the central service component returns the obtained encrypted data to the synchronization service component;
[0089] In step S707, the synchronization service component receives the encrypted data returned by the central service component, decrypts the encrypted data using the task private key, and obtains the synchronization data.
[0090] Step S708: The synchronization service component stores the obtained synchronization data into the target database;
[0091] Step S709: The synchronization service component sends a synchronization request to the central service component, the synchronization request carrying the synchronization field obtained from the encrypted data;
[0092] In step S710, the central service component repeats steps S703-S706.
[0093] from Figure 7 As can be seen, after receiving the initial synchronization request for the data synchronization task, the central service component sends a request to the source database to obtain the source data table. Then, it retrieves the synchronized data from the source data table by combining the synchronization fields and the number of data rows to be queried. In this method, when the central service component retrieves synchronization data for different synchronization requests of the same data synchronization task, it can directly query the obtained source data table. It should be noted that... Figure 7 The example shown is requesting the source data table from the source database, which is only one possible method. In other cases, the source database can request the source data table before receiving the synchronization request, but this will not be repeated here.
[0094] In this embodiment of the application, the process of querying synchronized data from the source data table can be represented as follows:
[0095] SELECT * FROM SOURCE_TABLE (Select from source table)
[0096] WHERE (from...where)
[0097] (UPDATE_TIME = #{MAX_LAST_UPD}) AND ID > #{MAX_ID})(Query time = MAX_LAST_UPD, Query ID > MAX_ID)
[0098] OR UPDATE_TIME>#{MAX_LAST_UPD}(query time>MAX_LAST_UPD)
[0099] ORDER BY ID DESC (Retrieve data by identifier)
[0100] The structure of the source data table during the data query process can be found in [reference needed]. Figure 8 As shown.
[0101] In this embodiment, to ensure the accuracy of the next data query, after retrieving synchronized data from the source data table, the synchronization field to be used in the next synchronization request query is determined based on the location of the retrieved synchronized data in the source data table, and the synchronization field is returned to the synchronization service component along with the retrieved synchronized data; for example, see [link to relevant documentation]. Figure 7 ,from Figure 7 As can be seen, after the central service component retrieves the synchronization data from the source data table based on the synchronization field in the synchronization request, it determines the synchronization field to be used in the next synchronization request and returns the synchronization data to the synchronization service component. This allows the synchronization service component to use the synchronization field returned by the central service component when it retrieves synchronization data from the central service component again. Subsequent requests are recursively called until all data matching the data synchronization task in the source data table has been sent. At this point, an end flag is returned to the synchronization service component to indicate the end of the task.
[0102] In step S302, the central service component encrypts the synchronization data using the task public key.
[0103] In step S303, the central service component returns the obtained encrypted data to the synchronization service component.
[0104] In step S304, the synchronization service component receives the encrypted data returned by the central service component, decrypts the encrypted data using the task private key, and obtains the synchronization data.
[0105] In step S305, the synchronization service component stores the obtained synchronization data into the target database.
[0106] In one possible implementation, when the synchronization request successfully obtains the synchronization data, the synchronization service component will return the synchronization fields MAX_ID and MAX_LAST_UPD along with the synchronization data and store them in the synchronization task table to record the synchronization fields and mark the data synchronization task status as successful; when the end identifier is found, the synchronization service component will return the synchronization field record along with the synchronization data obtained at the end and mark the data synchronization task status as task end.
[0107] In one possible implementation, when an abnormal situation such as network fluctuation causes the data synchronization task to fail, the synchronization task table records the synchronization fields MAX_ID and MAX_LAST_UPD carried in the failed synchronization request, and marks the data synchronization task status as synchronization failure. When the next task starts, the synchronization field of the latest failed execution is used to make the synchronization request.
[0108] It should be noted that if the data synchronization task fails to execute successfully after exceeding the set number of attempts (e.g., three times), an alarm message will be sent to notify the responsible person via email.
[0109] In this embodiment of the application, in order to ensure that the synchronization service component can successfully obtain synchronization data from the central service component, and in order to ensure the security of data synchronization during the data synchronization task, the synchronization service component needs to register with the central service component. Before making a synchronization data request, the central service component needs to verify the synchronization service component and determine the task public and private key pair used in the data synchronization process. That is, the task public key is used to encrypt the synchronization data, and the task private key is used to decrypt and obtain the synchronization data.
[0110] For details, see Figure 9 , Figure 9 This application provides a schematic diagram of generating a public-private key pair for a data synchronization task, including the process of the synchronization service component registering with the central service component. Figure 9 Includes the following steps:
[0111] In step S900, the synchronization service component sends a registration request to the central service component, and the registration request carries registration information.
[0112] The registration request is sent to the central service component after the synchronization service component goes online;
[0113] The registration information includes: the registration name N1 of the synchronization service component and the registration hardware fingerprint M1. The registration hardware fingerprint M1 includes information such as the CPU unique identifier, memory serial number, and hard drive serial number; that is, the registration hardware fingerprint M1 is obtained by concatenating the CPU unique identifier, memory serial number, and hard drive serial number. Alternatively,
[0114] The registration information includes: the registration name N1 and the registration hardware fingerprint M1 based on the synchronization service component, combined with the registration identifier RegisterID determined by the hash algorithm; specifically, RegisterID = SHA256(M1+N1).
[0115] Step S901: After the central service component successfully registers the synchronization service component based on the registration information, it generates a service public key S1 and a service private key P1.
[0116] It should be noted that the central service component registers with the synchronization service component, that is, the registration information of the synchronization service component is recorded in the central service component; and the public and private key pairs for the service can be generated using algorithms such as RSA encryption and elliptic curve encryption.
[0117] In step S902, the central service component returns the service private key P1 to the synchronization service component.
[0118] In step S903, the synchronization service component sends a verification request to the central service component. The verification request includes at least the service identifier ServerID, which is determined based on the service name N1' and the service hardware fingerprint M1' of the synchronization service component.
[0119] The service hardware fingerprint M1' includes information such as the CPU unique identifier, memory, and hard disk serial number. In other words, the service hardware fingerprint M1' is obtained by concatenating information such as the CPU unique identifier, memory, and hard disk serial number. ServerID = SHA256(M1'+N1').
[0120] In step S904, the central service component verifies the service identifier based on the registration information pre-sent by the synchronization service component.
[0121] In one possible implementation, when verifying the service identifier based on registration information:
[0122] If the registration information includes the registration name of the synchronization service component and the registration hardware fingerprint, a registration identifier is first generated based on the registration name and the registration hardware fingerprint using a hash algorithm. Then, the registration identifier is matched with the service identifier. If the match is successful, the verification is considered successful; otherwise, the verification is considered unsuccessful.
[0123] If the registration information includes a registration identifier determined by combining the registration name and the registration hardware fingerprint with a hash algorithm, then the registration identifier is directly matched with the service identifier. If the match is successful, the verification is considered successful; otherwise, the verification is considered unsuccessful.
[0124] In this embodiment of the application, subsequent steps can only be executed after the service identifier has been verified; otherwise, subsequent steps cannot be executed.
[0125] In step S905, after the central service component confirms that the service identifier has been verified, it generates the task public key S2 and the task private key P2.
[0126] It should be noted that the public and private key pairs for generating the task can be generated using algorithms such as RSA encryption or elliptic curve encryption.
[0127] In step S906, the central service component encrypts the task private key P2 using the service public key S1 to generate the encrypted task private key P2'.
[0128] In step S907, the central service component returns the encrypted task private key P2' to the synchronization service component.
[0129] In step S908, the synchronization service component decrypts the encrypted task private key P2' using the service private key P1 to obtain the task private key P2.
[0130] Among them, the task private key P2 is used to decrypt the encrypted data obtained by encrypting the synchronization data through the task public key S2, and obtain the synchronization data.
[0131] In this embodiment, each data synchronization task requires a separate acquisition of its associated public-private key pair to ensure the accuracy of the synchronized data. Therefore, to avoid conflicting use of public-private key pairs between data synchronization tasks, the public-private key pair corresponding to the data synchronization task is invalidated upon completion of the task. Specifically, after the central service component determines that all data for the data synchronization task has been synchronized, it determines that the data synchronization task has ended and invalidates the public-private key pair corresponding to the task. Simultaneously, after determining that the data synchronization task has ended, the central service component returns a task completion flag to the synchronization service component, indicating that the public-private key pair is invalid.
[0132] In one possible implementation, the invalidation of the task public / private key can be represented by deleting the stored task public / private key pair.
[0133] In this embodiment, to prevent forged synchronization service components from requesting synchronization data from the central service component and to ensure secure data selection, the synchronization service component also needs to maintain a heartbeat with the central service component during the interaction between the synchronization service component and the central service component to obtain synchronization data. That is, the central service component and the synchronization service component perform secure verification. For details, see... Figure 10 , Figure 10 This application provides a schematic diagram illustrating security verification for a central service component and a synchronization service component, including the following steps:
[0134] Step S1000: The synchronization service component sends a heartbeat request to the central service component.
[0135] Step S1001: After receiving the heartbeat request, the central service component generates verification information for security verification.
[0136] The verification information used for security verification can be a random number R1 generated by the central service component.
[0137] In step S1002, the central service component returns a heartbeat response message carrying verification information for security verification to the synchronization service component in response to the heartbeat request.
[0138] In step S1003, after receiving the heartbeat response message, the synchronization service component generates target information based on the verification information in the heartbeat response message.
[0139] Specifically, when the verification information is a random number R1, the random number R1 is combined with the service identifier of the synchronization service component and a hash algorithm to generate the target information; where the service identifier ServerID = SHA256(M1'+N1') and the target information T = SHA256(R1+ServerID).
[0140] Step S1004: The synchronization service component sends a security verification request carrying the target information to the central service component.
[0141] In step S1005, after receiving the security verification request, the central service component performs security verification based on the target information in the security verification request.
[0142] In one possible implementation, security verification is performed based on the target information in the security verification request. First, the registration identifier determined when the synchronization service component registers for online service is determined. The method for determining the registration identifier is described above and will not be repeated here. Then, based on the registration identifier and the verification information generated after receiving the heartbeat request, a hash algorithm is used to generate security information, where security information T' = SHA256(R1 + RegisterID). Finally, the target information is matched with the security information. If the match is successful, the security verification is considered successful; otherwise, it is considered a failure.
[0143] In step S1006, the central service component sends a verification response message carrying the verification result to the synchronization service component.
[0144] It should be noted that the synchronization service component can only obtain synchronization data from the central service component if the verification result indicates that the security verification has passed. Therefore, the synchronization service component can send a heartbeat request to the central service component before each synchronization request is sent, or the synchronization service component can send a heartbeat request to the central service component periodically.
[0145] To prevent forged synchronization service components from requesting data synchronization from the central service component and to ensure data security, when the verification results indicate different security verifications (i.e., when the heartbeat between the synchronization service component and the central service component is interrupted), the public and private key pair of the data synchronization task request becomes invalid, preventing the forged synchronization service component from decrypting and obtaining the synchronized data.
[0146] Specifically, after the heartbeat of the central service component and the synchronization service component is interrupted, the public and private key pair corresponding to the data synchronization task becomes invalid. At the same time, after the heartbeat of the central service component and the synchronization service component is interrupted, the central service component returns verification response information to the synchronization service component, carrying verification results that indicate that the security verification failed, to indicate that the public and private key of the task is invalid.
[0147] In another possible implementation, after the heartbeat between the central service component and the synchronization service component is interrupted, the public and private key pair corresponding to the data synchronization task becomes invalid, and no verification response information is returned to the synchronization service component. At this time, the synchronization service component, without receiving the verification response information, determines that the heartbeat between the central service component and the central service component is interrupted and invalidates the public and private key pair.
[0148] It should be noted that invalidating the task's public and private keys can be represented by deleting the stored task's public and private keys.
[0149] See Figure 11 , Figure 11 A data synchronization method provided in this application embodiment, applied to the central service component of a source database, includes the following steps:
[0150] Step S1100: Receive a synchronization request sent by the synchronization service component of the target database for the data synchronization task; wherein the synchronization request carries a synchronization field for indicating the starting query position and the number of query data rows for determining the ending query position.
[0151] Step S1101: Based on the synchronization field, obtain the synchronization data from the source data table that matches the number of data records queried;
[0152] Step S1102: Encrypt the synchronization data using the task public key and return the encrypted data to the synchronization service component.
[0153] In one possible implementation, the synchronization field is determined as follows:
[0154] If the synchronization request is the initial request for a data synchronization task, then the synchronization fields are the initially set ones;
[0155] If the synchronization request is a non-initial request of the data synchronization task, and the data synchronization of the previous synchronization request was successful, then the synchronization field is determined based on the synchronization data queried in the previous synchronization request.
[0156] If the synchronization request is a non-initial request of the data synchronization task, and the data synchronization of the previous synchronization request failed, then the synchronization field is the synchronization field carried in the previous synchronization request.
[0157] In one possible implementation, before encrypting the synchronization data using the task's public key, the following steps are also included:
[0158] Receive a verification request sent by the synchronization service component; the verification request shall include at least a service identifier, which is determined based on the service name and service hardware fingerprint of the synchronization service component;
[0159] Based on the registration information pre-sent by the synchronization service component, after the service identifier is verified, a task public key and a corresponding task private key are generated; wherein, the registration information includes the registration name of the synchronization service component and the registration hardware fingerprint, or, the registration information includes a registration identifier determined based on the registration name and the registration hardware fingerprint, combined with a hash algorithm;
[0160] After encrypting the task private key with the service public key, the encrypted task private key is sent to the synchronization service component so that the synchronization service component can decrypt the encrypted data based on the task private key. The service public key is generated by the central service component for the synchronization service component after the synchronization service component is registered online.
[0161] In one possible implementation, a heartbeat response message is returned in response to a heartbeat request sent by the synchronization service component; wherein the heartbeat response message carries verification information for security verification.
[0162] Receive a security verification request sent by the synchronization service component. The security verification request carries target information determined based on the verification information.
[0163] Security verification is performed based on the target information, the corresponding verification result is obtained, and a verification response message carrying the verification result is returned to the synchronization service component.
[0164] In one possible implementation, if the verification result indicates that the verification has failed, the verification response message is also used to indicate that the task public key and the associated task private key have expired.
[0165] In one possible implementation, when the data synchronization task is completed, a task completion identifier is returned to the synchronization service component; wherein, the task completion identifier is used to indicate that the task public key and the associated task private key have expired.
[0166] See Figure 12 , Figure 12 Another data synchronization method provided in this application embodiment, applied to a synchronization service component of a target database, includes:
[0167] Step S1200: For the data synchronization task, a synchronization request is sent to the central service component of the source database; wherein, the synchronization request carries a synchronization field for indicating the starting query position and the number of query data rows for determining the ending query position.
[0168] Step S1201: Receive encrypted data returned by the central service component; wherein, the encrypted data is obtained by the central service component through the task public key, which encrypts the synchronization data obtained from the source data table based on the synchronization field and matches the number of query data records.
[0169] Step S1202: Decrypt the encrypted data using the task private key and store the obtained synchronization data into the target database.
[0170] In one possible implementation, the synchronization field is determined as follows:
[0171] If the synchronization request is the initial request for a data synchronization task, then the synchronization fields are the initially set ones;
[0172] If the synchronization request is a non-initial request of the data synchronization task, and the data synchronization of the previous synchronization request was successful, then the synchronization field is determined based on the synchronization data queried in the previous synchronization request.
[0173] If the synchronization request is a non-initial request of the data synchronization task, and the data synchronization of the previous synchronization request failed, then the synchronization field is the synchronization field carried in the previous synchronization request.
[0174] In one possible implementation, before decrypting the encrypted data using the task's private key, the following steps are also included:
[0175] A verification request sent to the central service component; the verification request includes at least a service identifier, which is determined based on the service name and service hardware fingerprint of the synchronization service component;
[0176] The receiving center service component returns a task private key encrypted with the service public key. The task private key is generated by the center service component after verifying the service identifier based on the registration information pre-sent by the synchronization service component. The registration information includes the registration name and registration hardware fingerprint of the synchronization service component, or the registration information includes a registration identifier determined by combining the registration name and registration hardware fingerprint with a hash algorithm. The service public key is generated by the center service component for the synchronization service component after it has been registered online.
[0177] In one possible implementation, a heartbeat request is sent to the central service component, and a corresponding heartbeat response message is received; wherein the heartbeat response message carries verification information for security verification.
[0178] Send a security verification request to the central service component and receive the corresponding verification response information carrying the verification result; wherein, the security verification request carries target information determined based on the verification information, and the verification result is obtained by performing security verification based on the target information.
[0179] In one possible implementation, if the verification result indicates that the verification has failed, the verification response message is also used to indicate that the task public key and the associated task private key have expired.
[0180] In one possible implementation, when the data synchronization task is completed, a task completion identifier is returned to the synchronization service component; wherein, the task completion identifier is used to indicate that the task public key and the associated task private key have expired.
[0181] In this application, the central service component of the source database interacts with the synchronization service component of the target database to achieve data synchronization of cloud databases in cross-cloud scenarios, ensuring data consistency, so as to make full use of the resources and advantages of different cloud databases and improve service quality and response speed globally. Specifically, the central service component receives synchronization requests sent by the synchronization service component for data synchronization tasks. These requests carry a synchronization field indicating the starting query position and the number of query data rows to determine the ending query position. Based on the synchronization field, the central service component retrieves synchronization data from the source data table that matches the number of query data rows, ensuring the accuracy of the synchronized data. Furthermore, the central service component encrypts the synchronization data using the task's public key and returns the encrypted data to the synchronization service component. Encryption of the synchronization data during the synchronization process ensures data security, prevents data loss and leakage, and guarantees the security of business data. Simultaneously, in cross-cloud scenarios, it is not necessary to expose the database port to the public network; only the database components (such as the central service component of the source database and the synchronization service component of the target database) need to be exposed. This avoids excessive reliance on the functions provided by cloud vendors associated with the cloud database and reduces the coupling between the business and cloud vendor services.
[0182] Based on the same inventive concept, embodiments of this application provide a data synchronization device applied to a central service component of a source database, see [link to relevant documentation]. Figure 13 The data synchronization device 1300 includes:
[0183] The first receiving module 1301 is used to receive a synchronization request sent by the synchronization service component of the target database for a data synchronization task; wherein the synchronization request carries a synchronization field for indicating the starting query position and the number of query data rows for determining the ending query position.
[0184] The acquisition module 1302 is used to retrieve synchronized data from the source data table based on the synchronization field, which matches the number of data records queried.
[0185] Return module 1303 is used to encrypt the synchronization data using the task public key and return the encrypted data to the synchronization service component.
[0186] In one possible implementation, the synchronization field is determined as follows:
[0187] If the synchronization request is the initial request for a data synchronization task, then the synchronization fields are the initially set ones;
[0188] If the synchronization request is a non-initial request of the data synchronization task, and the data synchronization of the previous synchronization request was successful, then the synchronization field is determined based on the synchronization data queried in the previous synchronization request.
[0189] If the synchronization request is a non-initial request of the data synchronization task, and the data synchronization of the previous synchronization request failed, then the synchronization field is the synchronization field carried in the previous synchronization request.
[0190] In one possible implementation, the return module 1303 is also used for:
[0191] Before encrypting the synchronized data using the task public key, a verification request is received from the synchronization service component; the verification request includes at least a service identifier, which is determined based on the service name and service hardware fingerprint of the synchronization service component.
[0192] Based on the registration information pre-sent by the synchronization service component, after the service identifier is verified, a task public key and a corresponding task private key are generated; wherein, the registration information includes the registration name of the synchronization service component and the registration hardware fingerprint, or, the registration information includes a registration identifier determined based on the registration name and the registration hardware fingerprint, combined with a hash algorithm;
[0193] After encrypting the task private key with the service public key, the encrypted task private key is sent to the synchronization service component so that the synchronization service component can decrypt the encrypted data based on the task private key. The service public key is generated by the central service component for the synchronization service component after the synchronization service component is registered online.
[0194] In one possible implementation, the return module 1303 is also used for:
[0195] In response to a heartbeat request sent by the synchronization service component, a heartbeat response message is returned; the heartbeat response message carries verification information for security verification.
[0196] Receive a security verification request sent by the synchronization service component. The security verification request carries target information determined based on the verification information.
[0197] Security verification is performed based on the target information, the corresponding verification result is obtained, and a verification response message carrying the verification result is returned to the synchronization service component.
[0198] In one possible implementation, if the verification result indicates that the verification has failed, the verification response message is also used to indicate that the task public key and the associated task private key have expired.
[0199] In one possible implementation, when the data synchronization task is completed, a task completion identifier is returned to the synchronization service component; wherein, the task completion identifier is used to indicate that the task public key and the associated task private key have expired.
[0200] Based on the same inventive concept, embodiments of this application provide a data synchronization device, applied to a synchronization service component of a target database, see [link to relevant documentation]. Figure 14 The data synchronization device 1400 includes:
[0201] The sending module 1401 is used to send a synchronization request to the central service component of the source database for a data synchronization task; wherein the synchronization request carries a synchronization field for indicating the starting query position and the number of query data rows for determining the ending query position.
[0202] The second receiving module 1402 is used to receive encrypted data returned by the central service component; wherein, the encrypted data is obtained by the central service component through the task public key, which encrypts the synchronization data obtained from the source data table based on the synchronization field and matches the number of query data records.
[0203] The data storage module 1403 is used to decrypt encrypted data using the task private key and store the obtained synchronized data into the target database.
[0204] In one possible implementation, the synchronization field is determined as follows:
[0205] If the synchronization request is the initial request for a data synchronization task, then the synchronization fields are the initially set ones;
[0206] If the synchronization request is a non-initial request of the data synchronization task, and the data synchronization of the previous synchronization request was successful, then the synchronization field is determined based on the synchronization data queried in the previous synchronization request.
[0207] If the synchronization request is a non-initial request of the data synchronization task, and the data synchronization of the previous synchronization request failed, then the synchronization field is the synchronization field carried in the previous synchronization request.
[0208] In one possible implementation, the data storage module 1403 is also used for:
[0209] Before decrypting the encrypted data using the task's private key, a verification request is sent to the central service component; the verification request includes at least a service identifier, which is determined based on the service name and service hardware fingerprint of the synchronization service component.
[0210] The receiving center service component returns a task private key encrypted with the service public key. The task private key is generated by the center service component after verifying the service identifier based on the registration information pre-sent by the synchronization service component. The registration information includes the registration name and registration hardware fingerprint of the synchronization service component, or the registration information includes a registration identifier determined by combining the registration name and registration hardware fingerprint with a hash algorithm. The service public key is generated by the center service component for the synchronization service component after it has been registered online.
[0211] In one possible implementation, the sending module 1401 is further configured to:
[0212] Send a heartbeat request to the central service component and receive the corresponding heartbeat response message; the heartbeat response message carries verification information for security verification.
[0213] Send a security verification request to the central service component and receive the corresponding verification response information carrying the verification result; wherein, the security verification request carries target information determined based on the verification information, and the verification result is obtained by performing security verification based on the target information.
[0214] In one possible implementation, if the verification result indicates that the verification has failed, the verification response message is also used to indicate that the task public key and the associated task private key have expired.
[0215] In one possible implementation, when the data synchronization task is completed, a task completion identifier is returned to the synchronization service component; wherein, the task completion identifier is used to indicate that the task public key and the associated task private key have expired.
[0216] It should be noted that although several units (or modules) of the device have been mentioned in the detailed description above, this division is merely exemplary and not mandatory. In fact, according to embodiments of this application, the features and functions of two or more units (or modules) described above can be embodied in one unit (or module). Conversely, the features and functions of one unit (or module) described above can be further divided and embodied by multiple units (or modules). Of course, in implementing this application, the functions of each unit (or module) can also be implemented in one or more software or hardware components.
[0217] In this application embodiment, the term "unit" (or "module") refers to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.
[0218] After introducing the data synchronization method and apparatus of exemplary embodiments of this application, another exemplary embodiment of this application, an electronic device, will be introduced next.
[0219] Those skilled in the art will understand that aspects of this application can be implemented as systems, methods, or program products. Therefore, aspects of this application can be specifically implemented in the following forms: a completely hardware implementation, a completely software implementation (including firmware, microcode, etc.), or a combination of hardware and software implementations, collectively referred to herein as a "circuit," "module," or "system."
[0220] In one possible implementation, the electronic device provided in this application may include at least a processor and a memory. The memory stores a computer program that, when executed by the processor, causes the processor to perform any step of the data synchronization method in the various exemplary embodiments of this application.
[0221] In this embodiment, the structure of the electronic device can be as follows: Figure 15 As shown, it includes a memory 1501, a communication module 1503, and one or more processors 1502.
[0222] The memory 1501 is used to store computer programs executed by the processor 1502. The memory 1501 may mainly include a program storage area and a data storage area. The program storage area may store the operating system and programs required to run instant messaging functions, etc.; the data storage area may store various instant messaging information and operation instruction sets, etc.
[0223] Memory 1501 may be volatile memory, such as random-access memory (RAM); memory 1501 may also be non-volatile memory, such as read-only memory, flash memory, hard disk drive (HDD), or solid-state drive (SSD); or memory 1501 may be any other medium capable of carrying or storing a desired computer program having the form of instructions or data structures and accessible by a computer, but is not limited thereto. Memory 1501 may be a combination of the above-described memories.
[0224] Processor 1502 may include one or more central processing units (CPUs) or digital processing units, etc. Processor 1502 is used to implement the above-described data synchronization method when calling computer programs stored in memory 1501.
[0225] The communication module 1503 is used to communicate with the target device and other servers.
[0226] This application embodiment does not limit the specific connection medium between the memory 1501, communication module 1503, and processor 1502. This application embodiment... Figure 15 The memory 1501 and the processor 1502 are connected via a bus 1504, and the bus 1504 is in Figure 15 The diagram uses thick lines to describe the connections between other components; these are for illustrative purposes only and should not be considered limiting. The 1504 bus can be divided into address bus, data bus, control bus, etc. For ease of description, Figure 15 It is described using only a thick line, but does not indicate that there is only one bus or one type of bus.
[0227] The memory 1501 stores a computer storage medium, which stores computer-executable instructions for implementing the data synchronization method of this application embodiment. The processor 1502 is used to execute the above-described data synchronization method.
[0228] In some possible implementations, aspects of the data synchronization method provided in this application can also be implemented as a program product, which includes a computer program that, when run on an electronic device, causes the electronic device to perform the steps of the data synchronization method according to the various exemplary embodiments of this application described above.
[0229] The program product may employ any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of readable storage media include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0230] The program product of the embodiments of this application may employ a portable compact disc read-only memory (CD-ROM) and include a computer program, and may run on a computing device. However, the program product of this application is not limited thereto. In this document, the readable storage medium may be any tangible medium that contains or stores a program that may be used by or in conjunction with a command execution system, apparatus, or device.
[0231] A readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying a readable computer program. This propagated data signal may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium, capable of sending, propagating, or transmitting a program for use by or in conjunction with a command execution system, apparatus, or device.
[0232] Computer programs contained on readable media may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.
[0233] Computer programs for performing the operations of this application can be written in any combination of one or more programming languages, including object-oriented programming languages such as Java and C++, and conventional procedural programming languages such as C or similar languages. The computer program can execute entirely on the user's computing device, partially on a terminal device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0234] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can 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, etc.) containing a computer-usable computer program.
[0235] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable device, produce a mechanism for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that specifies a function in one or more boxes.
[0236] These computer program commands may also be stored in a computer-readable storage medium that can direct a computer or other programmable device to function in a particular manner, such that the commands stored in the computer-readable storage medium produce an article of manufacture including command means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function is specified in one or more boxes.
[0237] These computer program instructions can also be loaded onto a computer or other programmable device to cause a series of operational steps to be performed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions that execute on the computer or other programmable device for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps that specify the function are in one or more boxes.
[0238] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.
[0239] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.
Claims
1. A data synchronization method, characterized in that, The method, applied to a central service component of the source database, includes: Receive a synchronization request sent by the synchronization service component of the target database for a data synchronization task; wherein the synchronization request carries a synchronization field for indicating the starting query position and the number of query data records for determining the ending query position; Based on the synchronization field, synchronized data matching the number of data entries queried is obtained from the source data table; The synchronization data is encrypted using the task public key, and the obtained encrypted data is returned to the synchronization service component. Before encrypting the synchronization data using the task public key, the method further includes: Receive a verification request sent by the synchronization service component; the verification request includes at least a service identifier, which is determined based on the service name and service hardware fingerprint of the synchronization service component; Based on the registration information pre-sent by the synchronization service component, after the service identifier is verified, the task public key and the corresponding task private key are generated; wherein, the registration information includes the registration name and registration hardware fingerprint of the synchronization service component, or, the registration information includes a registration identifier determined based on the registration name and the registration hardware fingerprint, combined with a hash algorithm; After encrypting the task private key with the service public key, the encrypted task private key is sent to the synchronization service component so that the synchronization service component can decrypt the encrypted data based on the task private key; wherein, the service public key is generated by the central service component for the synchronization service component after the synchronization service component is confirmed to be online and registered.
2. The method as described in claim 1, characterized in that, The synchronization field is determined in the following way: If the synchronization request is the initial request for the data synchronization task, then the synchronization field is initially set; If the synchronization request is a non-initial request of the data synchronization task, and the data synchronization of the previous synchronization request was successful, then the synchronization field is determined based on the synchronization data queried from the previous synchronization request; If the synchronization request is a non-initial request of the data synchronization task, and the data synchronization of the previous synchronization request failed, then the synchronization field is the synchronization field carried in the previous synchronization request.
3. The method as described in any one of claims 1-2, characterized in that, The method further includes: In response to the heartbeat request sent by the synchronization service component, a heartbeat response message is returned; wherein the heartbeat response message carries verification information for security verification. Receive a security verification request sent by the synchronization service component, wherein the security verification request carries target information determined based on the verification information; Based on the target information, a security verification is performed to obtain the corresponding verification result, and a verification response information carrying the verification result is returned to the synchronization service component.
4. The method as described in claim 3, characterized in that, If the verification result indicates that the verification has failed, the verification response information is also used to indicate that the task public key and the associated task private key have become invalid.
5. The method as described in any one of claims 1-2, characterized in that, The method further includes: When the data synchronization task is completed, a task completion identifier is returned to the synchronization service component; wherein, the task completion identifier is used to indicate that the task public key and the associated task private key have expired.
6. A data synchronization method, characterized in that, A synchronization service component applied to a target database, the method comprising: For a data synchronization task, a synchronization request is sent to the central service component of the source database; wherein, the synchronization request carries a synchronization field for indicating the starting query position and the number of query data records for determining the ending query position; Receive encrypted data returned by the central service component; wherein, the encrypted data is obtained by the central service component through the task public key, after encrypting the synchronization data obtained from the source data table based on the synchronization field that matches the number of query data entries; The encrypted data is decrypted using the task's private key, and the resulting synchronization data is stored in the target database. Before decrypting the encrypted data using the task private key, the process further includes: A verification request is sent to the central service component; the verification request includes at least a service identifier, which is determined based on the service name and service hardware fingerprint of the synchronization service component. The system receives a task private key encrypted with a service public key returned by the central service component. The task private key is generated by the central service component after verifying the service identifier based on registration information pre-sent by the synchronization service component. The registration information includes the registration name and registration hardware fingerprint of the synchronization service component, or, the registration information includes a registration identifier determined by combining the registration name and registration hardware fingerprint with a hash algorithm. The service public key is generated by the central service component for the synchronization service component after determining that the synchronization service component has registered online.
7. The method as described in claim 6, characterized in that, The synchronization field is determined in the following way: If the synchronization request is the initial request for the data synchronization task, then the synchronization field is initially set; If the synchronization request is a non-initial request of the data synchronization task, and the data synchronization of the previous synchronization request was successful, then the synchronization field is determined based on the synchronization data queried from the previous synchronization request; If the synchronization request is a non-initial request of the data synchronization task, and the data synchronization of the previous synchronization request failed, then the synchronization field is the synchronization field carried in the previous synchronization request.
8. The method as described in any one of claims 6-7, characterized in that, The method further includes: Send a heartbeat request to the central service component and receive a corresponding heartbeat response message; wherein the heartbeat response message carries verification information for security verification; A security verification request is sent to the central service component, and a corresponding verification response information carrying the verification result is received; wherein, the security verification request carries target information determined based on the verification information, and the verification result is obtained by performing security verification based on the target information.
9. The method as described in claim 8, characterized in that, If the verification result indicates that the verification has failed, the verification response information is also used to indicate that the task public key and the associated task private key have become invalid.
10. The method according to any one of claims 6-7, characterized in that, The method further includes: When the data synchronization task is completed, a task completion identifier is returned to the synchronization service component; wherein, the task completion identifier is used to indicate that the task public key and the associated task private key have expired.
11. A data synchronization device, characterized in that, The central service component applied to the source database, the device comprising: The first receiving module is used to receive a synchronization request sent by the synchronization service component of the target database for a data synchronization task; wherein the synchronization request carries a synchronization field for indicating the starting query position and the number of query data records for determining the ending query position. The acquisition module is used to acquire synchronized data that matches the number of data entries in the query from the source data table based on the synchronization field. The return module is used to encrypt the synchronization data using the task public key and return the encrypted data to the synchronization service component. The return module is also used for: Before encrypting the synchronization data using the task public key, a verification request is received from the synchronization service component; the verification request includes at least a service identifier, which is determined based on the service name and service hardware fingerprint of the synchronization service component. Based on the registration information pre-sent by the synchronization service component, after the service identifier is verified, the task public key and the corresponding task private key are generated; wherein, the registration information includes the registration name and registration hardware fingerprint of the synchronization service component, or, the registration information includes a registration identifier determined based on the registration name and the registration hardware fingerprint, combined with a hash algorithm; After encrypting the task private key with the service public key, the encrypted task private key is sent to the synchronization service component so that the synchronization service component can decrypt the encrypted data based on the task private key; wherein, the service public key is generated by the central service component for the synchronization service component after the synchronization service component is confirmed to be online and registered.
12. A data synchronization device, characterized in that, A synchronization service component applied to a target database, the apparatus comprising: The sending module is used to send a synchronization request to the central service component of the source database for a data synchronization task; wherein the synchronization request carries a synchronization field for indicating the starting query position and the number of query data records for determining the ending query position. The second receiving module is used to receive encrypted data returned by the central service component; wherein, the encrypted data is obtained by the central service component through encrypting the synchronization data obtained from the source data table based on the synchronization field, which matches the number of query data entries, using the task public key; The data storage module is used to decrypt the encrypted data using the task private key and store the obtained synchronization data into the target database. The data storage module is also used for: Before decrypting the encrypted data using the task private key, a verification request is sent to the central service component; the verification request includes at least a service identifier, which is determined based on the service name and service hardware fingerprint of the synchronization service component; The system receives a task private key encrypted with a service public key returned by the central service component. The task private key is generated by the central service component after verifying the service identifier based on registration information pre-sent by the synchronization service component. The registration information includes the registration name and registration hardware fingerprint of the synchronization service component, or, the registration information includes a registration identifier determined by combining the registration name and registration hardware fingerprint with a hash algorithm. The service public key is generated by the central service component for the synchronization service component after determining that the synchronization service component has registered online.
13. A computing device, characterized in that, The computing device includes: a processor and a memory, wherein: The memory is used to store computer programs; The processor is configured to execute the computer program to implement the method according to any one of claims 1-5, or to implement the method according to any one of claims 6-10.
14. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the method according to any one of claims 1-5, or implements the method according to any one of claims 6-10.
15. A computer program product, characterized in that, Includes a computer program that, when executed by a processor, implements the method of any one of claims 1-5, or implements the method of any one of claims 6-10.
Citation Information
Patent Citations
Data synchronization method and device
CN107343049A
Data synchronization method and device for cross-machine-room Redis database
CN115687511A