Background technology
The mainstream data synchronization scheme in industry is generally two kinds at present, is the data synchronization for being based on trigger respectively
Scheme and the data synchronization scheme of logic-based daily record.
In data synchronization scheme based on trigger, need to create trigger in tables of data in database facility, work as number
When changing according to table, trigger can capture the variation of data, and be recorded in daily record, then by client device according to
The triggering situation of trigger reads the data of variation, and reconvert is synchronized to other databases into corresponding structured query sentence
In.But due to, there are problems that writing amplification in above process, the data of a variation may need in whole process
The write-in consumption of several times can just complete data synchronization, therefore there is the problem of processing expense is excessive, be not suitable for lasting processing pressure
The larger application scenarios of power.
In the data synchronization scheme of logic-based daily record, the variation of data is obtained at its kernel end in database facility, then
The variation of data is converted to structural data of the homogeneous data library in logic level as data synchronization information, is sent to other
Homogeneous data library synchronizes, and therefore, such scheme can only apply between isomorphism database (such as PostgreSQL databases
Between PostgreSQL databases) data it is synchronous in, can not realize that data between heterogeneous database synchronize.
Therefore, lack in the prior art it is a kind of handle expense it is smaller and suitable for heterogeneous database data synchronization scheme.
Apply for content
The purpose of the application is to provide a kind of scheme realized data and synchronized, to solve in the prior art can not be same
Shi Shixian processing expense it is smaller and suitable for heterogeneous database the problem of.
To achieve the above object, this application provides it is a kind of database facility end generation data synchronization information method,
This method includes:
The affair logic information is obtained based on redoing log, wherein, the affair logic information reforms day for representing described
The delta data of the corresponding affairs of will;
The affair logic information is sent to client device, so that the client device is redo log pair according to
The structured query sentence that the delta data generation for the affairs answered synchronizes for data.
Further, based on redo log obtain the affair logic information, including:
Acquisition and the relevant pre-parsed data of affairs are redo log based on described, the pre-parsed data include determining
The row information that tables of data changes in the label information and affairs of affairs;
Index information according to corresponding to the system table of database determines the row information that tables of data changes in the affairs, and
Row information index information corresponding with its that tables of data in the affairs changes is determined as to the data change information of affairs;
According to described for determining the data change information of the label information and affairs of affairs, generate to represent described heavy
Do the affair logic information of the delta data of the corresponding affairs of daily record.
Further, the index information includes the row name of the primary key column of tables of data.
Further, this method further includes:
If it is replaced in the row information that tables of data changes in the affairs comprising the big field not changed with big field label
Change the big field not changed.
Further, this method further includes:
The reception progress msg about the affair logic information of client device passback is obtained, wherein, the reception progress
Information is used to indicate the affair logic information that the client device has completed reception;
According to the reception progress msg that client device returns, the affairs for not completing and receiving are sent to the client device
Logical message.
Further, the affair logic information is sent to client device, including:
The affair logic information is sent to the client device in the form of character string, wherein, the character string packet
Containing the check information for verifying the affair logic information and the text message for representing the affair logic information.
Correspondingly, present invention also provides a kind of method in client device end generation data synchronization information, this method
Including:
It is received from database facility based on the affair logic information for redoing log acquisition, wherein, the affair logic information
Including being used to represent the delta data for redoing log corresponding affairs;
The structured query sentence synchronized according to the delta data generation for redoing log corresponding affairs for data.
Present invention also provides a kind of method for carrying out data synchronization at client device end, wherein, this method includes:
It is received from database facility based on the affair logic information for redoing log acquisition, wherein, the affair logic information
For representing the delta data for redoing log corresponding affairs;
The structured query sentence synchronized according to the delta data generation for redoing log corresponding affairs for data;
The structured query sentence is sent to target data library facilities, so that the target data library facilities performs institute
Structured query sentence is stated, data is completed and synchronizes.
Further, this method further includes:
When being received from database facility based on the affair logic information for redoing log acquisition, interrupted if receiving, to described
Database facility sends the reception progress msg about the affair logic information, wherein, the reception progress msg is used to mark
Show that client device has completed the affair logic information received.
Further, it is received from database facility based on the affair logic information for redoing log acquisition, including:
It is received in the form of character string from database facility based on the affair logic information for redoing log acquisition, wherein, institute
Character string is stated to include for verifying the check information of the affair logic information and for representing the affair logic information just
Literary information;
After being received from database facility based on the affair logic information of acquisition is redo log, using check information to institute
The affair logic information represented by text message is stated to be verified.
Further, the structured query sentence synchronized according to the affair logic information generation for data, including:
According to predefined data rule, by obtaining the affair logic information in the character string, and generate about institute
State the structural data of the affair logic information;
The label information for being used to determine affairs in the structural data encapsulates the data change information of affairs
For the delta data as unit of affairs;
According to the delta data as unit of affairs, the structured query sentence of each affairs is generated.
Another aspect based on the application additionally provides a kind of database facility for being used to generate data synchronization information, should
Equipment includes:
Resolver obtains the affair logic information for being based on redoing log, wherein, the affair logic information is used for table
Show the delta data for redoing log corresponding affairs;
Transmitting device, for sending the affair logic information to client device so that the client device according to
The structured query sentence that the delta data generation for redoing log corresponding affairs synchronizes for data.
Further, the resolver, for be based on it is described redo log acquisition and the relevant pre-parsed data of affairs,
The pre-parsed data include for determine affairs label information and affairs in tables of data change row information;According to data
The system table in library determines the index information corresponding to the row information that tables of data in the affairs changes, and by data in the affairs
Row information index information corresponding with its of table change is determined as the data change information of affairs;And it is used to determine according to described
The label information of affairs and the data change information of affairs generate to represent the variation number for redoing log corresponding affairs
According to the affair logic information.
Further, the index information includes the row name of the primary key column of tables of data.
Further, the resolver is not sent out if being additionally operable to include in the row information that tables of data changes in the affairs
The big field to change more, with the big field not changed described in big field label replacement.
Further, the transmitting device is additionally operable to obtain the connecing about the affair logic information of client device passback
Progress msg is received, wherein, the progress msg that receives is used to indicate the affair logic letter that the client device has completed reception
Breath;And the reception progress msg returned according to client device, the affairs for not completing and receiving are sent to the client device
Logical message.
Further, the transmitting device, for sending the affairs to the client device in the form of character string
Logical message, wherein, the character string is comprising the check information for verifying the affair logic information and for representing described
The text message of the affair logic information.
Correspondingly, present invention also provides a kind of for generating the client device of data synchronization information, which includes:
Transmitting device, for being received from database facility based on the affair logic information for redoing log acquisition, wherein, it is described
The affair logic information is used to represent the delta data for redoing log corresponding affairs;
Integrating apparatus, the knot that the delta data generation for redoing log corresponding affairs according to synchronizes for data
Structure query statement.
Present invention also provides a kind of for carrying out the client device of data synchronization, which includes:
Transmitting device, for being received from database facility based on the affair logic information for redoing log acquisition, wherein, it is described
The affair logic information is used to represent the delta data for redoing log corresponding affairs;And structured query sentence is sent
To target data library facilities, so that the target data library facilities performs the structured query sentence, complete data and synchronize.
Integrating apparatus, the knot that the delta data generation for redoing log corresponding affairs according to synchronizes for data
Structure query statement.
Further, the transmitting device is additionally operable to receive based on the affairs for redoing log acquisition from database facility
It during logical message, is interrupted if receiving, the reception progress msg about the affair logic information is sent to the database facility,
Wherein, the progress msg that receives is used to indicate the affair logic information that client device has completed reception.
Further, the transmitting device is based on redoing log for receiving from database facility in the form of character string
The affair logic information of acquisition, wherein, the character string includes the check information and use for verifying the affair logic information
In the text message for representing the affair logic information;
The integrating apparatus, be additionally operable to from database facility receive based on redo log acquisition the affair logic information it
Afterwards, the affair logic information represented by the text message is verified using check information.
Further, the integrating apparatus, for according to predefined data rule, as described in being obtained in the character string
The affair logic information, and generate the structural data about the affair logic information;According to the use in the structural data
In determining the label informations of affairs by the data change information of affairs and be encapsulated as the delta data as unit of affairs;And according to
The delta data as unit of affairs generates the structured query sentence of each affairs.
In addition, present invention also provides a kind of for generating the database facility of data synchronization information, which includes:
Processor;And
The memory of storage computer executable instructions is arranged to, the executable instruction makes the place when executed
Manage device:The affair logic information is obtained based on redoing log, wherein, the affair logic information is redo log pair for representing described
The delta data for the affairs answered;And the affair logic information is sent to client device, so that the client device root
The structured query sentence synchronized according to the delta data generation for redoing log corresponding affairs for data
Present invention also provides a kind of for generating the client device of data synchronization information, which includes:
Processor;And
The memory of storage computer executable instructions is arranged to, the executable instruction makes the place when executed
Manage device:It is received from database facility based on the affair logic information for redoing log acquisition, wherein, the affair logic information is used for
The delta data of corresponding affairs is redo log described in expression;And according to the delta data for redoing log corresponding affairs
The structured query sentence that generation synchronizes for data.
Present invention also provides a kind of for carrying out the client device of data synchronization, which includes:
Processor;And
The memory of storage computer executable instructions is arranged to, the executable instruction makes the place when executed
Manage device:It is received from database facility based on the affair logic information for redoing log acquisition, wherein, the affair logic information is used for
The delta data of corresponding affairs is redo log described in expression;According to the delta data for redoing log corresponding affairs
The structured query sentence that generation synchronizes for data;And the structured query sentence is sent to target database and is set
It is standby, so that the target data library facilities performs the structured query sentence, complete data and synchronize.
Compared with prior art, this application provides a kind of scheme realized data and synchronized, the program, which is primarily based on, to be reformed
Log acquisition the affair logic information, the affair logic information table show that the data of each affairs in database are increased newly, update, deleted
Situation of change after the affair logic information is sent to client device by database facility, carries out it by client device whole
It closes, generating structure query statement (SQL statement), as data synchronization information, without using trigger during this, therefore not
The problem of writing amplification is had, processing expense is smaller.Since structured query sentence can be suitable for the arbitrarily database based on SQL
(such as PostgreSQL, MySQL, SQL Server etc.) thus when carrying out data synchronization, can be adapted for heterogeneous database
Between data synchronize.
Specific embodiment
The application is described in further detail below in conjunction with the accompanying drawings.
In a typical configuration of this application, terminal, the equipment of service network include one or more processors
(CPU), input/output interface, network interface and memory.
Memory may include computer-readable medium in volatile memory, random access memory (RAM) and/or
The forms such as Nonvolatile memory, such as read-only memory (ROM) or flash memory (flash RAM).Memory is computer-readable medium
Example.
Computer-readable medium includes permanent and non-permanent, removable and non-removable media, can be by any side
Method or technology realize that information stores.Information can be computer-readable instruction, data structure, the module of program or other numbers
According to.The example of the storage medium of computer includes, but are not limited to phase transition internal memory (PRAM), static RAM
(SRAM), dynamic random access memory (DRAM), other kinds of random access memory (RAM), read-only memory
(ROM), electrically erasable programmable read-only memory (EEPROM), fast flash memory bank or other memory techniques, CD-ROM (CD-
ROM), digital versatile disc (DVD) or other optical storages, magnetic tape cassette, magnetic tape disk storage or other magnetic storages
Equipment or any other non-transmission medium, available for storing the information that can be accessed by a computing device.
Fig. 1 shows a kind of heterogeneous database system, the Database Systems include the database facility of multiple isomeries with
And data sync client end equipment, during being simplicity, with two database facilities and a data sync client in the present embodiment
It is described in detail for end equipment 130, wherein, the use PostgreSQL databases of database facility 110, and database facility
120 use MySQL database, and the two is heterogeneous database.The quantity of each dvielement shown in figure is likely less than actual field
The quantity of respective element in scape, but it is this omission be far and away with do not interfere with the present invention is carried out it is clear, be adequately disclosed as
Premise.For above-mentioned database facility and client device, specific implementation can include but is not limited to:User equipment, net
Network equipment or user equipment are integrated formed equipment by network with the network equipment.The user equipment includes but not limited to
The equipment such as personal computer, touch control terminal, mobile terminal;The network equipment include but not limited to as single network server,
The cluster of multiple network server compositions or the set of computers based on cloud computing etc..
The embodiment of the present application provide it is a kind of generate data synchronization information method, for generate one kind can be suitable for it is different
The data synchronization information of data synchronization is carried out between structure database, with reference to the equipment in Fig. 1, process flow such as Fig. 2 of this method
It is shown.
At database facility end, specific processing step includes:
S201, database facility are based on redoing log (redo log) acquisition the affair logic information.Wherein, the affairs are patrolled
Information is collected to be used to represent the delta data for redoing log corresponding affairs.
In actual scene, the middle affair related information that can be recorded and be submitted in a period of time is redo log, wherein can wrap
Delta data containing these affairs, these delta datas are the variation that data are occurred in database in corresponding this time, are led to
The affair logic information for obtaining and can representing these delta datas is crossed, so as to provide the foundation of data synchronization.
The delta data for redoing log corresponding affairs can include at least for determine affairs label information and
The data change information of affairs.Wherein, it is described to be used to determine that the label information of affairs refers to uniquely determine a certain affairs
Information, such as can be the information such as Transaction Identifier, transaction start time, affairs submission time, it is each by these data separations
Affairs.And the data change information of affairs refers to the content of the data variation involved by each affairs.As a result, by being used for really
Determining the label information of affairs and the data change information of affairs can determine to redo log the delta data of corresponding affairs.
In actual scene, the Transaction Identifier can be affairs ID, and transaction start time and affairs submission time can be by
With being determined in the relevant timestamp of affairs, the data change informations of affairs refers to changed in this transaction process
The relevant information of data.The data change information of affairs refers in a certain affairs, the change occurred about the data in tables of data
The information of change.
In one embodiment of the application, the concrete processing procedure that database facility obtains the affair logic information can adopt
With following processing step:
First, based on acquisition and the relevant pre-parsed data of affairs is redo log, the pre-parsed data are included for true
Determine affairs label information and affairs in tables of data change row information.
Due in redoing log other than comprising with the relevant pre-parsed data of affairs, also comprising other unrelated numbers
According to such as with storing relevant data, therefore pair being pre-processed with it, screening needs and the relevant pre-parsed number of affairs
It can include the row information that tables of data changes in label information and affairs for determining affairs according to, these pre-parsed data.
For db transaction, data variation type includes newly-increased (insert), modification (update) and deletes (delete), by
This, the row information that tables of data changes in the affairs, can be that a data " 10 " in a certain tables of data in Nth row is modified as
Data " A " in " 11 " or M rows are deleted, it is also possible to which a certain row in L rows have increased data " B " etc. newly
Deng.
Then, the index letter according to corresponding to the system table of database determines the row information that tables of data changes in the affairs
Breath.Pass through inquiry system table (catalog), it may be determined that the corresponding table name of delta data, row name, table schema name, data type
Index informations are waited, specific position of the delta data in all data of database can be quickly navigated to by these index informations
It puts.
At this point it is possible to row information index information corresponding with its that tables of data in the affairs is changed is determined as affairs
Data change information.Finally, it is used to determine the label information of affairs and the change data of affairs according to the basis got
Information can generate the affair logic information for representing the delta data for redoing log corresponding affairs.As a result,
By the affair logic information can quickly determine in database positioned at which position data have occurred which kind of variation, in order to
During data synchronization updating, realize and fast and accurately position and be written, improve treatment effeciency.
S202, database facility sends the affair logic information to client device, so that the client device root
The structured query sentence synchronized according to the affair logic information generation for data.
In one embodiment of the application, the database facility when sending the affair logic information, can first by
Into after character string, in the form of character string send the affair logic to the client device believes the affair logic information integration
Breath.It is therefore, described since mistake occurs for the data that in transmission process, may cause transmission because of reasons such as network environments
Character string can specifically include two parts, that is, be used to verify the check information of the affair logic information and for representing described
The text message of the affair logic information so that check information may be used to institute after character string is received in client device
It states the affair logic information represented by text message to be verified, to ensure the accuracy of data transmission.
In actual scene, other than may be there is a situation where error in data, when sending the affair logic information,
It is also possible to there is the situation of Transmission, one embodiment of the application also supports the breakpoint of the affair logic information to continue as a result,
It passes.Specifically, the method for generating data synchronization information further includes:Database facility obtain client device passback about affairs
The reception progress msg of logical message and need carry out breakpoint transmission when, according to client device return reception progress
Information sends the affair logic information for not completing and receiving to the client device.Wherein, the reception progress msg is used to mark
Show that the client device has completed the affair logic information received.
For example, database facility is had no progeny in the transmission, receive and believe from what client device returned about the affair logic
The reception progress msg of breath shows that client device has completed the reception of information 001~100 in the reception progress msg.Rear
During continuous, if the client device will continue to obtain the affair logic information, it can be believed according to the reception progress received before
Breath, sends subsequent the affair logic information since information 101.In specific implementation process, suitable interface may be used
The transmission of relevant information is carried out, such as PostgreSQL databases, is answered since it provides logic flow after 9.4 versions
Interface processed then can utilize logic flow to replicate interface transmission transaction logical message and receive progress msg accordingly.
In addition, the embodiment of the present application additionally provides a kind of embodiment, to realize to the excellent of the tables of data comprising big field
Change.For the row information of tables of data change, if comprising big field in the row, and the big field does not change, then database is set
During standby acquisition the affair logic information, the big field not changed described in replacing can be marked by big field, so as to not transmit
Big field.Since big field label is only a label information, it is big field to be only used for representing the contents of the section in the row, and not
It changes, data volume is far smaller than practical big field, therefore can reduce transmitted data amount, to reach optimization flow
Purpose.
Correspondingly, at client device end, the method for generating data synchronization information includes:
Step S203, client device are received from database facility based on the affair logic information for redoing log acquisition.
If database facility is that the affair logic information is sent in a manner of character string, client device also can be with word
The form for according with string is received from database facility based on the affair logic information for redoing log acquisition, wherein, the binary-coded character
String includes to verify the check information of the affair logic information and the text message for representing the affair logic information.
After being received from database facility based on the affair logic information of acquisition is redo log, client device can be adopted
The affair logic information represented by the text message is verified with check information.For example, each data frame during transmission
Total length is 4 bytes, and the first two byte is verification information, latter two byte is text message, is receiving the first two byte
After verification information, two subsequently received byte text messages can be verified based on the verification information, only existed
Just think to have received the affair logic information represented by text message after being verified, thus improve the accurate of information transmission
Property.
In addition, client device from database facility receive based on the affair logic information for redoing log acquisition when, if
It receives and interrupts, the reception progress msg about the affair logic information is sent to the database facility, wherein, the reception
Progress msg is used to indicate the affair logic information that client device has completed reception.Hereby it is achieved that the affair logic information is disconnected
Point resumes function.
Step S204, client device redo log corresponding affairs according to represented by the affair logic information
Delta data generation for data synchronize structured query sentence, using the structured query sentence as data synchronize letter
Breath.Accordingly, for the target data library facilities for needing progress data synchronization, as long as the database that the target data library facilities uses
Product can use structured query sentence (SQL statement), you can using the synchrodata information generated in the embodiment of the present application
Carry out data synchronization.For example, to the database facility shown in Fig. 1, according to scheme of the prior art, it can only realize and adopt
It is synchronized with the data between the database facility of PostgreSQL;And to scheme provided by the embodiments of the present application, it uses
The database facility of PostgreSQL can be realized to arbitrary database facility (such as the number using MySQL using SQL statement
According to library facilities 120) carry out data synchronization.
In one embodiment of the application, specific process flow such as Fig. 3 of client device generating structure query statement
It is shown, including:
Step S301, according to predefined data rule, by obtaining the affair logic information, and life in the character string
Into the structural data about the affair logic information.Still by taking aforementioned scene as an example, if client device leads to given interface,
It, will be according to predefined data rule, to string of binary characters after the string of binary characters for getting database facility transmission
It is handled, such as extracts the content of specific position in string of binary characters, after being parsed to these contents, extraction meets accident
Information corresponding to logical message of being engaged in.Further, for ease of subsequent processing, the format data of specific format can be formed.
Step S302, change data of the label information by affairs for being used to determine affairs in the structural data
Information encapsulation is the delta data as unit of affairs.If still by taking the label information in precedent as an example, that is, it is used to determine affairs
Label information includes the timestamp that affairs ID, the timestamp that affairs start, affairs are submitted, thus, it is possible to pass through affairs ID, affairs
It is involved in period to submission that the timestamp that the timestamp of beginning, affairs are submitted can determine that a certain affairs start at it
Data change information, thus by the delta data as unit of affairs.For example, for the affairs that affairs ID is 001, start
Timestamp is 01:00:00:000, the timestamp of submission is:01:00:02:000, it is possible thereby to determine the affairs interior during this period
Data change information, and then encapsulate as unit of affairs the delta data of the affairs.
Step S303 according to the delta data as unit of affairs, generates the structured query sentence of each affairs.
According to the content of encapsulation, after the data of variation are converted into SQL statement for unit according to affairs so that need synchronous number of targets
The synchronization of data can be realized according to library facilities by performing the SQL statement.
In addition, the embodiment of the present application additionally provides a kind of method for carrying out data synchronization, in this method, using aforementioned generation
The mode of data synchronization information generates the structured query sentence of affairs, then by client device by the structuralized query
Sentence is sent to target data library facilities, so that the target data library facilities performs the structured query sentence, completes number
According to synchronization.
For target data library facilities, if when updating the data comprising major key in tables of data, it can be by inquiring major key
The change of mode rapidly locating table row information, without traversing entire tables of data, and target data library facilities can be with
It realizes that parallel data are written according to tables of data or major key, thus improves the write performance of target data library facilities.Therefore, it is raw
During into data synchronization information, if comprising major key in tables of data where the row information of change, database facility can be by the data
The row name of the primary key column of table also serves as an entry index acquisition of information, is contained in data synchronization information, thus same in progress data
High performance write-in is realized during step.
Based on same inventive concept, additionally provided in the embodiment of the present application be used to implement data synchronization database facility and
Client device, database facility method corresponding with client device are the synchronous correlations of the realization data in previous embodiment
Method, and its principle solved the problems, such as is similar to the method.
Fig. 4 shows a kind of database facility 400 for being used to generate data synchronization information provided by the embodiments of the present application, should
Database facility 400 includes resolver 410 and transmitting device 420.The resolver 410 is used to be based on redoing log acquisition
The affair logic information.Wherein, the affair logic information is used to represent the delta data for redoing log corresponding affairs.Institute
State transmitting device 420 and send the affair logic information to client device for equipment so that the client device according to
The structured query sentence that the affair logic information generation synchronizes for data.
In actual scene, the middle affair related information that can be recorded and be submitted in a period of time is redo log, wherein can wrap
Delta data containing these affairs, these delta datas are the variation that data are occurred in database in corresponding this time, are led to
The affair logic information for obtaining and can representing these delta datas is crossed, so as to provide the foundation of data synchronization.
The delta data for redoing log corresponding affairs can include at least for determine affairs label information and
The data change information of affairs.Wherein, it is described to be used to determine that the label information of affairs refers to uniquely determine a certain affairs
Information, such as can be the information such as Transaction Identifier, transaction start time, affairs submission time, it is each by these data separations
Affairs.And the data change information of affairs refers to the content of the data variation involved by each affairs.As a result, by being used for really
Determining the label information of affairs and the data change information of affairs can determine to redo log the delta data of corresponding affairs.
In actual scene, the Transaction Identifier can be affairs ID, and transaction start time and affairs submission time can be by
With being determined in the relevant timestamp of affairs, the data change informations of affairs refers to changed in this transaction process
The relevant information of data.The data change information of affairs refers in a certain affairs, the change occurred about the data in tables of data
The information of change.
In one embodiment of the application, the resolver 410 of database facility obtains the specific of the affair logic information
Following processing step may be used in processing procedure:
First, resolver is based on redoing log acquisition and the relevant pre-parsed data of affairs, and the pre-parsed data are used
The row information that tables of data changes in the label information and affairs for determining affairs.
Due in redoing log other than comprising with the relevant pre-parsed data of affairs, also comprising other unrelated numbers
According to such as with storing relevant data, therefore pair being pre-processed with it, screening needs and the relevant pre-parsed number of affairs
It can include the row information that tables of data changes in label information and affairs for determining affairs according to, these pre-parsed data.
For db transaction, data variation type includes newly-increased (insert), modification (update) and deletes (delete), by
This, the row information that tables of data changes in the affairs, can be that a data " 10 " in a certain tables of data in Nth row is modified as
Data " A " in " 11 " or M rows are deleted, it is also possible to which a certain row in L rows have increased data " B " etc. newly
Deng.
Then, resolver is according to corresponding to the system table of database determines the row information that tables of data changes in the affairs
Index information.Pass through inquiry system table (catalog), it may be determined that the corresponding table name of delta data, row name, table schema name,
The index informations such as data type can quickly navigate to delta data in all data of database by these index informations
Specific location.
At this point, resolver can determine row information index information corresponding with its that tables of data in the affairs changes
Data change information for affairs.Finally, resolver is used to determine according to the basis got the label information of affairs
With the data change information of affairs, the thing for representing the delta data for redoing log corresponding affairs can be generated
Business logical message.It can quickly determine that the data in database positioned at which position have occurred by the affair logic information as a result,
Which kind of variation fast and accurately positions and is written in order in data synchronization updating, realize, improves treatment effeciency.
In one embodiment of the application, the transmitting device 420 of the database facility is sending the affair logic letter
During breath, it can be sent in the form of character string to the client device first by the affair logic information integration into after character string
The affair logic information.Since the data that in transmission process, may cause transmission because of reasons such as network environments occur
Mistake, therefore, the character string can specifically include two parts, that is, be used to verify the check information of the affair logic information
With for representing the text message of the affair logic information so that client device can be adopted after character string is received
The affair logic information represented by the text message is verified with check information, to ensure the accuracy of data transmission.
In actual scene, other than may be there is a situation where error in data, transmitting device 420 sending the affairs
During logical message, it is also possible to the situation of Transmission occur, one embodiment of the application also supports the affair logic to believe as a result,
The breakpoint transmission of breath.Specifically, the transmitting device 420 be additionally operable to obtain client device passback about the affair logic information
Reception progress msg and need carry out breakpoint transmission when, according to client device return reception progress msg, to institute
It states client device and sends the affair logic information for not completing and receiving.Wherein, the reception progress msg is used to indicate the visitor
Family end equipment has completed the affair logic information received.
For example, database facility is had no progeny in the transmission, the transmitting device can be received to be returned from client device
About the reception progress msg of the affair logic information, show in the reception progress msg client device completed information 001~
100 reception.It in the follow-up process, can be according to receiving before if the client device will continue to obtain the affair logic information
The reception progress msg arrived sends subsequent the affair logic information since information 101.In specific implementation process, it can adopt
The transmission of relevant information is carried out with suitable interface, such as PostgreSQL databases, since it is after 9.4 versions
Provide logic flow and replicate interface, then can utilize logic flow replicate interface transmission transaction logical message and it is corresponding receive into
Spend information.
In addition, the embodiment of the present application additionally provides a kind of embodiment, to realize to the excellent of the tables of data comprising big field
Change.For the row information of tables of data change, if comprising big field in the row, and the big field does not change, then database is set
The standby resolver, can be big by not changed described in big field label replacement when obtaining the affair logic information
Field, so as to not transmit big field.Since big field label is only a label information, it is only used for representing in the part in the row
To hold for big field, and do not change, data volume is far smaller than practical big field, therefore can reduce transmitted data amount,
To achieve the purpose that optimize flow.
Correspondingly, the embodiment of the present application additionally provides a kind of for generating the client device 500 of data synchronization information, should
The structure of client device is as shown in figure 4, including transmitting device 510 and integrating apparatus 520.Wherein, the transmitting device 510 is used
It is received in from database facility based on the affair logic information for redoing log acquisition.The integrating apparatus 520 is used for according to
The structuring that the delta data generation for redoing log corresponding affairs represented by the affair logic information synchronizes for data
Query statement, using the structured query sentence as data synchronization information.
If the transmitting device 420 of database facility is that the affair logic information, client are sent in a manner of character string
The transmitting device 510 of end equipment can also be received from database facility in the form of character string and be patrolled based on the affairs for redoing log acquisition
Information is collected, wherein, the string of binary characters is included for verifying the check information of the affair logic information and for representing
The text message of the affair logic information.
After being received from database facility based on the affair logic information of acquisition is redo log, client device can be adopted
The affair logic information represented by the text message is verified with check information.For example, each data frame during transmission
Total length is 4 bytes, and the first two byte is verification information, latter two byte is text message, is receiving the first two byte
After verification information, two subsequently received byte text messages can be verified based on the verification information, only existed
Just think to have received the affair logic information represented by text message after being verified, thus improve the accurate of information transmission
Property.
In addition, the transmitting device 510 of client device is received from database facility based on the affairs for redoing log acquisition
It during logical message, is interrupted if receiving, the reception progress msg about the affair logic information is sent to the database facility,
Wherein, the progress msg that receives is used to indicate the affair logic information that client device has completed reception.Hereby it is achieved that affairs
The breakpoint transmission function of logical message.
For needing the target data library facilities of progress data synchronization, as long as the database that the target data library facilities uses
Product can use structured query sentence (SQL statement), you can using the synchrodata information generated in the embodiment of the present application
Carry out data synchronization.For example, to the database facility shown in Fig. 1, according to scheme of the prior art, it can only realize and adopt
It is synchronized with the data between the database facility of PostgreSQL;And to scheme provided by the embodiments of the present application, it uses
The database facility of PostgreSQL can be realized to arbitrary database facility (such as the number using MySQL using SQL statement
According to library facilities 120) carry out data synchronization.
In one embodiment of the application, the 510 generating structure query statement of integrating apparatus of client device it is specific
Process flow as shown in figure 3, including:
Step S301, integrating apparatus is according to predefined data rule, by obtaining the affair logic in the character string
Information, and generate the structural data about the affair logic information.Still by taking aforementioned scene as an example, if client device lead to
Fixed interface, after the string of binary characters for getting database facility transmission, will according to predefined data rule, to two into
Character string processed is handled, such as extracts the content of specific position in string of binary characters, after being parsed to these contents,
Extract the information corresponding to the affair logic information.Further, for ease of subsequent processing, the form of specific format can be formed
Change data.
Step S302, integrating apparatus in the structural data for determining the label informations of affairs by affairs
Data change information is encapsulated as the delta data as unit of affairs.If still by taking the label information in precedent as an example, i.e., for true
The label information for determining affairs includes the timestamp that affairs ID, the timestamp that affairs start, affairs are submitted, thus, it is possible to pass through thing
The timestamp that timestamp that business ID, affairs start, affairs are submitted can determine that a certain affairs start at it to the period of submission
Interior involved data change information, thus by the delta data as unit of affairs.For example, for the thing that affairs ID is 001
Business, the timestamp started are 01:00:00:000, the timestamp of submission is:01:00:02:000, it is possible thereby to determine herein
During the affairs data change information, and then encapsulate as unit of affairs the delta data of the affairs.
Step S303, integrating apparatus generate the structuring of each affairs according to the delta data as unit of affairs
Query statement.According to the content of encapsulation, it is after unit is converted into SQL statement according to affairs by the data of variation so that needs are same
The target data library facilities of step can realize the synchronization of data by performing the SQL statement.
In addition, the embodiment of the present application additionally provides a kind of client device for carrying out data synchronization, the client device packet
Include transmitting device 510 and integrating apparatus 520.Wherein, the transmitting device 510 is used to receive from database facility and is based on reforming day
The affair logic information that will obtains, and the integrating apparatus 520 is for same for data according to the affair logic information generation
The structured query sentence of step, using the structured query sentence as data synchronization information.Further, the transmitting device
510 are additionally operable to structured query sentence being sent to target data library facilities, so that described in target data library facilities execution
Structured query sentence is completed data and is synchronized.
For target data library facilities, if when updating the data comprising major key in tables of data, it can be by inquiring major key
The change of mode rapidly locating table row information, without traversing entire tables of data, and target data library facilities can be with
It realizes that parallel data are written according to tables of data or major key, thus improves the write performance of target data library facilities.Therefore, it is raw
During into data synchronization information, if comprising major key in tables of data where the row information of change, the resolver 410 of database facility
The row name of the primary key column of the tables of data can be also served as an entry index acquisition of information, be contained in data synchronization information, thus
High performance write-in is realized in data synchronization process is carried out.
As another embodiment, the embodiment of the present application additionally provides a kind of data for being used to generate data synchronization information
Library facilities, wherein, which includes:Processor;And be arranged to storage computer executable instructions memory, it is described can
Execute instruction makes the processor when executed:Redoing log based on database obtains the affair logic information, wherein, it is described
The affair logic information includes at least the data change information of Transaction Identifier, transaction start time, affairs submission time and affairs;
And the affair logic information is sent to client, so that the client generates to count according to the affair logic information
According to synchronous structured query sentence
The embodiment of the present application additionally provides a kind of client device for being used to generate data synchronization information, wherein, the equipment
Including:Processor;And the memory of storage computer executable instructions is arranged to, the executable instruction is when executed
Make the processor:It is received from database facility based on the affair logic information for redoing log acquisition, wherein, the affair logic
Information includes at least the data change information of Transaction Identifier, transaction start time, affairs submission time and affairs;And according to
The structured query sentence that the affair logic information generation synchronizes for data.
The embodiment of the present application additionally provides a kind of client device for being used to carry out data synchronization, wherein, which includes:
Processor;And the memory of storage computer executable instructions is arranged to, the executable instruction makes institute when executed
State processor:It is received from database facility based on the affair logic information for redoing log acquisition, wherein, the affair logic information
Including at least the data change information of Transaction Identifier, transaction start time, affairs submission time and affairs;According to the affairs
The structured query sentence that logical message generation synchronizes for data;And the structured query sentence is sent to number of targets
According to library facilities, so that the target data library facilities performs the structured query sentence, complete data and synchronize.
In conclusion the program, which is primarily based on to redo log, obtains the affair logic information, the affair logic information table registration
It situations of change, the database facility such as increases, update, deleting newly according to the data of affairs each in library and the affair logic information is sent to visitor
After the end equipment of family, it is integrated by client device, generating structure query statement (SQL statement) is same as data
Information is walked, this does not have the problem of writing amplification in the process without using trigger, and processing expense is smaller.Due to structuring
Query statement can be suitable for the database (such as PostgreSQL, MySQL, SQL Server etc.) arbitrarily based on SQL, thus
When carrying out data synchronization, the data that can be adapted between heterogeneous database synchronize.
It should be noted that the application can be carried out in the assembly of software and/or software and hardware, for example, can adopt
With application-specific integrated circuit (ASIC), general purpose computer or any other realized similar to hardware device.In one embodiment
In, the software program of the application can perform to realize steps described above or function by processor.Similarly, the application
Software program can be stored in computer readable recording medium storing program for performing (including relevant data structure), for example, RAM memory,
Magnetic or optical driver or floppy disc and similar devices.In addition, hardware can be used to realize in some steps or function of the application, example
Such as, as coordinating with processor so as to perform the circuit of each step or function.
In addition, the part of the application can be applied to computer program product, such as computer program instructions, when its quilt
When computer performs, by the operation of the computer, it can call or provide according to the present processes and/or technical solution.
And the program instruction of the present processes is called, be possibly stored in fixed or moveable recording medium and/or is passed through
Broadcast or the data flow in other signal loaded mediums and be transmitted and/or be stored according to described program instruction operation
In the working storage of computer equipment.Here, including a device according to one embodiment of the application, which includes using
Memory in storage computer program instructions and processor for executing program instructions, wherein, when the computer program refers to
When order is performed by the processor, method and/or skill of the device operation based on aforementioned multiple embodiments according to the application are triggered
Art scheme.
It is obvious to a person skilled in the art that the application is not limited to the details of above-mentioned exemplary embodiment, Er Qie
In the case of without departing substantially from spirit herein or essential characteristic, the application can be realized in other specific forms.Therefore, no matter
From the point of view of which point, the present embodiments are to be considered as illustrative and not restrictive, and scope of the present application is by appended power
Profit requirement rather than above description limit, it is intended that all by what is fallen within the meaning and scope of the equivalent requirements of the claims
Variation is included in the application.Any reference numeral in claim should not be considered as to the involved claim of limitation.This
Outside, it is clear that one word of " comprising " is not excluded for other units or step, and odd number is not excluded for plural number.That is stated in device claim is multiple
Unit or device can also be realized by a unit or device by software or hardware.