Specific embodiment
Carry out the various exemplary embodiments of detailed description of the present invention now with reference to attached drawing.It should also be noted that unless in addition having
Body explanation, the unlimited system of component and the positioned opposite of step, numerical expression and the numerical value otherwise illustrated in these embodiments is originally
The range of invention.
Be to the description only actually of at least one exemplary embodiment below it is illustrative, never as to the present invention
And its application or any restrictions used.
Technology known to related fields ordinary skill personage, method and apparatus may be not discussed in detail, but suitable
In the case of, the technology, method and apparatus should be considered as part of specification.
It is shown here and discuss all examples in, any occurrence should be construed as merely illustratively, without
It is as limitation.Therefore, other examples of exemplary embodiment can have different values.
It should also be noted that similar label and letter indicate similar terms in following attached drawing, therefore, once a certain Xiang Yi
It is defined in a attached drawing, then in subsequent attached drawing does not need that it is further discussed.
<data synchronous system>
As shown in Figure 1, the data synchronous system of the embodiment of the present invention can be realized by server 400.
400 offer processing of server, database, communications service service point.Server 400 can be monolithic servers
Or the decentralized service device across multicomputer or computer data center.Server 400 can be it is various types of, such as but
It is not limited to, network server, NEWS SERVER, mail server, message server, Advertisement Server, file server, applies
Server, interactive server, database server or proxy server.In some embodiments, server 400 may include
Hardware, software, or the embedded logic module or two or more of proper function supported or realized for execute server 400
The combination of this class component.For example, server 400 can be the server farm being made of multiple servers, it may include above-mentioned
One of server of type is a variety of etc..
In one example, server 400 can be as shown in Figure 1, include processor 4010, memory 4020, interface dress
Set 4030, communication device 4040, display device 4050, input unit 4060 etc..Although server also may include loudspeaker, wheat
Gram wind etc., still, these components are unrelated to the invention, therefore omit herein.
Wherein, processor 4010 is such as can be central processor CPU, Micro-processor MCV.Memory 4020 for example wraps
Include ROM (read-only memory), RAM (random access memory), nonvolatile memory of hard disk etc..Interface arrangement 4030
For example including USB interface, serial line interface, infrared interface etc..Communication device 4040 is for example able to carry out wired or wireless communication.It is aobvious
Showing device 4050 is, for example, liquid crystal display, LED display touch display screen etc..Input unit 4060 for example may include touching
Screen, keyboard etc..
Although showing multiple devices to server 400 in Fig. 1, the present invention can only relate to part therein
Device, for example, server 400 pertains only to memory 4020 and processor 4010.
In the foregoing description, technical staff can the instruction of the conceptual design according to provided by the disclosure.How instruction controls
Processor is operated, this is it is known in the art that therefore being not described in detail herein.
Data synchronous system shown in FIG. 1 is only explanatory, and never be intended to limitation the disclosure, its application or
Purposes.
It is shown in Figure 2, illustrate data synchronous system provided in an embodiment of the present invention.
Data synchronous system includes data decryptor module 20, message distribution module 30, data simultaneous module 40 and configuration
Management module 50.
Data decryptor module 20, for monitoring data source 10, to obtain the data change record of data source 10.Number
It can be one or more according to source 10.That is, the data synchronous system of the embodiment of the present invention can be simultaneously to multiple numbers
It is synchronous that data are carried out according to source 10.
Message distribution module 30, for creating corresponding with data source message queue, that is, data source and message queue are one
One-to-one correspondence.Message distribution module 30 from data decryptor module 20 obtains the data change record of data source and by data source
Data change record be added in message queue corresponding with data source.
Configuration management module 50, for managing the synchronization configuration parameter of data source, the synchronization configuration parameter of data source includes
Mark, the position of target storage 60 and the mark of message queue corresponding with data source of data source.
Data simultaneous module 40 obtains the synchronization configuration parameter of data source for monitoring configuration management module 20, according to
The synchronization configuration parameter of data source creates consumption corresponding with message queue and assists journey;And corresponding disappear is monitored by consumption association journey
Breath queue will be disappeared with consuming the data change record being written in corresponding message queue according to the synchronization configuration parameter of data source
The data change record being written in breath queue is updated into corresponding target storage 60.Assisting journey is a kind of program assembly, is process
In a relatively independent, schedulable execution unit entity.Assist journey generally more light weight and flexibly, can be in designated position
It hangs up and restores to execute.Consumption association journey is a kind of association's journey for serving as consumer role, for consuming the message in message queue.Figure
3 target storages 60 are shown in 2, in practical applications, the data of multiple data sources 10 can be merged and are synchronized to a mesh
In mark storage, the data of a data source 10 can also be synchronized to respectively in multiple target storages.
Data synchronous system provided in an embodiment of the present invention is added data change record using message queue subscribing mechanism
Enter into message queue, the change of data source is written to the consumption of message queue by target storage by consumption association's journey in real time
In, the real-time synchronization for realizing data updates.
Data synchronous system provided in an embodiment of the present invention according to synchronous configuration parameter setting consumption association journey, and is consumed
Journey is assisted to carry out data update according to synchronous configuration parameter, when synchronous configuration parameter is updated by user, data synchronous system can be with
Increase, delete or modify consumption association journey in time, therefore, the data synchronous system of the embodiment of the present invention also has good spirit
Activity and scalability.
In a specific example, the synchronization configuration parameter of data source can also include the concurrent speed of message queue.
In one example, multiple consumption associations journey corresponding with the same message queue can be in concurrent form from the message queue
Consumption data.The quantity of association's journey is consumed by setting, can the speed consumed of the message in control message queue, that is, control
The concurrent speed of message queue processed.Data simultaneous module is also used to determine need to create and message queue according to concurrent speed
The quantity of corresponding consumption association journey, that is to say, that the concurrent speed of message queue is higher, consumes the consumption association of this message queue
The quantity of journey is more.Data synchronous system provided in an embodiment of the present invention can easily pass through the number of extension consumption association journey
Amount is to increase synchronizing speed.
Shown in Figure 3 in a specific example, main association's journey 41 of data simultaneous module 40 monitors configuration management mould
Block 50, when the synchronization configuration parameter of data source is updated, main association's journey 41 can obtain updated synchronous configuration parameter in time,
Consumption association Cheng Jinhang is increased, deleted or modified according to updated synchronous configuration parameter.
In the example shown in Fig. 3, the corresponding message queue of second data source is message queue 2, second data source
Synchronization configuration parameter in define that concurrent speed is 1, main association journey 41 creates 1 consumption association journey (journey 424 is assisted in consumption) monitoring and disappears
Cease queue 1.The corresponding message queue of first data source is message queue 1, is limited in the synchronization configuration parameter of first data source
Having determined concurrent speed is 3, main association journey 41 will create 3 consumption association journeys (respectively consume and assist journey 421,422,423) while listening for
Message queue 1, message queue subscribing mechanism itself can guarantee that 1 message can only be by 1 consumer spending, that is to say, that every
One data change record only can be by a consumption association journey consumption, without being repeatedly processed through vaporization, condensation and absorption.
In a specific example, data decryptor module 20 is also used to convert the data change record of data source to
Preset format, so that the format of the data change record in message queue is unified, and this preset format should
It is the consumption association analysable format of journey, to facilitate the journey consumption of consumption association.For example, the format of first data source is Binlog lattice
Formula, the change record of the first data source are also Binlog format;The format of second data source is Oplog format, the second data
The change record in source is also Oplog format;Preset format is JSON format, and data synchronous system can be by first data source
Data change record is JSON format by Binlog format conversion, converts the change record of second data source to by Oplog
JSON format, then the data change record of JSON format is passed into message queue.
In a specific example, data simultaneous module 40 is also used to for itself being registered in configuration management module 50,
By the working condition of 50 monitored data synchronization module 40 of configuration management module, user is allowed to observe consumption association journey in time
Consumption progress.
In a specific example, the message queue that message distribution module 30 creates is the message queue of persistence, is made
Obtaining data change record will not lose easily.When starting or retroversion return to some after consuming association's journey and needing to suspend, suspend
Between point when being consumed again, required data change record can be read from message queue.
In a specific example, the message queue that message distribution module 30 creates uses first in first out mechanism, so that
Consumption association journey can consume the data change record in message queue in sequence.
In a specific example, message distribution module 30 subscribes to message system using Kafka distributed post.
Kafka distributed post subscribes to message system, is the open source stream process platform developed by Apache Software Foundation, by
Scala and Java language are write.Kafka is that a kind of distributed post of high-throughput subscribes to message system, it, which can handle, disappears
Everything flow data in the website of the person's of expense scale.By using Kafka as message distribution module 30, this implementation can be made
Data synchronous system handling capacity with higher in example, and the message queue of persistence easy to accomplish.In addition, being based on
The mechanism of Kafka message distribution module itself can guarantee that 1 message can only be by 1 consumer spending, that is to say, that each
Data change record only can be by a consumption association journey consumption, without being repeatedly processed through vaporization, condensation and absorption, to ensure that the synchronous standard of data
Really efficiently.
In a specific example, configuration management module 50 uses the coordination service of Zookeeper distributed application program
System.Zookeeper distributed application program coordination service system is the realization of an open source of Google, is Distributed Application
Consistency service is provided, the function of providing includes: configuring maintenance, domain name service, distributed synchronization, group service etc..Zookeeper
Distributed application program coordination service system has informing mechanism.By using Zookeeper as configuration management module, so that
The performance efficiency of configuration management module 50 and reliable.In addition, the notice itself being had based on Zookeeper configuration management module
Mechanism can be realized the effect of user's real time modifying synchronous task.
In a specific example, data simultaneous module 40 can be realized using finger daemon.Finger daemon is a kind of
The special process of the one kind on backstage is operated in, can be executed independently of controlling terminal and periodically at certain task or waiting
Manage the event of certain generations.
Message system is subscribed to using Kafka distributed post with message distribution module 30 below, configuration management module 50 is adopted
With Zookeeper distributed application program coordination service system, data simultaneous module 40 illustrates this hair using for finger daemon
The data synchronous system that bright embodiment provides:
Data synchronous system include data decryptor module, Kafka message distribution module, data simultaneous module and
Zookeeper configuration management module.
Data decryptor module monitors data source, to obtain the data change record of data source.The change of data source
Record is for example including the following contents: the mark of data source, the mark of the affiliated database of data source, the timestamp of this change, this
It is secondary to change the field that is related to, before changing after content etc..
Kafka message distribution module, for creating Kafka message queue corresponding with data source, that is, data source and message
Queue is one-to-one relationship.Kafka message distribution module obtains the data change record of data source from data decryptor module,
The data change record of data source is added in Kafka message queue corresponding with data source.
Zookeeper configuration management module, for being managed collectively the synchronization configuration parameter of each data source.Data source it is same
Step configuration parameter includes the mark of the mark of data source, the position of target storage and Kafka message queue corresponding with data source
Know.The synchronization configuration parameter of data source for example can also include: the field for needing synchronized update, corresponding with the data source
Concurrent speed of Kafka message queue etc..
On the one hand, user is managed collectively the synchronization configuration parameter of each data source by Zookeeper configuration management module.
Based on the informing mechanism that Zookeeper configuration management module has itself, when user is repaired by Zookeeper configuration management module
When changing synchronous configuration parameter, it can be known in time by main association's journey of data simultaneous module, main association's journey is timely according to synchronous configuration parameter
Consuming process is adjusted, to realize the effect of user's real time modifying synchronous task.
On the other hand, data simultaneous module itself will be registered in Zookeeper configuration management module, by Zookeeper
The working condition of configuration management module monitored data synchronization module.When consumption association Cheng Yichang is closed, can be matched by Zookeeper
It sets management module to capture in time, user is allowed to observe the state of synchronous task in time.
Specifically:
Main association's journey of data simultaneous module is corresponding with Kafka message queue according to the synchronization configuration parameter creation of data source
Consumption association journey.Corresponding Kafka message queue monitored by consumption association journey, is written in corresponding Kafka message queue with consuming
Data change record updates the data change record being written in Kafka message queue according to the synchronization configuration parameter of data source
Into the storage of corresponding target.
Main association's journey of data simultaneous module monitors Zookeeper configuration management module, when the synchronization configuration parameter of data source
When being updated, main association's journey can obtain updated synchronous configuration parameter in time, be offseted according to updated synchronous configuration parameter
Fei Xiecheng is increased, deleted or is modified.
Based on the mechanism of Kafka message distribution module itself, can guarantee 1 message can only by 1 consumer spending,
That is each data change record only can be by a consumption association journey consumption, without being repeatedly processed through vaporization, condensation and absorption.
Kafka message queue is the message queue of persistence, so that data change record will not be lost easily.When consumption is assisted
Journey needs to suspend, starts after pause or falls back when returning to some time point and being consumed again, can disappear from Kafka
Required data change record is read in breath queue.Also, Kafka message queue follows first in first out mechanism, guarantees consumption
The order of process.
For Kafka message distribution module, data decryptor module is its contents producer, and data simultaneous module disappears
Fei Xiecheng is its content consumer.Kafka message distribution module itself has Decoupling Characteristics, can be by contents producer and content
Consumer's decoupling, shields the perception between contents producer and content consumer, when data decryptor module and data simultaneous module
Any one of module when something goes wrong, all will not influence the normal work of another module.
Data are changed and are remembered using Kafka message subscribing distribution mechanisms by data synchronous system provided in an embodiment of the present invention
Record is added in Kafka message queue, is write the change of data source in real time to the consumption of Kafka message queue by consumption association journey
Enter into target storage, the real-time synchronization for realizing data updates.
<method of data synchronization>
As shown in figure 4, the embodiment of the invention also provides a kind of method of data synchronization, comprising the following steps:
Step S110, data source is monitored, to obtain the data change record of data source.
Step S120, the data change record of data source is added to and number by creation message queue corresponding with data source
According in the corresponding message queue in source.
Step S130, the synchronization configuration parameter of data source is monitored, is created according to the synchronization configuration parameter of data source
Journey is assisted in consumption corresponding with message queue;Wherein, the synchronization configuration parameter of data source includes that the mark of data source, target store
The mark of position and message queue corresponding with data source.
Step S140, corresponding message queue is monitored by consumption association journey, to consume the number being written in corresponding message queue
According to change record, the data change record being written in message queue is updated to corresponding according to the synchronization configuration parameter of data source
In target storage.
Method of data synchronization provided in an embodiment of the present invention is added data change record using message queue subscribing mechanism
Enter into message queue, the change of data source is written to the consumption of message queue by target storage by consumption association's journey in real time
In, the real-time synchronization for realizing data updates.
In a specific example, the synchronization configuration parameter of data source further includes message queue corresponding with data source
Concurrent speed.Consumption corresponding with message queue is created according to the synchronization configuration parameter of data source and assists journey, further includes according to concurrent
Speed determines the quantity of consumption association corresponding with message queue journey.
In a specific example, data source is monitored, to obtain the data change record of data source, further includes
Preset format is converted by the data change record of data source, preset format is the consumption association analysable format of journey.
In one example, message system is subscribed to using Kafka distributed post and realizes message distribution module.
In one example, configuration management module is realized using Zookeeper distributed application program coordination service.
In one example, the synchronization configuration parameter of data source further includes the concurrent speed of message queue corresponding with data source
Degree;Data simultaneous module is also used to determine the number for consumption association corresponding with the message queue journey for needing to create according to concurrent speed
Amount.
In one example, data simultaneous module is also used to for itself being registered in configuration management module, by configuration management
The working condition of module monitored data synchronization module.
In a specific example, message queue is the message queue of persistence.
In a specific example, message queue uses first in first out mechanism.
Method of data synchronization provided in this embodiment with the data synchronous system that previous embodiment provides be it is corresponding, it is aforementioned
The embodiment of data synchronous system can be used for explaining the method for data synchronization in the present embodiment, repeat no more in the present embodiment.
Similarly, method of data synchronization provided in an embodiment of the present invention is changed data using message queue subscribing mechanism
Record is added in message queue, and the change of data source is written to target in real time to the consumption of message queue by consumption association journey
In storage, the real-time synchronization for realizing data updates.In addition, method of data synchronization provided in an embodiment of the present invention, according to synchronization
Configuration parameter setting consumption association journey, and consume association's journey and carry out data update according to synchronous configuration parameter, when synchronous configuration parameter
When being updated by user, it can increase, delete or modify consumption association journey, therefore, the data side of synchronization of the embodiment of the present invention in time
Method also has considerable flexibility and scalability.
<data synchronization unit>
The embodiment of the invention also provides a kind of data synchronization units, including processor and memory;The memory is deposited
Containing executable computer instruction can be realized aforementioned data when the executable computer instruction is executed by the processor
The method of data synchronization that synchronous method embodiment provides.
Specifically, the embodiment of aforementioned data synchronous method can be used for explaining the data synchronization unit of the present embodiment, this number
According to being repeated no more in the embodiment of synchronizing device.
<computer storage medium>
The embodiment of the invention also provides a kind of computer storage medium, the computer storage medium is stored with executable
Computer instruction when the executable computer instruction is executed by processor, can be realized aforementioned data synchronous method embodiment
The method of data synchronization of offer.
Specifically, the embodiment of aforementioned data synchronous method can be used for explaining the computer storage medium of the present embodiment, this
It is repeated no more in the embodiment of computer storage medium.
The present invention can be system, method and/or computer program product.Computer program product may include computer
Readable storage medium storing program for executing, containing for making processor realize the computer-readable program instructions of various aspects of the invention.
Computer readable storage medium, which can be, can keep and store the tangible of the instruction used by instruction execution equipment
Equipment.Computer readable storage medium for example can be-- but it is not limited to-- storage device electric, magnetic storage apparatus, optical storage
Equipment, electric magnetic storage apparatus, semiconductor memory apparatus or above-mentioned any appropriate combination.Computer readable storage medium
More specific example (non exhaustive list) includes: portable computer diskette, hard disk, random access memory (RAM), read-only deposits
It is reservoir (ROM), erasable programmable read only memory (EPROM or flash memory), static random access memory (SRAM), portable
Compact disk read-only memory (CD-ROM), digital versatile disc (DVD), memory stick, floppy disk, mechanical coding equipment, for example thereon
It is stored with punch card or groove internal projection structure and the above-mentioned any appropriate combination of instruction.Calculating used herein above
Machine readable storage medium storing program for executing is not interpreted that instantaneous signal itself, the electromagnetic wave of such as radio wave or other Free propagations lead to
It crosses the electromagnetic wave (for example, the light pulse for passing through fiber optic cables) of waveguide or the propagation of other transmission mediums or is transmitted by electric wire
Electric signal.
Computer-readable program instructions as described herein can be downloaded to from computer readable storage medium it is each calculate/
Processing equipment, or outer computer or outer is downloaded to by network, such as internet, local area network, wide area network and/or wireless network
Portion stores equipment.Network may include copper transmission cable, optical fiber transmission, wireless transmission, router, firewall, interchanger, gateway
Computer and/or Edge Server.Adapter or network interface in each calculating/processing equipment are received from network to be counted
Calculation machine readable program instructions, and the computer-readable program instructions are forwarded, for the meter being stored in each calculating/processing equipment
In calculation machine readable storage medium storing program for executing.
Computer program instructions for executing operation of the present invention can be assembly instruction, instruction set architecture (ISA) instructs,
Machine instruction, machine-dependent instructions, microcode, firmware instructions, condition setup data or with one or more programming languages
The source code or object code that any combination is write, the programming language include the programming language-of object-oriented such as
Smalltalk, C++ etc., and conventional procedural programming languages-such as " C " language or similar programming language.Computer
Readable program instructions can be executed fully on the user computer, partly execute on the user computer, be only as one
Vertical software package executes, part executes on the remote computer or completely in remote computer on the user computer for part
Or it is executed on server.In situations involving remote computers, remote computer can pass through network-packet of any kind
It includes local area network (LAN) or wide area network (WAN)-is connected to subscriber computer, or, it may be connected to outer computer (such as benefit
It is connected with ISP by internet).In some embodiments, by utilizing computer-readable program instructions
Status information carry out personalized customization electronic circuit, such as programmable logic circuit, field programmable gate array (FPGA) or can
Programmed logic array (PLA) (PLA), the electronic circuit can execute computer-readable program instructions, to realize each side of the invention
Face.
Referring herein to according to the method for the embodiment of the present invention, the flow chart of device (system) and computer program product and/
Or block diagram describes various aspects of the invention.It should be appreciated that flowchart and or block diagram each box and flow chart and/
Or in block diagram each box combination, can be realized by computer-readable program instructions.
These computer-readable program instructions can be supplied to general purpose computer, special purpose computer or other programmable datas
The processor of processing unit, so that a kind of machine is produced, so that these instructions are passing through computer or other programmable datas
When the processor of processing unit executes, function specified in one or more boxes in implementation flow chart and/or block diagram is produced
The device of energy/movement.These computer-readable program instructions can also be stored in a computer-readable storage medium, these refer to
It enables so that computer, programmable data processing unit and/or other equipment work in a specific way, thus, it is stored with instruction
Computer-readable medium then includes a manufacture comprising in one or more boxes in implementation flow chart and/or block diagram
The instruction of the various aspects of defined function action.
Computer-readable program instructions can also be loaded into computer, other programmable data processing units or other
In equipment, so that series of operation steps are executed in computer, other programmable data processing units or other equipment, to produce
Raw computer implemented process, so that executed in computer, other programmable data processing units or other equipment
Instruct function action specified in one or more boxes in implementation flow chart and/or block diagram.
The flow chart and block diagram in the drawings show the system of multiple embodiments according to the present invention, method and computer journeys
The architecture, function and operation in the cards of sequence product.In this regard, each box in flowchart or block diagram can generation
One module of table, program segment or a part of instruction, the module, program segment or a part of instruction include one or more use
The executable instruction of the logic function as defined in realizing.In some implementations as replacements, function marked in the box
It can occur in a different order than that indicated in the drawings.For example, two continuous boxes can actually be held substantially in parallel
Row, they can also be executed in the opposite order sometimes, and this depends on the function involved.It is also noted that block diagram and/or
The combination of each box in flow chart and the box in block diagram and or flow chart, can the function as defined in executing or dynamic
The dedicated hardware based system made is realized, or can be realized using a combination of dedicated hardware and computer instructions.It is right
For art technology personage it is well known that, by hardware mode realize, by software mode realize and pass through software and
It is all of equal value that the mode of combination of hardware, which is realized,.
Various embodiments of the present invention are described above, above description is exemplary, and non-exclusive, and
It is not limited to disclosed each embodiment.Without departing from the scope and spirit of illustrated each embodiment, for this skill
Many modifications and changes are obvious for the ordinary skill personage in art field.The selection of term used herein, purport
In principle, the practical application or to the technological improvement in market for best explaining each embodiment, or make the art its
Its ordinary skill personage can understand each embodiment disclosed herein.The scope of the present invention is defined by the appended claims.