Data synchronization method, device, equipment and medium

By comparing the metadata of the source database and the target database, and the corresponding synchronization operation, the problem of synchronization difficulties in the existing technologies in the existing technologies has achieved efficient metadata synchronization and reducing the cost of operation and maintenance costs.

CN118897865BActive Publication Date: 2025-01-28TIANJIN NANKAI UNIV GENERAL DATA TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411391005.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-08
Publication Date
2025-01-28
Estimated Expiration
2044-10-08

AI Technical Summary

Technical Problem

The existing technology cannot effectively synchronize metadata objects such as stored procedures, functions and views between the source database cluster and the target database cluster, and cannot synchronize in inconsistent data tables during the data table synchronization process, resulting in a burden on the system. High cost.

Method used

Through response meta -data synchronous requests, call the synchronous type scheduling component, extract the synchronous metadata from the source database, and compare it with the target metadata in the target database to determine that the target meta -target meta -target meta -be different from the synchronous metadata data Data and then synchronize the corresponding metadata to the target database.

Benefits of technology

The synchronization of meta -data is achieved, avoiding the problem that cannot be synchronized with metadata, reduced the deployment needs of the target database, reduced operation and maintenance costs, and improved the synchronization efficiency of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118897865B_ABST
    Figure CN118897865B_ABST
Patent Text Reader

Abstract

The present invention provides a data synchronization method, device, equipment and medium, which relate to the field of computer technology. The method comprises: in response to a metadata synchronization request, calling a synchronization type scheduling component to extract metadata to be synchronized from a source database; comparing the metadata to be synchronized with target metadata in a target database to obtain a comparison result; according to the comparison result, determining different target metadata different from the metadata to be synchronized in the target metadata; synchronizing the metadata to be synchronized corresponding to the different target metadata to the target database.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and more specifically to a data synchronization method, device, equipment and medium. Background Art

[0002] In the related art, when synchronizing a source database cluster with a target database cluster, it is often determined whether the data tables between the source database cluster and the target database cluster are consistent. If they are inconsistent, the data tables of the target database cluster are redeployed.

[0003] However, it is impossible to synchronize metadata objects such as stored procedures, functions, and views between the source database cluster and the target database cluster. In addition, during the data table synchronization process, it is impossible to synchronize inconsistent data tables and redeploy the target database cluster, which not only places a heavy burden on the system, but also increases the operation and maintenance costs. Summary of the invention

[0004] In view of the above problems, the present invention provides a data synchronization method, apparatus, device, medium and program product.

[0005] According to a first aspect of the present invention, a data synchronization method is provided, comprising: in response to a metadata synchronization request, calling a synchronization type scheduling component to extract metadata to be synchronized from a source database; comparing the metadata to be synchronized with target metadata in a target database to obtain a comparison result; according to the comparison result, determining different target metadata that is different from the metadata to be synchronized in the target metadata; and synchronizing the metadata to be synchronized corresponding to the different target metadata to the target database.

[0006] According to an embodiment of the present invention, calling a synchronization type scheduling component to extract metadata to be synchronized from a source database includes: calling the synchronization type scheduling component to perform the following operations: determining a first synchronization type according to a data synchronization request; the first synchronization type characterizes that the metadata type of the metadata to be synchronized includes multiple categories, or the metadata type only includes one of a stored procedure type, a function type, and a view type; determining a metadata object identifier associated with the metadata to be synchronized from the source database according to the first synchronization type; the metadata to be synchronized includes the first metadata to be synchronized; constructing an initial first data table to be synchronized according to the metadata object identifier; extracting first data to be synchronized associated with the metadata object identifier from the source database based on the metadata object identifier in the initial first data table to be synchronized; and storing the first data to be synchronized and the metadata object identifier in association with each other in the initial first data table to be synchronized to obtain a first data table to be synchronized, wherein the metadata to be synchronized includes the first data table to be synchronized.

[0007] According to an embodiment of the present invention, calling a synchronization type scheduling component to extract metadata to be synchronized from a source database also includes: determining a second synchronization type according to a data synchronization request; the second synchronization type characterizes that the metadata type of the metadata to be synchronized only includes a table type; determining table data to be synchronized associated with the metadata to be synchronized from the source database according to the second synchronization type; the table data to be synchronized includes a field name and second synchronization type data corresponding to the field name; the metadata to be synchronized includes the field name and the second synchronization type data.

[0008] According to an embodiment of the present invention, the metadata to be synchronized is compared with the target metadata in the target database to obtain a comparison result, including: obtaining target table data from the target database, the target metadata including the target table data; obtaining a target field name consistent with the field name of the metadata to be synchronized from the target table data according to the field name of the metadata to be synchronized; obtaining target data corresponding to the target field name from the target table data, the target metadata including the target data corresponding to the target field name; comparing the second synchronization type data corresponding to the field name of the metadata to be synchronized with the target data corresponding to the target field name to obtain a comparison result.

[0009] According to an embodiment of the present invention, the metadata to be synchronized is compared with the target metadata in the target database to obtain a comparison result, which also includes: comparing the name information of the metadata to be synchronized with the name information of the target metadata to obtain a name comparison result; when the name comparison result indicates that the name comparison is consistent, performing the following processing operations: using an information digest algorithm to process the metadata to be synchronized to obtain a first value to be compared; using an information digest algorithm to process the target metadata to obtain a second value to be compared; comparing the first value to be compared with the second value to be compared to obtain a comparison result.

[0010] According to an embodiment of the present invention, the metadata to be synchronized includes view data to be synchronized, storage data to be synchronized, and function data to be synchronized; the name information of the metadata to be synchronized is determined by the following operations: acquiring the name information of the view data to be synchronized from a first storage table corresponding to the metadata to be synchronized; acquiring the name information of the storage data to be synchronized and the name information of the function data to be synchronized from a second storage component corresponding to the metadata to be synchronized; and determining the name information of the metadata to be synchronized according to at least one of the name information of the view data to be synchronized, the name information of the storage data to be synchronized, and the name information of the function data to be synchronized.

[0011] According to an embodiment of the present invention, synchronizing metadata to be synchronized corresponding to different target metadata to a target database includes: determining structural information of the metadata to be synchronized corresponding to the different target metadata; and updating the different target metadata of the target database according to the structural information.

[0012] The second aspect of the present invention provides a data synchronization device, including: an extraction module, which is used to respond to a metadata synchronization request, call a synchronization type scheduling component, and extract the metadata to be synchronized from a source database; a comparison module, which is used to compare the metadata to be synchronized with the target metadata in the target database to obtain a comparison result; a determination module, which is used to determine different target metadata that is different from the metadata to be synchronized in the target metadata based on the comparison result; and a synchronization module, which is used to synchronize the metadata to be synchronized corresponding to the different target metadata to the target database.

[0013] Another aspect of the present invention provides an electronic device, comprising: one or more processors; and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the above method.

[0014] Another aspect of the present invention provides a computer-readable storage medium storing computer-executable instructions, which are used to implement the above method when executed.

[0015] Another aspect of the present invention provides a computer program product, which includes computer executable instructions, and the instructions are used to implement the above method when being executed.

[0016] According to an embodiment of the present invention, in response to a metadata synchronization request, a synchronization type scheduling component is called to extract metadata to be synchronized from a source database; the metadata to be synchronized is compared with the target metadata in a target database to obtain a comparison result; according to the comparison result, different target metadata different from the metadata to be synchronized is determined in the target metadata; the metadata to be synchronized corresponding to the different target metadata is synchronized to the target database. Due to the adoption of a technical means of comparing the metadata to be synchronized with the target metadata in the target database, determining the different target metadata different from the metadata to be synchronized, and synchronizing the target database, the problem of being unable to synchronize metadata and even more unable to synchronize the target database in a targeted manner is avoided, and the technical effect of synchronizing metadata without deploying metadata on a large scale in the target database is achieved. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] The above contents and other objects, features and advantages of the present invention will become more apparent through the following description of the embodiments of the present invention with reference to the accompanying drawings, in which:

[0018] Figure 1 An application scenario diagram of a data synchronization method, apparatus, device, medium, and program product according to an embodiment of the present invention is shown;

[0019] Figure 2 A flow chart of a data synchronization method according to an embodiment of the present invention is shown;

[0020] Figure 3 A schematic diagram showing a data synchronization method according to an embodiment of the present invention is shown;

[0021] Figure 4 It shows a structural block diagram of a data synchronization device according to an embodiment of the present invention;

[0022] Figure 5 A block diagram of an electronic device suitable for implementing a data synchronization method according to an embodiment of the present invention is shown. DETAILED DESCRIPTION

[0023] Below, embodiments of the present invention will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present invention. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of embodiments of the present invention. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of concepts of the present invention.

[0024] The terms used herein are only for describing specific embodiments and are not intended to limit the present invention. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.

[0025] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification and should not be interpreted in an idealized or overly rigid manner.

[0026] When using expressions such as "at least one of A, B, and C, etc.", they should generally be interpreted according to the meaning of the expression commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).

[0027] An embodiment of the present invention provides a data synchronization method, comprising: in response to a metadata synchronization request, calling a synchronization type scheduling component to extract metadata to be synchronized from a source database; comparing the metadata to be synchronized with target metadata in a target database to obtain a comparison result; according to the comparison result, determining different target metadata that is different from the metadata to be synchronized in the target metadata; and synchronizing the metadata to be synchronized corresponding to the different target metadata to the target database.

[0028] Figure 1 An application scenario diagram of a data synchronization method, apparatus, device, medium, and program product according to an embodiment of the present invention is shown.

[0029] like Figure 1 As shown, the application scenario 100 according to this embodiment may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104, and a server 105. The network 104 is used to provide a medium for a communication link between the first terminal device 101, the second terminal device 102, the third terminal device 103, and the server 105. The network 104 may include various connection types, such as wired, wireless communication links, or optical fiber cables, etc.

[0030] The user can use the first terminal device 101, the second terminal device 102, and the third terminal device 103 to interact with the server 105 through the network 104 to receive or send messages, etc. Various communication client applications can be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only for example).

[0031] The first terminal device 101, the second terminal device 102, and the third terminal device 103 may be various electronic devices having display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.

[0032] The server 105 may be a server that provides various services, such as a background management server (only as an example) that provides support for websites browsed by users using the first terminal device 101, the second terminal device 102, and the third terminal device 103. The background management server may analyze and process the received data such as the data synchronization request, and feed back the processing results (such as synchronization of target metadata, etc.) to the terminal device.

[0033] It should be noted that the data synchronization method provided in the embodiment of the present invention can generally be executed by the server 105. Accordingly, the data synchronization device provided in the embodiment of the present invention can generally be set in the server 105. The data synchronization method provided in the embodiment of the present invention can also be executed by a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105. Accordingly, the data synchronization device provided in the embodiment of the present invention can also be set in a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105.

[0034] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to the implementation requirements.

[0035] Figure 2 A flow chart of a data synchronization method according to an embodiment of the present invention is shown.

[0036] like Figure 2 As shown, the method includes operations S210 to S240.

[0037] In operation S210 , in response to a metadata synchronization request, a synchronization type scheduling component is called to extract metadata to be synchronized from a source database.

[0038] According to an embodiment of the present invention, a metadata synchronization request may be a request parameter used to characterize the synchronization object of the metadata to be synchronized, wherein the synchronization object may be metadata such as "table", "stored procedure", "function", "view", etc.

[0039] According to an embodiment of the present invention, the metadata synchronization request may be automatically generated or manually input.

[0040] According to an embodiment of the present invention, a synchronization type scheduling component is used to parse the above-mentioned metadata synchronization request, determine the metadata that needs to be synchronized, and extract the metadata to be synchronized from the source database, wherein the synchronization type scheduling component can be a synchronization tool such as a visual cluster active-active synchronization tool.

[0041] In operation S220, the metadata to be synchronized is compared with the target metadata in the target database to obtain a comparison result.

[0042] According to an embodiment of the present invention, the target database may be used to perform disaster recovery backup of the source database.

[0043] According to an embodiment of the present invention, metadata in all target databases are traversed, and target metadata corresponding to the metadata to be synchronized is determined in the metadata in the target databases.

[0044] According to an embodiment of the present invention, the metadata to be synchronized is compared with the target metadata to determine whether their data structures or data contents are consistent, so as to obtain a comparison result.

[0045] In operation S230 , different target metadata that is different from the metadata to be synchronized is determined in the target metadata according to the comparison result.

[0046] According to an embodiment of the present invention, the metadata to be synchronized includes multiple metadata types, and each metadata type corresponds to a comparison result.

[0047] According to an embodiment of the present invention, each comparison result is traversed to determine the target metadata corresponding to the comparison inconsistency represented by the comparison result, and the target metadata is used as different target metadata different from the metadata to be synchronized.

[0048] In operation S240, the metadata to be synchronized corresponding to the different target metadata is synchronized to the target database.

[0049] According to an embodiment of the present invention, the target database is updated according to the data structure of the metadata to be synchronized corresponding to the different target metadata to complete the synchronization so that the source database is consistent with the target database.

[0050] According to an embodiment of the present invention, in response to a metadata synchronization request, a synchronization type scheduling component is called to extract metadata to be synchronized from a source database; the metadata to be synchronized is compared with the target metadata in a target database to obtain a comparison result; according to the comparison result, different target metadata different from the metadata to be synchronized is determined in the target metadata; the metadata to be synchronized corresponding to the different target metadata is synchronized to the target database. Due to the adoption of a technical means of comparing the metadata to be synchronized with the target metadata in the target database, determining the different target metadata different from the metadata to be synchronized, and synchronizing the target database, the problem of being unable to synchronize metadata and even more unable to synchronize the target database in a targeted manner is avoided, and the technical effect of synchronizing metadata without deploying metadata on a large scale in the target database is achieved.

[0051] According to an embodiment of the present invention, calling a synchronization type scheduling component to extract metadata to be synchronized from a source database includes: calling the synchronization type scheduling component to perform the following operations: determining a first synchronization type according to a data synchronization request; the first synchronization type characterizes that the metadata type of the metadata to be synchronized includes multiple categories, or the metadata type only includes one of a stored procedure type, a function type, and a view type; determining a metadata object identifier associated with the metadata to be synchronized from the source database according to the first synchronization type; the metadata to be synchronized includes the first metadata to be synchronized; constructing an initial first data table to be synchronized according to the metadata object identifier; extracting first data to be synchronized associated with the metadata object identifier from the source database based on the metadata object identifier in the initial first data table to be synchronized; and storing the first data to be synchronized and the metadata object identifier in association with each other in the initial first data table to be synchronized to obtain a first data table to be synchronized, wherein the metadata to be synchronized includes the first data table to be synchronized.

[0052] According to an embodiment of the present invention, the data synchronization request corresponding to the first synchronization type may be an automatically generated request parameter, and the to-be-synchronized metadata of multiple metadata types are synchronized by default.

[0053] According to an embodiment of the present invention, the metadata to be synchronized of the stored procedure type may be a structured statement for implementing functions such as data scheduling.

[0054] According to an embodiment of the present invention, the metadata to be synchronized of the function type may be codes used for data verification, conversion or calculation.

[0055] According to an embodiment of the present invention, the metadata to be synchronized of the view type may be a virtual table, which is used to maintain the data security of the database.

[0056] According to an embodiment of the present invention, the metadata object identifier may be in a digital form, corresponding one-to-one to different types of metadata.

[0057]

[0058] As shown in Table 1, the number corresponding to the stored procedure type is 0100, the number corresponding to the function type is 0010, and the number corresponding to the view type is 0001. If the first synchronization type represents that the metadata types of the metadata to be synchronized include multiple types, the metadata object identifiers corresponding to the above metadata types can be combined. For example, if the first synchronization type represents that the metadata types of the metadata to be synchronized are stored procedure types and function types, then the metadata object identifier corresponding to the first synchronization type is 0110.

[0059] According to an embodiment of the present invention, a synchronization type scheduling component determines a first synchronization type corresponding to a data synchronization request, and based on the metadata object identifier corresponding to the first synchronization type, further determines the metadata type of the data to be synchronized that needs to be obtained, and according to the metadata type, extracts the first data to be synchronized associated with the metadata object identifier from the source database.

[0060] According to an embodiment of the present invention, an initial first data table to be synchronized corresponding to the metadata type is constructed according to the metadata object identifier. For example, for a stored procedure type, all input parameters and output parameters involved in the stored procedure can be used as table fields to create the initial first data table to be synchronized.

[0061] According to an embodiment of the present invention, the first data to be synchronized is imported into the initial first data table to be synchronized to obtain the first data table to be synchronized.

[0062] According to an embodiment of the present invention, for example, the value of sync_scope of the data synchronization request is db (first synchronization type), the sync_object parameter in the synchronization type scheduling component gcluster_rsynctool takes effect, and it is determined that sync_object=0100, then the first data to be synchronized db_list_file corresponding to the stored procedure type is extracted from the source database and converted into the form of table_list_file, that is, the first data table to be synchronized.

[0063] According to an embodiment of the present invention, by utilizing metadata object identifiers, the required metadata to be synchronized can be confirmed in the source database without retrieving all data for synchronization, thereby reducing the system resources required for synchronization. In addition, by converting the metadata objects in the metadata to be synchronized into the form of a data table to be synchronized, the metadata is easy to process, so as to facilitate the rapid synchronization of the metadata.

[0064] According to an embodiment of the present invention, calling a synchronization type scheduling component to extract metadata to be synchronized from a source database also includes: determining a second synchronization type according to a data synchronization request; the second synchronization type characterizes that the metadata type of the metadata to be synchronized only includes a table type; determining table data to be synchronized associated with the metadata to be synchronized from the source database according to the second synchronization type; the table data to be synchronized includes a field name and second synchronization type data corresponding to the field name; the metadata to be synchronized includes the field name and the second synchronization type data.

[0065] According to an embodiment of the present invention, the data synchronization request corresponding to the second synchronization type may be a request instruction input manually.

[0066] According to an embodiment of the present invention, the table-type metadata to be synchronized may be a data table for storing data.

[0067] According to an embodiment of the present invention, table data to be synchronized associated with metadata to be synchronized is determined from a source database, each table data to be synchronized includes multiple field names, and each field name includes multiple data, namely, second synchronization type data.

[0068] According to an embodiment of the present invention, the metadata to be synchronized is compared with the target metadata in the target database to obtain a comparison result, including: obtaining target table data from the target database, the target metadata including the target table data; obtaining a target field name consistent with the field name of the metadata to be synchronized from the target table data according to the field name of the metadata to be synchronized; obtaining target data corresponding to the target field name from the target table data, the target metadata including the target data corresponding to the target field name; comparing the second synchronization type data corresponding to the field name of the metadata to be synchronized with the target data corresponding to the target field name to obtain a comparison result.

[0069] According to an embodiment of the present invention, the target table data may be a data table for data storage in a target database, including a plurality of target field names corresponding to the data table and a plurality of rows of target data corresponding to each field name.

[0070] According to an embodiment of the present invention, based on the field name of the metadata to be synchronized, a target field name consistent with the field name is confirmed in the target table data.

[0071] According to an embodiment of the present invention, the second synchronization type data corresponding to the field name of the metadata to be synchronized is determined, and the target data corresponding to the target field name is determined. If the second synchronization type data and the target data are the same, the comparison result is expressed as a comparison result of the metadata to be synchronized and the target metadata in the target database, indicating that the two are consistent; if they are not the same, it indicates that the two are inconsistent.

[0072] According to an embodiment of the present invention, the metadata to be synchronized is compared with the target metadata in the target database to obtain a comparison result, which also includes: comparing the name information of the metadata to be synchronized with the name information of the target metadata to obtain a name comparison result; when the name comparison result indicates that the name comparison is consistent, performing the following processing operations: using an information digest algorithm to process the metadata to be synchronized to obtain a first value to be compared; using an information digest algorithm to process the target metadata to obtain a second value to be compared; comparing the first value to be compared with the second value to be compared to obtain a comparison result.

[0073] According to an embodiment of the present invention, the name information of the metadata to be synchronized is compared with the name information of the target metadata to obtain a name comparison result. If the names are inconsistent, the target metadata is considered to be different target metadata from the metadata to be synchronized.

[0074] According to an embodiment of the present invention, if the names are consistent, the metadata to be synchronized and the target metadata are further compared using an information digest algorithm.

[0075] According to an embodiment of the present invention, the message digest algorithm may be a digest algorithm (Message-Digest Algorithm 5, MD5) algorithm, which is used to take input data as input and obtain a 128-bit hash value after data processing operations.

[0076] According to an embodiment of the present invention, the metadata to be synchronized is processed using an information digest algorithm to obtain an MD5 value (128-bit hash value) corresponding to the metadata to be synchronized of each metadata type, that is, a first value to be compared.

[0077] According to an embodiment of the present invention, the target metadata is processed using an information digest algorithm to obtain an MD5 value corresponding to the target metadata of each metadata type, that is, a second value to be compared.

[0078] According to an embodiment of the present invention, it is determined whether the numerical values ​​of the first value to be compared and the second value to be compared are consistent, thereby obtaining a comparison result for each metadata type.

[0079] According to an embodiment of the present invention, an information digest algorithm is used to convert data into a hash value. By utilizing the information digest algorithm to process the metadata to be synchronized and the target metadata, even if only one character in the data is different, the resulting hash values ​​are completely different. There is no need to traverse and compare each data in the metadata to be synchronized and the target metadata one by one, thereby further improving the comparison efficiency while reducing resource cost consumption.

[0080] According to an embodiment of the present invention, the metadata to be synchronized includes view data to be synchronized, storage data to be synchronized, and function data to be synchronized; the name information of the metadata to be synchronized is determined by the following operations: acquiring the name information of the view data to be synchronized from a first storage table corresponding to the metadata to be synchronized; acquiring the name information of the storage data to be synchronized and the name information of the function data to be synchronized from a second storage table corresponding to the metadata to be synchronized; and determining the name information of the metadata to be synchronized according to at least one of the name information of the view data to be synchronized, the name information of the storage data to be synchronized, and the name information of the function data to be synchronized.

[0081] According to an embodiment of the present invention, the metadata to be synchronized includes stored data to be synchronized of stored procedure type, function data to be synchronized of function type, and view data to be synchronized of view type, wherein the name information of the view data to be synchronized is stored in the first storage table information schema. views, and the name information of the storage data to be synchronized and the name information of the function data to be synchronized are stored in the second storage table gbase.proc.

[0082] According to an embodiment of the present invention, for example, when the metadata to be synchronized includes view data to be synchronized, it is necessary to obtain all view data to be synchronized under the specified library through the first storage table information schema. Views of the source database, and the query statement is as follows: Select table_name,md5 (VIEW DEFINITION) from information schema.table schema ='db_name'; wherein db_name is the library name for which the view data to be synchronized needs to be queried, table_name is the name information of the queried view data to be synchronized, and VIEW DEFINITION is the content information of the view data to be synchronized. The processing operation of the target metadata is similar to that of the metadata to be synchronized, and will not be repeated here. When the name information of the view data to be synchronized is consistent with the name information of the corresponding target view data in the target metadata, the MD5 value (first value to be compared) of the view data to be synchronized is calculated based on the content information of the view data to be synchronized, and the MD5 value (second value to be compared) of the target view data is calculated based on the content information of the target view data, and the first value to be compared is compared with the second value to be compared to see whether they are consistent. If they are inconsistent, synchronization is required.

[0083] For another example, when the metadata to be synchronized includes storage data to be synchronized or function data to be synchronized, the relevant information is checked in the second storage table gbase.proc through the SQL statement select trim(name), type, md5 (body) from gbase.proc where db='db name'. In the query result, type=PROCEDURE indicates storage data to be synchronized, type=FUNCTION indicates function data to be synchronized, and md5(body) is for MD5 value (first value to be compared). The processing operation of the target metadata is similar to that of the metadata to be synchronized, which will not be repeated here. Compare the first value to be compared with the second value to be compared for consistency. If they are inconsistent, synchronization is required.

[0084] According to an embodiment of the present invention, synchronizing metadata to be synchronized corresponding to different target metadata to a target database includes: determining structural information of the metadata to be synchronized corresponding to the different target metadata; and updating the different target metadata of the target database according to the structural information.

[0085] According to an embodiment of the present invention, after different target metadata is determined, metadata to be synchronized that is of the same metadata type as the different target metadata is determined based on a metadata object identifier associated therewith.

[0086] According to an embodiment of the present invention, the synchronization type scheduling component gcluster_rsynctool is called to obtain metadata to be synchronized, and determine the data structure of the metadata to be synchronized.

[0087] According to an embodiment of the present invention, the target database deletes different target metadata, and constructs new target metadata in the target database based on the data structure of the metadata to be synchronized.

[0088] Figure 3 A schematic diagram of a data synchronization method according to an embodiment of the present invention is shown.

[0089] like Figure 3As shown, operation S301 is performed, and in response to a metadata synchronization request, the metadata to be synchronized corresponding to the metadata synchronization request is obtained from the source database using the synchronization type scheduling component. When the metadata to be synchronized is of the first synchronization type, operation S302 is performed to extract the metadata to be synchronized of the first synchronization type from the source database, and to construct a first table to be synchronized. Operation S303 is performed to compare the name information of the metadata to be synchronized with the name information of the target metadata, and operation S304 is performed for the metadata to be synchronized and the target metadata with the same name information, and the metadata to be synchronized including the first table of data to be synchronized is processed using an information digest algorithm to obtain a first comparison value corresponding to the metadata to be synchronized, and the comparison value is compared with the second comparison value corresponding to the target metadata, and then the comparison result is confirmed in operation S307. When the metadata to be synchronized is of the second synchronization type, operation S305 is performed to determine the table data to be synchronized associated with the metadata to be synchronized, and then operation S306 is performed to compare the second synchronization type data of the table data to be synchronized with the target data of the target table data based on the field name, and then the comparison result is confirmed in operation S307. In operation S308, the comparison result is judged. If the comparison result indicates that the metadata to be synchronized is consistent with the target metadata, operation S309 is executed, and no synchronization is required, and the data synchronization operation is terminated. If they are inconsistent, operation S310 is executed to confirm the different target metadata according to the comparison result. Operation S311 is executed to delete the different target metadata in the target database, and then operation S312 is executed to call the synchronization type scheduling component to extract the structural information including the data structure and data content of the metadata to be synchronized from the source database, and create new target metadata in the target database based on the structural information.

[0090] Based on the above data synchronization method, the present invention also provides a data synchronization device. Figure 4 The device is described in detail.

[0091] Figure 4 A structural block diagram of a data synchronization device according to an embodiment of the present invention is shown.

[0092] like Figure 4 As shown, the data synchronization device 400 of this embodiment includes an extraction module 410 , a comparison module 420 , a determination module 430 and a synchronization module 440 .

[0093] The extraction module 410 is used to call the synchronization type scheduling component in response to the metadata synchronization request to extract the metadata to be synchronized from the source database. In one embodiment, the extraction module 410 can be used to perform the operation S210 described above, which will not be described in detail here.

[0094] The comparison module 420 is used to compare the metadata to be synchronized with the target metadata in the target database to obtain a comparison result. In one embodiment, the comparison module 420 can be used to perform the operation S220 described above, which will not be described in detail here.

[0095] The determination module 430 is used to determine different target metadata that is different from the metadata to be synchronized in the target metadata according to the comparison result. In one embodiment, the determination module 430 can be used to perform the operation S230 described above, which will not be described in detail here.

[0096] The synchronization module 440 is used to synchronize the metadata to be synchronized corresponding to the different target metadata to the target database. In one embodiment, the synchronization module 440 can be used to perform the operation S240 described above, which will not be described in detail here.

[0097] According to an embodiment of the present invention, in response to a metadata synchronization request, a synchronization type scheduling component is called to extract metadata to be synchronized from a source database; the metadata to be synchronized is compared with the target metadata in a target database to obtain a comparison result; according to the comparison result, different target metadata different from the metadata to be synchronized is determined in the target metadata; the metadata to be synchronized corresponding to the different target metadata is synchronized to the target database. Due to the adoption of a technical means of comparing the metadata to be synchronized with the target metadata in the target database, determining the different target metadata different from the metadata to be synchronized, and synchronizing the target database, the problem of being unable to synchronize metadata and even more unable to synchronize the target database in a targeted manner is avoided, and the technical effect of synchronizing metadata without deploying metadata on a large scale in the target database is achieved.

[0098] According to an embodiment of the present invention, any multiple modules of the extraction module 410, the comparison module 420, the determination module 430 and the synchronization module 440 can be combined in one module for implementation, or any one of the modules can be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules can be combined with at least part of the functions of other modules and implemented in one module. According to an embodiment of the present invention, at least one of the extraction module 410, the comparison module 420, the determination module 430 and the synchronization module 440 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application-specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware and firmware or in any appropriate combination of any of them. Alternatively, at least one of the extraction module 410, the comparison module 420, the determination module 430 and the synchronization module 440 can be at least partially implemented as a computer program module, and when the computer program module is run, the corresponding function can be executed.

[0099] According to an embodiment of the present invention, the extraction module 410 includes a first determination submodule, a second determination submodule, a construction submodule, an extraction submodule and a obtaining submodule.

[0100] According to an embodiment of the present invention, the first determination submodule is used to determine the first synchronization type based on a data synchronization request; the first synchronization type represents that the metadata type of the metadata to be synchronized includes multiple categories, or the metadata type only includes one of the stored procedure type, function type and view type.

[0101] The second determination submodule is used to determine the metadata object identifier associated with the metadata to be synchronized from the source database according to the first synchronization type; the metadata to be synchronized includes the first metadata to be synchronized.

[0102] The construction submodule is used to construct an initial first data table to be synchronized according to the metadata object identifier.

[0103] The extraction submodule is used to extract the first data to be synchronized associated with the metadata object identifier from the source database based on the metadata object identifier in the initial first data table to be synchronized.

[0104] The obtaining submodule is used to associate and store the first data to be synchronized and the metadata object identifier in an initial first data table to be synchronized, so as to obtain the first data table to be synchronized. The metadata to be synchronized includes the first data table to be synchronized.

[0105] According to an embodiment of the present invention, the extraction module 410 further includes a third determination submodule and a fourth determination submodule.

[0106] The third determination submodule is used to determine a second synchronization type according to the data synchronization request; the second synchronization type indicates that the metadata type of the metadata to be synchronized only includes a table type.

[0107] The fourth determination submodule is used to determine the table data to be synchronized associated with the metadata to be synchronized from the source database according to the second synchronization type; the table data to be synchronized includes field names and second synchronization type data corresponding to the field names; the metadata to be synchronized includes field names and second synchronization type data.

[0108] According to an embodiment of the present invention, the comparison module 420 includes a first acquisition submodule, a second acquisition submodule, a third acquisition submodule and a first comparison submodule.

[0109] The first acquisition submodule is used to acquire target table data from a target database, where the target metadata includes the target table data.

[0110] The second acquisition submodule is used to acquire, from the target table data, a target field name that is consistent with the field name of the metadata to be synchronized, according to the field name of the metadata to be synchronized.

[0111] The third acquisition submodule is used to acquire target data corresponding to the target field name from the target table data, and the target metadata includes the target data corresponding to the target field name.

[0112] The first comparison submodule is used to compare the second synchronization type data corresponding to the field name of the metadata to be synchronized with the target data corresponding to the target field name to obtain a comparison result.

[0113] According to an embodiment of the present invention, the comparison module 420 further includes a second comparison submodule, a first processing submodule, a second processing submodule and a third comparison submodule.

[0114] The second comparison submodule is used to compare the name information of the metadata to be synchronized with the name information of the target metadata to obtain a name comparison result.

[0115] The first processing submodule is used to process the metadata to be synchronized by using an information summary algorithm to obtain a first value to be compared.

[0116] The second processing submodule is used to process the target metadata using an information summary algorithm to obtain a second value to be compared.

[0117] The third comparison submodule is used to compare the first value to be compared with the second value to be compared to obtain a comparison result.

[0118] According to an embodiment of the present invention, the second comparing submodule includes a first acquiring unit, a second acquiring unit and a determining unit.

[0119] The first acquiring unit is configured to acquire name information of the view data to be synchronized from a first storage table corresponding to the metadata to be synchronized.

[0120] The second acquisition unit is used to acquire the name information of the storage data to be synchronized and the name information of the function data to be synchronized from the second storage component corresponding to the metadata to be synchronized.

[0121] The determining unit is configured to determine the name information of the metadata to be synchronized according to at least one of the name information of the view data to be synchronized, the name information of the storage data to be synchronized, and the name information of the function data to be synchronized.

[0122] According to an embodiment of the present invention, the synchronization module 440 includes a fifth determination submodule and an update submodule.

[0123] The fifth determination submodule is used to determine the structural information of the metadata to be synchronized corresponding to the different target metadata.

[0124] The update submodule is used to update the different target metadata of the target database according to the structural information.

[0125] Figure 5 A block diagram of an electronic device suitable for implementing a data synchronization method according to an embodiment of the present invention is shown.

[0126] like Figure 5 As shown, the electronic device 500 according to an embodiment of the present invention includes a processor 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage part 508 to a random access memory (RAM) 503. The processor 501 may include, for example, a general-purpose microprocessor (such as a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (for example, an application-specific integrated circuit (ASIC)), etc. The processor 501 may also include an onboard memory for caching purposes. The processor 501 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present invention.

[0127] In RAM 503, various programs and data required for the operation of electronic device 500 are stored. Processor 501, ROM 502 and RAM 503 are connected to each other via bus 504. Processor 501 performs various operations of the method flow according to the embodiment of the present invention by executing the program in ROM 502 and / or RAM 503. It should be noted that the program can also be stored in one or more memories other than ROM 502 and RAM 503. Processor 501 can also perform various operations of the method flow according to the embodiment of the present invention by executing the program stored in the one or more memories.

[0128] According to an embodiment of the present invention, the electronic device 500 may further include an input / output (I / O) interface 505, which is also connected to the bus 504. The electronic device 500 may further include one or more of the following components connected to the input / output (I / O) interface 505: an input portion 506 including a keyboard, a mouse, etc.; an output portion 507 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 508 including a hard disk, etc.; and a communication portion 509 including a network interface card such as a LAN card, a modem, etc. The communication portion 509 performs communication processing via a network such as the Internet. A drive 510 is also connected to the input / output (I / O) interface 505 as needed. A removable medium 511, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 510 as needed, so that the computer program read therefrom is installed into the storage portion 508 as needed.

[0129] The present invention also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiment; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present invention is implemented.

[0130] According to an embodiment of the present invention, the computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present invention, the computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, an apparatus or a device. For example, according to an embodiment of the present invention, the computer-readable storage medium may include the ROM 502 and / or RAM 503 described above and / or one or more memories other than ROM 502 and RAM 503.

[0131] The embodiment of the present invention also includes a computer program product, which includes a computer program, and the computer program contains program code for executing the method shown in the flowchart. When the computer program product is run in a computer system, the program code is used to enable the computer system to implement the data synchronization method provided by the embodiment of the present invention.

[0132] The computer program executes the above functions defined in the system / device of the embodiment of the present invention when it is executed by the processor 501. According to the embodiment of the present invention, the system, device, module, unit, etc. described above can be implemented by a computer program module.

[0133] In one embodiment, the computer program may rely on tangible storage media such as optical storage devices, magnetic storage devices, etc. In another embodiment, the computer program may also be transmitted and distributed in the form of signals on a network medium, and downloaded and installed through the communication part 509, and / or installed from the removable medium 511. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.

[0134] In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 509, and / or installed from the removable medium 511. When the computer program is executed by the processor 501, the above functions defined in the system of the embodiment of the present invention are performed. According to the embodiment of the present invention, the system, device, means, module, unit, etc. described above can be implemented by a computer program module.

[0135] According to an embodiment of the present invention, the program code for executing the computer program provided by the embodiment of the present invention can be written in any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level process and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages ​​include, but are not limited to, Java, C++, python, "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on the remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (e.g., using an Internet service provider to connect through the Internet).

[0136] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0137] It will be appreciated by those skilled in the art that the features described in the various embodiments of the present invention may be combined and / or combined in various ways, even if such combinations or combinations are not explicitly described in the present invention. In particular, without departing from the spirit and teachings of the present invention, the features described in the various embodiments of the present invention may be combined and / or combined in various ways. All of these combinations and / or combinations fall within the scope of the present invention.

[0138] The embodiments of the present invention are described above. However, these embodiments are only for the purpose of illustration, and are not intended to limit the scope of the present invention. Although each embodiment is described above, it does not mean that the measures in each embodiment cannot be used in combination advantageously. Without departing from the scope of the present invention, those skilled in the art may make various substitutions and modifications, which should all fall within the scope of the present invention.

Claims

1. A data synchronization method, characterized in that: The method comprises: In response to the metadata synchronization request, the synchronization type scheduling component is called to extract the metadata to be synchronized from the source database; Comparing the metadata to be synchronized with the target metadata in the target database to obtain a comparison result; According to the comparison result, determining different target metadata different from the metadata to be synchronized in the target metadata; Synchronizing the metadata to be synchronized corresponding to the different target metadata to the target database; The calling synchronization type scheduling component performs the following operations: Determine a first synchronization type according to the data synchronization request; the first synchronization type indicates that the metadata types of the metadata to be synchronized include multiple types, or the metadata type includes only one of a stored procedure type, a function type, and a view type; Determining a metadata object identifier associated with the metadata to be synchronized from the source database according to the first synchronization type; the metadata to be synchronized includes first metadata to be synchronized; Constructing an initial first to-be-synchronized data table according to the metadata object identifier; Based on the metadata object identifier in the initial first data table to be synchronized, extracting the first data to be synchronized associated with the metadata object identifier from the source database; and In the initial first data table to be synchronized, the first data to be synchronized and the metadata object identifier are associated and stored to obtain a first data table to be synchronized, and the metadata to be synchronized includes the first data table to be synchronized.

2. The method according to claim 1, characterized in that The calling of the synchronization type scheduling component to extract metadata to be synchronized from the source database also includes: Determining a second synchronization type according to the data synchronization request; the second synchronization type indicates that the metadata type of the metadata to be synchronized only includes a table type; According to the second synchronization type, the table data to be synchronized associated with the metadata to be synchronized is determined from the source database; the table data to be synchronized includes a field name and second synchronization type data corresponding to the field name; the metadata to be synchronized includes the field name and the second synchronization type data.

3. The method according to claim 2, characterized in that The comparing the metadata to be synchronized with the target metadata in the target database to obtain a comparison result includes: Acquire target table data from the target database, wherein the target metadata includes the target table data; According to the field name of the metadata to be synchronized, acquiring a target field name consistent with the field name of the metadata to be synchronized from the target table data; Acquire target data corresponding to the target field name from the target table data, wherein the target metadata includes the target data corresponding to the target field name; The second synchronization type data corresponding to the field name of the metadata to be synchronized and the target data corresponding to the target field name are compared to obtain the comparison result.

4. The method according to claim 1, characterized in that The step of comparing the metadata to be synchronized with the target metadata in the target database to obtain a comparison result further includes: Compare the name information of the metadata to be synchronized with the name information of the target metadata to obtain a name comparison result; When the name comparison result indicates that the name comparison is consistent, the following processing operations are performed: Processing the metadata to be synchronized by using an information digest algorithm to obtain a first value to be compared; Processing the target metadata using an information summary algorithm to obtain a second value to be compared; The first value to be compared and the second value to be compared are compared to obtain the comparison result.

5. The method according to claim 4, characterized in that The metadata to be synchronized includes view data to be synchronized, storage data to be synchronized, and function data to be synchronized; The name information of the metadata to be synchronized is determined by the following operations: Acquire the name information of the view data to be synchronized from the first storage table corresponding to the metadata to be synchronized; Acquire the name information of the storage data to be synchronized and the name information of the function data to be synchronized from the second storage component corresponding to the metadata to be synchronized; The name information of the metadata to be synchronized is determined according to at least one of the name information of the view data to be synchronized, the name information of the storage data to be synchronized, and the name information of the function data to be synchronized.

6. The method according to claim 1, characterized in that The step of synchronizing the metadata to be synchronized corresponding to the different target metadata to the target database includes: Determining structural information of the metadata to be synchronized corresponding to the different target metadata; The different target metadata of the target database is updated according to the structural information.

7. A data synchronization device, characterized in that: The device comprises: The extraction module is used to call the synchronization type scheduling component in response to the metadata synchronization request to extract the metadata to be synchronized from the source database, wherein the calling of the synchronization type scheduling component performs the following operations: Determine a first synchronization type according to the data synchronization request; the first synchronization type indicates that the metadata types of the metadata to be synchronized include multiple types, or the metadata type includes only one of a stored procedure type, a function type, and a view type; Determining a metadata object identifier associated with the metadata to be synchronized from the source database according to the first synchronization type; the metadata to be synchronized includes first metadata to be synchronized; Constructing an initial first to-be-synchronized data table according to the metadata object identifier; Based on the metadata object identifier in the initial first data table to be synchronized, extracting the first data to be synchronized associated with the metadata object identifier from the source database; and In the initial first data table to be synchronized, the first data to be synchronized and the metadata object identifier are associated and stored to obtain a first data table to be synchronized, wherein the metadata to be synchronized includes the first data table to be synchronized; A comparison module, used to compare the metadata to be synchronized with the target metadata in the target database to obtain a comparison result; a determination module, configured to determine, in the target metadata, different target metadata that is different from the metadata to be synchronized, according to the comparison result; and The synchronization module is used to synchronize the metadata to be synchronized corresponding to the different target metadata to the target database.

8. An electronic device, characterized in that: The electronic device comprises: one or more processors; a memory for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that: Executable instructions are stored thereon, and when the instructions are executed by a processor, the processor implements the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Database synchronization method and device, electronic equipment and storage medium

    CN113434595A

  • Synchronous processing method and device of database, electronic equipment and storage medium

    CN116628085A