[go: up one dir, main page]

CN108200157A - The daily record synchronous method and device that host node triggering retracts - Google Patents

The daily record synchronous method and device that host node triggering retracts Download PDF

Info

Publication number
CN108200157A
CN108200157A CN201711478209.9A CN201711478209A CN108200157A CN 108200157 A CN108200157 A CN 108200157A CN 201711478209 A CN201711478209 A CN 201711478209A CN 108200157 A CN108200157 A CN 108200157A
Authority
CN
China
Prior art keywords
daily record
log
offset
log synchronization
node
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.)
Granted
Application number
CN201711478209.9A
Other languages
Chinese (zh)
Other versions
CN108200157B (en
Inventor
王康
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Qihoo Technology Co Ltd
Original Assignee
Beijing Qihoo 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 Beijing Qihoo Technology Co Ltd filed Critical Beijing Qihoo Technology Co Ltd
Priority to CN201711478209.9A priority Critical patent/CN108200157B/en
Publication of CN108200157A publication Critical patent/CN108200157A/en
Application granted granted Critical
Publication of CN108200157B publication Critical patent/CN108200157B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/06Protocols specially adapted for file transfer, e.g. file transfer protocol [FTP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1095Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer And Data Communications (AREA)
  • Hardware Redundancy (AREA)

Abstract

本发明公开了一种主节点触发回退的日志同步方法及装置。其中,所述方法包括:从节点根据从节点侧记录的第一日志同步偏移量,向主节点发送日志同步请求;主节点对接收到的日志同步请求中的第一日志同步偏移量进行验证;若验证失败,主节点根据第一日志同步偏移量确定所回退到的第二日志同步偏移量,将第二日志同步偏移量通知给从节点,以供从节点利用第二日志同步偏移量重新发送日志同步请求。上述方案可在主从节点日志同步过程中保证主从节点日志数据的一致性,并可在从节点向主节点发送的日志同步请求中的同步偏移量不正确时,无需强制清空从节点发起新的全量同步请求,从而降低系统负载及网络负载,提高主从节点日志同步效率。

The invention discloses a log synchronization method and device for a master node to trigger rollback. Wherein, the method includes: the slave node sends a log synchronization request to the master node according to the first log synchronization offset recorded by the slave node side; the master node performs the first log synchronization offset in the received log synchronization request Verify; if the verification fails, the master node determines the second log synchronization offset to be rolled back according to the first log synchronization offset, and notifies the second log synchronization offset to the slave node, so that the slave node can use the second Log sync offset to resend log sync requests. The above scheme can ensure the consistency of the master-slave node log data during the master-slave node log synchronization process, and when the synchronization offset in the log synchronization request sent from the slave node to the master node is incorrect, there is no need to force clear the slave node to initiate The new full synchronization request reduces system load and network load, and improves the efficiency of master-slave node log synchronization.

Description

主节点触发回退的日志同步方法及装置Log synchronization method and device for master node triggering rollback

技术领域technical field

本发明涉及计算机技术领域,具体涉及一种主节点触发回退的日志同步方法及装置。The present invention relates to the field of computer technology, in particular to a method and device for synchronizing logs triggered by a master node.

背景技术Background technique

主从结构的数据库系统以其具有高数据可靠性,低服务节点负荷,可实现读写分离,以及较高的数据的读写效率等特点已成为一种常用的数据库结构。The database system with master-slave structure has become a commonly used database structure because of its high data reliability, low service node load, separation of reading and writing, and high data reading and writing efficiency.

为实现主从节点的日志的同步,主节点会顺序发送位于主节点侧的日志文件,从节点根据主节点发送的日志文件来更新位于从节点侧的日志文件。然而,由于主从节点切换等原因,常常会导致从节点向主节点发送的日志同步请求中的同步偏移量不正确的情况,如日志同步请求中的同步偏移量不合法等。In order to realize the synchronization of the logs of the master and slave nodes, the master node will sequentially send the log files on the master node side, and the slave nodes will update the log files on the slave node side according to the log files sent by the master node. However, due to reasons such as master-slave node switching, the synchronization offset in the log synchronization request sent from the slave node to the master node is often incorrect, for example, the synchronization offset in the log synchronization request is illegal.

在现有技术中,当从节点向主节点发送的日志同步请求中的同步偏移量不正确时,往往采用强制清空从节点,使从节点重新向主节点发送全量日志同步请求的方法,来保证主从节点日志的同步。然而,采用该种方法会增加系统及网络负载,大幅延长主从节点日志同步时间。In the existing technology, when the synchronization offset in the log synchronization request sent from the slave node to the master node is incorrect, the method of forcibly clearing the slave node is often used to make the slave node re-send the full log synchronization request to the master node. Ensure the synchronization of master and slave node logs. However, using this method will increase the system and network load, and greatly prolong the log synchronization time of the master and slave nodes.

发明内容Contents of the invention

鉴于上述问题,提出了本发明以便提供一种克服上述问题或者至少部分地解决上述问题的主节点触发回退的日志同步方法In view of the above problems, the present invention is proposed in order to provide a log synchronization method that overcomes the above problems or at least partially solves the above problems.

根据本发明的一个方面,提供了一种主节点触发回退的日志同步方法,包括:According to one aspect of the present invention, there is provided a log synchronization method in which a master node triggers rollback, including:

从节点根据从节点侧记录的第一日志同步偏移量,向主节点发送日志同步请求;The slave node sends a log synchronization request to the master node according to the first log synchronization offset recorded on the slave node side;

主节点对接收到的日志同步请求中的第一日志同步偏移量进行验证;The master node verifies the first log synchronization offset in the received log synchronization request;

若验证失败,主节点根据第一日志同步偏移量确定所回退到的第二日志同步偏移量,将所述第二日志同步偏移量通知给从节点,以供所述从节点利用所述第二日志同步偏移量重新发送日志同步请求。If the verification fails, the master node determines the second log synchronization offset to fall back to according to the first log synchronization offset, and notifies the second log synchronization offset to the slave node for use by the slave node The second log synchronization offset resends the log synchronization request.

根据本发明的另一方面,提供了一种主节点触发回退的日志同步装置,包括:According to another aspect of the present invention, a log synchronization device for triggering rollback by the master node is provided, including:

同步请求发送模块,适于从节点根据从节点侧记录的第一日志同步偏移量,向主节点发送日志同步请求;The synchronization request sending module is suitable for the slave node to send a log synchronization request to the master node according to the first log synchronization offset recorded by the slave node side;

验证模块,适于主节点对接收到的日志同步请求中的第一日志同步偏移量进行验证;A verification module, adapted for the master node to verify the first log synchronization offset in the received log synchronization request;

通知模块,适于若验证模块验证失败,主节点根据第一日志同步偏移量确定所回退到的第二日志同步偏移量,将所述第二日志同步偏移量通知给从节点,以供所述从节点利用所述第二日志同步偏移量重新发送日志同步请求。The notification module is adapted to determine the second log synchronization offset that the master node falls back to according to the first log synchronization offset, and notify the second log synchronization offset to the slave node if the verification module fails the verification, For the slave node to resend the log synchronization request by using the second log synchronization offset.

根据本发明的又一方面,提供了一种计算设备,包括:处理器、存储器、通信接口和通信总线,所述处理器、所述存储器和所述通信接口通过所述通信总线完成相互间的通信;According to yet another aspect of the present invention, a computing device is provided, including: a processor, a memory, a communication interface, and a communication bus, and the processor, the memory, and the communication interface complete mutual communication through the communication bus communication;

所述存储器用于存放至少一可执行指令,所述可执行指令使所述处理器执行上述主节点触发回退的日志同步方法对应的操作。The memory is used to store at least one executable instruction, and the executable instruction causes the processor to execute the operation corresponding to the log synchronization method in which the master node triggers rollback.

根据本发明的再一方面,提供了一种计算机存储介质,所述存储介质中存储有至少一可执行指令,所述可执行指令使处理器执行如上述主节点触发回退的日志同步方法对应的操作。According to yet another aspect of the present invention, a computer storage medium is provided, wherein at least one executable instruction is stored in the storage medium, and the executable instruction causes the processor to perform the above log synchronization method corresponding to the master node triggering rollback. operation.

根据本发明提供的主节点触发回退的日志同步方法及装置。首先从节点根据从节点侧记录的第一日志同步偏移量,向主节点发送日志同步请求;主节点对接收到的日志同步请求中的第一日志同步偏移量进行验证;若验证失败,主节点根据第一日志同步偏移量确定所回退到的第二日志同步偏移量,将第二日志同步偏移量通知给从节点,以供从节点利用第二日志同步偏移量重新发送日志同步请求。采用本方案,可在主从节点日志同步过程中保证主从节点日志数据的一致性,并可在从节点向主节点发送的日志同步请求中的同步偏移量不正确时,无需强制清空从节点发起新的全量同步请求,从而降低系统负载及网络负载,提高主从节点日志同步效率。According to the log synchronization method and device for master node triggering rollback provided by the present invention. First, the slave node sends a log synchronization request to the master node according to the first log synchronization offset recorded on the slave node side; the master node verifies the first log synchronization offset in the received log synchronization request; if the verification fails, The master node determines the second log synchronization offset to fall back to according to the first log synchronization offset, and notifies the second log synchronization offset to the slave node, so that the slave node can use the second log synchronization offset to restart Send a log sync request. With this solution, the consistency of the log data of the master-slave node can be guaranteed during the log synchronization process of the master-slave node, and when the synchronization offset in the log synchronization request sent from the slave node to the master node is incorrect, there is no need to forcibly clear the slave The node initiates a new full synchronization request, thereby reducing the system load and network load, and improving the log synchronization efficiency of the master and slave nodes.

上述说明仅是本发明技术方案的概述,为了能够更清楚了解本发明的技术手段,而可依照说明书的内容予以实施,并且为了让本发明的上述和其它目的、特征和优点能够更明显易懂,以下特举本发明的具体实施方式。The above description is only an overview of the technical solution of the present invention. In order to better understand the technical means of the present invention, it can be implemented according to the contents of the description, and in order to make the above and other purposes, features and advantages of the present invention more obvious and understandable , the specific embodiments of the present invention are enumerated below.

附图说明Description of drawings

通过阅读下文优选实施方式的详细描述,各种其他的优点和益处对于本领域普通技术人员将变得清楚明了。附图仅用于示出优选实施方式的目的,而并不认为是对本发明的限制。而且在整个附图中,用相同的参考符号表示相同的部件。在附图中:Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiment. The drawings are only for the purpose of illustrating a preferred embodiment and are not to be considered as limiting the invention. Also throughout the drawings, the same reference numerals are used to designate the same components. In the attached picture:

图1示出了根据本发明一个实施例提供的主节点触发回退的日志同步方法的流程示意图;FIG. 1 shows a schematic flowchart of a log synchronization method in which a master node triggers rollback according to an embodiment of the present invention;

图2示出了根据本发明另一个实施例提供的主节点触发回退的日志同步方法的流程示意图;FIG. 2 shows a schematic flowchart of a log synchronization method in which a master node triggers rollback according to another embodiment of the present invention;

图3示出了根据本发明一个实施例提供的主节点触发回退的日志同步装置的流程示意图;FIG. 3 shows a schematic flow diagram of a log synchronization device in which a master node triggers rollback according to an embodiment of the present invention;

图4示出了根据本发明一个实施例提供的计算设备的结构示意图。Fig. 4 shows a schematic structural diagram of a computing device provided according to an embodiment of the present invention.

具体实施方式Detailed ways

下面将参照附图更详细地描述本公开的示例性实施例。虽然附图中显示了本公开的示例性实施例,然而应当理解,可以以各种形式实现本公开而不应被这里阐述的实施例所限制。相反,提供这些实施例是为了能够更透彻地理解本公开,并且能够将本公开的范围完整的传达给本领域的技术人员。Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided for more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.

图1示出了根据本发明一个实施例提供的主节点触发回退的日志同步方法的流程示意图。如图1所示,该方法包括:Fig. 1 shows a schematic flow diagram of a log synchronization method in which a master node triggers rollback according to an embodiment of the present invention. As shown in Figure 1, the method includes:

步骤S110,从节点根据从节点侧记录的第一日志同步偏移量,向主节点发送日志同步请求。Step S110, the slave node sends a log synchronization request to the master node according to the first log synchronization offset recorded on the slave node side.

其中,从节点侧记录有从节点日志文件以及第一日志同步偏移量。第一日志同步偏移量用于在主从节点日志同步过程中标识从节点日志文件的同步位置,根据第一日志同步偏移量可获知该从节点日志同步进度。其中,本发明对第一日志的类型不做限定,例如,第一日志可以为binlog日志(二进制日志),或者redo log日志(重做日志)等。Wherein, the slave node side records the slave node log file and the first log synchronization offset. The first log synchronization offset is used to identify the synchronization position of the log file of the slave node during the log synchronization process of the master and slave nodes, and the log synchronization progress of the slave node can be known according to the first log synchronization offset. Wherein, the present invention does not limit the type of the first log, for example, the first log may be a binlog log (binary log), or a redo log log (redo log).

本步骤中,从节点根据从节点侧记录的第一日志同步偏移量,向主节点发送日志同步请求。在具体实施过程中,从节点向主节点发送trysync请求,其中,trysync请求中包含有第一日志同步偏移量。In this step, the slave node sends a log synchronization request to the master node according to the first log synchronization offset recorded on the slave node side. In a specific implementation process, the slave node sends a trysync request to the master node, wherein the trysync request includes the first log synchronization offset.

步骤S120,主节点对接收到的日志同步请求中的第一日志同步偏移量进行验证。Step S120, the master node verifies the first log synchronization offset in the received log synchronization request.

当主节点接收到从节点发送的日志同步请求后,进一步地对接收到的日志同步请求中的第一日志同步偏移量进行验证。其中,具体地验证方法本领域技术人员可自行设置,本实施例在此不做限定。例如,可对日志同步请求中的第一日志同步偏移量的合法性进行验证,若第一日志同步偏移量合法,则验证成功,否则,则验证失败。After the master node receives the log synchronization request sent by the slave node, it further verifies the first log synchronization offset in the received log synchronization request. Wherein, the specific verification method can be set by those skilled in the art, and is not limited in this embodiment. For example, the validity of the first log synchronization offset in the log synchronization request may be verified. If the first log synchronization offset is legal, the verification succeeds; otherwise, the verification fails.

步骤S130,若验证失败,主节点根据第一日志同步偏移量确定所回退到的第二日志同步偏移量,将第二日志同步偏移量通知给从节点,以供从节点利用第二日志同步偏移量重新发送日志同步请求。Step S130, if the verification fails, the master node determines the second log synchronization offset to fall back to according to the first log synchronization offset, and notifies the second log synchronization offset to the slave node, so that the slave node can use the second log synchronization offset. 2 Log sync offset to resend the log sync request.

具体地,若步骤S120中主节点对接收到的日志同步请求中的第一日志同步偏移量验证失败,则主节点根据验证失败的具体情况,根据第一日志同步偏移量确定所回退到的第二日志同步偏移量。例如,若步骤S120中验证第一日志同步偏移量不合法,则本步骤中主节点根据第一日志同步偏移量确定在主节点侧的日志文件中确定出在第一日志同步偏移量之前最近的合法的偏移量确定为所回退到的第二日志同步偏移量。Specifically, if the master node fails to verify the first log synchronization offset in the received log synchronization request in step S120, the master node determines the fallback value according to the first log synchronization offset according to the specific circumstances of the verification failure. The second log synchronization offset to go to. For example, if it is verified in step S120 that the first log synchronization offset is illegal, then in this step, the master node determines that the first log synchronization offset is determined in the log file on the master node side according to the first log synchronization offset The latest legal offset before is determined as the second log synchronization offset to which to fall back.

进一步地,在确定第二日志同步偏移量后,将第二日志同步偏移量通知给从节点,以供从节点利用第二日志同步偏移量重新发送日志同步请求。Further, after the second log synchronization offset is determined, the second log synchronization offset is notified to the slave node, so that the slave node uses the second log synchronization offset to resend the log synchronization request.

根据本实施例提供的主节点触发回退的日志同步方法,首先从节点根据从节点侧记录的第一日志同步偏移量,向主节点发送日志同步请求;主节点对接收到的日志同步请求中的第一日志同步偏移量进行验证;若验证失败,主节点根据第一日志同步偏移量确定所回退到的第二日志同步偏移量,将第二日志同步偏移量通知给从节点,以供从节点利用第二日志同步偏移量重新发送日志同步请求。采用本方案,可在主从节点日志同步过程中保证主从节点日志数据的一致性,并可在从节点向主节点发送的日志同步请求中的同步偏移量不正确时,无需强制清空从节点发起新的全量同步请求,从而降低系统负载及网络负载,提高主从节点日志同步效率。According to the log synchronization method in which the master node triggers rollback provided in this embodiment, first, the slave node sends a log synchronization request to the master node according to the first log synchronization offset recorded on the slave node side; the master node sends a log synchronization request to the received log synchronization request Verify the first log synchronization offset in ; if the verification fails, the master node determines the second log synchronization offset according to the first log synchronization offset, and notifies the second log synchronization offset to The slave node is used for the slave node to resend the log synchronization request by using the second log synchronization offset. With this solution, the consistency of the log data of the master-slave node can be guaranteed during the log synchronization process of the master-slave node, and when the synchronization offset in the log synchronization request sent from the slave node to the master node is incorrect, there is no need to forcibly clear the slave The node initiates a new full synchronization request, thereby reducing the system load and network load, and improving the log synchronization efficiency of the master and slave nodes.

图2示出了根据本发明另一个实施例提供的主节点触发回退的日志同步方法的流程示意图。如图2所示,该方法包括:Fig. 2 shows a schematic flowchart of a method for synchronizing logs in which a master node triggers rollback according to another embodiment of the present invention. As shown in Figure 2, the method includes:

步骤S210,从节点根据从节点侧记录的第一日志同步偏移量,向主节点发送日志同步请求。Step S210, the slave node sends a log synchronization request to the master node according to the first log synchronization offset recorded on the slave node side.

其中,从节点侧记录有从节点日志文件以及第一日志同步偏移量。第一日志同步偏移量用于在主从节点日志同步过程中标识从节点日志文件的同步位置,根据第一日志同步偏移量可获知该从节点日志同步进度。其中,本发明对第一日志的类型不做限定,例如,第一日志可以为binlog日志(二进制日志),或者redo log日志(重做日志)等。Wherein, the slave node side records the slave node log file and the first log synchronization offset. The first log synchronization offset is used to identify the synchronization position of the log file of the slave node during the log synchronization process of the master and slave nodes, and the log synchronization progress of the slave node can be known according to the first log synchronization offset. Wherein, the present invention does not limit the type of the first log, for example, the first log may be a binlog log (binary log), or a redo log log (redo log).

本步骤中,从节点根据从节点侧记录的第一日志同步偏移量,向主节点发送日志同步请求。在具体实施过程中,从节点向主节点发送trysync请求,其中,trysync请求中包含有第一日志同步偏移量。In this step, the slave node sends a log synchronization request to the master node according to the first log synchronization offset recorded on the slave node side. In a specific implementation process, the slave node sends a trysync request to the master node, wherein the trysync request includes the first log synchronization offset.

步骤S220,主节点将第一日志同步偏移量与主节点侧记录的第三日志同步偏移量进行比较;和/或,主节点判断第一日志同步偏移量是否合法,以实现主节点对接收到的日志同步请求中的第一日志同步偏移量的验证。Step S220, the master node compares the first log synchronization offset with the third log synchronization offset recorded on the master node side; and/or, the master node judges whether the first log synchronization offset is legal, so as to realize the master node Verification of the first log sync offset in the received log sync request.

其中,主节点侧记录有与主节点中数据的操作或变化相关的主节点日志文件,主节点日志文件中记录有第三日志同步偏移量,其中,第三日志同步偏移量标识主节点日志文件同步的位置。Among them, the master node side records the master node log file related to the operation or change of the data in the master node, and the third log synchronization offset is recorded in the master node log file, wherein the third log synchronization offset identifies the master node The location where the log files are synchronized.

当主节点接收到从节点发送的日志同步请求后,进一步地对接收到的日志同步请求中的第一日志同步偏移量进行验证。具体地,主节点将第一日志同步偏移量与主节点侧记录的第三日志同步偏移量进行比较;和/或,主节点判断第一日志同步偏移量是否合法。After the master node receives the log synchronization request sent by the slave node, it further verifies the first log synchronization offset in the received log synchronization request. Specifically, the master node compares the first log synchronization offset with the third log synchronization offset recorded on the master node side; and/or, the master node judges whether the first log synchronization offset is legal.

若主节点将第一日志同步偏移量与主节点侧记录的第三日志同步偏移量进行比较;以及,主节点判断第一日志同步偏移量是否合法。则当第一日志同步偏移量小于或等于主节点侧记录的第三日志同步偏移量,且第一日志同步偏移量合法时,则确定验证成功;若第一日志同步偏移量与主节点侧记录的第三日志同步偏移量大于主节点侧记录的第三日志同步偏移量,和/或,第一日志同步偏移量不合法时,则确定验证失败。If the master node compares the first log synchronization offset with the third log synchronization offset recorded on the master node side; and, the master node judges whether the first log synchronization offset is legal. Then when the first log synchronization offset is less than or equal to the third log synchronization offset recorded on the master node side, and the first log synchronization offset is legal, then it is determined that the verification is successful; if the first log synchronization offset is equal to If the third log synchronization offset recorded on the master node side is greater than the third log synchronization offset recorded on the master node side, and/or if the first log synchronization offset is illegal, then it is determined that the verification fails.

步骤S230,若验证失败,主节点根据第一日志同步偏移量确定所回退到的第二日志同步偏移量,将第二日志同步偏移量通知给从节点,以供从节点利用第二日志同步偏移量重新发送日志同步请求。Step S230, if the verification fails, the master node determines the second log synchronization offset to fall back to according to the first log synchronization offset, and notifies the second log synchronization offset to the slave node, so that the slave node can use the second log synchronization offset. 2 Log sync offset to resend the log sync request.

具体地,当步骤S220对主节点对接收到的日志同步请求中的第一日志同步偏移量的验证失败时,可根据验证失败的具体情况,根据第一日志同步偏移量确定所回退到的第二日志同步偏移量。其中,确定所回退到的第二日志同步偏移量的实施方法包括但不限于以下实施方法中的一种或多种的组合。Specifically, when the master node fails to verify the first log synchronization offset in the received log synchronization request in step S220, it can be determined according to the first log synchronization offset according to the specific circumstances of the verification failure. The second log synchronization offset to go to. Wherein, the implementation method for determining the second log synchronization offset to roll back to includes but is not limited to a combination of one or more of the following implementation methods.

实施方式一:当第一日志同步偏移量大于第三日志同步偏移量时,主节点将第三日志同步偏移量作为第二日志同步偏移量。具体地,由于频繁的主从节点切换,会导致从节点向主节点发送的日志同步请求中包含的第一日志同步偏移量大于主节点侧的第三日志同步偏移量,为保证主从节点日志文件同步的一致性,当第一日志同步偏移量大于第三日志同步偏移量时,可将主节点侧的第三日志同步偏移量作为第二日志同步偏移量。可选的,若第三日志同步偏移量不合法,则在主节点日志文件中在第三日志偏移量之前,并距离第三日志偏移量最近的合法偏移量确定为第二日志同步偏移量。Embodiment 1: When the first log synchronization offset is greater than the third log synchronization offset, the master node uses the third log synchronization offset as the second log synchronization offset. Specifically, due to frequent master-slave node switching, the first log synchronization offset included in the log synchronization request sent from the slave node to the master node is greater than the third log synchronization offset on the master node side. For the consistency of node log file synchronization, when the first log synchronization offset is greater than the third log synchronization offset, the third log synchronization offset on the master node side can be used as the second log synchronization offset. Optionally, if the synchronization offset of the third log is illegal, the legal offset before the offset of the third log in the log file of the master node and closest to the offset of the third log is determined as the second log Synchronization offset.

实施方式二:当主节点判断第一日志同步偏移量不合法,则主节点查询与第一日志同步偏移量距离最小的合法的日志同步偏移量作为第二日志同步偏移量。例如,日志文件中记录有各条数据长度以及数据内容,每条数据起始位置中记录有该条数据的数据长度,并紧邻数据长度之后记录有该条数据的数据内容,若第一日志同步偏移量对应于主节点日志文件中某条数据的数据内容的中间位置时,则确定该第一日志同步偏移量不合法,则主节点可在主节点日志文件中查询在第一日志同步偏移量之前,且距离第一日志同步偏移量最近的一条数据的起始位置作为第二日志同步偏移量,如第一日志同步偏移量对应于主节点日志文件中第20条日志数据的中间位置,当该第20条数据的数据长度读取正常时,可将该第20条日志数据的起始位置作为第二日志同步偏移量;或者,日志文件中记录有各个数据块的长度,每个数据块中记录有至少一条数据,则当主节点判断第一日志同步偏移量不合法,可将在主节点日志文件中在第一日志偏移量之前,且距离第一日志偏移量最近的数据块的起始位置作为第二日志同步偏移量。Embodiment 2: When the master node judges that the first log synchronization offset is illegal, the master node queries the legal log synchronization offset with the smallest distance from the first log synchronization offset as the second log synchronization offset. For example, the length and content of each piece of data are recorded in the log file. The data length of the piece of data is recorded in the starting position of each piece of data, and the data content of the piece of data is recorded immediately after the data length. If the first log is synchronized When the offset corresponds to the middle position of the data content of a piece of data in the master node log file, it is determined that the first log synchronization offset is illegal, and the master node can query the first log synchronization offset in the master node log file. The starting position of a piece of data that is before the offset and closest to the first log synchronization offset is used as the second log synchronization offset. For example, the first log synchronization offset corresponds to the 20th log in the master node log file The middle position of the data, when the data length of the 20th piece of data is read normally, the starting position of the 20th piece of log data can be used as the second log synchronization offset; or, each data block is recorded in the log file length, at least one piece of data is recorded in each data block, then when the master node judges that the first log synchronization offset is illegal, it can be in the log file of the master node before the first log The starting position of the data block with the latest offset is used as the second log synchronization offset.

实施方式三:当第一日志同步偏移量大于第三日志同步偏移量,和/或,主节点判断第一日志同步偏移量不合法,则主节点查询成为主节点之前最近的合法的日志同步偏移量作为第二日志同步偏移量。为保证主从节点的日志文件的一致性,且进一步提高主从节点中数据的一致性,本实施方式三中可查询当前主节点本次刚成为主节点之前最近的合法的日志同步偏移量作为第二日志同步偏移量。Implementation Mode 3: When the first log synchronization offset is greater than the third log synchronization offset, and/or the master node judges that the first log synchronization offset is illegal, the master node queries the latest legal log before becoming the master node The log synchronization offset is used as the second log synchronization offset. In order to ensure the consistency of the log files of the master-slave node and further improve the consistency of the data in the master-slave node, in the third embodiment, the latest legal log synchronization offset of the current master node just before becoming the master node can be queried Used as the second log sync offset.

进一步地,在确定第二日志同步偏移量后,将第二日志同步偏移量通知给从节点。从节点根据主节点通知的第二日志同步偏移量重置从节点侧日志文件的偏移量,并重新向主节点发送日志同步请求,其中,重新向主节点发送日志同步请求中包含有第二日志同步偏移量。主节点在接收到从节点重新发起的日志同步请求后,根据该重新发起的日志同步请求中的第二日志同步偏移量,向该从节点发送日志同步命令,从而实现主从节点的日志同步。Further, after the second log synchronization offset is determined, the second log synchronization offset is notified to the slave node. The slave node resets the offset of the log file on the slave node side according to the second log synchronization offset notified by the master node, and resends a log synchronization request to the master node, wherein the resent log synchronization request to the master node contains the first Second log synchronization offset. After receiving the log synchronization request re-initiated by the slave node, the master node sends a log synchronization command to the slave node according to the second log synchronization offset in the re-initiated log synchronization request, thereby realizing the log synchronization of the master-slave node .

根据本实施例提供的主节点触发回退的日志同步方法,首先从节点根据从节点侧记录的第一日志同步偏移量,向主节点发送日志同步请求;主节点将所述第一日志同步偏移量与主节点侧记录的第三日志同步偏移量进行比较;和/或,主节点判断所述第一日志同步偏移量是否合法;若第一日志同步偏移量大于第三日志同步偏移量,则主节点将第三日志同步偏移量作为第二日志同步偏移量;若主节点判断第一日志同步偏移量不合法,则主节点查询与第一日志同步偏移量距离最小的合法的日志同步偏移量作为第二日志同步偏移量;或者,若第一日志同步偏移量大于第三日志同步偏移量,和/或,主节点判断第一日志同步偏移量不合法,则主节点查询成为主节点之前最近的合法的日志同步偏移量作为第二日志同步偏移量;并进一步将第二日志同步偏移量通知给从节点,以供从节点利用所述第二日志同步偏移量重新发送日志同步请求。采用本方案,可在主从节点日志同步过程中保证主从节点日志数据的一致性,并可在从节点向主节点发送的日志同步请求中的同步偏移量不正确时,无需强制清空从节点发起新的全量同步请求,从而降低系统负载及网络负载,提高主从节点日志同步效率。According to the log synchronization method in which the master node triggers rollback provided in this embodiment, first, the slave node sends a log synchronization request to the master node according to the first log synchronization offset recorded on the slave node side; the master node synchronizes the first log The offset is compared with the third log synchronization offset recorded on the master node side; and/or, the master node judges whether the first log synchronization offset is legal; if the first log synchronization offset is greater than the third log synchronization offset, the master node uses the third log synchronization offset as the second log synchronization offset; if the master node judges that the first log synchronization offset is illegal, the master node queries the first log synchronization offset The legal log synchronization offset with the smallest distance is used as the second log synchronization offset; or, if the first log synchronization offset is greater than the third log synchronization offset, and/or, the master node judges that the first log synchronization If the offset is illegal, the master node queries the latest legal log synchronization offset before becoming the master node as the second log synchronization offset; and further notifies the second log synchronization offset to the slave node for The node resends the log synchronization request by using the second log synchronization offset. With this solution, the consistency of the log data of the master-slave node can be guaranteed during the log synchronization process of the master-slave node, and when the synchronization offset in the log synchronization request sent from the slave node to the master node is incorrect, there is no need to forcibly clear the slave The node initiates a new full synchronization request, thereby reducing the system load and network load, and improving the log synchronization efficiency of the master and slave nodes.

图3示出了根据本发明一个实施例提供的主节点触发回退的日志同步装置的结构框图。如图3所示,该装置包括:同步请求发送模块31、验证模块32、以及通知模块33。FIG. 3 shows a structural block diagram of a log synchronization device in which a master node triggers rollback according to an embodiment of the present invention. As shown in FIG. 3 , the device includes: a synchronization request sending module 31 , a verification module 32 , and a notification module 33 .

同步请求发送模块31,适于从节点根据从节点侧记录的第一日志同步偏移量,向主节点发送日志同步请求。The synchronization request sending module 31 is adapted for the slave node to send a log synchronization request to the master node according to the first log synchronization offset recorded by the slave node side.

验证模块32,适于主节点对接收到的日志同步请求中的第一日志同步偏移量进行验证。The verification module 32 is adapted for the master node to verify the first log synchronization offset in the received log synchronization request.

通知模块33,适于若验证模块验证失败,主节点根据第一日志同步偏移量确定所回退到的第二日志同步偏移量,将第二日志同步偏移量通知给从节点,以供从节点利用所述第二日志同步偏移量重新发送日志同步请求。The notification module 33 is adapted to determine the second log synchronization offset that the master node falls back to according to the first log synchronization offset, and notify the second log synchronization offset to the slave node if the verification module fails to verify, so as to For the slave node to resend the log synchronization request by using the second log synchronization offset.

可选的,验证模块32进一步适于:主节点将所述第一日志同步偏移量与主节点侧记录的第三日志同步偏移量进行比较;和/或,主节点判断所述第一日志同步偏移量是否合法。Optionally, the verification module 32 is further adapted to: the master node compares the first log synchronization offset with the third log synchronization offset recorded on the master node side; and/or, the master node judges that the first Whether the log synchronization offset is legal.

可选的,通知模块33进一步适于:若第一日志同步偏移量大于第三日志同步偏移量,则主节点将第三日志同步偏移量作为第二日志同步偏移量。Optionally, the notification module 33 is further adapted to: if the first log synchronization offset is greater than the third log synchronization offset, the master node uses the third log synchronization offset as the second log synchronization offset.

可选的,通知模块33进一步适于:若主节点判断所述第一日志同步偏移量不合法,则主节点查询与第一日志同步偏移量距离最小的合法的日志同步偏移量作为第二日志同步偏移量。Optionally, the notification module 33 is further adapted to: if the master node judges that the first log synchronization offset is illegal, then the master node queries the legal log synchronization offset with the smallest distance from the first log synchronization offset as Second log synchronization offset.

可选的,通知模块33进一步适于:若第一日志同步偏移量大于第三日志同步偏移量,和/或,主节点判断第一日志同步偏移量不合法,则主节点查询成为主节点之前最近的合法的日志同步偏移量作为所述第二日志同步偏移量。Optionally, the notification module 33 is further adapted to: if the first log synchronization offset is greater than the third log synchronization offset, and/or the master node judges that the first log synchronization offset is illegal, then the master node query becomes The most recent legal log synchronization offset before the master node is used as the second log synchronization offset.

根据本实施例提供的主节点触发回退的日志同步装置,首先从节点根据从节点侧记录的第一日志同步偏移量,向主节点发送日志同步请求;主节点对接收到的日志同步请求中的第一日志同步偏移量进行验证;若验证失败,主节点根据第一日志同步偏移量确定所回退到的第二日志同步偏移量,将第二日志同步偏移量通知给从节点,以供从节点利用第二日志同步偏移量重新发送日志同步请求。采用本方案,可在主从节点日志同步过程中保证主从节点日志数据的一致性,并可在从节点向主节点发送的日志同步请求中的同步偏移量不正确时,无需强制清空从节点发起新的全量同步请求,从而降低系统负载及网络负载,提高主从节点日志同步效率。According to the log synchronization device in which the master node triggers rollback provided in this embodiment, first, the slave node sends a log synchronization request to the master node according to the first log synchronization offset recorded on the slave node side; the master node sends a log synchronization request to the received log synchronization request Verify the first log synchronization offset in ; if the verification fails, the master node determines the second log synchronization offset according to the first log synchronization offset, and notifies the second log synchronization offset to The slave node is used for the slave node to resend the log synchronization request by using the second log synchronization offset. With this solution, the consistency of the log data of the master-slave node can be guaranteed during the log synchronization process of the master-slave node, and when the synchronization offset in the log synchronization request sent from the slave node to the master node is incorrect, there is no need to forcibly clear the slave The node initiates a new full synchronization request, thereby reducing the system load and network load, and improving the log synchronization efficiency of the master and slave nodes.

根据本发明一个实施例提供了一种非易失性计算机存储介质,所述计算机存储介质存储有至少一可执行指令,该计算机可执行指令可执行上述任意方法实施例中的主节点触发回退的日志同步方法。According to one embodiment of the present invention, a non-volatile computer storage medium is provided, the computer storage medium stores at least one executable instruction, and the computer executable instruction can execute the master node triggering rollback in any of the above method embodiments The log synchronization method.

图4示出了根据本发明一个实施例提供的一种计算设备的结构示意图,本发明具体实施例并不对计算设备的具体实现做限定。FIG. 4 shows a schematic structural diagram of a computing device according to an embodiment of the present invention, and the specific embodiment of the present invention does not limit the specific implementation of the computing device.

如图4所示,该计算设备可以包括:处理器(processor)402、通信接口(Communications Interface)404、存储器(memory)406、以及通信总线408。As shown in FIG. 4 , the computing device may include: a processor (processor) 402 , a communication interface (Communications Interface) 404 , a memory (memory) 406 , and a communication bus 408 .

其中:in:

处理器402、通信接口404、以及存储器406通过通信总线408完成相互间的通信。The processor 402 , the communication interface 404 , and the memory 406 communicate with each other through the communication bus 408 .

通信接口404,用于与其它设备比如客户端或其它服务器等的网元通信。The communication interface 404 is used to communicate with network elements of other devices such as clients or other servers.

处理器402,用于执行程序410,具体可以执行上述主节点触发回退的日志同步方法实施例中的相关步骤。The processor 402 is configured to execute the program 410, specifically, may execute the relevant steps in the above embodiment of the log synchronization method in which the master node triggers rollback.

具体地,程序410可以包括程序代码,该程序代码包括计算机操作指令。Specifically, the program 410 may include program codes including computer operation instructions.

处理器402可能是中央处理器CPU,或者是特定集成电路ASIC(ApplicationSpecific Integrated Circuit),或者是被配置成实施本发明实施例的一个或多个集成电路。计算设备包括的一个或多个处理器,可以是同一类型的处理器,如一个或多个CPU;也可以是不同类型的处理器,如一个或多个CPU以及一个或多个ASIC。The processor 402 may be a central processing unit CPU, or an Application Specific Integrated Circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present invention. The one or more processors included in the computing device may be of the same type, such as one or more CPUs, or may be different types of processors, such as one or more CPUs and one or more ASICs.

存储器406,用于存放程序410。存储器406可能包含高速RAM存储器,也可能还包括非易失性存储器(non-volatile memory),例如至少一个磁盘存储器。The memory 406 is used to store the program 410 . The memory 406 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.

程序410具体可以用于使得处理器402执行以下操作:The program 410 can specifically be used to make the processor 402 perform the following operations:

从节点根据从节点侧记录的第一日志同步偏移量,向主节点发送日志同步请求;The slave node sends a log synchronization request to the master node according to the first log synchronization offset recorded on the slave node side;

主节点对接收到的日志同步请求中的第一日志同步偏移量进行验证;The master node verifies the first log synchronization offset in the received log synchronization request;

若验证失败,主节点根据第一日志同步偏移量确定所回退到的第二日志同步偏移量,将所述第二日志同步偏移量通知给从节点,以供所述从节点利用所述第二日志同步偏移量重新发送日志同步请求。If the verification fails, the master node determines the second log synchronization offset to fall back to according to the first log synchronization offset, and notifies the second log synchronization offset to the slave node for use by the slave node The second log synchronization offset resends the log synchronization request.

在一种可选的实施方式中,程序410具体可以用于使得处理器402执行以下操作:In an optional implementation manner, the program 410 may be specifically configured to enable the processor 402 to perform the following operations:

主节点将所述第一日志同步偏移量与主节点侧记录的第三日志同步偏移量进行比较;The master node compares the first log synchronization offset with the third log synchronization offset recorded on the master node side;

和/或,主节点判断所述第一日志同步偏移量是否合法。And/or, the master node judges whether the first log synchronization offset is legal.

在一种可选的实施方式中,程序410具体可以用于使得处理器402执行以下操作:In an optional implementation manner, the program 410 may be specifically configured to enable the processor 402 to perform the following operations:

若所述第一日志同步偏移量大于所述第三日志同步偏移量,则主节点将所述第三日志同步偏移量作为所述第二日志同步偏移量。If the first log synchronization offset is greater than the third log synchronization offset, the master node uses the third log synchronization offset as the second log synchronization offset.

在一种可选的实施方式中,程序410具体可以用于使得处理器402执行以下操作:In an optional implementation manner, the program 410 may be specifically configured to enable the processor 402 to perform the following operations:

若主节点判断所述第一日志同步偏移量不合法,则主节点查询与所述第一日志同步偏移量距离最小的合法的日志同步偏移量作为所述第二日志同步偏移量。If the master node judges that the first log synchronization offset is illegal, the master node queries the legal log synchronization offset with the smallest distance from the first log synchronization offset as the second log synchronization offset .

在一种可选的实施方式中,程序410具体可以用于使得处理器402执行以下操作:In an optional implementation manner, the program 410 may be specifically configured to enable the processor 402 to perform the following operations:

若所述第一日志同步偏移量大于所述第三日志同步偏移量,和/或,主节点判断所述第一日志同步偏移量不合法,则主节点查询成为主节点之前最近的合法的日志同步偏移量作为所述第二日志同步偏移量。If the first log synchronization offset is greater than the third log synchronization offset, and/or the master node judges that the first log synchronization offset is illegal, then the master node queries the latest A valid log synchronization offset is used as the second log synchronization offset.

在此提供的算法和显示不与任何特定计算机、虚拟系统或者其它设备固有相关。各种通用系统也可以与基于在此的示教一起使用。根据上面的描述,构造这类系统所要求的结构是显而易见的。此外,本发明也不针对任何特定编程语言。应当明白,可以利用各种编程语言实现在此描述的本发明的内容,并且上面对特定语言所做的描述是为了披露本发明的最佳实施方式。The algorithms and displays presented herein are not inherently related to any particular computer, virtual system, or other device. Various generic systems can also be used with the teachings based on this. The structure required to construct such a system is apparent from the above description. Furthermore, the present invention is not specific to any particular programming language. It should be understood that various programming languages can be used to implement the content of the present invention described herein, and the above description of specific languages is for disclosing the best mode of the present invention.

在此处所提供的说明书中,说明了大量具体细节。然而,能够理解,本发明的实施例可以在没有这些具体细节的情况下实践。在一些实例中,并未详细示出公知的方法、结构和技术,以便不模糊对本说明书的理解。In the description provided herein, numerous specific details are set forth. However, it is understood that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure the understanding of this description.

类似地,应当理解,为了精简本公开并帮助理解各个发明方面中的一个或多个,在上面对本发明的示例性实施例的描述中,本发明的各个特征有时被一起分组到单个实施例、图、或者对其的描述中。然而,并不应将该公开的方法解释成反映如下意图:即所要求保护的本发明要求比在每个权利要求中所明确记载的特征更多的特征。更确切地说,如下面的权利要求书所反映的那样,发明方面在于少于前面公开的单个实施例的所有特征。因此,遵循具体实施方式的权利要求书由此明确地并入该具体实施方式,其中每个权利要求本身都作为本发明的单独实施例。Similarly, it should be appreciated that in the foregoing description of exemplary embodiments of the invention, in order to streamline this disclosure and to facilitate an understanding of one or more of the various inventive aspects, various features of the invention are sometimes grouped together in a single embodiment, figure, or its description. This method of disclosure, however, is not to be interpreted as reflecting an intention that the claimed invention requires more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive aspects lie in less than all features of a single foregoing disclosed embodiment. Thus, the claims following the Detailed Description are hereby expressly incorporated into this Detailed Description, with each claim standing on its own as a separate embodiment of this invention.

本领域那些技术人员可以理解,可以对实施例中的设备中的模块进行自适应性地改变并且把它们设置在与该实施例不同的一个或多个设备中。可以把实施例中的模块或单元或组件组合成一个模块或单元或组件,以及此外可以把它们分成多个子模块或子单元或子组件。除了这样的特征和/或过程或者单元中的至少一些是相互排斥之外,可以采用任何组合对本说明书(包括伴随的权利要求、摘要和附图)中公开的所有特征以及如此公开的任何方法或者设备的所有过程或单元进行组合。除非另外明确陈述,本说明书(包括伴随的权利要求、摘要和附图)中公开的每个特征可以由提供相同、等同或相似目的的替代特征来代替。Those skilled in the art can understand that the modules in the device in the embodiment can be adaptively changed and arranged in one or more devices different from the embodiment. Modules or units or components in the embodiments may be combined into one module or unit or component, and furthermore may be divided into a plurality of sub-modules or sub-units or sub-assemblies. All features disclosed in this specification (including accompanying claims, abstract and drawings) and any method or method so disclosed may be used in any combination, except that at least some of such features and/or processes or units are mutually exclusive. All processes or units of equipment are combined. Each feature disclosed in this specification (including accompanying claims, abstract and drawings) may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.

此外,本领域的技术人员能够理解,尽管在此所述的一些实施例包括其它实施例中所包括的某些特征而不是其它特征,但是不同实施例的特征的组合意味着处于本发明的范围之内并且形成不同的实施例。例如,在下面的权利要求书中,所要求保护的实施例的任意之一都可以以任意的组合方式来使用。Furthermore, those skilled in the art will understand that although some embodiments described herein include some features included in other embodiments but not others, combinations of features from different embodiments are meant to be within the scope of the invention. and form different embodiments. For example, in the following claims, any of the claimed embodiments may be used in any combination.

本发明的各个部件实施例可以以硬件实现,或者以在一个或者多个处理器上运行的软件模块实现,或者以它们的组合实现。本领域的技术人员应当理解,可以在实践中使用微处理器或者数字信号处理器(DSP)来实现根据本发明实施例的主节点触发回退的日志同步装置中的一些或者全部部件的一些或者全部功能。本发明还可以实现为用于执行这里所描述的方法的一部分或者全部的设备或者装置程序(例如,计算机程序和计算机程序产品)。这样的实现本发明的程序可以存储在计算机可读介质上,或者可以具有一个或者多个信号的形式。这样的信号可以从因特网网站上下载得到,或者在载体信号上提供,或者以任何其他形式提供。The various component embodiments of the present invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. Those skilled in the art should understand that a microprocessor or a digital signal processor (DSP) may be used in practice to implement some or all of some or all of the components in the log synchronization device in which the master node triggers rollback according to the embodiment of the present invention. Full functionality. The present invention can also be implemented as an apparatus or an apparatus program (for example, a computer program and a computer program product) for performing a part or all of the methods described herein. Such a program for realizing the present invention may be stored on a computer-readable medium, or may be in the form of one or more signals. Such a signal may be downloaded from an Internet site, or provided on a carrier signal, or provided in any other form.

应该注意的是上述实施例对本发明进行说明而不是对本发明进行限制,并且本领域技术人员在不脱离所附权利要求的范围的情况下可设计出替换实施例。在权利要求中,不应将位于括号之间的任何参考符号构造成对权利要求的限制。单词“包含”不排除存在未列在权利要求中的元件或步骤。位于元件之前的单词“一”或“一个”不排除存在多个这样的元件。本发明可以借助于包括有若干不同元件的硬件以及借助于适当编程的计算机来实现。在列举了若干装置的单元权利要求中,这些装置中的若干个可以是通过同一个硬件项来具体体现。单词第一、第二、以及第三等的使用不表示任何顺序。可将这些单词解释为名称。It should be noted that the above-mentioned embodiments illustrate rather than limit the invention, and that those skilled in the art will be able to design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention can be implemented by means of hardware comprising several distinct elements, and by means of a suitably programmed computer. In a unit claim enumerating several means, several of these means can be embodied by one and the same item of hardware. The use of the words first, second, and third, etc. does not indicate any order. These words can be interpreted as names.

本发明公开了:A1.一种主节点触发回退的日志同步方法,包括:The present invention discloses: A1. A log synchronization method in which master node triggers rollback, comprising:

从节点根据从节点侧记录的第一日志同步偏移量,向主节点发送日志同步请求;The slave node sends a log synchronization request to the master node according to the first log synchronization offset recorded on the slave node side;

主节点对接收到的日志同步请求中的第一日志同步偏移量进行验证;The master node verifies the first log synchronization offset in the received log synchronization request;

若验证失败,主节点根据第一日志同步偏移量确定所回退到的第二日志同步偏移量,将所述第二日志同步偏移量通知给从节点,以供所述从节点利用所述第二日志同步偏移量重新发送日志同步请求。If the verification fails, the master node determines the second log synchronization offset to fall back to according to the first log synchronization offset, and notifies the second log synchronization offset to the slave node for use by the slave node The second log synchronization offset resends the log synchronization request.

A2.根据A1所述的方法,其中,所述主节点对接收到的日志同步请求中的第一日志同步偏移量进行验证进一步包括:A2. The method according to A1, wherein the verification of the first log synchronization offset in the received log synchronization request by the master node further includes:

主节点将所述第一日志同步偏移量与主节点侧记录的第三日志同步偏移量进行比较;The master node compares the first log synchronization offset with the third log synchronization offset recorded on the master node side;

和/或,主节点判断所述第一日志同步偏移量是否合法。And/or, the master node judges whether the first log synchronization offset is legal.

A3.根据A2所述的方法,其中,所述若验证失败,主节点根据第一日志同步偏移量确定所回退到的第二日志同步偏移量进一步包括:A3. The method according to A2, wherein, if the verification fails, determining the second log synchronization offset to be rolled back by the master node according to the first log synchronization offset further includes:

若所述第一日志同步偏移量大于所述第三日志同步偏移量,则主节点将所述第三日志同步偏移量作为所述第二日志同步偏移量。If the first log synchronization offset is greater than the third log synchronization offset, the master node uses the third log synchronization offset as the second log synchronization offset.

A4.根据A2所述的方法,其中,所述若验证失败,主节点根据第一日志同步偏移量确定所回退到的第二日志同步偏移量进一步包括:A4. The method according to A2, wherein, if the verification fails, determining the second log synchronization offset to be rolled back by the master node according to the first log synchronization offset further includes:

若主节点判断所述第一日志同步偏移量不合法,则主节点查询与所述第一日志同步偏移量距离最小的合法的日志同步偏移量作为所述第二日志同步偏移量。If the master node judges that the first log synchronization offset is illegal, the master node queries the legal log synchronization offset with the smallest distance from the first log synchronization offset as the second log synchronization offset .

A5.根据A2所述的方法,其中,所述若验证失败,主节点根据第一日志同步偏移量确定所回退到的第二日志同步偏移量进一步包括:A5. The method according to A2, wherein, if the verification fails, determining the second log synchronization offset to fall back to by the master node according to the first log synchronization offset further includes:

若所述第一日志同步偏移量大于所述第三日志同步偏移量,和/或,主节点判断所述第一日志同步偏移量不合法,则主节点查询成为主节点之前最近的合法的日志同步偏移量作为所述第二日志同步偏移量。If the first log synchronization offset is greater than the third log synchronization offset, and/or the master node judges that the first log synchronization offset is illegal, then the master node queries the latest A valid log synchronization offset is used as the second log synchronization offset.

本发明还公开了:B6.一种主节点触发回退的日志同步装置,包括:The present invention also discloses: B6. A log synchronization device for master node triggering rollback, comprising:

同步请求发送模块,适于从节点根据从节点侧记录的第一日志同步偏移量,向主节点发送日志同步请求;The synchronization request sending module is suitable for the slave node to send a log synchronization request to the master node according to the first log synchronization offset recorded by the slave node side;

验证模块,适于主节点对接收到的日志同步请求中的第一日志同步偏移量进行验证;A verification module, adapted for the master node to verify the first log synchronization offset in the received log synchronization request;

通知模块,适于若验证模块验证失败,主节点根据第一日志同步偏移量确定所回退到的第二日志同步偏移量,将所述第二日志同步偏移量通知给从节点,以供所述从节点利用所述第二日志同步偏移量重新发送日志同步请求。The notification module is adapted to determine the second log synchronization offset that the master node falls back to according to the first log synchronization offset, and notify the second log synchronization offset to the slave node if the verification module fails the verification, For the slave node to resend the log synchronization request by using the second log synchronization offset.

B7.根据B6所述的装置,其中,所述验证模块进一步适于:B7. The device according to B6, wherein the authentication module is further adapted to:

主节点将所述第一日志同步偏移量与主节点侧记录的第三日志同步偏移量进行比较;The master node compares the first log synchronization offset with the third log synchronization offset recorded on the master node side;

和/或,主节点判断所述第一日志同步偏移量是否合法。And/or, the master node judges whether the first log synchronization offset is legal.

B8.根据B7所述的装置,其中,所述通知模块进一步适于:B8. The device according to B7, wherein the notification module is further adapted to:

若所述第一日志同步偏移量大于所述第三日志同步偏移量,则主节点将所述第三日志同步偏移量作为所述第二日志同步偏移量。If the first log synchronization offset is greater than the third log synchronization offset, the master node uses the third log synchronization offset as the second log synchronization offset.

B9.根据B7所述的装置,其中,所述通知模块进一步适于:B9. The device according to B7, wherein the notification module is further adapted to:

若主节点判断所述第一日志同步偏移量不合法,则主节点查询与所述第一日志同步偏移量距离最小的合法的日志同步偏移量作为所述第二日志同步偏移量。If the master node judges that the first log synchronization offset is illegal, the master node queries the legal log synchronization offset with the smallest distance from the first log synchronization offset as the second log synchronization offset .

B10.根据B7所述的装置,其中,所述通知模块进一步适于:B10. The device according to B7, wherein the notification module is further adapted to:

若所述第一日志同步偏移量大于所述第三日志同步偏移量,和/或,主节点判断所述第一日志同步偏移量不合法,则主节点查询成为主节点之前最近的合法的日志同步偏移量作为所述第二日志同步偏移量。If the first log synchronization offset is greater than the third log synchronization offset, and/or the master node judges that the first log synchronization offset is illegal, then the master node queries the latest A valid log synchronization offset is used as the second log synchronization offset.

本发明还公开了:C11.一种计算设备,包括:处理器、存储器、通信接口和通信总线,所述处理器、所述存储器和所述通信接口通过所述通信总线完成相互间的通信;The present invention also discloses: C11. A computing device, comprising: a processor, a memory, a communication interface, and a communication bus, and the processor, the memory, and the communication interface complete mutual communication through the communication bus;

所述存储器用于存放至少一可执行指令,所述可执行指令使所述处理器执行如A1-A5中任一项所述的主节点触发回退的日志同步方法对应的操作。The memory is used to store at least one executable instruction, and the executable instruction causes the processor to execute the operation corresponding to the log synchronization method in which the master node triggers rollback described in any one of A1-A5.

本发明还公开了:D12.一种计算机存储介质,所述存储介质中存储有至少一可执行指令,所述可执行指令使处理器执行如A1-A5中任一项所述的主节点触发回退的日志同步方法对应的操作。The present invention also discloses: D12. A computer storage medium, at least one executable instruction is stored in the storage medium, and the executable instruction causes the processor to execute the master node trigger described in any one of A1-A5 The operation corresponding to the fallback log synchronization method.

Claims (10)

1. the daily record synchronous method that a kind of host node triggering retracts, including:
From node according to the first daily record synchronisation offset recorded from node sidelights, daily record synchronization request is sent to host node;
Host node verifies the first daily record synchronisation offset in the daily record synchronization request that receives;
If authentication failed, host node determines the second return back to daily record synchronisation offset according to the first daily record synchronisation offset, The second daily record synchronisation offset is notified, to from node, the second daily record synchronisation offset to be utilized from node for described Retransmit daily record synchronization request.
2. according to the method described in claim 1, wherein, the host node was to first day in the daily record synchronization request that receives Will synchronisation offset carries out verification and further comprises:
The third daily record synchronisation offset that the first daily record synchronisation offset is recorded with host node sidelights is compared by host node;
And/or host node judges whether the first daily record synchronisation offset is legal.
3. according to the method described in claim 2, wherein, if the authentication failed, host node is according to the first daily record simultaneous bias Amount determines that the second return back to daily record synchronisation offset further comprises:
If the first daily record synchronisation offset is more than the third daily record synchronisation offset, host node is by the third daily record Synchronisation offset is as the second daily record synchronisation offset.
4. according to the method described in claim 2, wherein, if the authentication failed, host node is according to the first daily record simultaneous bias Amount determines that the second return back to daily record synchronisation offset further comprises:
If host node judges that the first daily record synchronisation offset is illegal, host node inquiry is synchronous with first daily record partially Span is moved from minimum legal daily record synchronisation offset as the second daily record synchronisation offset.
5. according to the method described in claim 2, wherein, if the authentication failed, host node is according to the first daily record simultaneous bias Amount determines that the second return back to daily record synchronisation offset further comprises:
If the first daily record synchronisation offset be more than the third daily record synchronisation offset and/or, host node judges described the One daily record synchronisation offset is illegal, then host node inquiry legal daily record synchronisation offset nearest before becoming host node is made For the second daily record synchronisation offset.
6. the daily record synchronizing device that a kind of host node triggering retracts, including:
Synchronization request sending module, suitable for from node according to the first daily record synchronisation offset recorded from node sidelights, to host node Send daily record synchronization request;
Authentication module verifies the first daily record synchronisation offset in the daily record synchronization request that receives suitable for host node;
Notification module, if suitable for authentication module authentication failed, host node determines to be return back to according to the first daily record synchronisation offset The second daily record synchronisation offset, the second daily record synchronisation offset is notified, to from node, to utilize from node for described The second daily record synchronisation offset retransmits daily record synchronization request.
7. device according to claim 6, wherein, the authentication module is further adapted for:
The third daily record synchronisation offset that the first daily record synchronisation offset is recorded with host node sidelights is compared by host node;
And/or host node judges whether the first daily record synchronisation offset is legal.
8. device according to claim 7, wherein, the notification module is further adapted for:
If the first daily record synchronisation offset is more than the third daily record synchronisation offset, host node is by the third daily record Synchronisation offset is as the second daily record synchronisation offset.
9. a kind of computing device, including:Processor, memory, communication interface and communication bus, the processor, the storage Device and the communication interface complete mutual communication by the communication bus;
For the memory for storing an at least executable instruction, the executable instruction makes the processor perform right such as will The host node described in any one of 1-5 is asked to trigger the corresponding operation of daily record synchronous method to retract.
10. a kind of computer storage media, an at least executable instruction, the executable instruction are stored in the storage medium Processor is made to perform the corresponding behaviour of daily record synchronous method that the host node triggering as described in any one of claim 1-5 retracts Make.
CN201711478209.9A 2017-12-29 2017-12-29 Log synchronization method and device for triggering rollback by master node Active CN108200157B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711478209.9A CN108200157B (en) 2017-12-29 2017-12-29 Log synchronization method and device for triggering rollback by master node

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711478209.9A CN108200157B (en) 2017-12-29 2017-12-29 Log synchronization method and device for triggering rollback by master node

Publications (2)

Publication Number Publication Date
CN108200157A true CN108200157A (en) 2018-06-22
CN108200157B CN108200157B (en) 2020-12-25

Family

ID=62586561

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711478209.9A Active CN108200157B (en) 2017-12-29 2017-12-29 Log synchronization method and device for triggering rollback by master node

Country Status (1)

Country Link
CN (1) CN108200157B (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112506938A (en) * 2020-11-11 2021-03-16 凌韬(济南)信息科技有限责任公司 Data synchronization mode supporting distributed deployment and spanning multiple data source types
CN112910694A (en) * 2021-01-22 2021-06-04 苏州浪潮智能科技有限公司 Method, system and medium for transmitting filing log
CN113515574A (en) * 2021-05-17 2021-10-19 聚好看科技股份有限公司 Data synchronization method and device
WO2022068220A1 (en) * 2020-09-30 2022-04-07 北京金山云网络技术有限公司 Data processing method and apparatus, computer device, and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070174695A1 (en) * 2006-01-18 2007-07-26 Srinidhi Varadarajan Log-based rollback-recovery
CN104504062A (en) * 2014-12-22 2015-04-08 浙江宇视科技有限公司 Data synchronization method and device of primary and standby databases
CN105512266A (en) * 2015-12-03 2016-04-20 曙光信息产业(北京)有限公司 Method and device for achieving operational consistency of distributed database
CN106598762A (en) * 2016-12-29 2017-04-26 上海理想信息产业(集团)有限公司 Message synchronization method and system
CN107016087A (en) * 2017-04-05 2017-08-04 杭州铭师堂教育科技发展有限公司 Hierarchical database high-availability system based on sentry's model

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070174695A1 (en) * 2006-01-18 2007-07-26 Srinidhi Varadarajan Log-based rollback-recovery
CN104504062A (en) * 2014-12-22 2015-04-08 浙江宇视科技有限公司 Data synchronization method and device of primary and standby databases
CN105512266A (en) * 2015-12-03 2016-04-20 曙光信息产业(北京)有限公司 Method and device for achieving operational consistency of distributed database
CN106598762A (en) * 2016-12-29 2017-04-26 上海理想信息产业(集团)有限公司 Message synchronization method and system
CN107016087A (en) * 2017-04-05 2017-08-04 杭州铭师堂教育科技发展有限公司 Hierarchical database high-availability system based on sentry's model

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2022068220A1 (en) * 2020-09-30 2022-04-07 北京金山云网络技术有限公司 Data processing method and apparatus, computer device, and storage medium
CN112506938A (en) * 2020-11-11 2021-03-16 凌韬(济南)信息科技有限责任公司 Data synchronization mode supporting distributed deployment and spanning multiple data source types
CN112506938B (en) * 2020-11-11 2025-12-05 凌韬(济南)信息科技有限责任公司 A data synchronization pattern that supports distributed deployment across multiple data source types
CN112910694A (en) * 2021-01-22 2021-06-04 苏州浪潮智能科技有限公司 Method, system and medium for transmitting filing log
CN112910694B (en) * 2021-01-22 2022-11-29 苏州浪潮智能科技有限公司 Method, system and medium for transmitting filing log
CN113515574A (en) * 2021-05-17 2021-10-19 聚好看科技股份有限公司 Data synchronization method and device

Also Published As

Publication number Publication date
CN108200157B (en) 2020-12-25

Similar Documents

Publication Publication Date Title
CN103875229B (en) asynchronous replication method, device and system
CN104504062B (en) Master/slave data storehouse method of data synchronization and device
US20180150501A1 (en) Database system, server device, computer program product, and information processing method
US20190129976A1 (en) Apparatus for controlling synchronization of metadata on network and method for the same
CN107181686B (en) Routing table synchronization method, device and system
CN104717314B (en) A kind of IP management method and system, client, server
JP5686034B2 (en) Cluster system, synchronization control method, server device, and synchronization control program
JP6700308B2 (en) Data copy method and device
CN108200157A (en) The daily record synchronous method and device that host node triggering retracts
CN104376127A (en) Data manipulation method and device
CN108881231A (en) The method, apparatus and storage medium of synchronous account information in a kind of group system
CN108228733A (en) A kind of file syn chronizing system and method
CN104967536A (en) Method and device for realizing data consistency in multiple computer rooms
CN112749172A (en) Data synchronization method and system between cache and database
CN106446300A (en) Transaction processing method and system based on shared storage pool
US7933962B1 (en) Reducing reliance on a central data store while maintaining idempotency in a multi-client, multi-server environment
CN105550230A (en) Method and device for detecting failure of node of distributed storage system
WO2012171345A1 (en) Method and distributed cache system for data recovery in temporary fault
CN108228789B (en) Synchronous abnormity recovery method and device triggered by slave node
CN109241004A (en) Meta data file size restoration methods, system, device and readable storage medium storing program for executing
CN108228812A (en) Adaptive host node switching method and device
CN101854373B (en) Target switching method, server node and colony system
CN107526652A (en) A kind of method of data synchronization and storage device
CN113760519B (en) Distributed transaction processing method, device, system and electronic equipment
US20130110782A1 (en) Oportunistic database duplex operations

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant