CN112015815B - Data synchronization method, device and computer readable storage medium - Google Patents

Data synchronization method, device and computer readable storage medium Download PDF

Info

Publication number
CN112015815B
CN112015815B CN202010879371.7A CN202010879371A CN112015815B CN 112015815 B CN112015815 B CN 112015815B CN 202010879371 A CN202010879371 A CN 202010879371A CN 112015815 B CN112015815 B CN 112015815B
Authority
CN
China
Prior art keywords
data
message
synchronized
database
synchronization
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
Application number
CN202010879371.7A
Other languages
Chinese (zh)
Other versions
CN112015815A (en
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.)
Ping An Property and Casualty Insurance Company of China Ltd
Original Assignee
Ping An Property and Casualty Insurance Company of China Ltd
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 Ping An Property and Casualty Insurance Company of China Ltd filed Critical Ping An Property and Casualty Insurance Company of China Ltd
Priority to CN202010879371.7A priority Critical patent/CN112015815B/en
Publication of CN112015815A publication Critical patent/CN112015815A/en
Application granted granted Critical
Publication of CN112015815B publication Critical patent/CN112015815B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Computing Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention relates to big data, and discloses a data synchronization method, which comprises the following steps: intercepting SQL operation in data to be synchronized stored in a database; analyzing the intercepted SQL operation, and acquiring and packaging a parameter object and a mapping relation corresponding to the SQL operation so as to acquire packaging data corresponding to the SQL operation; sending the encapsulated data to a message platform, monitoring the encapsulated data through the message platform, and sending the monitored message to a data storage space of the subscription message; and receiving and processing the encapsulation data corresponding to the monitored information through the data storage space, and synchronizing the data to be synchronized into the data storage space according to the encapsulation data. The invention also relates to a blockchain technology, and the data to be synchronized is stored in the blockchain. The invention can improve the efficiency and the precision of data synchronization.

Description

Data synchronization method, device and computer readable storage medium
Technical Field
The present invention relates to big data processing, and in particular, to a method, an apparatus, an electronic device, and a computer readable storage medium for data synchronization.
Background
At present, the synchronization of two aspects mainly relates to the realization of data synchronization through background program coding, and the realization of data synchronization at the database level by directly acting on a database. The data synchronization is realized through background program coding, the main idea is that the data is updated if any, the data is newly added if no, and the other conditions are recorded through a log. The realization of data synchronization at the database level is further divided into three ways: 1. the synchronization is realized through a publish/subscribe mode, 2, the data synchronization is realized through an SQL JOB mode, and 3, the data synchronization is realized through a Service Broker message queuing mode.
The three modes further comprise two modes of real-time synchronous data and asynchronous synchronous data, wherein the real-time synchronous data has high pressure on a program, the efficiency of program execution is affected, and under the condition that strong coupling exists in service, the risk of data writing failure exists, so that the problems of synchronous data missing or unavailable and the like are caused. In addition, the data synchronization realized by adopting the MQ asynchronous double-writing mode also faces the problem of high service coupling degree.
At present, in the aspect of data synchronization, the data is synchronized from a database table to an elastic search or an internal memory in a mode of timing task JOB, so that the data synchronization can be only performed in a non-business peak period to reduce the pressure on the database, and a certain business coupling degree problem still exists.
Disclosure of Invention
The invention provides a data synchronization method, a data synchronization device, electronic equipment and a computer readable storage medium, and mainly aims to improve the efficiency, the precision and the timeliness of data synchronization.
In order to achieve the above object, the present invention provides a data synchronization method, including:
intercepting SQL operation in data to be synchronized stored in a database;
analyzing the intercepted SQL operation, and acquiring and packaging a parameter object and a mapping relation corresponding to the SQL operation so as to acquire packaging data corresponding to the SQL operation;
the encapsulation data is sent to a message platform, the encapsulation data is monitored through the message platform, and the monitored message is sent to a data storage space for subscribing the message;
and receiving and processing the encapsulation data corresponding to the monitored information through the data storage space, and synchronizing the data to be synchronized into the data storage space according to the encapsulation data.
Optionally, after synchronizing the data to be synchronized to the data storage space, the method further includes:
judging the synchronization result of the data to be synchronized;
when the data to be synchronized is successful in synchronization, feeding back an execution success notification to the message platform; otherwise, when the data to be synchronized fails to synchronize, prompting the selective retransmission of the message of the prior transmission failure.
Optionally, the data to be synchronized is stored in a blockchain, and the process of intercepting the SQL operation in the data to be synchronized stored in the server includes:
intercepting SQL operation in the data to be synchronized through an SQL interceptor, and acquiring a version value of the data to be synchronized in the database; packaging the Version value, the parameter object and the mapping relation into the packaging data; the statement information of the SQL operation comprises: the data operation type, the data value and the table structure corresponding to the data to be synchronized; wherein the data operation types include a data addition operation, a data deletion operation, and a data modification operation. .
Optionally, the process of synchronizing the data to be synchronized into the data storage space according to the encapsulated data includes: and sequencing or discarding the monitored information according to the version value in the package data.
Optionally, when the synchronization of the data to be synchronized fails, judging whether the version value of the corresponding failed message is the maximum value in the message queue of the message platform;
if the version value of the failed message is the maximum value in the message queue, carrying out database warehousing processing on the failed message, and recording the content of the failed message and a corresponding table of version values;
and carrying out logic judgment on the failed message after the warehousing processing.
Preferably, if the version value of the failed message is smaller than the version value in the database, discarding the failed message; otherwise, the prompt message is sent again.
In order to solve the above problems, the present invention also provides a data synchronization apparatus, including:
the operation interception module is used for intercepting SQL operations in the data to be synchronized stored in the database;
the encapsulated data acquisition module is used for analyzing the intercepted SQL operation, acquiring and encapsulating a parameter object and a mapping relation corresponding to the SQL operation so as to acquire encapsulated data corresponding to the SQL operation;
the message sending module is used for sending the encapsulated data to a message platform, monitoring the encapsulated data through the message platform and sending the monitored message to a data storage space of a subscription message;
and the data synchronization module is used for receiving and processing the encapsulation data corresponding to the monitored information through the data storage space and synchronizing the data to be synchronized into the data storage space according to the encapsulation data.
Optionally, after synchronizing the data to be synchronized to the data storage space, further comprising:
judging the synchronization result of the data to be synchronized;
when the data to be synchronized is successful in synchronization, feeding back an execution success notification to the message platform; otherwise, when the data to be synchronized fails to synchronize, prompting the selective retransmission of the message of the prior transmission failure.
In order to solve the above-mentioned problems, the present invention also provides an electronic apparatus including:
at least one processor; the method comprises the steps of,
a memory communicatively coupled to the processor; wherein,
the memory stores instructions executable by the processor to implement the data synchronization method described above.
In order to solve the above-described problems, the present invention also provides a computer-readable storage medium having stored therein at least one instruction that is executed by a processor in an electronic device to implement the above-described data synchronization method.
According to the embodiment of the invention, the data sent to the database is intercepted and acquired by the message interception and the distribution mode of the message platform and is sent to other data storage spaces, and the data is judged and consumed by the data storage spaces, so that the coupling degree of the service can be reduced, and the timeliness of the data synchronization can be improved, thereby realizing the accuracy and timeliness of the data synchronization.
Drawings
FIG. 1 is a flow chart of a data synchronization method according to an embodiment of the invention;
FIG. 2 is a logic diagram of a data synchronization method according to an embodiment of the present invention;
FIG. 3 is a schematic block diagram of a data synchronization apparatus according to an embodiment of the present invention;
fig. 4 is a schematic diagram of an internal structure of an electronic device for implementing a data synchronization method according to an embodiment of the present invention.
The achievement of the objects, functional features and advantages of the present invention will be further described with reference to the accompanying drawings, in conjunction with the embodiments.
Detailed Description
It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention.
The invention provides a data synchronization method. Referring to fig. 1, a flow chart of a data synchronization method according to an embodiment of the invention is shown. The method may be performed by an apparatus, which may be implemented in software and/or hardware.
In one embodiment of the present invention, a data synchronization method includes:
s110: SQL operations in the data to be synchronized stored in the database are intercepted.
Specifically, SQL operations in the data to be synchronized can be intercepted by an SQL interceptor, and a version value of the data to be synchronized in a database can be obtained; and packaging the Version value, the parameter object and the mapping relation into the packaging data, wherein the Version value is used for judging and selecting the message when the message is consumed in a data storage space or when the message is resent.
It should be emphasized that, to further ensure the privacy and security of the data to be synchronized, the synchronized data may also be stored in a node of a blockchain
The statement information of the SQL operation comprises: the data operation type, the data value and the table structure corresponding to the data to be synchronized; wherein the data operation types include a data addition operation, a data deletion operation, and a data modification operation.
S120: analyzing the intercepted SQL operation, and acquiring and packaging a parameter object and a mapping relation corresponding to the SQL operation so as to acquire packaging data corresponding to the SQL operation.
When the package data is obtained, the package data also comprises an intercepted version value, when the message consumption is carried out on the data storage space, message sorting and message discarding processing are carried out according to the version value, so that the fact that the message corresponding to the maximum version value, namely the latest record kept by the database interception message, is ensured under the condition that the data of the same target data are kept up to date.
S130: and sending the encapsulated data to a message platform, monitoring the encapsulated data through the message platform, and sending the monitored message to a data storage space of the subscription message.
When the messages are consumed in the data storage space, message ordering and message discarding processing are carried out according to the version values, so that the messages corresponding to the maximum version value of the same data to be synchronized are ensured, and the data to be synchronized can keep the latest version.
When the message consumption fails or the data to be synchronized fails, judging whether the version value of the failed message is the maximum value in a message queue of the message platform; if the version value of the failed message is the maximum value in the message queue, carrying out database warehousing processing on the failed message so as to record the content of the failed message and a corresponding table of the version value; logically judging the failed message after the warehousing processing, and if the version value of the failed message is smaller than the version value in the database, discarding the failed message; otherwise, the prompt message is sent again.
Specifically, when the consumption of the information in the data storage space fails, judging whether the version value of the information is the maximum value in the information queue, if so, carrying out database warehousing processing on the failed information, and recording the failed content of the information, the version corresponding table and the like. Then, a logical decision is made on the failure message, and if the version of the failure message is smaller than the version in the database table, then the failure message is discarded. If the version of the failure message is greater than or equal to the maximum version value of the current database correspondence table, then attention is paid to manually resending the message. Wherein the data of the data storage space and the database are kept up to date consistent, the manual messaging here can be performed by timing tasks.
In addition, the data storage space same as the database implementation data may be other databases or Elastic Search (ES) or the like.
S140: and receiving and processing the encapsulation data corresponding to the monitored information through the data storage space, and synchronizing the data to be synchronized into the data storage space according to the encapsulation data.
After the data to be synchronized is synchronized to the data storage space, the method further comprises: judging the consumption state of the message sent by the message platform, namely the synchronizing result of the data to be synchronized; when the synchronization result of the data to be synchronized is successful or the message consumption is successful, feeding back an execution success notification to the message platform; otherwise, when the data to be synchronized fails in synchronization or the message consumption fails, prompting the selective retransmission of the message which fails in transmission before.
As a specific example, the data synchronization method of the present invention will be described in detail below taking the synchronization of policy data to a database and ES as an example.
After the business generates the policy data, the policy data belongs to a basic data source, and the related policy number, policy information, insured persons, insurance companies and other basic information are mainly stored in the policy data. The data are stored in the ES, so that the corresponding information can be obtained on the ES rapidly and efficiently during data statistics analysis, and the strong dependence on the database is eliminated.
Fig. 2 shows specific logic of a policy data synchronization method according to an embodiment of the invention.
As shown in fig. 2, the policy data synchronization method of the present invention includes the following steps:
the first step: SQL operations (or SQL statements) in policy data stored in the database are intercepted by a Mybat interceptor.
When the policy data is persisted, related added and deleted SQL sentences are involved, and the added and deleted SQL sentences can be intercepted by a Mybat interceptor and respectively correspond to the database operation types of INSERT, DELETE, UPDATE. For the same data, the unique identification of the policy code in the database has only one record. In other words, only one record is saved in the database regardless of how many times the data of the policy is modified.
Correspondingly, a version field is set in a table corresponding to the database storing the policy data to record the version number of the current data, and the version field is synchronously updated every time the database is updated, so that after each database operation is executed, the version field in the database can be ensured to be the current latest version.
Step two: and processing the intercepted SQL statement to acquire the operation type, the data value and the table structure corresponding to the statement.
The information in the SQL sentence comprises: a data operation type (INSERT, UPDATE, DELETE), a data value, and a table structure corresponding to the data; the data operation type mainly refers to operations of adding, deleting and changing data, the data value refers to a value size corresponding to a data structure, for example, a new policy data is added, then the data operation type of the service operation is INSERT, and the table structure corresponding to the data refers to: the table structure and the database synchronously stored with the target data are kept consistent, namely one-to-one data field mapping relation.
When new data is created, firstly judging whether the table structure exists, if not, creating a set of table structures consistent with the database by default and adding the data newly. The data values mainly refer to the corresponding value sizes of these table structures: for example, policy number: 202001140000000; the insured person: village XX; the amount of the deposit: 1000; version 10.
Step three: the operation type, the data value and the table structure are packaged and then sent to a message platform, monitoring is carried out through the message platform, and monitored packaged data are sent to an ES subscribing to the message;
the method comprises the steps that the version field and basic data corresponding to SQL prediction can be obtained from an SQL interceptor, then the messages are packaged into a message body, the message body is sent to a topic queue designated by a message platform, and a consumer circularly monitors the messages in the topic queue, so that the corresponding message body can be obtained, and subsequent operations can be carried out.
Step four: and the ES consumes the message sent by the message platform and feeds back the consumption status.
In addition, in the data synchronization method of the invention, when the first step is executed, the Mybatis interceptor intercepts the policy data to be stored in the database, when the policy data is recorded in the database, SQL modification is synchronous, the version number of the current data is recorded through the corresponding version field, and the version field is synchronously updated every time the database is updated, so that the version field in the database is ensured to be up to date after the related operation is completed in every database operation.
In a specific embodiment of the invention, after the SQL sentence in the policy data is intercepted by the Mybat interceptor, the corresponding version field and related basic data can be obtained, but when the version field and the related basic data are sent to the message platform, the problems of concurrency, disorder and the sequence of consumed messages exist.
Therefore, the ES may perform message ordering or message discarding according to the version value, and if the same unique data keeps the data up to date, the version takes the message with the largest value, which is the latest record kept by the database interception message. In other words, when the version value of the current version of data to be consumed is smaller than the version value of version data already consumed, the version data with the smaller version value can be discarded, otherwise normal consumption is performed, and therefore final consumption of the version with the largest message ordering version value is guaranteed.
In another embodiment of the present invention, if a message consumption failure is encountered and at the same time, when the version of the message is the maximum value in the message queue, for such a consumption failure message, a database warehouse entry process is required, and the content of the message failure and the version corresponding table are recorded in the failure table of the database. Further, the logic that manually sends the message determines that if the version of the failed message is less than the version value of the latest version in the database table, then the failed message may be discarded. If the version value of the failure message is greater than or equal to the version value of the maximum of the corresponding table of the current database, the message needs to be manually sent again, and finally, the data of the ES and the database are kept up to date and consistent.
It should be noted that the manual messaging operation herein may be performed by timing tasks.
According to the data synchronization method, the data sent to the database is intercepted and acquired through the message interception and the distribution mode of the message platform and is sent to other data storage spaces, and the data is judged and consumed through the data storage spaces, so that the service coupling degree can be reduced, and meanwhile, the timeliness of the data synchronization can be improved, and the accuracy and timeliness of the data synchronization are realized.
As shown in fig. 3, a functional block diagram of the data synchronization device of the present invention is shown.
The data synchronization device 100 of the present invention may be installed in an electronic apparatus. The data synchronization means may comprise an operation interception module 101, an encapsulated data acquisition module 102, a message sending module 103, a data synchronization module 104, depending on the implemented functions. The module of the present invention may also be referred to as a unit, meaning a series of computer program segments capable of being executed by the processor of the electronic device and of performing fixed functions, stored in the memory of the electronic device.
In the present embodiment, the functions concerning the respective modules/units are as follows:
an operation interception module 101, configured to intercept an SQL operation in data to be synchronized stored in a database;
the encapsulated data obtaining module 102 is configured to parse the intercepted SQL operation, obtain and encapsulate a parameter object and a mapping relationship corresponding to the SQL operation, so as to obtain encapsulated data corresponding to the SQL operation;
a message sending module 103, configured to send the encapsulated data to a message platform, monitor the encapsulated data through the message platform, and send the monitored message to a data storage space of a subscription message;
and the data synchronization module 104 is configured to receive and process the encapsulated data corresponding to the monitored message through the data storage space, and synchronize the data to be synchronized to the data storage space according to the encapsulated data.
Optionally, after synchronizing the data to be synchronized to the data storage space, the method further includes:
judging the synchronization result of the data to be synchronized;
when the data to be synchronized is successful in synchronization, feeding back an execution success notification to the message platform; otherwise, when the data to be synchronized fails to synchronize, prompting the selective retransmission of the message of the prior transmission failure.
Optionally, the process of intercepting the SQL operation in the data to be synchronized stored in the server includes:
intercepting SQL operation in the data to be synchronized through an SQL interceptor, and acquiring a version value of the data to be synchronized in the database; packaging the Version value, the parameter object and the mapping relation into the packaging data; the statement information of the SQL operation comprises: the data operation type, the data value and the table structure corresponding to the data to be synchronized; wherein the data operation types include a data addition operation, a data deletion operation, and a data modification operation. It should be emphasized that, to further ensure the privacy and security of the data to be synchronized, the data to be synchronized may also be stored in a node of a blockchain.
Optionally, the process of synchronizing the data to be synchronized into the data storage space according to the encapsulated data includes: and sequencing or discarding the monitored information according to the version value in the package data.
Optionally, when the synchronization of the data to be synchronized fails, judging whether the version value of the corresponding failed message is the maximum value in the message queue of the message platform;
if the version value of the failed message is the maximum value in the message queue, carrying out database warehousing processing on the failed message, and recording the content of the failed message and a corresponding table of version values;
and carrying out logic judgment on the failed message after the warehousing processing.
Preferably, if the version value of the failed message is smaller than the version value in the database, discarding the failed message; otherwise, the prompt message is sent again.
Fig. 4 is a schematic structural diagram of an electronic device for implementing the data synchronization method according to the present invention.
The electronic device 1 may comprise a processor 10, a memory 11 and a bus, and may further comprise a computer program, such as a data synchronization program 12, stored in the memory 11 and executable on the processor 10.
The memory 11 includes at least one type of readable storage medium, including flash memory, a mobile hard disk, a multimedia card, a card memory (e.g., SD or DX memory, etc.), a magnetic memory, a magnetic disk, an optical disk, etc. The memory 11 may in some embodiments be an internal storage unit of the electronic device 1, such as a removable hard disk of the electronic device 1. The memory 11 may in other embodiments also be an external storage device of the electronic device 1, such as a plug-in mobile hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card) or the like, which are provided on the electronic device 1. Further, the memory 11 may also include both an internal storage unit and an external storage device of the electronic device 1. The memory 11 may be used not only for storing application software installed in the electronic device 1 and various types of data, such as codes of data synchronization programs, but also for temporarily storing data that has been output or is to be output.
The processor 10 may be comprised of integrated circuits in some embodiments, for example, a single packaged integrated circuit, or may be comprised of multiple integrated circuits packaged with the same or different functions, including one or more central processing units (Central Processing unit, CPU), microprocessors, digital processing chips, graphics processors, combinations of various control chips, and the like. The processor 10 is a Control Unit (Control Unit) of the electronic device, connects respective components of the entire electronic device using various interfaces and lines, and executes various functions of the electronic device 1 and processes data by running or executing programs or modules (e.g., a data synchronization program, etc.) stored in the memory 11, and calling data stored in the memory 11.
The bus may be a peripheral component interconnect standard (peripheral component interconnect, PCI) bus or an extended industry standard architecture (extended industry standard architecture, EISA) bus, among others. The bus may be classified as an address bus, a data bus, a control bus, etc. The bus is arranged to enable a connection communication between the memory 11 and at least one processor 10 etc.
Fig. 4 shows only an electronic device with components, it being understood by a person skilled in the art that the structure shown in fig. 3 does not constitute a limitation of the electronic device 1, and may comprise fewer or more components than shown, or may combine certain components, or may be arranged in different components.
For example, although not shown, the electronic device 1 may further include a power source (such as a battery) for supplying power to each component, and preferably, the power source may be logically connected to the at least one processor 10 through a power management device, so that functions of charge management, discharge management, power consumption management, and the like are implemented through the power management device. The power supply may also include one or more of any of a direct current or alternating current power supply, recharging device, power failure detection circuit, power converter or inverter, power status indicator, etc. The electronic device 1 may further include various sensors, bluetooth modules, wi-Fi modules, etc., which will not be described herein.
Further, the electronic device 1 may also comprise a network interface, optionally the network interface may comprise a wired interface and/or a wireless interface (e.g. WI-FI interface, bluetooth interface, etc.), typically used for establishing a communication connection between the electronic device 1 and other electronic devices.
The electronic device 1 may optionally further comprise a user interface, which may be a Display, an input unit, such as a Keyboard (Keyboard), or a standard wired interface, a wireless interface. Alternatively, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch, or the like. The display may also be referred to as a display screen or display unit, as appropriate, for displaying information processed in the electronic device 1 and for displaying a visual user interface.
It should be understood that the embodiments described are for illustrative purposes only and are not limited to this configuration in the scope of the patent application.
The data synchronization program 12 stored in the memory 11 of the electronic device 1 is a combination of instructions that, when executed in the processor 10, may implement:
intercepting SQL operation in data to be synchronized stored in a database;
analyzing the intercepted SQL operation, and acquiring and encapsulating a corresponding parameter object and a mapping relation to acquire encapsulation data corresponding to the SQL operation;
the encapsulated data is sent to a message platform, the message platform monitors the encapsulated data and sends the monitored message to a data storage space of a subscription message;
and receiving and processing the encapsulated data through the data storage space, and carrying out data synchronization operation on the data to be synchronized according to the encapsulated data.
Specifically, the specific implementation method of the above instructions by the processor 10 may refer to the description of the relevant steps in the corresponding embodiment of fig. 1, which is not repeated herein. It should be emphasized that, to further ensure the privacy and security of the data to be synchronized, the data to be synchronized may also be stored in a node of a blockchain.
Further, the modules/units integrated in the electronic device 1 may be stored in a computer readable storage medium if implemented in the form of software functional units and sold or used as separate products. The computer readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer Memory, a Read-Only Memory (ROM).
In the several embodiments provided in the present invention, it should be understood that the disclosed apparatus, device and method may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is merely a logical function division, and there may be other manners of division when actually implemented.
The modules described as separate components may or may not be physically separate, and components shown as modules may or may not be physical units, may be located in one place, or may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional module in the embodiments of the present invention may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units can be realized in a form of hardware or a form of hardware and a form of software functional modules.
It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential characteristics thereof.
The present embodiments are, therefore, to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference signs in the claims shall not be construed as limiting the claim concerned.
The blockchain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, encryption algorithm and the like. The Blockchain (Blockchain), which is essentially a decentralised database, is a string of data blocks that are generated by cryptographic means in association, each data block containing a batch of information of network transactions for verifying the validity of the information (anti-counterfeiting) and generating the next block. The blockchain may include a blockchain underlying platform, a platform product services layer, an application services layer, and the like.
Furthermore, it is evident that the word "comprising" does not exclude other elements or steps, and that the singular does not exclude a plurality. A plurality of units or means recited in the system claims can also be implemented by means of software or hardware by means of one unit or means. The terms second, etc. are used to denote a name, but not any particular order.
Finally, it should be noted that the above-mentioned embodiments are merely for illustrating the technical solution of the present invention and not for limiting the same, and although the present invention has been described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications and equivalents may be made to the technical solution of the present invention without departing from the spirit and scope of the technical solution of the present invention.

Claims (6)

1. A method of data synchronization, the method comprising:
intercepting SQL operation in data to be synchronized stored in a database;
analyzing the intercepted SQL operation, and acquiring and packaging a parameter object and a mapping relation corresponding to the SQL operation so as to acquire packaging data corresponding to the SQL operation;
the encapsulation data is sent to a message platform, the encapsulation data is monitored through the message platform, and the monitored message is sent to a data storage space for subscribing the message;
receiving and processing encapsulation data corresponding to the monitored information through the data storage space, and synchronizing the data to be synchronized into the data storage space according to the encapsulation data;
the data to be synchronized is stored in a blockchain, and the process of intercepting SQL operation in the data to be synchronized stored in the database comprises the following steps:
intercepting SQL operation in the data to be synchronized through an SQL interceptor, and acquiring a version value of the data to be synchronized in the database;
packaging the version value, the parameter object and the mapping relation into the packaging data; the statement information of the SQL operation comprises: the data operation type, the data value and the table structure corresponding to the data to be synchronized; wherein the data operation types comprise a data adding operation, a data deleting operation and a data modifying operation;
the process of synchronizing the data to be synchronized into the data storage space according to the encapsulated data comprises the following steps: sorting or discarding the monitored messages according to the version value in the package data;
when the data to be synchronized fails in synchronization, judging whether the version value of the corresponding failed message is the maximum value in the message queue of the message platform;
if the version value of the failed message is the maximum value in the message queue, carrying out database warehousing processing on the failed message, and recording the content of the failed message and a corresponding table of version values;
logic judgment is carried out on the failed message after warehousing processing;
the logic judgment process comprises the following steps:
if the version value of the failed message is smaller than the version value in the database, discarding the failed message;
otherwise, the prompt message is sent again.
2. The data synchronization method according to claim 1, further comprising, after synchronizing the data to be synchronized to a data storage space:
judging the synchronization result of the data to be synchronized;
when the data to be synchronized is successful in synchronization, feeding back an execution success notification to the message platform; otherwise, when the data to be synchronized fails to synchronize, prompting the selective retransmission of the message of the prior transmission failure.
3. A data synchronization device, the device comprising:
the operation interception module is used for intercepting SQL operations in the data to be synchronized stored in the database;
the encapsulated data acquisition module is used for analyzing the intercepted SQL operation, acquiring and encapsulating a parameter object and a mapping relation corresponding to the SQL operation so as to acquire encapsulated data corresponding to the SQL operation;
the message sending module is used for sending the encapsulated data to a message platform, monitoring the encapsulated data through the message platform and sending the monitored message to a data storage space of a subscription message;
the data synchronization module is used for receiving and processing the encapsulation data corresponding to the monitored information through the data storage space and synchronizing the data to be synchronized into the data storage space according to the encapsulation data;
the data to be synchronized is stored in a blockchain, and the process of intercepting SQL operation in the data to be synchronized stored in the database comprises the following steps:
intercepting SQL operation in the data to be synchronized through an SQL interceptor, and acquiring a version value of the data to be synchronized in the database;
packaging the version value, the parameter object and the mapping relation into the packaging data; the statement information of the SQL operation comprises: the data operation type, the data value and the table structure corresponding to the data to be synchronized; wherein the data operation types comprise a data adding operation, a data deleting operation and a data modifying operation;
the process of synchronizing the data to be synchronized into the data storage space according to the encapsulated data comprises the following steps: sorting or discarding the monitored messages according to the version value in the package data;
when the data to be synchronized fails in synchronization, judging whether the version value of the corresponding failed message is the maximum value in the message queue of the message platform;
if the version value of the failed message is the maximum value in the message queue, carrying out database warehousing processing on the failed message, and recording the content of the failed message and a corresponding table of version values;
logic judgment is carried out on the failed message after warehousing processing;
the logic judgment process comprises the following steps:
if the version value of the failed message is smaller than the version value in the database, discarding the failed message;
otherwise, the prompt message is sent again.
4. The data synchronization device of claim 3, further comprising, after synchronizing the data to be synchronized to the data storage space:
judging the synchronization result of the data to be synchronized;
when the data to be synchronized is successful in synchronization, feeding back an execution success notification to the message platform; otherwise, when the data to be synchronized fails to synchronize, prompting the selective retransmission of the message of the prior transmission failure.
5. An electronic device, the electronic device comprising:
at least one processor; the method comprises the steps of,
a memory communicatively coupled to the processor; wherein,
the memory stores instructions executable by the processor to implement the data synchronization method of claim 1 or 2.
6. A computer readable storage medium storing a computer program, which when executed by a processor implements the data synchronization method according to claim 1 or 2.
CN202010879371.7A 2020-08-27 2020-08-27 Data synchronization method, device and computer readable storage medium Active CN112015815B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010879371.7A CN112015815B (en) 2020-08-27 2020-08-27 Data synchronization method, device and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010879371.7A CN112015815B (en) 2020-08-27 2020-08-27 Data synchronization method, device and computer readable storage medium

Publications (2)

Publication Number Publication Date
CN112015815A CN112015815A (en) 2020-12-01
CN112015815B true CN112015815B (en) 2024-02-02

Family

ID=73503777

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010879371.7A Active CN112015815B (en) 2020-08-27 2020-08-27 Data synchronization method, device and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN112015815B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112685499B (en) * 2020-12-30 2024-06-18 珠海格力电器股份有限公司 Method, device and equipment for synchronizing flow data of working service flow
CN112988897A (en) * 2021-03-30 2021-06-18 工银科技有限公司 Data bidirectional synchronization method and device in system upgrading scene
CN113392161A (en) * 2021-07-08 2021-09-14 苏州海管家物流科技有限公司 Data bidirectional real-time synchronization system
CN113946628A (en) * 2021-10-27 2022-01-18 中国建设银行股份有限公司 Data synchronization method and device based on interceptor

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103595812A (en) * 2013-11-21 2014-02-19 北京京东尚科信息技术有限公司 Method and device for sending Web service message
CN108833199A (en) * 2018-04-26 2018-11-16 广州视源电子科技股份有限公司 Method, apparatus, equipment and the storage medium that data report
CN108985757A (en) * 2017-11-27 2018-12-11 北京京东金融科技控股有限公司 Information processing method, apparatus and system, storage medium, electronic equipment
CN109446273A (en) * 2018-12-04 2019-03-08 深圳前海环融联易信息科技服务有限公司 Method of data synchronization, device, computer equipment and the storage medium of block chain
CN110232097A (en) * 2019-06-21 2019-09-13 北京奇艺世纪科技有限公司 A kind of method of data synchronization and device
CN110898434A (en) * 2019-11-06 2020-03-24 上饶市中科院云计算中心大数据研究院 Method, server, system, and computer-readable program medium for processing data
CN111400130A (en) * 2020-03-06 2020-07-10 平安科技(深圳)有限公司 Task monitoring method and device, electronic equipment and storage medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8019863B2 (en) * 2008-03-28 2011-09-13 Ianywhere Solutions, Inc. Synchronizing events between mobile devices and servers

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103595812A (en) * 2013-11-21 2014-02-19 北京京东尚科信息技术有限公司 Method and device for sending Web service message
CN108985757A (en) * 2017-11-27 2018-12-11 北京京东金融科技控股有限公司 Information processing method, apparatus and system, storage medium, electronic equipment
CN108833199A (en) * 2018-04-26 2018-11-16 广州视源电子科技股份有限公司 Method, apparatus, equipment and the storage medium that data report
CN109446273A (en) * 2018-12-04 2019-03-08 深圳前海环融联易信息科技服务有限公司 Method of data synchronization, device, computer equipment and the storage medium of block chain
CN110232097A (en) * 2019-06-21 2019-09-13 北京奇艺世纪科技有限公司 A kind of method of data synchronization and device
CN110898434A (en) * 2019-11-06 2020-03-24 上饶市中科院云计算中心大数据研究院 Method, server, system, and computer-readable program medium for processing data
CN111400130A (en) * 2020-03-06 2020-07-10 平安科技(深圳)有限公司 Task monitoring method and device, electronic equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
"分布式***中数据同步机制的研究与实现";崔伟等;<计算机工程与设计>;全文 *

Also Published As

Publication number Publication date
CN112015815A (en) 2020-12-01

Similar Documents

Publication Publication Date Title
CN112015815B (en) Data synchronization method, device and computer readable storage medium
CN112653760B (en) Cross-server file transmission method and device, electronic equipment and storage medium
CN112631806B (en) Asynchronous message arrangement and scheduling method and device, electronic equipment and storage medium
CN112446022A (en) Data authority control method and device, electronic equipment and storage medium
CN112084486A (en) User information verification method and device, electronic equipment and storage medium
CN114035987A (en) Data transmission method and device based on message queue, electronic equipment and medium
CN112506559A (en) Gray scale publishing method and device based on gateway, electronic equipment and storage medium
CN112256783A (en) Data export method and device, electronic equipment and storage medium
CN113890712A (en) Data transmission method and device, electronic equipment and readable storage medium
CN113420032A (en) Classification storage method and device for logs
CN114205322A (en) Message sending method and device, electronic equipment and storage medium
CN114201466B (en) Anti-cache breakdown method, device, equipment and readable storage medium
CN112540839B (en) Information changing method, device, electronic equipment and storage medium
CN113347245B (en) File fragment breakpoint transmission method and device based on message queue
CN115687384A (en) UUID (user identifier) identification generation method, device, equipment and storage medium
CN114547011A (en) Data extraction method and device, electronic equipment and storage medium
CN115145870A (en) Method and device for positioning reason of failed task, electronic equipment and storage medium
CN114820132A (en) Order distribution method and device, electronic equipment and storage medium
CN114826725A (en) Data interaction method, device, equipment and storage medium
CN113568904B (en) Work delivery method and device, electronic equipment and readable storage medium
CN115174691B (en) Big data loading method, device, equipment and medium based on page request
CN113542387B (en) System release method and device, electronic equipment and storage medium
CN115225458A (en) Alarm notification method, alarm notification device, electronic equipment and storage medium
CN112860394A (en) Timing task scheduling execution method and device, electronic equipment and storage medium
CN117851506A (en) GIT-based cross-library synchronization method and device, electronic equipment and storage medium

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