CN108228814B - Data synchronization method and device - Google Patents
Data synchronization method and device Download PDFInfo
- Publication number
- CN108228814B CN108228814B CN201711486489.8A CN201711486489A CN108228814B CN 108228814 B CN108228814 B CN 108228814B CN 201711486489 A CN201711486489 A CN 201711486489A CN 108228814 B CN108228814 B CN 108228814B
- Authority
- CN
- China
- Prior art keywords
- data
- target database
- database
- data table
- information
- 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.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/22—Indexing; Data structures therefor; Storage structures
- G06F16/2282—Tablespace storage structures; Management thereof
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/27—Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
- G06F16/275—Synchronous replication
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Databases & Information Systems (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computing Systems (AREA)
- Software Systems (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
According to the data synchronization method and device provided by the invention, the information of the data table with data change in the source database is acquired, the data synchronization configuration information is inquired according to the identification of the data table with data change, the address of the target database is acquired, and the data change information of the database is synchronized into the target database according to the acquired address of the target database.
Description
Technical Field
The invention relates to the technical field of database synchronization, in particular to a data synchronization method and device.
Background
With the wide application of enterprise information systems, the information systems have become the key for enterprises to maintain business operation. The diversified business types of enterprises cause the data access demand to increase sharply, and the core database cannot support such large concurrent operation, so that the database server is overwhelmed. In view of the above, a common practice is to split the core database and to place a large amount of service data into multiple target databases. Therefore, it is important to build a data synchronization system between the core database and each target database.
At present, most of existing database systems need to perform a large amount of manual operations by operation and maintenance personnel to complete data synchronization operations of a core database and each target database, so that a large error risk is brought, and problems of data missing update or untimely update can occur. In addition, between databases in different development environments, it is often difficult to implement data sharing and interaction due to different development languages.
Disclosure of Invention
The invention provides a data synchronization method and a data synchronization device, which are used for realizing data synchronization among different databases and ensuring the normal operation of a database system.
A first aspect of the present invention provides a data synchronization method, including:
acquiring information of a data table with data change in a source database, wherein the data table is used for storing data, and the information of the data table comprises an identifier of the data table;
inquiring data synchronization configuration information according to the identifier of the data table, and determining the address of a target database; the data synchronization configuration information comprises corresponding relations between each data table and a target database;
and synchronizing the data change information of the data table to the target database according to the address of the target database.
Optionally, the data change information of the data table is basic code change information, where the basic code change information includes a first basic code corresponding to a new or deleted attribute in the data table, and the data synchronization configuration information further includes a database code conversion table;
the synchronizing the data change information of the data table to the target database according to the address of the target database includes:
converting the first basic code into a second basic code which can be identified by a target database according to the database code conversion table;
and synchronizing the second basic code into the attribute configuration code segment of the target database according to the address of the target database.
Optionally, the database code conversion table includes a conversion rule table of code statements of the source database and code statements of each target database; the converting the first basic code into a second basic code recognizable by a target database according to the database code conversion table includes:
and converting a first code statement corresponding to the first basic code into a second code statement corresponding to a second basic code according to the database code conversion table.
Optionally, the data change information of the data table is service data change information, where the service change information includes a service data value corresponding to a first field in the data table, and the service data value is added, modified, or deleted; the information of the data table also comprises an identifier of a first field with changed service data;
the synchronizing the data change information of the data table to the target database according to the address of the target database includes:
acquiring the identifier of a second field of the target database corresponding to the identifier of the first field;
and synchronizing the service data value into the second field of the target database according to the address of the target database and the identification of the second field.
Optionally, the data synchronization configuration information further includes an execution cycle of each target database, where the execution cycle includes a first execution cycle and a second execution cycle;
the first execution cycle is a cycle for synchronizing a first basic code corresponding to an addition or deletion attribute in a data table of the source database into each target database;
the second execution cycle is a cycle for synchronizing the service data value corresponding to the first field in the data table of the source database to each of the target databases.
Optionally, the first execution cycle is smaller than the second execution cycle.
Optionally, before synchronizing the data change information of the data table to the target database according to the address of the target database, the method further includes:
acquiring a user name and a password of the target database;
sending a user name and a password of the target database to the target data;
and receiving the information which is sent by the target database and successfully verified.
A second aspect of the present invention provides a data synchronization apparatus, comprising:
the device comprises an acquisition module, a storage module and a processing module, wherein the acquisition module is used for acquiring information of a data table with data change in a source database, the data table is used for storing data, and the information of the data table comprises an identifier of the data table;
the determining module is used for inquiring data synchronization configuration information according to the identification of the data table and determining the address of the target database; the data synchronization configuration information comprises corresponding relations between each data table and a target database;
and the synchronization module is used for synchronizing the data change information of the data table to the target database according to the address of the target database.
A third aspect of the invention provides a computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the method of any of the first aspects.
A fourth aspect of the present invention provides an electronic apparatus comprising:
a processor; and
a memory for storing executable instructions of the processor;
wherein the processor is configured to perform the method of any of the first aspects via execution of the executable instructions.
According to the data synchronization method and device provided by the embodiment of the invention, the information of the data table with data change in the source database is acquired, the data synchronization configuration information is inquired according to the identifier of the data table with data change, the address of the target database is acquired, and the data change information of the database is synchronized into the target database according to the acquired address of the target database.
Drawings
In order to more clearly illustrate the embodiments of the present invention 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 introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
Fig. 1 is an application scenario diagram of a data synchronization method provided by the present invention;
fig. 2 is a schematic flow chart of a data synchronization method according to an embodiment of the present invention;
FIG. 3 is a schematic diagram illustrating data changes of a data table of a source database according to the present invention;
fig. 4 is a schematic flowchart of a data synchronization method according to another embodiment of the present invention;
fig. 5 is a schematic flowchart of a data synchronization method according to another embodiment of the present invention;
FIG. 6 is a flowchart illustrating a data synchronization method according to yet another embodiment of the present invention;
fig. 7 is a schematic structural diagram of a data synchronization apparatus according to an embodiment of the present invention;
FIG. 8 is a schematic structural diagram of a data synchronization apparatus according to another embodiment of the present invention;
fig. 9 is a schematic structural diagram of an embodiment of an electronic device provided in the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. 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 invention.
The terms "first," "second," and the like in the description and in the claims, and in the drawings described above, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein.
It will be understood that the terms "comprises" and "comprising," and any variations thereof, as used herein, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Fig. 1 is an application scenario diagram of the data synchronization method provided by the present invention, and as shown in fig. 1, the data synchronization method provided by the present invention is applied to a data synchronization system, where the data synchronization system includes a source database, a data synchronization apparatus, and N target databases, where N is a positive integer. Wherein,
the source database and the N target databases may be databases of the same version and the same storage structure, or databases of different versions and different storage structures, or databases of different development environments.
The source database is provided with a plurality of data tables, mapping relations among the data tables and storage processes, and correspondingly, each target database is also provided with a plurality of data tables, mapping relations among the data tables and storage processes. The target database may synchronize data of all data tables of the source database, or synchronize data of a part of data tables of the source database, which is not specifically limited in this embodiment.
When a data table in the source database has data change, the number of the target databases having a correspondence relationship with the data table is at least one, in other words, the correspondence relationship between each data table of the source database and the target database may be a one-to-one relationship or a one-to-many relationship. The corresponding relation between each data table of the source database and the target database is pre-stored in the data synchronization device, and when data change occurs in a certain data table of the source database, the target database corresponding to the data table can be inquired through the data synchronization device.
The data synchronization device may specifically be a server or a processor, and is configured to synchronize data changes in the source database to each target database according to data synchronization configuration information stored on the server or the processor.
The technical solution of the present invention will be described in detail below with specific examples. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments.
Fig. 2 is a diagram illustrating a data synchronization method according to an embodiment of the present invention, and fig. 3 is a diagram illustrating data changes of a data table of a source database according to the present invention. As shown in fig. 2, the data synchronization method provided in this embodiment specifically includes the following steps:
s201, acquiring information of a data table with data change in a source database;
the data table is used for storing data, and the information of the data table comprises the identification of the data table.
In this embodiment, when the source database has data change, specifically, when the data table in the source database has data change, the data change of the data table is recorded in a data change list of the source database, where the data change list at least includes an identifier of the data table, and may also include an identifier of a field in the data table where the data change occurs. The data synchronization device acquires the data change information of the data table through the data change list.
The data change information in this embodiment includes at least one of basic code change information and service data change information.
Specifically, the basic code change information includes a basic code corresponding to an attribute in the addition or deletion data table. It should be noted that each data table in the source database includes an attribute group, there are multiple attributes in the attribute group, each record of the data table includes data contents of all attributes or part of attributes, where the attribute uniquely identifying a record is a primary key of the data table, and the data contents of the primary key cannot be null. For example, the attribute group of the user information table includes five attributes, which are a user number, a user name, a gender, an age, and a telephone number, wherein the user number is a primary key of the data table, as shown in fig. 3.
When an address attribute is newly added to the user information table of the source database, the basic code configuration corresponding to the address attribute needs to be added to the basic code base of the source database. After the source database completes the configuration of the basic code, the basic code change information is recorded in a data change list of the source database.
Specifically, the service data change information includes adding, modifying or deleting a service data value corresponding to a certain field in the data table. The fields of the data table specifically include the identification of the fields, the types of the fields, and the attributes of the fields. The identification of the field is used for identifying the address of the field of certain service data of the data table, the type of the field comprises a text type, a numerical type, a date-time type, a currency type, a type of existence, a hyperlink type and the like, and the attribute of the field is field size, format, default value, mandatory field, validity rule and the like. For example, a phone call of a certain user in the user information table is changed, the data change belongs to a service data change, the source database needs to record the data change in the data change list, and record an identifier of a field in which the service data change occurs and an updated service data value of the field.
S202, inquiring data synchronization configuration information according to the identification of the data table, and acquiring the address of a target database;
the data synchronization configuration information comprises corresponding relations between each data table and a target database;
the target database in this embodiment may be the same version of the database as the source database, or a different version of the database from the source database. The database structures of the databases in different versions are different, for example, the source database is the latest version database, the target database is the old version database, and the difference between the two databases includes the difference of the service data corresponding to the attribute group in the data table, and also includes the difference of the basic code (non-service data) corresponding to the attribute group in the data table.
And the data synchronization device determines the address of the target database corresponding to the data table according to the identifier of the changed data table in the source database. In particular, the method comprises the following steps of,
the data synchronization device inquires data synchronization configuration information according to the identification of the data table, the data synchronization configuration information comprises the corresponding relation between each data table in the source database and the target database, namely the corresponding relation between the identification of each data table in the source database and the identification of the target database, and the address of the target database is determined according to the identification of the target database.
S203, synchronizing the data change information of the data table to the target database according to the address of the target database.
And synchronizing the data change information of the data table to the target database corresponding to the data change according to the address of the target database. In particular, the method comprises the following steps of,
the data synchronization device can synchronize the data change information of the data table of the source database to each target database in real time, and can also synchronize the change information of the data table of the source database to each target database in batches according to a preset execution period. The data of the source database and the data of each target database are automatically synchronized, so that the workload of manual operation of related operation and maintenance personnel on the plurality of databases is greatly reduced, and the risk of human errors is reduced.
According to the data synchronization method provided by the embodiment of the invention, the information of the data table with data change in the source database is acquired, the data synchronization configuration information is inquired according to the identifier of the data table with data change, the address of the target database is acquired, and the data change information of the database is synchronized into the target database according to the acquired address of the target database.
The following describes in detail a specific implementation of the data synchronization method using the data change information of the data table as the basic code change information by using a detailed embodiment.
Fig. 4 is a schematic flow chart of a data synchronization method according to another embodiment of the present invention, and as shown in fig. 4, the data synchronization method according to this embodiment includes the following steps:
the data change information of the data table is base code change information,
s301, acquiring information of a data table with data change in a source database;
the data table is used for storing data, and the information of the data table comprises the identification of the data table.
In this embodiment, the data change in the source database is a non-service data change, that is, a change of a basic code in the source database. Correspondingly, the data change information of the data table is the basic code change information, and the basic code change information comprises a first basic code corresponding to the added or deleted attribute in the data table. For example: adding address attribute in user data table, adding first basic code configuration corresponding to the address attribute in basic code base in source database.
Optionally, the basic code change information further includes a basic code corresponding to an attribute value of an existing attribute added or deleted in the data table, for example: one attribute in the attribute group in the vehicle information table is a license plate type, the license plate type comprises a small vehicle license plate, a special vehicle license plate, a large vehicle license plate, a farm vehicle license plate and the like, a new energy license plate is newly added in the license plate type, and the new energy license plate is an attribute value of the existing attribute.
S302, inquiring data synchronization configuration information according to the identification of the data table, and acquiring the address of a target database;
the data synchronization configuration information comprises corresponding relations between the data tables and the target databases, the identification of each target database corresponding to the data tables is inquired through the identification of the data tables, and the address of each target database is obtained according to the identification of each target database.
S303, converting the first basic code into a second basic code which can be identified by a target database according to a database code conversion table;
in this embodiment, the data synchronization configuration information further includes: a database code conversion table.
Specifically, the database code conversion table includes a conversion rule table of the code statement of the source database and the code statement of each target database. Wherein,
code statements include insert statements, update statements, delete statements, and the like.
And converting a first code statement corresponding to a first basic code of the source database into a second code statement corresponding to a second basic code which can be recognized by the target database based on the database code conversion table.
The first code statement is specifically an insert statement, an update statement and a delete statement which can be identified by a source database, and correspondingly, the second code statement is an insert statement, an update statement and a delete statement which can be identified by a target database.
In this embodiment, because the development environments of different databases are different, and the code statements corresponding to the basic code configuration are different, the data synchronization device stores a conversion rule table of the code statements between different databases, so as to meet the data synchronization requirements of the source database and the target database under different development environments.
S304, synchronizing the second basic code into the attribute configuration code segment of the target database according to the address of the target database.
In this step, the data synchronization device synchronizes the second code statements corresponding to the second basic code to the attribute configuration code segments of the target databases according to the addresses of the target databases.
In this embodiment, a synchronization process of non-business data of each target database is completed by obtaining a first basic code corresponding to a newly added or deleted attribute in a source database and converting a first code statement corresponding to the first basic code of the source database into a second code statement corresponding to a second basic code recognizable by a target database, so as to update a database version of each target database in time.
The following describes in detail a specific implementation manner of the data synchronization method in which the data change information in the data table is the service data change information, by using a detailed embodiment.
Fig. 5 is a schematic flow chart of a data synchronization method according to another embodiment of the present invention, and as shown in fig. 5, the data synchronization method according to this embodiment specifically includes the following steps:
s401, acquiring information of a data table with data change in a source database;
the data table is used for storing data, and the information of the data table comprises the identification of the data table.
In this embodiment, the data change in the source database is a service data change, that is, an addition, a modification, or a deletion of a service data value of a certain field in the source database. Correspondingly, the data change information of the data table is service data change information, and the service data change information includes a service data value corresponding to the first field in the data table, which is added, modified or deleted.
The information of the data table of this embodiment further includes: the identification of a first field with changed service data;
for example, the first field of the source database is used to record data information of an 'age' attribute in the user information table, the original service data value of the first field of a certain user is a null value, the service data value added to the user in the source database is 26, and the data change is a new service data change.
S402, inquiring data synchronization configuration information according to the identification of the data table, and acquiring the address of a target database;
the data synchronization configuration information comprises corresponding relations between each data table and a target database;
in this embodiment, S402 is the same as S202 in the above embodiment, and has the same or similar concept, and the description thereof is omitted.
S403, acquiring the identifier of the second field of the target database corresponding to the identifier of the first field;
and the data synchronization device inquires data synchronization configuration information according to the identifier of the data table in the source database and the identifier of the first field, and acquires the identifier of each target database corresponding to the identifier of the data table and the identifier of the second field of each target database corresponding to the identifier of the first field.
S404, synchronizing the service data value into the second field of the target database according to the address of the target database and the identification of the second field.
And the data synchronization device synchronizes the service data change value into the second field of the target database according to the address of the target database and the identification of the second field of the target database with changed service data, thereby completing the synchronization process of the service data.
In this embodiment, by acquiring an identifier of a data table in which service data in a source database changes and an identifier of a first field in the data table, querying data synchronization configuration information to acquire an identifier of a target database and an identifier of a second field, determining an address of the target database according to the identifier of the target data, and synchronizing a service data change value to the second field of the target database, a synchronization process of service data of each target database is completed, so that service data information of each target database is updated in time.
Optionally, on the basis of the foregoing embodiments, the data synchronization configuration information further includes:
executing cycles of each target database, wherein the executing cycles comprise a first executing cycle and a second executing cycle;
the first execution cycle is a cycle for synchronizing a first basic code corresponding to the addition or deletion attribute in the data table of the source database to each target database;
the second execution cycle is a cycle for synchronizing the service data value corresponding to the first field in the data table of the source database to each target database.
Optionally, the first execution cycle is smaller than the second execution cycle.
It will be understood by those skilled in the art that if the first execution period is greater than the second execution period, i.e. the synchronization frequency of the base code is less than the synchronization frequency of the data traffic value, the following may occur:
the reason why a certain service data value is a newly added service data value and an error is reported when the newly added service data value is subjected to data synchronization is that a basic code of an attribute corresponding to the newly added service data is not configured in a basic code segment of the target database. Therefore, in order to avoid the above problem, the setting of the execution cycle of the two kinds of data synchronization should be added to the data synchronization configuration information in the data synchronization device.
In this embodiment, by setting the execution period of the basic code change information and the service data change information, it is ensured that the basic code update period of each target database is smaller than the service data update period, and the problem that the data service corresponding to the basic code cannot be normally synchronized to the target database because the basic code is not updated is avoided.
For the first execution cycle and the second execution cycle in this embodiment, a special case needs to be pointed out, and after the configuration of the basic code corresponding to the newly added attribute in the data table of the source database, until the source database of the latest version is on-line, service data corresponding to the newly added attribute does not appear. At this time, the first execution cycle is often smaller than the second execution cycle, for example, an address attribute is added to a certain data table of the source database, the source database including the basic code configuration corresponding to the address attribute completes synchronization on the second day, the first execution cycle is set to 1 day, and for the service data change of the existing attribute, the second execution cycle is often set to 1 minute or 30 seconds.
Optionally, on the basis of the foregoing embodiments, before the data synchronization device synchronizes the data change information of the data table to the target database according to the address of the target database, a process of data synchronization security verification is further included, so as to avoid malicious intrusion of an external device to the database system.
Fig. 6 is a schematic flow chart of a data synchronization method according to still another embodiment of the present invention, and as shown in fig. 6, the data synchronization method provided in this embodiment specifically includes the following steps:
s501, acquiring information of a data table with data change in a source database;
the data table is used for storing data, and the information of the data table comprises the identification of the data table.
S502, inquiring data synchronization configuration information according to the identification of the data table, and acquiring the address of a target database;
the data synchronization configuration information comprises corresponding relations between each data table and a target database;
s503, acquiring a user name and a password of the target database;
s504, sending a user name and a password of the target database to the target database;
s505, receiving information which is sent by a target database and successfully verified;
in the database system of this embodiment, the source database and each target database are provided with the user name and password of the database, so as to ensure the data security of each database.
Specifically, a source database and user names and passwords of target databases are stored in the data synchronization device, when data change exists in the source database, the data synchronization device obtains the user names and passwords of the target databases through identifiers of the target databases, before data synchronization is performed, the data synchronization device sends the user names and passwords of the target databases to the target databases, so that the target databases verify whether the user names and passwords are correct, and if so, information of successful verification is sent to the data synchronization device.
After receiving the information of successful verification transmitted by the target database, the data synchronization apparatus executes S506.
S506, synchronizing the data change information of the data table to the target database according to the address of the target database.
S501 to S502 and S506 in this embodiment are the same as S201 to S203 in the above embodiment, and the implementation principle and technical effect are similar, and are not described herein again.
In this embodiment, the user name and the password of the target database to be synchronized are obtained, and the data change information of the source database is synchronized into each target database after the verification success information is obtained, so that the security of the data synchronization system is increased, and the data tampering of the data synchronization system by the external device is avoided.
Fig. 7 is a schematic structural diagram of a data synchronization apparatus according to an embodiment of the present invention, and as shown in fig. 7, a data synchronization apparatus 60 according to the embodiment includes:
an obtaining module 61, configured to obtain information of a data table in which data changes occur in a source database, where the data table is used to store data, and the information of the data table includes an identifier of the data table;
a determining module 62, configured to query data synchronization configuration information according to the identifier of the data table, and determine an address of a target database; the data synchronization configuration information comprises corresponding relations between each data table and a target database;
and a synchronization module 63, configured to synchronize the data change information of the data table to the target database according to the address of the target database.
The data synchronization device provided by the embodiment of the invention comprises an acquisition module, a determination module and a synchronization module, wherein the acquisition module acquires data change information in a source database, the determination module determines the address of a target database corresponding to the data change information, and the synchronization module synchronizes the data change information to the target database according to the address of the target database, so that the data change of the source database is synchronized to each target database, and the normal operation of a database system is ensured.
Optionally, the data change information of the data table is change information of a basic code, the change information of the basic code includes a first basic code corresponding to an addition or deletion attribute in the data table, and the data synchronization configuration information further includes a database code conversion table.
Fig. 8 is a schematic structural diagram of a data synchronization apparatus according to another embodiment of the present invention, and further, based on the embodiment of the apparatus shown in fig. 7, the data synchronization apparatus 60 further includes:
a conversion module 64, configured to convert the first basic code into a second basic code that can be recognized by a target database according to the database code conversion table;
the synchronization module 63 is further configured to synchronize the second basic code into the attribute configuration code segment of the target database according to the address of the target database.
Optionally, the database code conversion table includes a conversion rule table of code statements of the source database and code statements of each target database;
the converting module 64 is further configured to convert the first code statement corresponding to the first basic code into a second code statement corresponding to a second basic code according to the database code conversion table.
Optionally, the data change information of the data table is service data change information, where the service change information includes a service data value corresponding to a first field in the data table, and the service data value is added, modified, or deleted; the information of the data table also comprises an identifier of a first field with changed service data;
the obtaining module 61 is further configured to obtain an identifier of a second field of the target database, where the identifier of the second field corresponds to the identifier of the first field;
the synchronizing device 63 is further configured to synchronize the service data value into the second field of the target database according to the address of the target database and the identifier of the second field.
Optionally, the obtaining module 61 is further configured to obtain a user name and a password of the target database;
the data synchronization device 60 further includes:
a sending module 65, configured to send the user name and the password of the target database to the target data;
and the receiving module 66 is used for receiving the information of successful verification sent by the target database.
The data synchronization apparatus provided in this embodiment may implement the technical solutions of the above method embodiments, and the implementation principles and technical effects are similar, which are not described herein again.
The present embodiment provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when being executed by a processor, implements the technical solution according to any of the foregoing method embodiments, and the implementation principle and the technical effect are similar, and are not described herein again.
Fig. 9 is a schematic structural diagram of an embodiment of an electronic device provided in the present invention, and as shown in fig. 9, the electronic device of the present embodiment includes:
a processor 71; and
a memory 72 for storing executable instructions of the processor;
the processor is configured to execute the technical solution of any one of the foregoing method embodiments by executing the executable instructions, and the implementation principle and technical effect thereof are similar, and are not described herein again.
The functions of the various modules in the system described above may be implemented by the processor 71.
Those of ordinary skill in the art will understand that: all or a portion of the steps of implementing the above-described method embodiments may be performed by hardware associated with program instructions. The program may be stored in a computer-readable storage medium. When executed, the program performs steps comprising the method embodiments described above; and the aforementioned storage medium includes: various media capable of storing program codes, such as ROM, RAM, SRAM, DRAM, FLASH, magnetic disk, or optical disk.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.
Claims (8)
1. A method of data synchronization, comprising:
acquiring information of a data table with data change in a source database, wherein the data table is used for storing data, and the information of the data table comprises an identifier of the data table;
inquiring data synchronization configuration information according to the identifier of the data table, and determining the address of a target database; the data synchronization configuration information comprises corresponding relations between each data table and a target database; the data synchronization configuration information also comprises the execution period of each target database; the execution cycle comprises a first execution cycle and a second execution cycle; the first execution cycle is less than the second execution cycle; the first execution cycle is a cycle for synchronizing a first basic code corresponding to an addition or deletion attribute in a data table of the source database into each target database; the second execution cycle is a cycle of synchronizing the service data value corresponding to the first field in the data table of the source database to each target database;
synchronizing the data change information of the data table to the target database according to the address of the target database; the data change of the data table is recorded in a data change list of the source database, the data change list at least comprises an identifier of the data table and an identifier of a field with changed data, and the data change information is acquired through the data change list; the data change information comprises at least one item of basic code change information and service data change information; the basic code change information comprises a first basic code corresponding to the added or deleted attribute in the data table; the service change information comprises a service data value corresponding to a first field in the addition, modification or deletion data table.
2. The method of claim 1, wherein the data change information of the data table is base code change information, and the data synchronization configuration information further comprises a database code conversion table;
the synchronizing the data change information of the data table to the target database according to the address of the target database includes:
converting the first basic code into a second basic code which can be identified by a target database according to the database code conversion table;
and synchronizing the second basic code into the attribute configuration code segment of the target database according to the address of the target database.
3. The method of claim 2, wherein the database code conversion table comprises a table of conversion rules between code statements of the source database and code statements of each target database; the converting the first basic code into a second basic code recognizable by a target database according to the database code conversion table includes:
and converting a first code statement corresponding to the first basic code into a second code statement corresponding to a second basic code according to the database code conversion table.
4. The method according to claim 1, wherein the data change information of the data table is service data change information, and the information of the data table further includes an identifier of a first field in which service data changes;
the synchronizing the data change information of the data table to the target database according to the address of the target database includes:
acquiring the identifier of a second field of the target database corresponding to the identifier of the first field;
and synchronizing the service data value into the second field of the target database according to the address of the target database and the identification of the second field.
5. The method of claim 1, wherein before synchronizing the data change information of the data table to the target database according to the address of the target database, further comprising:
acquiring a user name and a password of the target database;
sending a user name and a password of the target database to the target data;
and receiving the information which is sent by the target database and successfully verified.
6. A data synchronization apparatus, comprising:
the device comprises an acquisition module, a storage module and a processing module, wherein the acquisition module is used for acquiring information of a data table with data change in a source database, the data table is used for storing data, and the information of the data table comprises an identifier of the data table;
the determining module is used for inquiring data synchronization configuration information according to the identification of the data table and determining the address of the target database; the data synchronization configuration information comprises corresponding relations between each data table and a target database; the data synchronization configuration information also comprises the execution period of each target database; the execution cycle comprises a first execution cycle and a second execution cycle; the first execution cycle is a cycle for synchronizing a first basic code corresponding to an addition or deletion attribute in a data table of the source database into each target database; the second execution cycle is a cycle of synchronizing the service data value corresponding to the first field in the data table of the source database to each target database; the synchronization module is used for synchronizing the data change information of the data table to the target database according to the address of the target database; the data change of the data table is recorded in a data change list of the source database, the data change list at least comprises an identifier of the data table and an identifier of a field with changed data, and the data change information is acquired through the data change list; the data change information comprises at least one item of basic code change information and service data change information; the basic code change information comprises a first basic code corresponding to the added or deleted attribute in the data table; the service change information comprises a service data value corresponding to a first field in the addition, modification or deletion data table.
7. A computer-readable storage medium having stored thereon a computer program, characterized in that,
the program, when executed by a processor, implements the method of any of claims 1-5.
8. An electronic device, comprising:
a processor; and
a memory for storing executable instructions of the processor;
wherein the processor is configured to perform the method of any of claims 1-5 via execution of the executable instructions.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201711486489.8A CN108228814B (en) | 2017-12-29 | 2017-12-29 | Data synchronization method and device |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201711486489.8A CN108228814B (en) | 2017-12-29 | 2017-12-29 | Data synchronization method and device |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN108228814A CN108228814A (en) | 2018-06-29 |
| CN108228814B true CN108228814B (en) | 2022-02-15 |
Family
ID=62647418
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201711486489.8A Active CN108228814B (en) | 2017-12-29 | 2017-12-29 | Data synchronization method and device |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN108228814B (en) |
Families Citing this family (18)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN108933828A (en) * | 2018-07-04 | 2018-12-04 | 中国银行股份有限公司 | A kind of data synchronizer and method |
| CN109241183B (en) * | 2018-08-16 | 2020-12-29 | 武汉元鼎创天信息科技有限公司 | Data synchronization method and system based on socket communication |
| CN109254997B (en) * | 2018-08-27 | 2020-12-11 | 广州城市信息研究所有限公司 | Data synchronization method, system, computer device and readable storage medium |
| CN109542872B (en) * | 2018-10-26 | 2021-01-22 | 金蝶软件(中国)有限公司 | Data reading method and device, computer equipment and storage medium |
| CN109597687B (en) * | 2018-10-31 | 2020-11-13 | 东软集团股份有限公司 | Resource allocation method and device for data synchronization, storage medium and electronic equipment |
| CN109657002B (en) * | 2018-11-09 | 2022-04-08 | 山东中创软件商用中间件股份有限公司 | Multi-table batch data synchronization method, device and equipment |
| CN109657004A (en) * | 2018-12-10 | 2019-04-19 | 北京明朝万达科技股份有限公司 | A kind of method of data synchronization and device |
| CN109634975B (en) * | 2018-12-10 | 2022-02-25 | 拉扎斯网络科技(上海)有限公司 | Data synchronization method and device, electronic equipment and computer readable storage medium |
| CN109885614B (en) * | 2019-01-04 | 2024-06-28 | 平安科技(深圳)有限公司 | Data synchronization method and device |
| CN111352993B (en) * | 2019-03-20 | 2025-01-07 | 深圳市鸿合创新信息技术有限责任公司 | Cross-platform data synchronization method and device, and electronic device |
| CN111090803B (en) * | 2019-11-22 | 2024-12-13 | 贝壳技术有限公司 | Data processing method, device, electronic device and storage medium |
| CN113032480A (en) * | 2019-12-25 | 2021-06-25 | 陕西西部资信股份有限公司 | Data synchronization method, system and device |
| CN111241198B (en) * | 2020-01-02 | 2024-02-27 | 广州虎牙科技有限公司 | Data synchronization method and device and data processing equipment |
| CN111259104A (en) * | 2020-01-22 | 2020-06-09 | 山东浪潮通软信息科技有限公司 | Report data synchronization method and device capable of defining rules |
| CN111611244B (en) * | 2020-05-20 | 2023-07-28 | 浩云科技股份有限公司 | Method and device for cascading data of database |
| CN113407209B (en) * | 2021-06-18 | 2023-06-02 | 湖南快乐阳光互动娱乐传媒有限公司 | Configuration data updating method and device |
| CN114840593B (en) * | 2022-04-29 | 2026-01-09 | 南方电网电算科技数字工程(广东)有限公司 | Business data processing methods, apparatus, computer equipment and storage media |
| CN115587143A (en) * | 2022-09-08 | 2023-01-10 | 中国建设银行股份有限公司 | Data synchronization method, device, equipment and computer readable storage medium |
Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN102129478A (en) * | 2011-04-26 | 2011-07-20 | 广州从兴电子开发有限公司 | Database synchronization method and system thereof |
| CN103020112A (en) * | 2012-11-06 | 2013-04-03 | 深圳中兴网信科技有限公司 | Heterogeneous database synchronizing system and heterogeneous database synchronizing method |
| CN103699580A (en) * | 2013-12-03 | 2014-04-02 | 中铁程科技有限责任公司 | Database synchronization method and database synchronization device |
| CN104268234A (en) * | 2014-09-26 | 2015-01-07 | 东软集团股份有限公司 | Method and device for synchronizing data based on SQL statements |
| CN106649378A (en) * | 2015-11-02 | 2017-05-10 | 北大方正集团有限公司 | Data synchronizing method and device |
-
2017
- 2017-12-29 CN CN201711486489.8A patent/CN108228814B/en active Active
Patent Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN102129478A (en) * | 2011-04-26 | 2011-07-20 | 广州从兴电子开发有限公司 | Database synchronization method and system thereof |
| CN103020112A (en) * | 2012-11-06 | 2013-04-03 | 深圳中兴网信科技有限公司 | Heterogeneous database synchronizing system and heterogeneous database synchronizing method |
| CN103699580A (en) * | 2013-12-03 | 2014-04-02 | 中铁程科技有限责任公司 | Database synchronization method and database synchronization device |
| CN104268234A (en) * | 2014-09-26 | 2015-01-07 | 东软集团股份有限公司 | Method and device for synchronizing data based on SQL statements |
| CN106649378A (en) * | 2015-11-02 | 2017-05-10 | 北大方正集团有限公司 | Data synchronizing method and device |
Also Published As
| Publication number | Publication date |
|---|---|
| CN108228814A (en) | 2018-06-29 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN108228814B (en) | Data synchronization method and device | |
| CN107870982B (en) | Data processing method, system and computer readable storage medium | |
| CN112699151A (en) | Data processing method, device, equipment and medium | |
| CN110619226A (en) | Platform-based data processing method, system, equipment and storage medium | |
| CN114900531B (en) | Data synchronization method, device and system | |
| CN111984264B (en) | Static library generation method and device | |
| CN108134696A (en) | A kind of micro services configuration update method and device | |
| CN107203642A (en) | A kind of method of data synchronization and device | |
| CN114519199A (en) | Civil aviation data synchronization method and device based on DataX | |
| CN111506358A (en) | Method and device for updating container configuration | |
| CN113449035A (en) | Data synchronization method and device, computer equipment and readable storage medium | |
| CN110580216B (en) | Application lifting method and device | |
| CN107291938B (en) | Order inquiry system and method | |
| CN110119429B (en) | Data processing method, data processing device, computer equipment and storage medium | |
| CN109800069B (en) | Method and device for realizing data management | |
| CN109032641B (en) | Application version update method and device | |
| CN108491448B (en) | Data pushing method and device | |
| CN109391658B (en) | Account data synchronization method and equipment, storage medium and terminal thereof | |
| CN111291127B (en) | Data synchronization method, device, server and storage medium | |
| CN115329395B (en) | Database data processing method, device, system, equipment and storage medium | |
| CN114491653B (en) | Data content tamper-proof system, method and device | |
| CN116150273A (en) | Data processing method, device, computer equipment and storage medium | |
| CN115098889A (en) | Authority management method, device, equipment and storage medium | |
| CN114980186A (en) | Method and device for detecting false sending of short message and electronic equipment | |
| CN116578649B (en) | Data synchronization methods, devices, equipment and storage media |
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 | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant | ||
| CP03 | Change of name, title or address | ||
| CP03 | Change of name, title or address |
Address after: Floor 36, Zheshang Building, No. 718 Jianshe Avenue, Jiang'an District, Wuhan, Hubei 430019 Patentee after: TK.CN INSURANCE Co.,Ltd. Patentee after: TAIKANG INSURANCE GROUP Co.,Ltd. Address before: Taikang Life Building, 156 fuxingmennei street, Xicheng District, Beijing 100031 Patentee before: TAIKANG INSURANCE GROUP Co.,Ltd. Patentee before: TK.CN INSURANCE Co.,Ltd. |