CN102184183B - Data synchronization method for distributed database - Google Patents

Data synchronization method for distributed database Download PDF

Info

Publication number
CN102184183B
CN102184183B CN 201110079997 CN201110079997A CN102184183B CN 102184183 B CN102184183 B CN 102184183B CN 201110079997 CN201110079997 CN 201110079997 CN 201110079997 A CN201110079997 A CN 201110079997A CN 102184183 B CN102184183 B CN 102184183B
Authority
CN
Grant status
Grant
Patent type
Prior art keywords
data
synchronization
method
distributed
database
Prior art date
Application number
CN 201110079997
Other languages
Chinese (zh)
Other versions
CN102184183A (en )
Inventor
梁晖
魏阳
柴秀英
Original Assignee
迈普通信技术股份有限公司
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
Grant date

Links

Abstract

本发明涉及分布式数据库,其公开了一种分布式数据库数据同步方法,以实现嵌入式设备板卡之间的数据同步,同时保证板卡数据的一致性,提高数据同步的效率。 The present invention relates to a distributed database, which discloses a distributed database synchronization method of the data, to enable data synchronization between the boards embedded devices, while ensuring consistency of the data card, to improve the efficiency of data synchronization. 其实现步骤包括:a.源板卡对分布式数据库中的操作进行下发;b.各目的板卡的分布式数据库接收到源板卡下发的操作后,对其进行缓存,并向源板卡的分布式数据库返回确认消息;c.源板卡的分布式数据库接收到所有目的板卡的确认消息后,向目的板卡的分布式数据库发送执行消息;d.各目的板卡的分布式数据库接收到执行消息后,执行其缓存的操作,并将将执行结果返回给源板卡的分布式数据库。 Its implementation step comprises:.. A source on board in a distributed database operation issued; B each card distributed database object delivered by the source is received after the board operation, its cache, to the source board distributed database returns an acknowledgment message;. c-source board after receiving all of the distributed database purposes acknowledgment message board, a distributed database object sends a message board performed; D distribution of the object of the board. after the database receives the execution message, it performs its cache operations, and returns the execution result to the source board distributed database. 本发明适用于嵌入式设备板卡之间的数据同步。 The present invention is applicable to embedded devices between the board data synchronization.

Description

一种分布式数据库数据同步方法 A distributed database data synchronization method

技术领域 FIELD

[0001] 本发明涉及分布式数据库,尤其涉及一种分布式数据库的数据同步方法。 [0001] The present invention relates to a distributed database, particularly to a method for synchronizing data in a distributed database.

背景技术 Background technique

[0002] 嵌入式设备中一般包括主控卡和业务线卡。 [0002] Embedded devices typically include a main control card and line of business cards. 其中主控卡完成控制功能,而业务线卡则通过特定的业务接口完成数据转发功能。 Wherein the master control card function is completed, and the service line card through the interface to a particular service data forwarding function is completed. 为了提高可靠性,目前的嵌入式设备内一般配备了双主控卡,分为主用主控卡和备用主控卡;当主用主控卡发生故障时,进行主备倒换,备用主控卡切换成主用主控卡,负责所有控制业务的运行。 To improve reliability, the present general embedded device is equipped with dual master card, the card MPU divided into a main and standby master card; master card when the master fails, a standby switchover, the standby control card switch to the active main card, is responsible for all operational control of the business. 主用主控卡、备用主控卡和业务线卡部署在嵌入式设备的不同槽位上,在系统运行过程中,系统的配置管理信息和路由信息等一般由主用主控卡根据变化情况实时下发到各业务线卡和备用主控卡的;所以嵌入式设备中各个板卡的数据如何存储是一个比较核心的问题。 The active main control card, master card and standby line card services deployed in different slots embedded device, during the operation of the system, the configuration and routing information management systems and the like comprising a main master card is generally in accordance with changes in Real-time onward transport line cards and SMB business cards; so how embedded devices each board data storage is a more central issue. 本申请人在中国专利申请“201110022830. O分布式网络设备中同步数据的存储方法及系统”中提出了一种采用分布式数据库进行数据存储的方法,即主用主控卡、业务线卡和备用主控卡采用分布式数据库进行数据存储。 The present applicant in Chinese Patent Application "201110022830. O devices distributed network storage method and system for synchronizing data" is proposed a method of using a distributed database for data storage, i.e., the active control card, business cards and the line the standby main control card uses a distributed database for data storage.

[0003] 嵌入式设备中板卡之间数据的同步是必不可少的,即需要能够保证板卡数据的一致性,对于采用分布式数据库进行数据存储的嵌入式设备来说,涉及到分布式数据库的分发处理技术。 [0003] The embedded device synchronize data between cards is essential that the board needs to be able to ensure consistency of data, for embedded devices using distributed databases for data storage, it relates to distributed distribution process technology database. 现在开源或者商业的小型数据库包括:mysql、sqlite、fastdb、postgresql等等,其中有嵌入式的数据库,也有非嵌入式的数据库,但是涉及数据分发处理的都比较少,一般只局限于以文件的形式进行备份,即是将操作完成后的文件数据进行拷贝,此种情况下,数据同步效率低。 Now a small open-source or commercial database include: mysql, sqlite, fastdb, postgresql, etc., which have an embedded database, there are also non-embedded database, but relatively few involve processing of data distribution, generally confined to file in the form of backup, that is, the data file copy operation is complete, in this case, the low efficiency of data synchronization.

发明内容 SUMMARY

[0004] 本发明所要解决的技术问题是:提出一种分布式数据库数据同步方法,以实现嵌入式设备板卡之间的数据同步,同时保证板卡数据的一致性,提高数据同步的效率。 [0004] The present invention solves the technical problem are: to provide a distributed database synchronization method of the data, to enable data synchronization between the boards embedded devices, while ensuring consistency of the data card, to improve the efficiency of data synchronization.

[0005] 本发明解决上述技术问题所采用的方案是:一种分布式数据库数据同步方法,包括以下步骤: [0005] The present invention solves the above technical problem solution is: a distributed database data synchronization method, comprising the steps of:

[0006] a.源板卡对其分布式数据库中的操作进行下发; . [0006] a source of issued cards for its operation in a distributed database;

[0007] b.各目的板卡的分布式数据库接收到源板卡下发的操作后,对该操作进行缓存,并向源板卡的分布式数据库返回确认消息; After [0007] b each card distributed database object receives the card issued by the source operation, the cache operation, the distributed database and a source card returns an acknowledgment message;

[0008] c.源板卡的分布式数据库接收到所有目的板卡的确认消息后,向目的板卡的分布式数据库发送执行消息; After [0008] c source board distributed database receives an acknowledgment message board for all purposes, distributed database object sends a message board performed;

[0009] d.各目的板卡的分布式数据库接收到执行消息后,执行其缓存的操作,并将执行结果返回给源板卡的分布式数据库。 [0009] d. Each card object database distributed after receiving the COMMIT message, it performs the cache operation, and returns the execution result to the source board distributed database.

[0010] 进一步的,本发明的分布式数据库数据同步方法还包括以下步骤: [0010] Further, the data distributed database synchronization method of the present invention further comprises the step of:

[0011] e.源板卡的分布式数据库汇总所有目的板卡的执行结果,并将结果通告给各目的板卡;[0012] f.各目的板卡的分布式数据库在接收到源板卡的分布式数据库的通告消息后,清除其缓存中的操作或者发送错误确认消息。 . [0011] e source board summarized the results of all distributed object database board, and the board results to the respective object; [0012] f of each object in the distributed database card receiving board to the source. after the advertisement message distributed database, its cache cleanup operation or send an error message acknowledgment.

[0013] 进一步,步骤e中,源板卡的分布式数据库汇总所有目的板卡的执行结果后,如果判断所有目的板卡成功执行操作,则执行如下操作: After [0013] Further, in step e, the source board summarized the results of all distributed object database board, if the board is determined for all purposes successfully executed operation is performed as follows:

[0014] el.源板卡的分布式数据库将汇总后的执行结果发送给本地对应的应用模块; . [0014] el source board distributed database summary execution result to the local corresponding application modules;

[0015] e2.本地对应的应用模块将对执行结果的确认消息返回分布式数据库; . [0015] e2 local acknowledgment message corresponding to the application module will return the execution result of the distributed database;

[0016] e3.源板卡的分布式数据库收到本地对应的应用模块对执行结果的确认消息后,向各个目的板卡通告本次操作的执行结果。 [0016] e3. When the source board distributed database application module receives a local acknowledgment message corresponding to the result of the execution, the execution result to each object of Notice boards of this operation.

[0017] 进一步,步骤e中,源板卡的分布式数据库汇总所有目的板卡的执行结果后,如果判断有目的板卡执行操作出现错误,则向所有目的板卡通告错误消息。 After [0017] Further, in step e, the source board summarized the results of all distributed object database board, if an error is determined to perform operations purpose board occurs, an error message to the advertisement boards for all purposes.

[0018] 进一步,步骤f中,所有目的板卡的分布式数据库接收到源板卡的分布式数据库的通告消息后,如果判断有目的板卡的执行操作出现错误,则向源板卡的分布式数据库发送错误确认消息,否则清除其缓存中的操作。 After [0018] Further, in step f, the distributed database for all purposes board receives an advertisement message board sources distributed database, an error is determined if the object has performed the operation board occurs, to the source distribution board database error confirmation message is sent, otherwise the cleanup operation in its cache.

[0019] 具体的,源板卡的分布式数据库接收到所有目的板卡的错误确认消息后,再将汇总后的执行结果返回给源板卡的应用模块,所述应用模块首先对错误进行处理,然后终结本次下发的操作。 After [0019] Specifically, the source board distributed database object receives all error acknowledgment message board, and then the execution result is returned to the source of the summary module board application, the application processing module first error , then the end of this operation issued.

[0020] 进一步,步骤a中,源板卡对其分布式数据库中的操作进行下发之前,源板卡首先对其分布式数据库的数据库表执行所述操作,如果操作成功,则对其分布式数据库中的操作进行下发,如果操作失败,则不进行操作下发。 [0020] Further, in a step, prior to source issued card, the first card source database table operation performed its its distributed database in a distributed database operation, if the operation is successful, its distribution operated issued in the database, if the operation fails, issued operation occurs.

[0021] 具体的,每一个被下发的操作都分配有唯一的序列号。 [0021] Specifically, each of which is issued by the operator is assigned a unique serial number.

[0022] 具体的,所述源板卡是指主用主控卡,所述目的板卡包括业务线卡和备用主控卡。 [0022] Specifically, the source refers to the active main control board card, the card object comprises a service line cards and standby master card.

[0023] 进一步,在分布式数据库的分发处理过程中,源板卡如果发生了主备切换,则切换后,备用主控卡作为切换后的源板卡执行如下操作: [0023] Further, in the distribution process of the distributed database, if the source board standby switching occurs, then after the handover, the source standby main control board as the card after the handover execution follows:

[0024] gl.如果切换后的源板卡中无切换前的源板卡下发的操作,则切换后的源板卡向目的板卡发送切换通知消息,并携带最新操作序列号;各个目的板卡接收到切换通知消息后,将所述最新操作序列号与本地最新操作序列号相比较,丢弃本地缓存中比切换通知消息中操作序列号新的操作; . [0024] gl sent if the source of the board after the board prior to the handover source switching without operating, the board after the handover source transmits handover notification message, and serial numbers to carry the latest operation card object; each object after receiving the handover notification message board, the latest operating sequence number is compared with the latest operating local sequence number, discarding the local cache than the switching operation of the sequence number of the new notification message operation;

[0025] g2.如果切换后的源板卡接收有切换前的源板卡下发的操作但是还未执行,则切换后的源板卡需要重发操作,目的板卡判断本地缓存中是否有对应操作,如否,则目的板卡缓存该操作并向切换后的源板卡的分布式数据库返回确认消息,否则,不管是否执行,则向切换后的源板卡的分布式数据库直接返回确认消息; [0025] g2. If the source switching of the board after receiving the board has delivered by the source before the switching operation has not been performed, however, the source board to switch the operation needs to be retransmitted, the purpose of the board is determined whether a local cache corresponding to the operation, if not, the object of the operation board cache and returns an acknowledgment message board after switching the source distributed database, otherwise, regardless of whether, after the handover to the source board directly distributed database returns an acknowledgment news;

[0026] g3.如果切换后的源板卡已经执行切换前的源板卡下发的操作但未确认,则切换后的源板卡向目的板卡发送执行消息,如果目的板卡判断本地缓存的对应操作还未执行,则目的板卡执行操作并发送执行结果消息;若目的板卡判断本地缓存的对应操作已经执行但未确认,则目的板卡发送缓存中的执行结果; [0026] g3. If the source switching after the board has been performed but unacknowledged operation sent by the source before the switching board, the board after the handover source transmits to the object execution message board, if the board is determined local cache object a corresponding operation has not been performed, the object of the board operation and sends an execution result executed message; if the object corresponding to the local cache board determination operation has been performed, but not confirmed, the card object transmits the execution result cache;

[0027] g4.如果切换后的源板卡判断目的板卡的执行结果出现错误,则切换后的源板卡发送错误消息,目的板卡向切换后的源板卡发送错误确认消息; . [0027] g4 if the source board to switch the board object execution result determination error occurs, the source board sends an error message after the handover, the card sends an error acknowledgment message object to the source after switching board;

[0028] g5.如果切换后的源板卡缓存的操作已经终结,则切换后的源板卡在切换之初,下发本地缓存中最小的操作序列号和最大的操作序列号对应的操作到目的板卡,目的板卡接收到操作后,丢弃序列号小于切换后的源板卡发送的最小序列号的操作和序列号大于切换后的源板卡发送的最大序列号的操作。 [0028] g5. If the source switching after the board cache operation has ended, after the board at the beginning of the handover source switching, delivers the corresponding local cache operation sequence number and the smallest maximum number of operations to the operation sequence purpose card, the card object after receiving the operation, the maximum discard operation sequence number and the smallest serial number of the operation card serial number for the source is less than the transmission source switching after the board greater than the switching of the transmission.

[0029] 本发明的有益效果是:实现嵌入式设备板卡之间的数据同步,同时保证板卡数据的一致性,提高数据同步的效率。 [0029] Advantageous effects of the present invention are: to synchronize data between the embedded device board, the board while maintaining the consistency of data and improve the efficiency of data synchronization.

附图说明 BRIEF DESCRIPTION

[0030] 图1是本发明分布式数据库数据同步流程示意图。 [0030] FIG. 1 is a distributed database data synchronization process of the present invention, FIG.

[0031] 图2是本发明实施例的分布式数据库对多个板卡分发操作流程示意图。 [0031] FIG. 2 is a schematic flow diagram of the operation of the distributed database embodiment of the present invention to a plurality of distribution board.

[0032] 图3是本发明实施例的下发操作执行错误的处理流程示意图。 [0032] FIG. 3 is an embodiment of the present invention made an error operation performed schematic process flow.

[0033] 图4是本发明中应用模块调用分布式数据库接口分发数据框图。 [0033] The present invention FIG. 4 is a block diagram of the distribution data distributed database interface application module calls.

具体实施方式 detailed description

[0034] 下面结合附图及具体的实施方式对本发明作进一步的描述。 [0034] The present invention will be further described in conjunction with the accompanying drawings and specific embodiments.

[0035] 针对传统技术中分布式数据库的分发处理局限于以文件形式的备份,数据同步效率低下的缺陷,本发明提出一种分布式数据库的分发处理方法,以实现嵌入式设备板卡之间的数据同步,同时保证板卡数据的一致性,提高数据同步的效率。 [0035] limited to the backup file format, data synchronization low efficiency defects, the present invention provides a distributed database distributed processing method in order to achieve the embedded device in the conventional art for the card distribution process database distributed between data synchronization, while ensuring consistency card data and improve the efficiency of data synchronization. 本发明中,主控卡上应用模块的数据,是以添加或者删除或者修改的等操作方式进入分布式数据库的数据库表中,应用模块对数据库表进行的添加或者删除或者修改操作下发到多个目的板卡中,各个目的板卡(主要是指备用主控卡和各个业务线卡)的数据也以添加或者删除或者修改的操作方式进入其分布式数据库的数据库表中,目的板卡完成数据同步后向主控卡返回结果。 In the present invention, the data on the application module control card, is sent to the multi-add or delete or modify the way into the distributed database operations such as database tables, the database tables application module is added or removed or the modify operation object cards, each card object (mainly master card and standby line cards of each service) of data to be added or deleted or modified operating its way into a database table in a distributed database, object of the complete board after data synchronization returns the result to the master card. 本发明中,对数据库表执行的操作本身所携带的信息必须缓存在分布式数据库中,操作以操作缓存的形式存在,直到操作被终结。 In the present invention, information of the operation performed on the database table itself must be carried in a distributed database in the cache, the cache operation in the form of operation until the operation is terminated.

[0036] 一个操作通过分布式数据库进行分发的过程分为两个阶段: [0036] during a distribution operation by a distributed database is divided into two stages:

[0037]1.源板卡本地数据库表实施操作阶段:本阶段是源板卡首先对本地分布式数据库的数据库表执行相关操作,本次操作成功则进入第二阶段,操作失败,则不进行操作下发。 [0037] Table 1 Source board local database embodiment operating phases: The first phase is the source for performing the operation board table of the local database distributed database, this operation is successful, the second phase, the operation fails, does not perform operation issued.

[0038] 2.源板卡和目的板卡数据同步阶段:图1为本发明实施例的分布式数据库的数据下发过程示意图,将源板卡和目的板卡数据同步的整个下发过程分为五个阶段,即: A schematic view of the development process the data distributed databases embodiment 1 of the present invention, the source and destination cards issued card data of the whole process of synchronization points: [0038] 2. The source and destination board card data synchronization stage five stages, namely:

[0039] 第一阶段:源板卡(即主用主控卡)将操作进行下发; [0039] The first stage: the source board (i.e., the master control card) The operation issued;

[0040] 第二阶段:各目的板卡(包括备用主控卡、各业务线卡)接收源板卡下发的操作后,对操作进行缓存,并对源板卡返回接收确认消息; [0040] Second stage: each object of the boards (including the standby control card, each line card service) delivered by the source receiving the board operation, the operation cache, and returns the source receiving an acknowledgment message board;

[0041] 第三阶段:源板卡向目的板卡发送执行消息; [0041] The third stage: the source board executes a message transmission to the target board;

[0042]第四阶段:各目的板卡接收执行消息后,执行其缓存的操作,并将执行结果返回给源板卡; [0042] Fourth stage: each object receives the execution message boards, which perform caching operations, and returns the execution result to the source board;

[0043] 第五阶段:源板卡汇总所有的执行结果后通告各目的板卡;各目的板卡在接收到通告消息后清除其缓存中的操作。 [0043] Fifth stage: Source board advertisement summary of all the results of the board after each object; each object in the board after receiving the advertisement message clear operation in its cache.

[0044] 实施例 [0044] Example

[0045] 本发明实施例中,源板卡下发操作到各个目的板卡,下发的操作中带有操作序列号,各个目的板卡接收该带有操作序列号的操作并缓存,并向该源板卡返回该操作的序列号作为接收确认消息;源板卡接收到所有目的板卡的确认消息后,再发送执行操作的消息到所有目的板卡;目的板卡接收到来自源板卡的执行操作的消息后执行其缓存的操作,并将执行结果返回给源板卡。 Embodiment [0045] In the present invention, the operation to send each object card, issued by the operation with the operation card serial number on the source, the operation of the respective object with the card receiving operation of the serial number and the cache, and the serial number of the source board returns a reception confirmation message operation; source board after receiving the acknowledgment message boards for all purposes, and then performs an operation to send a message to all the card object; object board received from a source card its cache operation performed after the message operation is performed, and the execution result is returned to the source board. 源板卡的分布式数据库汇总所有目的板卡的执行结果,判断所有目的板卡都成功执行下发的操作后,将该操作结果返回给应用模块,源板卡的分布式数据库为其应用模块提供结果确认接口函数,应用模块调用该结果确认函数将操作结果确认返回给本地分布式数据库,源板卡的分布式数据库再将执行结果通告给各个目的板卡,各目的板卡在接收到通告消息后清除其缓存中的操作;至此本次数据同步成功完成。 Source board summarized the results of all distributed object database board, after determining all purposes boards are delivered by the successful execution of the operation, the operation result is returned to the application module, the source board for distributed database application modules provides an interface function was confirmed, it was confirmed that the application module calls the function returns to operation it was confirmed that the local distributed database, a distributed database source board then perform various board results to the object, each object receives an advertisement board in after the message is cleared in the cache operation thereof; point of this data synchronization completed successfully. 本实施例中,源板卡下发的操作中带有为该操作分配的唯一序列号,即下发的操作由主控卡下发到各个业务线卡,业务线卡接收该操作并缓存,这个缓存中包含了操作的上下文和序列号,以便于对结果进行回溯。 In this embodiment, the source operation card issued with a unique serial number assigned for the operation, i.e., operation issued by the master card receives the operation onward transport lines of business cards, business cards and the line buffer, this cache contains the context and sequence number operations, in order to back the results. 业务线卡向主控卡返回该操作的序列号作为接收确认消息,然后主控卡发送操作执行消息,目的板卡接收执行操作,并将操作结果返回。 Service line card is returned to the master card serial number of the operation as a reception confirmation message, then the message transmit operations master card, the card object receiving operation performed, the operation result is returned.

[0046]图2中为本发明实施例源板卡与目的板卡的缓存状态及操作的流转关系示意图。 Example source board and a buffer status object relations and board transfer operation of the schematic embodiment [0046] FIG. 2 of the present invention. 由于添加、删除、修改操作本身会在源、目的板卡的分布式数据库中缓存,在源板卡中,用于缓存下发操作的缓存有两种状态,一种状态是分发未确认,即下发操作未被确认,源板卡已下发操作到目的板卡,但是还未接收到所有目的板卡的接收确认消息;另一种状态分发执行未确认,即是下发执行操作未被确认,源板卡向各个目的板卡下发了执行操作的消息,但是还没有接收到所有目的板卡的执行结果。 Due to add, delete, modify the operation itself is cached in a distributed database source and destination board, the board in the source, for emitting operation cached buffer has two states, one state distribution is not confirmed, i.e., issued operation is not confirmed, the board has issued the source to the destination card operation, but has not yet received the reception confirmation message board for all purposes; another state distribution is not confirmed execution, perform an operation that is not issued confirmed, the source message board made to perform the operation at each destination board, but has not received the execution result for all purposes board. 在目的板卡中,用于缓存来自源板卡的操作的缓存也有两种状态,一种状态是接收未执行,即目的板卡接收到了源板卡发送的操作,但是还没有接收到执行操作的消息;另一种状态是执行返回未确认,对应于目的板卡已经执行了操作,并且将执行结果发送给源板卡,但未收到源板卡发送的执行结果确认消息。 The purpose of the board, the operation from the buffer for buffering the source board has two states, one state is received is not performed, i.e., the object of the operation board received transmission source board, but has not received the operation performed message; and a state is not confirmed execution returns corresponding to the object of the board operation has been performed, and the execution result to the source of the board, but did not receive the results of an acknowledgment message sent by the source board.

[0047]但是注意,本发明中还有一个错误处理机制,即在源板卡的分布式数据库汇总所有目的板卡的执行结果后,如果判断有目的板卡的执行操作出现错误,则直接向目的板卡通告执行结果。 [0047] Note, however, the present invention also has a mechanism for error handling, i.e. the summary results for all performed in a distributed object database source board after board, if the error is determined to perform operations occur purpose board, directly to the The purpose board notice the results. 所有目的板卡的分布式数据库接收到源板卡的分布式数据库的通告消息后,如果判断有目的板卡的执行操作出现错误,则向源板卡的分布式数据库发送错误确认消息。 After all the cards distributed database object receives the distributed database sources announce message board, if the error is determined to perform operations purpose board occurs, send an error to the distributed database source board acknowledgment message. 源板卡的分布式数据库接收到所有目的板卡的错误确认消息后,再将当前汇总后的执行结果返回应用模块,应用模块首先对错误进行处理,然后终结本次下发的操作。 When the source board distributed database receives all error acknowledgment message board purposes, and then the current execution result of the application returns the summary module, an application error processing module first, and then the end of this operation issued. 其处理流程可以参见图4,相比正常流程多出了错误确认的步骤,S卩:源板卡根据执行结果向出错的目的板卡告知错误信息,收到通告消息的目的板卡后向源板卡送错误确认消息。 Which process flow may Referring to FIG 4, compared to the normal flow of the steps of a plurality of error acknowledgment, S Jie: After the error message to the source board to inform the error object according to the execution result of the board, the board received announce message to the source object send confirmation message board error.

[0048] 本发明实施例中作为源板卡的主控卡如果发生了主备切换,则切换后的源板卡对于板卡在下发过程中有5个状态:还未获取_>接收未执行_>执行未确认_>错误确认_>操作已经终结。 [0048] The embodiment of the invention occurs if the main board as the source standby switching control card, the card after the handover source five states for the next card in the development process: acquiring yet _> reception is not performed _> execute unconfirmed _> error acknowledgment _> operation has ended. 在切换完成后,对于错误处理的流程来说,切换后的源主控卡的操作缓存可以分为三个小阶段,第一阶段仍然是接收未执行,第二阶段可以划分为执行未确认和错误未确认两个小阶段。 After the completion of the handover, to the error handling process, the operation of the cache after the handover source host card can be divided into three smaller phases, the first still is to receive is not performed, the second stage can be divided into unacknowledged and perform error unconfirmed two small stages. 为了保持操作的一致性,其原则为:一个板卡的操作缓存处于某种状态时,那么其余的板卡中对应操作缓存一定处于三种状态之一:该状态之前一个状态、该状态、该状态之后一个状态。 For consistency of operation, which principle is: the cache operation when a board in a certain state, then the rest of the board in a certain cache operations corresponding to one of three states: a state before the state that the a state after state. 因此保持数据一致的方法为各个板卡都回退到前一个状态。 So keeping data consistent approach to the various boards are to fall back to the previous state. 例如从处于接收未执行,则其他的板卡应该处于还未获取或者接受未执行或者执行未确认的状态。 It is received from, for example, is not performed, in yet another card should be acquired or not to accept the execution state or perform unacknowledged. 其具体处理流程为图4所示:其中部件A为切换后的主控卡,部件B为其它业务线卡, The specific processing flow is shown in Figure 4: wherein A is a member after the switching master card, member B to other services line cards,

[0049]1.如果部件A的操作缓存状态为还未获取状态,即还未接收到操作,则部件A向部件B发送切换通知消息,并携带最新操作序列号,部件B接收切换通知消息,并将其携带的最新操作序列号与本地最新操作序列号相比较,丢弃本地中比切换通知消息中操作序列号新的操作缓存; [0049] 1. If the operation state of the buffer member A is not yet acquired state, i.e. the operation has not been received, the member A transmits a handover notification message to the member B, and carry the latest operation serial number, part B receiving a handover notification message, and comparing the latest operating sequence number carried in the latest operation with the local sequence number, a local switching discard notification message than the buffering operation in the new operating sequence number;

[0050] 2.如果部件A的操作缓存状态为接收未执行状态,即已经接收到了操作但是还未执行,则部件A需要重发操作,部件B判断本地缓存状态:若本地缓存状态为还未获取状态,则部件B保存操作缓存并发送接收确认消息;若本地缓存状态为接收未执行状态,则部件B发送接收确认消息;若本地缓存为执行未确认状态,即已经执行操作但未收到确认返回,则部件B发送接收确认消息,但是执行结果并不清除,在随后接收执行消息时,发送缓存中的执行结果; [0050] 2. If the operation status of the cache state of the receiving member A is not performed, i.e., the operation has been received but has not yet performed, the operation needs to be retransmitted member A, member B determines the local cache status: If the local cache state is not yet acquiring state buffer B save operation member and the transmitting and receiving an acknowledgment message; status if the local cache is not performed reception state, the receiving member B sends an acknowledgment message; if the local buffer to perform the unconfirmed state, i.e., the operation has been performed but did not receive acknowledge back, B transmitting the acknowledgment message reception section, but does not clear the execution result, the execution message is subsequently received, the transmission buffer of an execution result;

[0051] 3.如果部件A的操作缓存状态为执行未确认状态,则部件A发送执行消息,部件B判断本地缓存状态:若本地缓存状态为接收未执行状态,则部件B执行操作并发送执行结果消息;若本地缓存状态为执行未确认状态,则部件B发送缓存中的执行结果;若本地缓存状态为错误确认状态,即执行操作时出现了错误,目的分布式器件对错误进行确认,则部件B发送缓存中的执行结果; [0051] 3. If the operation state of the buffer member A is not confirmed execution state, the execution message transmission member A, member B determines the local cache status: If the local cache does not receive state execution state, the execution and transmission operation means B result message; if the local cache state is not confirmed execution state, an execution result transmission member B buffer; if the local cache status error acknowledgment status, i.e., an error occurs while performing an operation, the distributed object on the device to confirm the error, then section B sends an execution result cache;

[0052] 4.如果部件A的操作缓存状态为错误状态,即发现目的分布式器件在执行操作时出现错误,则部件A发送错误消息,部件B判断本地缓存状态:若本地缓存状态为执行未确认状态,则部件B发送错误确认消息;若本地缓存状态为错误确认状态,则部件B发送错误确认消息;若本地缓存状态为终结状态,即将汇总的执行结果通告各目的分布式器件,则部件B发送错误确认; [0052] 4. If the operating state of the buffer member A is an error state, i.e., that the destination device is distributed error occurs while performing an operation, an error message is transmitted member A, member B determines the local cache status: If the local cache state is not performed acknowledged, the member B sends an error acknowledgment message; if the local cache status error acknowledgment status, sending an error confirmation message for the component B; buffer state is terminated if the local state, i.e. the summary results of execution of each advertisement distributed object device, the member B sends an error acknowledgment;

[0053] 5.如果部件A的操作缓存状态为终结状态,则由切换之初部件A发送本地操作序列号来完成确认,部件A发送本地缓存中的最旧的操作序列号和最新的操作序列号,部件B接收操作序列号以后作以下操作:丢弃序列号小于部件A发送的最旧序列号的操作,丢弃序列号大于部件A发送的最新序列号的操作。 [0053] 5. If the operating state of the buffer member A is final state, by the switching operation at the beginning of the local transmission member A to complete the confirmation sequence number, member A sends the oldest sequence number and the latest operation of the operational sequence in the local cache number, part number B after receiving the sequence of operations for the following actions: abort sequence numbers less than the sequence number of the oldest operation member a is transmitted, the sequence number is greater than the discard operation member a latest sequence number sent.

Claims (6)

  1. 1. 一种分布式数据库数据同步方法,其特征在于,包括以下步骤:a.源板卡对其分布式数据库中的操作进行下发:源板卡首先对其分布式数据库的数据库表执行所述操作,如果操作成功,则对所述源板卡的分布式数据库中的操作进行下发, 每一个被下发的所述操作都分配有唯一的序列号;如果操作失败,则不进行操作下发;b.各目的板卡的分布式数据库接收到源板卡下发的操作后,对该操作进行缓存,并向源板卡的分布式数据库返回确认消息;c.源板卡的分布式数据库接收到所有目的板卡的确认消息后,向目的板卡的分布式数据库发送执行消息;d.各目的板卡的分布式数据库接收到执行消息后,执行其缓存的操作,并将执行结果返回给源板卡的分布式数据库;所述源板卡是指主用主控卡,所述目的板卡包括业务线卡和备用主控卡;源板卡如果发生了 A distributed database data synchronization method comprising the steps of:. A source card issued for the distributed database and its operation: First, the source board executes the distributed database tables of its database said operation, if the operation is successful, the source board in a distributed database operation issued, each of the operation is issued is assigned a unique serial number; if the operation fails, no action issued; after b are each distributed database object receives the board delivered by the source of the board operation, the cache operation, the distributed database and a source card returns an acknowledgment message; c-source distribution board. after receiving all database object acknowledgment message board, a distributed database object sends a message board performed;. d of each card distributed object database message received after performing the operations performed in its cache, and execution result is returned to the source board distributed database; refers to the source of the active main control board card, the card object comprises a service line cards and standby master card; if the source board occurs 备切换,则切换后,备用主控卡作为切换后的源板卡执行如下操作:(1)如果切换后的源板卡中无切换前的源板卡下发的操作,则切换后的源板卡向目的板卡发送切换通知消息,并携带最新操作序列号;各个目的板卡接收到切换通知消息后,将所述最新操作序列号与本地最新操作序列号相比较,丢弃本地缓存中比切换通知消息中操作序列号新的操作;(2)如果切换后的源板卡接收有切换前的源板卡下发的操作但是还未执行,则切换后的源板卡需要重发操作,目的板卡判断本地缓存中是否有对应操作,如否,则目的板卡缓存该操作并向切换后的源板卡的分布式数据库返回确认消息,否则,不管是否执行,则向切换后的源板卡的分布式数据库直接返回确认消息;(3)如果切换后的源板卡已经执行切换前的源板卡下发的操作但未将执行结果返回给源板卡的分 Source (1) If the source switching board after the board is no source issued before the switching operation, the switching after: Preparation of handover, after the handover, the source standby main control board as the card after the handover to perform operations card to a destination card transmits a handover notification message, and carries the serial number of the latest operation; after receiving the respective object board handover notification message, the latest operating sequence number is compared with the latest operating local sequence number, a local cache than to discard switching operation of the new notification message in the operation sequence number; (2) If the source switching after the card has received the card issued by the source before the switching operation has not been performed, however, the source board to switch the operation needs to be retransmitted, determines whether there is a corresponding object of card operations in the local cache, if not, the object of the operation board cache and returns an acknowledgment message board after switching the source distributed database, otherwise, regardless of whether, after the handover, the source of the distributed database board directly returns an acknowledgment message; (3) If the source switching after the board has been performed before the board delivered by the source switching operation but returns the execution result to the source board minutes 式数据库,则切换后的源板卡向目的板卡发送执行消息,如果目的板卡判断本地缓存的对应操作还未执行,则目的板卡执行操作并发送执行结果消息;若目的板卡判断本地缓存的对应操作已经执行但未将执行结果返回给源板卡的分布式数据库,则目的板卡发送缓存中的执行结果;(4)如果切换后的源板卡判断目的板卡的执行结果出现错误,则切换后的源板卡发送错误消息,目的板卡向切换后的源板卡发送错误确认消息;(5)如果切换后的源板卡缓存的操作已经终结,则切换后的源板卡在切换之初,下发本地缓存中最小的操作序列号和最大的操作序列号对应的操作到目的板卡,目的板卡接收到操作后,丢弃序列号小于切换后的源板卡发送的最小序列号的操作和序列号大于切换后的源板卡发送的最大序列号的操作。 Database, the source board to switch the transmission object to perform message board, if the board is determined locally cached object corresponding to the operation has not been performed, the object of the board operation and sends an execution result executed message; if the object is determined local board cache operation has been performed but the corresponding execution result is returned to the source board distributed database, the card transmits an execution result object cache; (4) If the source switching decision after the board object execution result appears board error, the source board sends an error message after the handover, send an error to the source object board after the handover acknowledgment message board; (5) If the source switching board cache operation has ended, after the handover source plate at the beginning of the switching cards, issued after the local cache and the serial number of the smallest maximum operating operation sequence number corresponding to the destination of the operation board, the purpose of receiving the operation board, the board is discarded after the sequence number is smaller than the switching source transmitted operation lowest sequence number and the sequence number is greater than the operation board after switching the source of the highest sequence numbers transmitted.
  2. 2.如权利要求1所述分布式数据库数据同步方法,其特征在于,还包括如下步骤:e.源板卡的分布式数据库汇总所有目的板卡的执行结果,并将结果通告给各目的板卡;f.各目的板卡的分布式数据库在接收到源板卡的分布式数据库的通告消息后,清除其缓存中的操作或者发送错误确认消息。 2. The distributed database data synchronization method according to claim 1, characterized by further comprising the step of:. E summary source boards distributed database execution results for all purposes board, and each of the results to the object plate card;. F board of each object in the distributed database after receiving the advertisement message board sources distributed database, its cache clear operation or send an error message acknowledgment.
  3. 3.如权利要求2所述分布式数据库数据同步方法,其特征在于,步骤e中,源板卡的分布式数据库汇总所有目的板卡的执行结果后,如果判断所有目的板卡成功执行操作,则执行如下操作:el.源板卡的分布式数据库将汇总后的执行结果发送给本地对应的应用模块; e2.本地对应的应用模块将对执行结果的确认消息返回分布式数据库; e3.源板卡的分布式数据库收到本地对应的应用模块对执行结果的确认消息后,向各个目的板卡通告本次操作的执行结果。 3. The distributed database data synchronization method of claim 2, wherein, in step e, the source board after performing distributed database summary results for all purposes board, if the board is determined successfully performed operation for all purposes, . performs the following operations: el source board distributed database summary execution result to the local corresponding application modules; E2 corresponding to the local application module will return the results of execution confirmation message distributed database; source E3. after the board distributed database application module receives a local acknowledgment message corresponding to the result of the execution, the execution result to each object of Notice boards of this operation.
  4. 4.如权利要求2所述分布式数据库数据同步方法,其特征在于,步骤e中,源板卡的分布式数据库汇总所有目的板卡的执行结果后,如果判断有目的板卡执行操作出现错误,则向所有目的板卡通告错误消息。 4. The distributed database data synchronization method of claim 2, wherein, in step e, the source board summarized the results of all distributed object database board, if an error is determined to perform operations occur purpose card the Notifier error message to all purpose card.
  5. 5.如权利要求2所述分布式数据库数据同步方法,其特征在于,步骤f中,所有目的板卡的分布式数据库接收到源板卡的分布式数据库的通告消息后,如果判断有目的板卡的执行操作出现错误,则向源板卡的分布式数据库发送错误确认消息,否则清除其缓存中的操作。 5. The distributed database data synchronization method of claim 2, wherein step f all purposes board receives an advertisement message distributed database distributed database source board, if the board is determined purposeful perform the operation card error, an error confirmation message is sent to a distributed database source board, otherwise clear operation in its cache.
  6. 6.如权利要求5所述分布式数据库数据同步方法,其特征在于,源板卡的分布式数据库接收到所有目的板卡的错误确认消息后,再将汇总后的执行结果返回给源板卡的应用模块,所述应用模块首先对错误进行处理,然后终结本次下发的操作。 6. The distributed database data synchronization method as claimed in claim 5, wherein the source board distributed database object receives all error acknowledgment message board, and then the execution result is returned to the source board Summary application modules, the application module of the first error processing, and then the end of this operation issued.
CN 201110079997 2011-03-31 2011-03-31 Data synchronization method for distributed database CN102184183B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN 201110079997 CN102184183B (en) 2011-03-31 2011-03-31 Data synchronization method for distributed database

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN 201110079997 CN102184183B (en) 2011-03-31 2011-03-31 Data synchronization method for distributed database

Publications (2)

Publication Number Publication Date
CN102184183A true CN102184183A (en) 2011-09-14
CN102184183B true CN102184183B (en) 2013-04-17

Family

ID=44570360

Family Applications (1)

Application Number Title Priority Date Filing Date
CN 201110079997 CN102184183B (en) 2011-03-31 2011-03-31 Data synchronization method for distributed database

Country Status (1)

Country Link
CN (1) CN102184183B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102541983B (en) * 2011-10-25 2013-07-31 无锡城市云计算中心有限公司 Method for synchronously caching by multiple clients in distributed file system
CN103186624B (en) * 2011-12-31 2017-10-20 亿阳信通股份有限公司 A data synchronization method for synchronizing data and means

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6529921B1 (en) 1999-06-29 2003-03-04 Microsoft Corporation Dynamic synchronization of tables
CN1437348A (en) 2002-02-04 2003-08-20 深圳市中兴通讯股份有限公司 Real-time synchronizing method for data in both main and spare board in communication system
CN1725186A (en) 2004-07-23 2006-01-25 中兴通讯股份有限公司 Multiple data base data syne method
CN1731400A (en) 2005-08-16 2006-02-08 杭州华为三康技术有限公司 Method of data query and method of inter-board data synchronization in distributed system
CN101197657A (en) 2007-11-12 2008-06-11 中兴通讯股份有限公司 Data synchronization method of distributed system single panel

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6662196B2 (en) * 2001-03-16 2003-12-09 Iti, Inc. Collision avoidance in bidirectional database replication

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6529921B1 (en) 1999-06-29 2003-03-04 Microsoft Corporation Dynamic synchronization of tables
CN1437348A (en) 2002-02-04 2003-08-20 深圳市中兴通讯股份有限公司 Real-time synchronizing method for data in both main and spare board in communication system
CN1725186A (en) 2004-07-23 2006-01-25 中兴通讯股份有限公司 Multiple data base data syne method
CN1731400A (en) 2005-08-16 2006-02-08 杭州华为三康技术有限公司 Method of data query and method of inter-board data synchronization in distributed system
CN101197657A (en) 2007-11-12 2008-06-11 中兴通讯股份有限公司 Data synchronization method of distributed system single panel

Also Published As

Publication number Publication date Type
CN102184183A (en) 2011-09-14 application

Similar Documents

Publication Publication Date Title
US6067567A (en) Message distribution capability which uses distribution nodes to collect acknowledgements for a primary node
US7203687B2 (en) Peer-to-peer replication member initialization and deactivation
US7882286B1 (en) Synchronizing volumes for replication
US20030041074A1 (en) System and method for data replication in a computer system
US7804769B1 (en) Non-stop forwarding in a multi-chassis router
US20040078625A1 (en) System and method for fault tolerant data communication
US6061807A (en) Methods systems and computer products for error recovery of endpoint nodes
US20070171919A1 (en) Message batching with checkpoints systems and methods
US7330860B2 (en) Fault tolerant mechanism to handle initial load of replicated object in live system
US6625117B1 (en) Method and apparatus for switching messages from a primary message channel to a secondary message channel in a message queuing system
US6421741B1 (en) Switching between active-replication and active-standby for data synchronization in virtual synchrony
US20030051047A1 (en) Data synchronization interface
US20120137164A1 (en) Methods and systems for fault-tolerant distributed stream processing
US7539760B1 (en) System and method for facilitating failover of stateful connections
CN101562543A (en) Cache data processing method and processing system and device thereof
US20120011098A1 (en) Method and system for managing replication of data
US8149691B1 (en) Push-based hierarchical state propagation within a multi-chassis network device
US20120323849A1 (en) Method For Maximizing Throughput And Minimizing Transaction Response Times On The Primary System In The Presence Of A Zero Data Loss Standby Replica
US7974315B2 (en) Method for implementing synchronization of link state database, router, line card and master board
US7689702B1 (en) Methods and apparatus for coordinating processing of network connections between two network protocol stacks
CN101136900A (en) Fast transparent fault shift device and implementing method facing to service
CN102306115A (en) Asynchronous remote copying method, system and equipment
US20080196039A1 (en) Method, Apparatus and Software for Managing a Transactional Message Queue
US20120096179A1 (en) Method For Processing Initial SIP Requests By Backends Of A SIP Cluster In The Presence Of A Fault, And Associated Processing Device
CN101075861A (en) Method for realizing main spared board thermal backup and reversing main spared board

Legal Events

Date Code Title Description
C06 Publication
C10 Request of examination as to substance
C14 Granted