[go: up one dir, main page]

CN109165258A - A kind of method of data synchronization and device - Google Patents

A kind of method of data synchronization and device Download PDF

Info

Publication number
CN109165258A
CN109165258A CN201810919871.1A CN201810919871A CN109165258A CN 109165258 A CN109165258 A CN 109165258A CN 201810919871 A CN201810919871 A CN 201810919871A CN 109165258 A CN109165258 A CN 109165258A
Authority
CN
China
Prior art keywords
database
statement
node
broadcast
nodes
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201810919871.1A
Other languages
Chinese (zh)
Inventor
王文庆
杜彦魁
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhengzhou Yunhai Information Technology Co Ltd
Original Assignee
Zhengzhou Yunhai Information Technology Co 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 Zhengzhou Yunhai Information Technology Co Ltd filed Critical Zhengzhou Yunhai Information Technology Co Ltd
Priority to CN201810919871.1A priority Critical patent/CN109165258A/en
Publication of CN109165258A publication Critical patent/CN109165258A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/542Event management; Broadcasting; Multicasting; Notifications

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Multimedia (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 discloses a data synchronization method and device, comprising: configuring database middleware and enabling the database middleware to enable a table broadcasting mechanism; enabling the database middleware to receive database statements in a data manipulation language; and judging whether the database statements need to execute global table logic according to the configuration ; When the database statement needs to execute the global table logic, use the table broadcasting mechanism to broadcast the database statement table to all database nodes; when the database statement does not need to execute the global table logic, send the database statement to all database nodes and execute the database statement. The data synchronization method and device provided by the present invention can perform data synchronization for different database nodes or different types of database nodes, and maintain the data consistency of the global table in the database.

Description

A kind of method of data synchronization and device
Technical field
The present invention relates to database fields, more specifically, particularly relating to a kind of method of data synchronization and device.
Background technique
Mycat is the distributed data base system of an open source, is the database middleware for realizing MySQL agreement.Before End subscriber can regard it as a database broker, with MySQL client utility and command-line access;Rear end can be used Primary (Native) agreement of MySQL is communicated with multiple MySQL servers, can also use JDBC agreement and most of mainstream datas Library server communication.
Affairs in Mycat mainly include SQL not across fragment affairs and across the fragment affairs of SQL.For SQL not across fragment thing Business, SQL statement only execute on a back end, and the db transaction mode of Mycat transaction mode and standard is complete at this time Unanimously, it submits and rollback is no can guarantee strong consistency.Affairs across fragment for SQL, the SQL in affairs is at respective point first On piece executes and returns status code, if the return code on some fragment is wrong (error), Mycat thinks that affairs fail, answers With end rollback (Rollback) affairs, after Mycat receives rollback instruction, all fragments for being successively related in rollback affairs;If The execution of all SQL in affairs all returns to the return code of successfully (OK), then application program submit affairs, from Mycat simultaneously to The node being related in affairs sends the instruction (Commit) for submitting affairs, if some node malfunctions in COMMIT, Mycat Again, there is part of nodes commit in commit after nodes can not be waited to restore and part of nodes does not have the case where commit.Due to Second stage across fragment affairs not can guarantee strong consistency, therefore Mycat is a kind of weak XA transaction mode.
There are two types of typical tables in Mycat: one is according to certain given fragment rule, data being carried out horizontal cutting Point, one big table horizontal segmentation at N number of small table, it is stored in rear end MySQL server or other different databases;It is another Kind is global table, and Mycat receives the extraneous SQL statement sent, the SQL statement of DML (data manipulation language) is sent respectively It is successively executed on to each database node.The DML operating process of Mycat global table is as shown in Figure 1.If continually to global table It carries out additions and deletions and changes operation, due to the weak XA affair mechanism of Mycat, frequent operation global table may result in the hair of abnormal conditions Raw: some user is modifying global table submission in a flash, some node malfunctions suddenly, it is possible that certain nodes are Success is modified and the node data that malfunctions does not change, so that the situation that each node data is inconsistent.The problem makes entire database Lose data consistency, be may be difficult to it is received.
Database middleware is made to cannot be guaranteed global table for the weak XA affair mechanism in the prior art across fragment affairs Data consistency the problem of, there has been no effective solution schemes at present.
Summary of the invention
In view of this, the purpose of the embodiment of the present invention is to propose a kind of method of data synchronization and device, it can be for not Data are carried out with database node or different types of database node to synchronize, and maintain the data of global table in database consistent Property.
Based on above-mentioned purpose, the one side of the embodiment of the present invention provides a kind of method of data synchronization, is applied to database, The following steps are included:
Configuration database middleware simultaneously makes database middleware enabling table broadcast mechanism;
Database middleware is set to receive the database statement of data manipulation language;
Global table logic whether is needed to be implemented according to configuration determination database statement;
When database statement needs to be implemented global table logic, database statement table is broadcast to institute using table broadcast mechanism There is database node;
When database statement does not need to execute global table logic, all database nodes are sent simultaneously for database statement Execute database statement.
In some embodiments, table broadcast mechanism includes:
A database host node is determined in all database nodes, and other database nodes are determined as database From node;
Database middleware is set to send the broadcast about database statement to database host node;
Make database host node that database statement table is broadcast to all databases from node.
In some embodiments, make database host node that database statement table is broadcast to all databases from node packet It includes:
Saving database host node includes the binary message file of database statement, and to all databases from node Push binary message file;
Make all databases that binary message file be dumped to all databases by dedicated worker thread from node From the respective relaying file of node;
Make database host node and all databases from node respectively according to binary message file and respective relaying text Part executes database statement.
In some embodiments, binary message file is dumped into corresponding relaying text from node in each database After in part, dedicated worker thread is recorded in binary message file;All numbers are recorded in binary message file After all having carried out unloading from node according to library, database host node sends to all databases from node and executes database statement Broadcast.
In some embodiments, when dedicated worker thread cannot read binary message file, corresponding data Library enters suspend mode from node and waits new broadcast.
In some embodiments, dedicated worker thread binary message file is written in a serial fashion corresponding Relay file.
In some embodiments, judge whether database statement needs to be implemented global table logic and include:
Judge whether the type of database statement is one of the following: insertion is updated, is deleted, and is then continued in this way;
Whether the Object table type for judging database statement is global table, is then continued in this way;
Judge whether database statement is configured to enable single node insertion, is that judgement needs to be implemented global table logic, no Then determine not needing.
In some embodiments, configuration database middleware includes:
The table label for judging table type is added in configuration file into database middleware;
The single node insertion attribute for judging whether enabling table broadcast mechanism is added into table label.
In some embodiments, database middleware Mycat, database MySQL.
The another aspect of the embodiment of the present invention additionally provides a kind of data synchronization unit, including processor and memory, institute It states memory and is stored with the executable instruction of processor, described instruction realizes the above method when executed.
The another aspect of the embodiment of the present invention additionally provides a kind of computer readable storage medium, computer-readable storage Media storage has computer program, and above-mentioned method is executed when computer program is executed by processor.
The another aspect of the embodiment of the present invention, additionally provides a kind of computer program product, and computer program product includes The calculation procedure being stored on computer readable storage medium, calculation procedure include instruction, when executed by the processor, are made Computer executes the above method.
The present invention has following advantageous effects: method of data synchronization and device provided in an embodiment of the present invention pass through Using enabling table broadcast mechanism, receive data manipulation language database statement, judge whether database statement needs to be implemented entirely Office's table logic will count when using table broadcast mechanism database statement table being broadcast to all database nodes when needing, do not needed All database nodes are sent to according to library sentence and execute the technical solution of database statement, can be directed to disparate databases node Or different types of database node carries out data and synchronizes, and maintains the data consistency of global table in database.
Detailed description of the invention
In order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, to embodiment or will show below There is attached drawing needed in technical description to be briefly described, it should be apparent that, the accompanying drawings in the following description is only this Some embodiments of invention for those of ordinary skill in the art without creative efforts, can be with It obtains other drawings based on these drawings.
Fig. 1 is the DML operating process schematic diagram of Mycat global table in the prior art;
Fig. 2 is the flow diagram of the embodiment of method of data synchronization provided by the invention;
Fig. 3 is that the table of Mycat global table provided by the invention broadcasts flow diagram;
Fig. 4 is the judgement flow diagram that the table of Mycat global table provided by the invention is broadcasted;
Fig. 5 is the hardware knot of one embodiment of the computer equipment provided by the invention for executing the method for data synchronization Structure schematic diagram.
Specific embodiment
To make the objectives, technical solutions, and advantages of the present invention clearer, below in conjunction with specific embodiment, and reference The embodiment of the present invention is further described in attached drawing.
It should be noted that all statements for using " first " and " second " are for differentiation two in the embodiment of the present invention The non-equal entity of a same names or non-equal parameter, it is seen that " first " " second " only for the convenience of statement, does not answer It is interpreted as the restriction to the embodiment of the present invention, subsequent embodiment no longer illustrates this one by one.
Based on above-mentioned purpose, the first aspect of the embodiment of the present invention, disparate databases section can be directed to by proposing one kind Point or different types of database node carry out the embodiment of the synchronous method of data.Fig. 2 shows be number provided by the invention According to the flow diagram of the embodiment of synchronous method.
The method of data synchronization is optionally applied to database, comprising the following steps:
Step S201, configuration database middleware simultaneously make database middleware enabling table broadcast mechanism;
Step S203 makes database middleware receive the database statement of data manipulation language;
Whether step S205 needs to be implemented global table logic according to configuration determination database statement;
Step S207, when database statement needs to be implemented global table logic, using table broadcast mechanism by database statement Table is broadcast to all database nodes;
Step S209 sends all numbers for database statement when database statement does not need to execute global table logic According to library node and execute database statement.
Those of ordinary skill in the art will appreciate that realizing all or part of the process in above-described embodiment method, Ke Yitong Computer program is crossed to instruct related hardware and complete, the program can be stored in a computer-readable storage medium, The program is when being executed, it may include such as the process of the embodiment of above-mentioned each method.Wherein, the storage medium can for magnetic disk, CD, read-only memory (ROM) or random access memory (RAM) etc..The embodiment of the computer program, Ke Yida The effect identical or similar to corresponding aforementioned any means embodiment.
The embodiment of the present invention will be acted on by changing the global table logic of Mycat (database middleware) when DML is accessed It is changed to the operation to host node in the operation of all nodes, then the data between each node are completed by table broadcast mechanism and are synchronized, is come Realize the data consistency between each node.
In some embodiments, table broadcast mechanism includes:
A database host node is determined in all database nodes, and other database nodes are determined as database From node;
Database middleware is set to send the broadcast about database statement to database host node;
Make database host node that database statement table is broadcast to all databases from node.
In some embodiments, make database host node that database statement table is broadcast to all databases from node packet It includes:
Saving database host node includes the binary message file of database statement, and to all databases from node Push binary message file;
Make all databases that binary message file be dumped to all databases by dedicated worker thread from node From the respective relaying file of node;
Make database host node and all databases from node respectively according to binary message file and respective relaying text Part executes database statement.
In addition, disclosed method is also implemented as the computer program executed by CPU according to embodiments of the present invention, it should Computer program may be stored in a computer readable storage medium.When the computer program is executed by CPU, the present invention is executed The above-mentioned function of being limited in method disclosed in embodiment.Above method step and system unit also can use controller and For storing so that controller realizes that the computer readable storage medium of the computer program of above-mentioned steps or Elementary Function is realized.
As shown in figure 3, in embodiments of the present invention, realizing that table broadcast mechanism includes three steps:
(1) user sends DML request, and host receives order, sends and broadcasts to host node.Host node receives message, By Message Record to binary file, and other are transmitted the message to from node;
(2) message is read from node, and message is written to the relaying log of oneself.
(3) event in relaying log is reformed from node, and changes the data of oneself.
In addition, typically, the embodiment of the present invention discloses described database middleware and node etc. can be whole for various electronics End equipment, such as mobile phone, personal digital assistant (PDA), tablet computer (PAD), smart television etc., are also possible to large-scale terminal and set It is standby, such as server, therefore protection scope disclosed by the embodiments of the present invention should not limit as certain certain types of device, set It is standby.The embodiment of the present invention discloses the client and can be is answered with the combining form of electronic hardware, computer software or both For in any one of the above electric terminal equipment.
In some embodiments, binary message file is dumped into corresponding relaying text from node in each database After in part, dedicated worker thread is recorded in binary message file;All numbers are recorded in binary message file After all having carried out unloading from node according to library, database host node sends to all databases from node and executes database statement Broadcast.
Host is broadcasted after receiving request to host node transmission, and host node receives message and simultaneously records binary file.Each Before affairs more new data is completed, host node records these changes in binary file.MySQL thread serially writes affairs Enter binary file, after the completion of event write-in, host node notifies storage engines to submit affairs and send to other from node wide It broadcasts.
It host node as described herein and can be volatile memory or nonvolatile memory from node, or can wrap Include both volatile memory and nonvolatile memory.As an example and not restrictive, nonvolatile memory can wrap Include read-only memory (ROM), programming ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory.Volatile memory may include random access memory (RAM), which can serve as outer Portion's cache memory.As an example and not restrictive, RAM can be obtained in a variety of forms, such as synchronous random access memory (DRAM), dynamic ram (DRAM), synchronous dram (SDRAM), double data rate SDRAM (DDR SDRAM), enhancing SDRAM (ESDRAM), synchronization link DRAM (SLDRAM) and directly Rambus RAM (DRRAM).The storage of disclosed aspect is set The standby memory for being intended to including but not limited to these and other suitable type.
In some embodiments, when dedicated worker thread cannot read binary message file, corresponding data Library enters suspend mode from node and waits new broadcast.In some embodiments, dedicated worker thread in a serial fashion will Corresponding relaying file is written in binary message file.
Message is received from node, the binary file of host node is copied to the relaying log of oneself.First from node Start a worker thread (I/O thread), I/O thread opens a common connection on the primary node, then starts binary system Unloading.Binary system loading program reads message event from the binary file of host node, if not new message, it can sleep It sleeps and host node is waited to send new broadcast.SQL from thread from relaying log read message event, and reset event therein with The data from node are updated, keep it consistent with the data in host node.
In some embodiments, judge whether database statement needs to be implemented global table logic and include:
Judge whether the type of database statement is one of the following: insertion is updated, is deleted, and is to continue next step;
Whether the Object table type for judging database statement is global table, is to continue next step;
Judge whether database statement is configured to enable single node insertion, is that judgement needs to be implemented global table logic, no Then determine not needing.
As shown in figure 4, the table broadcast mechanism in Mycat in the execution process Mycat of table broadcast mechanism is to be directed to the overall situation The DML of table is operated and is proposed, and only in writeOneNode=true, its function can just come into force, it is therefore desirable to be increased New SQL executes logic.
As shown in figure 4, Mycat carries out following judgement to the SQL statement received:
(1) whether the type of SQL statement is insert, update or delete;
(2) whether the table being inserted into is global table;
It (3) whether is single node write-in, i.e. writeOneNode=true.
Only meeting simultaneously there are three condition makes, and original multinode insertions function is just revised as single node insertion, is enabled Table broadcast capability.
Various illustrative logical blocks, module, circuit and algorithm steps in conjunction with described in disclosure herein can be implemented For the combination of electronic hardware, computer software or both.In order to clearly demonstrate this interchangeability of hardware and software, General description has been carried out to it with regard to the function of various exemplary components, square, module, circuit and step.This function is Software is implemented as also to be implemented as hardware depending on concrete application and be applied to the design constraint of whole system.This field Technical staff can realize the function in various ways for every kind of concrete application, but determine should not be by for this realization It is construed to lead to be detached from range disclosed by the embodiments of the present invention.
In some embodiments, configuration database middleware includes:
The table label for judging table type is added in configuration file into database middleware;
The single node insertion attribute for judging whether enabling table broadcast mechanism is added into table label.
Table broadcast mechanism in Mycat is for global table.Configuring Mycat is to have increased an attribute newly for global table, Change the execution logic of original SQL statement when the attribute value is true.Mycat receives DML order and sends extensively to host node It broadcasts, host node, which executes, orders and save binary message file simultaneously to from node PUSH message, and it is same to receive broadcast from node Walk the data of host node.When there is node exception when modifying data in the Mycat that the embodiment of the present invention realizes table broadcast mechanism Journal file, the synchrodata that storage message can be actively read after releasing extremely, ensure that strong consistency.
Specifically, configuration file is read first when Mycat starts, judged according to the setting information of wherein table label The type of table.Increase an attribute " writeOneNode " in the table label of configuration file schema.xml as enabling The mark of table broadcast mechanism just enables table broadcast capability when the type of logical table is global table i.e. " type=global ".Newly The attribute of increasing is Boolean type, and default value is " false ".As " writeOneNode=true ", the SQL of filtering DML operation Sentence acts on host node by table broadcast;As " writeOneNode=false ", the SQL statement of DML operation is according to original Beginning logical action is in all nodes.
When on the other hand, such as by java application accessing XML, Java object is first converted to XML file (marshall), then by the content transformation in XML file at corresponding Java object (unmarshal), which needs to use JAXB (the Java architecture of XML binding) explains to mark.Therefore it needs to modify to explain class Schemas.java, inside it The attribute setting that " writeOneNode " is added in class, make content unmarshal in configuration file " schema.xml " at It include the corresponding information of " writeOneNode " field when the object of Table type.Initialize the class of XML configuration file In XmlToYaml.java, increase the function of initializing to parameter " writeOneNode ", the load configuration text in startup program Part initializes the relevant parameter being arranged in configuration file, by parsing XML configuration file in each interior of Schemas This class object is instantiated in portion's static class, the Key-value key-value pair configured required for finally being stored again by HashMap, This class instance object is externally provided.
The step of method in conjunction with described in disclosure herein or algorithm, can be directly contained in hardware, be held by processor In capable software module or in combination of the two.Software module may reside within RAM memory, flash memory, ROM storage Device, eprom memory, eeprom memory, register, hard disk, removable disk, CD-ROM or known in the art it is any its In the storage medium of its form.Illustrative storage medium is coupled to processor, enables a processor to from the storage medium Information is written to the storage medium in middle reading information.In an alternative, the storage medium can be with processor collection At together.Pocessor and storage media may reside in ASIC.ASIC may reside in user terminal.It is replaced at one In scheme, it is resident in the user terminal that pocessor and storage media can be used as discrete assembly.
In some embodiments, database middleware Mycat, database MySQL.
From above-described embodiment as can be seen that method of data synchronization provided in an embodiment of the present invention, by using enabling, table is wide It broadcasts mechanism, the database statement for receiving data manipulation language, judge whether database statement needs to be implemented global table logic, needs When send database statement to when database statement table being broadcast to all database nodes, do not needed using table broadcast mechanism All database nodes and the technical solution for executing database statement can be directed to disparate databases node or different types of number Data are carried out according to library node to synchronize, and are changed Mycat when DML is accessed to the execution logic of global table, be will act on all nodes Operation to be changed to the data completing each node by table broadcast mechanism again to the operation of host node synchronous, to maintain database The data consistency of middle global table.
It is important to note that each step in each embodiment of above-mentioned method of data synchronization can be handed over mutually It pitches, replace, increase, delete, therefore, should also be as in method of data synchronization of these reasonable permutation and combination transformation belongs to the present invention Protection scope, and protection scope of the present invention should not be confined on the embodiment.
Based on above-mentioned purpose, the second aspect of the embodiment of the present invention, disparate databases section can be directed to by proposing one kind Point or different types of database node carry out the embodiment of the synchronous device of data.The data synchronization unit has used above-mentioned Method of data synchronization.
Various illustrative logical blocks, module and circuit, which can use, in conjunction with described in disclosure herein is designed to The following component of function described here is executed to realize or execute: general processor, digital signal processor (DSP), dedicated collection At circuit (ASIC), field programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic, divide Any combination of vertical hardware component or these components.General processor can be microprocessor, but alternatively, processing Device can be any conventional processors, controller, microcontroller or state machine.Processor also may be implemented as calculating equipment Combination, for example, the combination of DSP and microprocessor, multi-microprocessor, one or more microprocessors combination DSP and/or any Other this configurations.
Data synchronization unit provided in an embodiment of the present invention by using enabling table broadcast mechanism, receives data manipulation language The database statement of speech judges will count when whether database statement needs to be implemented global table logic, needs using table broadcast mechanism All database nodes are sent by database statement when being broadcast to all database nodes according to library statement list, do not need and are executed It is same can to carry out data for disparate databases node or different types of database node for the technical solution of database statement Step changes Mycat when DML is accessed to the execution logic of global table, and the operation that will act on all nodes is changed to host node Operation again by table broadcast mechanism complete the data between each node synchronization, to maintain the data of global table in database consistent Property.
It is important to note that the embodiment of above-mentioned data synchronization unit uses the implementation of the method for data synchronization Example illustrates the course of work of each module, and those skilled in the art can be it is readily conceivable that by these module applications to institute It states in the other embodiments of method of data synchronization.Certainly, due to each step in the method for data synchronization embodiment To intersect, replace, increase, delete, therefore, these reasonable permutation and combination transformation are also answered in the data synchronization unit When belonging to the scope of protection of the present invention, and protection scope of the present invention should not be confined on the embodiment.
The data synchronization unit includes memory, at least one processor, and memory, which is stored with, to be transported on a processor Capable computer program, processor execute any one of the above method when executing program.
As shown in figure 5, the hardware structural diagram of one embodiment for data synchronization unit provided by the invention.
It include several processors 501 and several in the computer equipment by taking computer equipment as shown in Figure 5 as an example Memory 502, and can also include: input unit 503 and output device 504.
Processor 501, memory 502, input unit 503 and output device 504 can pass through bus or other modes It connects, in Fig. 5 for being connected by bus.
Memory 502 is used as a kind of non-volatile computer readable storage medium storing program for executing, can be used for storing non-volatile software journey Sequence, non-volatile computer executable program and module, as the method for data synchronization in the embodiment of the present application is corresponding Program instruction/module.Non-volatile software program, instruction and the mould that processor 501 is stored in memory 502 by operation Block realizes the data side of synchronization of above method embodiment thereby executing the various function application and data processing of server Method.
Memory 502 may include storing program area and storage data area, wherein storing program area can store operation system Application program required for system, at least one function;Storage data area can be stored to be created according to using for data synchronization unit Data etc..In addition, memory 502 may include high-speed random access memory, it can also include nonvolatile memory, example Such as at least one disk memory, flush memory device or other non-volatile solid state memory parts.In some embodiments, it deposits Optional reservoir 502 includes the memory remotely located relative to processor 501, these remote memories can pass through network connection To local module.The example of above-mentioned network include but is not limited to internet, intranet, local area network, mobile radio communication and its Combination.
Input unit 503 can receive the number or character information of input, and generates and set with the user of data synchronization unit It sets and the related key signals of function control inputs.Output device 504 may include that display screen etc. shows equipment.
Corresponding program instruction/the module of one or more of method of data synchronization is stored in the memory 502, When being executed by the processor 501, the method for data synchronization in above-mentioned any means embodiment is executed.
Any one embodiment of the computer equipment for executing the method for data synchronization, can achieve and be corresponding to it The identical or similar effect of aforementioned any means embodiment.
Based on above-mentioned purpose, the third aspect of the embodiment of the present invention proposes a kind of computer readable storage medium, institute Stating computer-readable recording medium storage has computer executable instructions, which can be performed above-mentioned any side The data synchronization unit in method of data synchronization and the above-mentioned any device embodiment of realization in method embodiment.The computer can The embodiment for reading storage medium, it is identical or similar as Installation practice to can achieve corresponding aforementioned any means Effect.
Based on above-mentioned purpose, the 4th aspect of the embodiment of the present invention proposes a kind of computer program product, the calculating Machine program product includes the calculation procedure being stored on computer readable storage medium, which includes instruction, when this Instruction is when being computer-executed, and makes that the computer executes the method for data synchronization in above-mentioned any means embodiment and realization is above-mentioned Data synchronization unit in any device embodiment.The embodiment of the computer program product can achieve corresponding The aforementioned any means effect identical or similar with Installation practice.
It is exemplary embodiment disclosed by the invention above, it should be noted that in the sheet limited without departing substantially from claim Under the premise of inventive embodiments scope of disclosure, it may be many modifications and modify.According to open embodiment described herein The function of claim to a method, step and/or movement be not required to the execution of any particular order.In addition, although the present invention is implemented Element disclosed in example can be described or be required in the form of individual, but be unless explicitly limited odd number, it is understood that be multiple.
It should be understood that it is used in the present context, unless the context clearly supports exceptions, singular " one It is a " it is intended to also include plural form.It is to be further understood that "and/or" used herein refers to including one or one Any and all possible combinations of a above project listed in association.The embodiment of the present invention discloses embodiment sequence number Description, does not represent the advantages or disadvantages of the embodiments.
It should be understood by those ordinary skilled in the art that: the discussion of any of the above embodiment is exemplary only, not It is intended to imply that range disclosed by the embodiments of the present invention (including claim) is limited to these examples;In the think of of the embodiment of the present invention Under road, it can also be combined between the technical characteristic in above embodiments or different embodiments, and exist as described above Many other variations of the different aspect of the embodiment of the present invention, for simplicity, they are not provided in details.Therefore, all at this Within the spirit and principle of inventive embodiments, any omission, modification, equivalent replacement, improvement for being made etc. should be included in this hair Within the protection scope of bright embodiment.

Claims (10)

1.一种数据同步方法,其特征在于,应用于数据库,包括以下步骤:1. a data synchronization method, is characterized in that, is applied to database, comprises the following steps: 配置数据库中间件并使所述数据库中间件启用表广播机制;Configuring the database middleware and enabling the database middleware to enable the table broadcast mechanism; 使所述数据库中间件接收数据操纵语言的数据库语句;causing the database middleware to receive database statements in a data manipulation language; 根据所述配置判断所述数据库语句是否需要执行全局表逻辑;Determine whether the database statement needs to execute global table logic according to the configuration; 当所述数据库语句需要执行所述全局表逻辑时,使用所述表广播机制将所述数据库语句表广播到所有数据库节点;When the database statement needs to execute the global table logic, the table broadcasting mechanism is used to broadcast the database statement table to all database nodes; 当所述数据库语句不需要执行所述全局表逻辑时,将所述数据库语句发送到所述所有数据库节点并执行所述数据库语句。When the database statement does not need to execute the global table logic, the database statement is sent to all database nodes and the database statement is executed. 2.根据权利要求1所述的方法,其特征在于,所述表广播机制包括:2. The method according to claim 1, wherein the table broadcast mechanism comprises: 在所述所有数据库节点中确定一个数据库主节点,并将其他数据库节点确定为数据库从节点;Determine a database master node among all the database nodes, and determine other database nodes as database slave nodes; 使所述数据库中间件向所述数据库主节点发送关于所述数据库语句的广播;causing the database middleware to send a broadcast about the database statement to the database master node; 使所述数据库主节点将所述数据库语句表广播到所有所述数据库从节点。The database master node is caused to broadcast the database statement table to all the database slave nodes. 3.根据权利要求2所述的方法,其特征在于,使所述数据库主节点将所述数据库语句表广播到所有所述数据库从节点包括:3. The method according to claim 2, wherein causing the database master node to broadcast the database statement table to all the database slave nodes comprises: 使所述数据库主节点保存包括所述数据库语句的二进制消息文件,并向所有所述数据库从节点推送所述二进制消息文件;causing the database master node to save the binary message file including the database statement, and pushing the binary message file to all the database slave nodes; 使所有所述数据库从节点通过专用的工作线程将所述二进制消息文件转存到所有所述数据库从节点各自的中继文件中;causing all the database slave nodes to transfer the binary message file to the respective relay files of all the database slave nodes through a dedicated worker thread; 使所述数据库主节点和所有所述数据库从节点各自根据所述二进制消息文件和各自的所述中继文件来执行所述数据库语句。The database master node and all the database slave nodes are each caused to execute the database statement according to the binary message file and the respective relay file. 4.根据权利要求3所述的方法,其特征在于,在每个所述数据库从节点将所述二进制消息文件转存到对应的所述中继文件中后,所述专用的工作线程在所述二进制消息文件中进行记录;在所述二进制消息文件中记录所有所述数据库从节点都已经进行转存后,所述数据库主节点向所有所述数据库从节点发送执行所述数据库语句的广播。4. The method according to claim 3, wherein after each of the database slave nodes dumps the binary message file into the corresponding relay file, the dedicated worker thread is record in the binary message file; after it is recorded in the binary message file that all the database slave nodes have been dumped, the database master node sends a broadcast for executing the database statement to all the database slave nodes. 5.根据权利要求3所述的方法,其特征在于,在所述专用的工作线程不能读取所述二进制消息文件时,相应的所述数据库从节点进入休眠并等待新的广播。5. The method according to claim 3, wherein when the dedicated worker thread cannot read the binary message file, the corresponding database slave node goes to sleep and waits for a new broadcast. 6.根据权利要求3所述的方法,其特征在于,所述专用的工作线程以串行的方式将所述二进制消息文件写入对应的所述中继文件。6. The method according to claim 3, wherein the dedicated worker thread writes the binary message file to the corresponding relay file in a serial manner. 7.根据权利要求1所述的方法,其特征在于,判断所述数据库语句是否需要执行所述全局表逻辑包括:7. The method according to claim 1, wherein judging whether the database statement needs to execute the global table logic comprises: 判断所述数据库语句的类型是否为以下之一:插入、更新、删除,如是则继续;Determine whether the type of the database statement is one of the following: insert, update, delete, if so, continue; 判断所述数据库语句的对象表类型是否为全局表,如是则继续;Determine whether the object table type of the database statement is a global table, and if so, continue; 判断所述数据库语句是否配置为启用单节点插入,如是则判定需要执行所述全局表逻辑,否则判定不需要。It is determined whether the database statement is configured to enable single-node insertion, and if so, it is determined that the global table logic needs to be executed, otherwise it is determined that it is not required. 8.根据权利要求1所述的方法,其特征在于,配置所述数据库中间件包括:8. The method of claim 1, wherein configuring the database middleware comprises: 向所述数据库中间件中的配置文件中加入判断表类型的表标签;Add a table label for judging the table type to the configuration file in the database middleware; 向所述表标签中加入判断是否启用所述表广播机制的单节点插入属性。A single-node insertion attribute for judging whether to enable the table broadcast mechanism is added to the table tag. 9.根据权利要求1-8中任一项所述的方法,其特征在于,所述数据库中间件为Mycat,所述数据库为MySQL。9 . The method according to claim 1 , wherein the database middleware is Mycat, and the database is MySQL. 10 . 10.一种数据同步装置,其特征在于,包括处理器和存储器,所述存储器存储有处理器可执行的指令,所述指令在被执行时实现如权利要求1-9任意一项所述的方法。10. A data synchronization device, characterized in that it comprises a processor and a memory, wherein the memory stores instructions executable by the processor, and the instructions, when executed, implement the method according to any one of claims 1-9. method.
CN201810919871.1A 2018-08-14 2018-08-14 A kind of method of data synchronization and device Pending CN109165258A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810919871.1A CN109165258A (en) 2018-08-14 2018-08-14 A kind of method of data synchronization and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810919871.1A CN109165258A (en) 2018-08-14 2018-08-14 A kind of method of data synchronization and device

Publications (1)

Publication Number Publication Date
CN109165258A true CN109165258A (en) 2019-01-08

Family

ID=64895465

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810919871.1A Pending CN109165258A (en) 2018-08-14 2018-08-14 A kind of method of data synchronization and device

Country Status (1)

Country Link
CN (1) CN109165258A (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110413687A (en) * 2019-05-09 2019-11-05 国网冀北电力有限公司 Distributed transaction fault processing method and related equipment based on node mutual authentication verification
CN111104409A (en) * 2019-12-25 2020-05-05 上海米哈游天命科技有限公司 Database processing method and device, storage medium and electronic equipment
CN111459882A (en) * 2020-03-30 2020-07-28 北京百度网讯科技有限公司 Namespace transaction processing method and device for distributed file system
CN113434500A (en) * 2019-08-20 2021-09-24 北京奥星贝斯科技有限公司 Table connection method, device, distributed database system, server and medium
CN113742336A (en) * 2021-02-09 2021-12-03 北京沃东天骏信息技术有限公司 A data processing method and device, and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9317372B1 (en) * 2005-04-13 2016-04-19 Progress Software Corporation Dynamic membership management in a distributed system
CN106126600A (en) * 2016-06-21 2016-11-16 浪潮电子信息产业股份有限公司 A kind of perform the method for read and write abruption, Apparatus and system
CN106815097A (en) * 2017-01-18 2017-06-09 北京许继电气有限公司 Database disaster tolerance system and method
US20180004801A1 (en) * 2013-05-13 2018-01-04 Amazon Technologies, Inc. Transaction ordering

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9317372B1 (en) * 2005-04-13 2016-04-19 Progress Software Corporation Dynamic membership management in a distributed system
US20180004801A1 (en) * 2013-05-13 2018-01-04 Amazon Technologies, Inc. Transaction ordering
CN106126600A (en) * 2016-06-21 2016-11-16 浪潮电子信息产业股份有限公司 A kind of perform the method for read and write abruption, Apparatus and system
CN106815097A (en) * 2017-01-18 2017-06-09 北京许继电气有限公司 Database disaster tolerance system and method

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
王锦、梁正和、王法强: "表广播机制在MyCat中的实现", 《计算机技术与发展》 *

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110413687A (en) * 2019-05-09 2019-11-05 国网冀北电力有限公司 Distributed transaction fault processing method and related equipment based on node mutual authentication verification
CN113434500A (en) * 2019-08-20 2021-09-24 北京奥星贝斯科技有限公司 Table connection method, device, distributed database system, server and medium
CN111104409A (en) * 2019-12-25 2020-05-05 上海米哈游天命科技有限公司 Database processing method and device, storage medium and electronic equipment
CN111459882A (en) * 2020-03-30 2020-07-28 北京百度网讯科技有限公司 Namespace transaction processing method and device for distributed file system
CN111459882B (en) * 2020-03-30 2023-08-29 北京百度网讯科技有限公司 Distributed file system namespace transaction processing method and device
CN113742336A (en) * 2021-02-09 2021-12-03 北京沃东天骏信息技术有限公司 A data processing method and device, and storage medium

Similar Documents

Publication Publication Date Title
CN111143389B (en) Transaction execution method and device, computer equipment and storage medium
CN109165258A (en) A kind of method of data synchronization and device
US20230100223A1 (en) Transaction processing method and apparatus, computer device, and storage medium
US8131670B2 (en) Techniques to cross-synchronize data
EP2356560B1 (en) Atomic multiple modification of data in a distributed storage system
US10430298B2 (en) Versatile in-memory database recovery using logical log records
JP5387757B2 (en) Parallel data processing system, parallel data processing method and program
EP2797013B1 (en) Database update execution according to power management schemes
JP2022501747A (en) Data backup methods, equipment, servers and computer programs
CN112905613B (en) A bidirectional data synchronization method and device for heterogeneous databases
WO2023077971A1 (en) Transaction processing method and apparatus, and computing device and storage medium
US12111817B2 (en) Log execution method and apparatus, computer device and storage medium
CN111339131A (en) Data reading and writing method and system
US20240028598A1 (en) Transaction Processing Method, Distributed Database System, Cluster, and Medium
JP2008287548A (en) Database control method and program
CN113448977A (en) Distributed cache updating method and device based on database Binlog
CN119322657A (en) Data processing system, data processing method and related equipment
US12164434B1 (en) Systems and methods for coupled cache management
CN118069750A (en) Data processing method and device
CN112612647B (en) Log parallel replay method, device, equipment and storage medium
Donselaar Low latency asynchronous database synchronization and data transformation using the replication log.
CN114579604B (en) Database transaction implementation method and system of application layer
CN118838974B (en) Templated business cache processing method and system
US20050177774A1 (en) Automated generation of computer-executable compensation procedures for previously executed methods
EP3411799A1 (en) Systems and methods for mixed consistency in computing systems

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
RJ01 Rejection of invention patent application after publication

Application publication date: 20190108

RJ01 Rejection of invention patent application after publication