CN112632190A - Data synchronization method and device - Google Patents

Data synchronization method and device Download PDF

Info

Publication number
CN112632190A
CN112632190A CN202011569207.2A CN202011569207A CN112632190A CN 112632190 A CN112632190 A CN 112632190A CN 202011569207 A CN202011569207 A CN 202011569207A CN 112632190 A CN112632190 A CN 112632190A
Authority
CN
China
Prior art keywords
data
data type
database
target data
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202011569207.2A
Other languages
Chinese (zh)
Inventor
赵鹏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Agricultural Bank of China
Original Assignee
Agricultural Bank of China
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Agricultural Bank of China filed Critical Agricultural Bank of China
Priority to CN202011569207.2A priority Critical patent/CN112632190A/en
Publication of CN112632190A publication Critical patent/CN112632190A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • G06F16/275Synchronous replication
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems
    • G06F16/258Data format conversion from or to a database

Abstract

The embodiment of the application discloses a data synchronization method and a device, wherein the method comprises the following steps: acquiring target data of a first database, wherein the data type of the target data is a first data type; converting the data type of the target data from a first data type to a second data type; and updating the second database according to the target data of the second data type. Therefore, the data synchronization method provided by the embodiment of the application can realize the conversion of the target data from the first data type of the first database to the second data type of the second database, and update the second database according to the target data of the second data type, thereby realizing the data type conversion and data synchronization between different databases.

Description

Data synchronization method and device
Technical Field
The present application relates to the field of computers, and in particular, to a data synchronization method and apparatus.
Background
In the process of informatization of enterprises, different databases are used. The databases are usually operated independently, but with the development of enterprises, there is a need to process data between different databases simultaneously, which requires data synchronization between two databases, but currently, data synchronization between different databases cannot be realized.
In summary, the problem that data cannot be synchronized exists between different databases.
Disclosure of Invention
In order to solve the problem that data cannot be synchronized between different databases in the prior art, the application provides a data synchronization method and a data synchronization device, which can realize data type conversion and data synchronization between different databases.
The embodiment of the application provides a data synchronization method, which comprises the following steps:
acquiring target data of a first database, wherein the data type of the target data is a first data type;
converting the data type of the target data from the first data type to a second data type;
and updating the second database according to the target data of the second data type.
Optionally, the acquiring target data of the first database includes:
acquiring a first table of the first database, wherein the first table stores target data of the first data type;
the converting the data type of the target data from the first data type to a second data type comprises:
converting the first table into a second table, wherein the data type of the target data in the second table is the second data type;
the updating the second database according to the target data of the second data type includes:
storing the second table in a second database.
Optionally, the obtaining the first table includes:
and carrying out snapshot on a third table of the first database to obtain the first table.
Optionally, the converting the data type of the target data from the first data type to the second data type includes:
receiving a synchronization instruction, wherein the synchronization instruction is used for instructing the target data to be synchronized into a second database;
and converting the data type of the target data from the first data type to a second data type according to the synchronization instruction.
Optionally, the method further includes:
acquiring a timestamp of the target data;
the converting the data type of the target data from the first data type to a second data type according to the synchronization instruction comprises:
and converting the data type of the target data with the largest time stamp from the first data type to a second data type according to the synchronization instruction.
The embodiment of the application provides a data synchronization device, the device includes:
the device comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring target data of a first database, and the data type of the target data is a first data type;
the conversion unit is used for converting the data type of the target data from the first data type into a second data type;
and the updating unit is used for updating the second database according to the target data of the second data type.
Optionally, the acquiring unit acquiring the target data of the first database includes:
the acquisition unit acquires a first table of the first database, the first table storing target data of the first data type;
the converting unit converting the data type of the target data from the first data type to a second data type includes:
the conversion unit converts the first table into a second table, wherein the data type of the target data in the second table is the second data type;
the updating unit updating the second database according to the target data of the second data type includes:
the updating unit stores the second table in a second database.
Optionally, the obtaining the first table by the obtaining unit includes:
and the obtaining unit carries out snapshot on a third table of the first database to obtain the first table.
Optionally, the converting, by the converting unit, the data type of the target data from the first data type to a second data type includes:
the conversion unit receives a synchronization instruction, wherein the synchronization instruction is used for instructing the target data to be synchronized into a second database;
and the conversion unit converts the data type of the target data from the first data type to a second data type according to the synchronization instruction.
Optionally, the apparatus further comprises:
a timestamp acquiring unit configured to acquire a timestamp of the target data;
the converting unit converts the data type of the target data from the first data type to a second data type according to the synchronization instruction includes:
and the conversion unit converts the data type of the target data with the maximum timestamp from the first data type to a second data type according to the synchronization instruction.
Compared with the prior art, the method has the advantages that:
the embodiment of the application provides a data synchronization method, which comprises the following steps: acquiring target data of a first database, wherein the data type of the target data is a first data type; converting the data type of the target data from a first data type to a second data type; and updating the second database according to the target data of the second data type. Therefore, the data synchronization method provided by the embodiment of the application can realize the conversion of the target data from the first data type of the first database to the second data type of the second database, and update the second database according to the target data of the second data type, thereby realizing the data type conversion and data synchronization between different databases.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments described in the present application, and other drawings can be obtained by those skilled in the art without creative efforts.
Fig. 1 is a flowchart of an embodiment of a data synchronization method provided in the present application;
fig. 2 is a block diagram of an embodiment of a data synchronization apparatus provided in the present application.
Detailed Description
In order to make the technical solutions of the present application better understood, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
As described in the background art, the application of the database is wide in the scenes of enterprise informatization, electronic commerce and the like, the variety of the database is wide, along with the development of the enterprise, the application systems adopted by the enterprise have different software suppliers, different databases are used, and the databases are independent from each other. That is, a plurality of databases may exist in the same enterprise, and data stored in different databases are independent from each other, which results in information islands of data stored in different databases, and is not beneficial for the enterprise to use and process data. When an enterprise upgrades a system, services can be carried on different databases, which means that two or more databases simultaneously carry functions accessed to the outside in a period of time, and the data of the databases are required to be consistent in the period of time, so that data synchronization between different databases is very important.
Based on this, an embodiment of the present application provides a data synchronization method, where the method includes: acquiring target data of a first database, wherein the data type of the target data is a first data type; converting the data type of the target data from a first data type to a second data type; and updating the second database according to the target data of the second data type. Therefore, the data synchronization method provided by the embodiment of the application can convert the target data from the first data type of the first database to the second data type of the second database, and update the second database according to the target data of the second data type, so that data type conversion and data synchronization between different databases can be realized.
Referring to fig. 1, the figure is a flowchart of a data synchronization method provided in an embodiment of the present application.
The data synchronization method provided by the embodiment comprises the following steps:
step S101: and acquiring target data of a first database, wherein the data type of the target data is a first data type.
In an embodiment of the present application, the data type of the first database is different from the data type of the second database. The data type of the first database is a first data type, and the data type of the second database is a second data type.
As an implementation, a database resource, such as a database server or a database server cluster, may be added. The newly added database resource defines the data type of the newly added database resource according to the data types of the first database and the second database, namely the newly added database resource can store the data types of the first database and the second database. The newly added database resources can realize data access, data acquisition and data conversion of other databases or systems. Specifically, the system may access the newly added database resource through an original uniform Application Program Interface (API) of the system.
In this embodiment of the application, the newly added database resource may actively obtain the target data of the first database, or the first database may insert the target data into the newly added database resource.
As an implementation manner, the data of the first database may be stored in a first table, where the first table is a temporary storage location of the target data of the first database. The newly added database resource may obtain a first table of the first database, where the first table stores target data of the first data type. The trigger may be triggered at intervals by setting a trigger, and the first database inserts the first table storing the target data into the newly added database resource.
As another implementation, the data of the first database may be stored in a first table, where the first table is a temporary storage location of the target data of the first database. The newly added database resource may obtain a first table of the first database, where the first table stores target data of the first data type. The trigger may be triggered at intervals by setting a trigger, and the first database inserts the target data from the first table into the newly added database resource. Specifically, the newly added database resource may also store data in the form of a table, so that in the process of inserting, the target data is determined in which table to store according to the identifier of the table of the newly added database resource.
As an example, the tables in the newly added database resources can be divided into a contract table, a customer information table or a transfer flow meter, and the target data of the first database can be inserted according to the classification of a set rule and the identification of the tables.
In yet another implementation, the data of the first database may be stored in a third table, which is a temporary storage location of the target data of the first database. And performing snapshot on the third table of the first database to obtain a first table, wherein the newly added database resource can obtain the snapshot first table of the third table of the first database, and the first table stores the target data of the first data type.
In an embodiment of the application, the target data of the first database may be time-stamped to indicate an update time of the target data. When the newly added database resource acquires the target data, the timestamp of the target data can be acquired.
Step S102: and converting the data type of the target data from the first data type to the second data type.
In the embodiment of the application, after the newly added database resource acquires the target data of the first database, when the second database needs to acquire the target data of the newly added database resource, the newly added database resource may be used to convert the data type of the target data from the first data type to the second data type of the second database, so that the second database may process the target data according to its own data type.
As an implementation manner, after acquiring a first table of storage target data of a first database, a newly added database resource may convert the first table into a second table, where a data type of the target data in the second table is a second data type of a second database. The newly added database resource can receive a synchronization instruction, the synchronization instruction is used for indicating that the target data are synchronized to the second database, and the data type of the target data is converted from the first data type to the second data type according to the synchronization instruction. In order to ensure that the data does not have conflict during synchronization or conversion, the time stamp of the target data can be utilized, that is, the data type of the target data with the largest time stamp is converted from the first data type to the second data type according to the synchronization instruction. The timestamp max represents that the target data is the most recently updated version.
Step S103: and updating the second database according to the target data of the second data type.
In the embodiment of the present application, the second database may be updated according to the target data of the second data type, including being stored in the second database in whole or in part, that is, through the update of the data, the first database and the second database implement data synchronization.
As an implementation manner, the second table in the newly added database resource may be directly stored in the second database, so as to implement data synchronization between the first database and the second database.
As an implementation manner, the newly added database resource may receive a synchronization instruction sent by the second database, where the synchronization instruction is used to instruct to synchronize the target data to the second database.
In the embodiment of the application, the service class data and the configuration class data can realize data type conversion and data synchronization through the newly added database resources, and the data synchronization does not need top shutdown of the first database and the second database, so that real-time data acquisition, conversion and synchronization can be performed.
In the embodiment of the application, the newly added database resource can perform data conflict detection in the process of acquiring, converting or synchronizing data, and when data exception occurs, the data exception can be solved according to a preset conflict processing rule. Specifically, the data exception may be a conflict of the inserted data primary key, or may be that an updated data record does not exist.
In one implementation, when a conflict occurs in the primary key of the inserted data, the target data to be inserted may be determined according to the timestamp of the data, for example, the target data with the largest insertion timestamp.
The embodiment of the application provides a data synchronization method, which comprises the following steps: acquiring target data of a first database, wherein the data type of the target data is a first data type; converting the data type of the target data from a first data type to a second data type; and updating the second database according to the target data of the second data type. Therefore, the data synchronization method provided by the embodiment of the application can realize the conversion of the target data from the first data type of the first database to the second data type of the second database, and update the second database according to the target data of the second data type, thereby realizing the data type conversion and data synchronization between different databases.
Based on the data synchronization method provided by the above embodiments, the embodiments of the present application further provide a data synchronization apparatus, and the working principle of the data synchronization apparatus is described in detail below with reference to the accompanying drawings.
Referring to fig. 2, this figure is a block diagram of a data synchronization apparatus according to an embodiment of the present application.
The data synchronization apparatus 200 provided in this embodiment includes:
an obtaining unit 210, configured to obtain target data of a first database, where a data type of the target data is a first data type;
a converting unit 220, configured to convert the data type of the target data from the first data type to a second data type;
an updating unit 230, configured to update the second database according to the target data of the second data type.
Optionally, the acquiring unit 210 acquires the target data of the first database, including:
the obtaining unit 210 obtains a first table of the first database, the first table storing target data of the first data type;
the converting unit 220 converting the data type of the target data from the first data type to a second data type includes:
the converting unit 220 converts the first table into a second table, where the data type of the target data in the second table is the second data type;
the updating unit 230 updating the second database according to the target data of the second data type includes:
the updating unit 230 stores the second table in a second database.
Optionally, the obtaining the first table by the obtaining unit 210 includes:
the obtaining unit 210 performs a snapshot on the third table of the first database to obtain the first table.
Optionally, the converting unit 220 converts the data type of the target data from the first data type to a second data type, including:
the conversion unit 220 receives a synchronization instruction, which is used to instruct to synchronize the target data into a second database;
the conversion unit 220 converts the data type of the target data from the first data type to a second data type according to the synchronization instruction.
Optionally, the apparatus 200 further includes:
a timestamp acquiring unit configured to acquire a timestamp of the target data;
the converting unit converts the data type of the target data from the first data type to a second data type according to the synchronization instruction includes:
and the conversion unit converts the data type of the target data with the maximum timestamp from the first data type to a second data type according to the synchronization instruction.
When introducing elements of various embodiments of the present application, the articles "a," "an," "the," and "said" are intended to mean that there are one or more of the elements. The terms "comprising," "including," and "having" are intended to be inclusive and mean that there may be additional elements other than the listed elements.
It should be noted that, as one of ordinary skill in the art would understand, all or part of the processes of the above method embodiments may be implemented by a computer program to instruct related hardware, where the computer program may be stored in a computer readable storage medium, and when executed, the computer program may include the processes of the above method embodiments. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), or the like.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the apparatus embodiment, since it is substantially similar to the method embodiment, it is relatively simple to describe, and reference may be made to some descriptions of the method embodiment for relevant points. The above-described apparatus embodiments are merely illustrative, and the units and modules described as separate components may or may not be physically separate. In addition, some or all of the units and modules may be selected according to actual needs to achieve the purpose of the solution of the embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
The foregoing is directed to embodiments of the present application and it is noted that numerous modifications and adaptations may be made by those skilled in the art without departing from the principles of the present application and are intended to be within the scope of the present application.

Claims (10)

1. A method for synchronizing data, the method comprising:
acquiring target data of a first database, wherein the data type of the target data is a first data type;
converting the data type of the target data from the first data type to a second data type;
and updating the second database according to the target data of the second data type.
2. The method of claim 1, wherein obtaining target data for the first database comprises:
acquiring a first table of the first database, wherein the first table stores target data of the first data type;
the converting the data type of the target data from the first data type to a second data type comprises:
converting the first table into a second table, wherein the data type of the target data in the second table is the second data type;
the updating the second database according to the target data of the second data type includes:
storing the second table in a second database.
3. The method of claim 2, wherein obtaining the first table comprises:
and carrying out snapshot on a third table of the first database to obtain the first table.
4. The method of claim 1, wherein converting the data type of the target data from the first data type to a second data type comprises:
receiving a synchronization instruction, wherein the synchronization instruction is used for instructing the target data to be synchronized into a second database;
and converting the data type of the target data from the first data type to a second data type according to the synchronization instruction.
5. The method of claim 4, further comprising:
acquiring a timestamp of the target data;
the converting the data type of the target data from the first data type to a second data type according to the synchronization instruction comprises:
and converting the data type of the target data with the largest time stamp from the first data type to a second data type according to the synchronization instruction.
6. A data synchronization apparatus, the apparatus comprising:
the device comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring target data of a first database, and the data type of the target data is a first data type;
the conversion unit is used for converting the data type of the target data from the first data type into a second data type;
and the updating unit is used for updating the second database according to the target data of the second data type.
7. The apparatus according to claim 6, wherein the acquiring unit acquires the target data of the first database comprises:
the acquisition unit acquires a first table of the first database, the first table storing target data of the first data type;
the converting unit converting the data type of the target data from the first data type to a second data type includes:
the conversion unit converts the first table into a second table, wherein the data type of the target data in the second table is the second data type;
the updating unit updating the second database according to the target data of the second data type includes:
the updating unit stores the second table in a second database.
8. The apparatus according to claim 7, wherein the obtaining unit obtains the first table includes:
and the obtaining unit carries out snapshot on a third table of the first database to obtain the first table.
9. The apparatus of claim 6, wherein the converting unit converts the data type of the target data from the first data type to a second data type comprises:
the conversion unit receives a synchronization instruction, wherein the synchronization instruction is used for instructing the target data to be synchronized into a second database;
and the conversion unit converts the data type of the target data from the first data type to a second data type according to the synchronization instruction.
10. The apparatus of claim 9, further comprising:
a timestamp acquiring unit configured to acquire a timestamp of the target data;
the converting unit converts the data type of the target data from the first data type to a second data type according to the synchronization instruction includes:
and the conversion unit converts the data type of the target data with the maximum timestamp from the first data type to a second data type according to the synchronization instruction.
CN202011569207.2A 2020-12-26 2020-12-26 Data synchronization method and device Pending CN112632190A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011569207.2A CN112632190A (en) 2020-12-26 2020-12-26 Data synchronization method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011569207.2A CN112632190A (en) 2020-12-26 2020-12-26 Data synchronization method and device

Publications (1)

Publication Number Publication Date
CN112632190A true CN112632190A (en) 2021-04-09

Family

ID=75325223

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011569207.2A Pending CN112632190A (en) 2020-12-26 2020-12-26 Data synchronization method and device

Country Status (1)

Country Link
CN (1) CN112632190A (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170116206A1 (en) * 2015-10-27 2017-04-27 TalkCycle LLC dba FrontSpin Real-time synchronization of data between disparate cloud data sources
CN109783074A (en) * 2018-12-11 2019-05-21 平安科技(深圳)有限公司 The data type conversion method of programming, electronic equipment
CN110096541A (en) * 2019-04-28 2019-08-06 新华三大数据技术有限公司 Method for interchanging data and device between a kind of database
US20190340291A1 (en) * 2018-05-07 2019-11-07 Microsoft Technology Licensing, Llc Unified data organization for multi-model distributed databases
CN110674146A (en) * 2019-08-22 2020-01-10 视联动力信息技术股份有限公司 Data synchronization method, synchronization end, end to be synchronized, equipment and storage medium
CN110990482A (en) * 2019-11-11 2020-04-10 中国建设银行股份有限公司 Data synchronization method and device between asynchronous databases
CN111104445A (en) * 2019-12-06 2020-05-05 杭州数梦工场科技有限公司 Data synchronization method, device and equipment

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170116206A1 (en) * 2015-10-27 2017-04-27 TalkCycle LLC dba FrontSpin Real-time synchronization of data between disparate cloud data sources
US20190340291A1 (en) * 2018-05-07 2019-11-07 Microsoft Technology Licensing, Llc Unified data organization for multi-model distributed databases
CN109783074A (en) * 2018-12-11 2019-05-21 平安科技(深圳)有限公司 The data type conversion method of programming, electronic equipment
CN110096541A (en) * 2019-04-28 2019-08-06 新华三大数据技术有限公司 Method for interchanging data and device between a kind of database
CN110674146A (en) * 2019-08-22 2020-01-10 视联动力信息技术股份有限公司 Data synchronization method, synchronization end, end to be synchronized, equipment and storage medium
CN110990482A (en) * 2019-11-11 2020-04-10 中国建设银行股份有限公司 Data synchronization method and device between asynchronous databases
CN111104445A (en) * 2019-12-06 2020-05-05 杭州数梦工场科技有限公司 Data synchronization method, device and equipment

Similar Documents

Publication Publication Date Title
CN108228814B (en) Data synchronization method and device
CN108536752B (en) Data synchronization method, device and equipment
CN104809202A (en) Database synchronization method and device
CN109542865A (en) Distributed cluster system configuration file synchronous method, device, system and medium
CN107977396B (en) Method and device for updating data table of KeyValue database
TW200842627A (en) Techniques to cross-synchronize data
CN111399764B (en) Data storage method, data reading device, data storage equipment and data storage medium
CN104809200A (en) Database synchronization method and device
CN111355802B (en) Information pushing method and device
CN112579695A (en) Data synchronization method and device
CN110543469B (en) Database version management method and server
CN114416868B (en) Data synchronization method, device, equipment and storage medium
CN114020844A (en) Data monitoring synchronization method based on configuration
CN114238523A (en) Data synchronization method and device
CN111367916B (en) Data storage method and device
CN109189864B (en) Method, device and equipment for determining data synchronization delay
CN108900497B (en) Data synchronization method and system between heterogeneous systems
CN112632190A (en) Data synchronization method and device
CN115104295A (en) Data processing method, data processing device, electronic device and storage medium
CN107786661B (en) Information synchronization method
CN111966650B (en) Operation and maintenance big data sharing data table processing method and device and storage medium
CN111090648B (en) Relational database data synchronization conflict resolution method
CN115189931A (en) Distributed key management method, device, equipment and storage medium
CN112948494A (en) Data synchronization method and device, electronic equipment and computer readable medium
CN109783580A (en) Method of data synchronization and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination