CN106302700B - Distributed system consistent update method and system based on paxos algorithm - Google Patents
Distributed system consistent update method and system based on paxos algorithm Download PDFInfo
- Publication number
- CN106302700B CN106302700B CN201610658584.0A CN201610658584A CN106302700B CN 106302700 B CN106302700 B CN 106302700B CN 201610658584 A CN201610658584 A CN 201610658584A CN 106302700 B CN106302700 B CN 106302700B
- Authority
- CN
- China
- Prior art keywords
- node
- status information
- information
- state information
- state
- 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.)
- Active
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
- H04L67/1095—Replication 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)
Abstract
本发明公开了一种基于paxos算法的分布式服务器系统的一致性更新方法及系统,包括:主节点向从节点发送主节点状态信息;从节点根据主节点状态信息判断主节点的状态是否为最新状态;若否,则向主节点发送从节点自身的从节点状态信息;若是,则将主节点状态信息设置为从节点自身结点的状态信息;其中,主节点状态信息和从节点状态信息均为携带时间标号的状态信息;主节点从所有从节点状态信息中确定最新状态信息,并将最新状态信息设定为主节点的当前状态信息,并向从节点发送当前状态信息;从节点根据当前状态信息更新自身节点的状态信息。可见,通过本实施例提供的一致性更新方案,能随时更新系统中不同节点的状态,保证系统的一致性。
The invention discloses a consistent update method and system of a distributed server system based on paxos algorithm, comprising: a master node sends master node state information to a slave node; and the slave node judges whether the state of the master node is the latest according to the state information of the master node state; if not, then send the slave node’s own slave node status information to the master node; if so, set the master node status information as the status information of the slave node’s own node; wherein, the master node status information and the slave node status information are both It is the state information carrying the time label; the master node determines the latest state information from all slave node state information, and sets the latest state information as the current state information of the master node, and sends the current state information to the slave node; the slave node according to the current state information The status information updates the status information of its own node. It can be seen that, through the consistency update solution provided by this embodiment, the states of different nodes in the system can be updated at any time to ensure the consistency of the system.
Description
技术领域technical field
本发明涉及服务器软件领域,更具体地说,涉及一种基于paxos算法的分布式服务器系统的一致性更新方法及系统。The present invention relates to the field of server software, more specifically, to a method and system for consistent update of a distributed server system based on paxos algorithm.
背景技术Background technique
分布式服务器系统是一种计算机硬件的配置方式和相应的功能配置方式。它是一种多控制器的计算机系统,各控制器通过互连网络构成统一的系统。系统采用分布式计算结构,即把原来系统内中央处理器处理的任务分散给相应的控制器,实现不同功能的各个控制器相互协调,共享系统的外设与软件。从外界看,整个服务器系统是统一透明的。对每个节点控制器,需要保证它们的一致性状态。各节点控制器初始状态一致,工作过程中多个控制器之间需要进行通信,以保证一致性。分布式的节点通信模型主要有共享内存式通信模式和消息传递式通信模型两种。其中,共享内存式模型,多个进程共享某一段物理内存,通过少数服从多数来保持一致性。容错性不够强。消息传递式模型,容错性较强,可应用于消息延迟、丢失,乃至网络挂掉等非正常情况。分布式服务器系统加快了系统的处理速度,简化了主机的逻辑结构,特别适合于工业生产线自动控制和企事业单位的管理,成本低,易于维护,成为计算机在应用领域发展的一个重要方向。Distributed server system is a configuration method of computer hardware and corresponding function configuration method. It is a multi-controller computer system, and each controller forms a unified system through an interconnected network. The system adopts a distributed computing structure, that is, the tasks processed by the central processor in the original system are distributed to the corresponding controllers, so that the controllers with different functions can coordinate with each other and share the peripherals and software of the system. From the outside, the entire server system is unified and transparent. For each node controller, it is necessary to ensure their consistent state. The initial state of each node controller is consistent, and multiple controllers need to communicate during the working process to ensure consistency. Distributed node communication models mainly include shared memory communication model and message passing communication model. Among them, in the shared memory model, multiple processes share a certain section of physical memory, and the consistency is maintained by the minority obeying the majority. Fault tolerance is not strong enough. The message passing model has strong fault tolerance and can be applied to abnormal situations such as message delay, loss, and even network hangup. The distributed server system speeds up the processing speed of the system and simplifies the logical structure of the host computer. It is especially suitable for the automatic control of industrial production lines and the management of enterprises and institutions. It has low cost and is easy to maintain. It has become an important direction for the development of computers in the application field.
在单控制器数据库中,用户修改数据库中的数据,不用担心其他用户同时修改相同的数据。但是,在多控制器数据库中,同时执行的多个事务中的语句可以修改同一数据。同时执行的事务需要产生有意义的和一致性的结果。因而,在多控制器数据库中,如何维持数据的一致性是本领域技术人员需要解决的问题。In a single-controller database, users modify data in the database without worrying about other users modifying the same data at the same time. However, in a multi-controller database, statements in multiple transactions executing concurrently can modify the same data. Concurrently executing transactions need to produce meaningful and consistent results. Therefore, in a multi-controller database, how to maintain data consistency is a problem to be solved by those skilled in the art.
发明内容Contents of the invention
本发明的目的在于提供一种基于paxos算法的分布式服务器系统的一致性更新方法及系统,以实现维持数据的一致性。The object of the present invention is to provide a method and system for updating consistency of a distributed server system based on paxos algorithm, so as to maintain data consistency.
为实现上述目的,本发明实施例提供了如下技术方案:In order to achieve the above object, the embodiment of the present invention provides the following technical solutions:
一种基于paxos算法的分布式服务器系统的一致性更新方法,包括:A consistent update method for a distributed server system based on the Paxos algorithm, comprising:
主节点向从节点发送主节点状态信息;The master node sends master node status information to the slave node;
从节点根据所述主节点状态信息判断所述主节点的状态是否为最新状态;若否,则向所述主节点发送从节点自身的从节点状态信息;若是,则将所述主节点状态信息设置为从节点自身结点的状态信息;其中,所述主节点状态信息和从节点状态信息均为携带时间标号的状态信息;The slave node judges whether the state of the master node is the latest state according to the master node status information; if not, then sends the slave node status information of the slave node itself to the master node; It is set as the state information of the slave node itself; wherein, the master node state information and the slave node state information are state information carrying a time stamp;
所述主节点从所有从节点状态信息中确定最新状态信息,并将所述最新状态信息设定为所述主节点的当前状态信息,并向从节点发送所述当前状态信息;The master node determines the latest state information from all slave node state information, and sets the latest state information as the current state information of the master node, and sends the current state information to the slave nodes;
从节点根据所述当前状态信息更新自身节点的状态信息。The slave node updates the state information of its own node according to the current state information.
其中,所述从节点根据所述主节点状态信息判断所述主节点的状态是否为最新状态,包括:Wherein, the slave node judges whether the state of the master node is the latest state according to the state information of the master node, including:
从节点根据主节点状态信息中的时间标号与自身存储的状态信息的时间标号进行比较;The slave node compares the time stamp in the state information of the master node with the time stamp of the state information stored by itself;
若主节点状态信息中的时间标号为最新的,则判定所述主节点的状态为最新状态;若主节点状态信息中的时间标号不是最新的,则判定所述主节点的状态不是最新状态。If the timestamp in the status information of the master node is the latest, it is determined that the status of the master node is the latest state; if the timestamp in the status information of the master node is not the latest, it is determined that the status of the master node is not the latest state.
其中,所述主节点从所有从节点状态信息中确定最新状态信息,包括:Wherein, the master node determines the latest status information from all slave node status information, including:
所述主节点从所有的从节点状态信息中获取对应的时间标号;The master node obtains corresponding time labels from all slave node state information;
将最新的时间标号所对应的从节点状态信息作为最新状态信息。The slave node state information corresponding to the latest time label is taken as the latest state information.
其中,主节点向从节点发送主节点状态信息之后,还包括:Among them, after the master node sends the master node status information to the slave node, it also includes:
启动定时器开始计时;Start the timer to start timing;
当计时器的计时时间达到预定时长后,检测是否接收到从节点发送的从节点状态信息;When the timing time of the timer reaches the predetermined duration, detect whether the slave node status information sent by the slave node is received;
若接收到,则执行所述主节点从所有的从节点状态信息中确定最新状态信息的步骤;若没有接收到,则判定所述主节点状态信息为最新的状态信息。If received, execute the step of the master node determining the latest status information from all slave node status information; if not received, then determine that the master node status information is the latest status information.
其中,所述向从节点发送所述当前状态信息,包括:Wherein, the sending the current state information to the slave node includes:
所述主节点将所述最新状态信息设定为所述主节点的当前状态信息后,将所述主节点的当前状态信息作为主节点状态信息,并在下一个周期向从节点发送。After the master node sets the latest state information as the current state information of the master node, it uses the current state information of the master node as the master node state information, and sends it to the slave node in the next period.
一种基于paxos算法的分布式服务器系统的一致性更新系统,包括主节点和从节点;A consistent update system of a distributed server system based on the paxos algorithm, including a master node and a slave node;
所述主节点包括:The master nodes include:
第一发送模块,用于向从节点发送主节点状态信息;The first sending module is used to send the master node status information to the slave node;
当前状态信息确定模块,用于从所有从节点状态信息中确定最新状态信息,并将所述最新状态信息设定为所述主节点的当前状态信息,并触发所述发送模块向从节点发送所述当前状态信息;The current state information determination module is used to determine the latest state information from all slave node state information, and set the latest state information as the current state information of the master node, and trigger the sending module to send the slave node the Describe the current status information;
所述从节点包括:The slave nodes include:
判断模块,用于根据所述主节点状态信息判断所述主节点的状态是否为最新状态;若否,则触发第二发送模块;若是,则触发设置模块;A judging module, configured to judge whether the state of the master node is the latest state according to the state information of the master node; if not, trigger the second sending module; if so, trigger the setting module;
所述第二发送模块,用于向所述主节点发送从节点自身的从节点状态信息;The second sending module is configured to send slave node status information of the slave node itself to the master node;
所述设置模块,用于将所述主节点状态信息设置为从节点自身结点的状态信息,并根据所述当前状态信息更新自身节点的状态信息;其中,所述主节点状态信息和从节点状态信息均为携带时间标号的状态信息。The setting module is used to set the state information of the master node as the state information of its own node of the slave node, and update the state information of its own node according to the current state information; wherein, the state information of the master node and the state information of the slave node The state information is state information carrying a time stamp.
其中,所述判断模块根据主节点状态信息中的时间标号与从节点自身存储的状态信息的时间标号进行比较;若主节点状态信息中的时间标号为最新的,则判定所述主节点的状态为最新状态;若主节点状态信息中的时间标号不是最新的,则判定所述主节点的状态不是最新状态。Wherein, the judging module compares the time stamp in the state information of the master node with the time stamp of the state information stored in the slave node itself; if the time stamp in the state information of the master node is the latest, then judge the state of the master node is the latest state; if the time stamp in the state information of the master node is not the latest, then it is determined that the state of the master node is not the latest state.
其中,所述当前状态信息确定模块从所有从节点状态信息中获取对应的时间标号,并将最新的时间标号所对应的从节点状态信息作为最新状态信息。Wherein, the current state information determination module obtains corresponding time labels from all slave node state information, and uses the slave node state information corresponding to the latest time label as the latest state information.
其中,所述主节点还包括:Wherein, the master node also includes:
计时模块,用于启动定时器开始计时;Timing module, used to start the timer to start counting;
检测模块,用于当计时器的计时时间达到预定时长后,检测是否接收到从节点发送的从节点状态信息;若接收到,则执行所述主节点从所有的从节点状态信息中确定最新状态信息的步骤;若没有接收到,则判定所述主节点状态信息为最新的状态信息。The detection module is used to detect whether the slave node status information sent by the slave node is received when the timing time of the timer reaches a predetermined duration; if received, the master node determines the latest status from all slave node status information information step; if not received, then determine that the master node state information is the latest state information.
其中,所述当前状态信息确定模块将所述最新状态信息设定为所述主节点的当前状态信息之后,将所述主节点的当前状态信息作为主节点状态信息,并通过所述发送模块在下一个周期向从节点发送。Wherein, after the current state information determination module sets the latest state information as the current state information of the master node, it uses the current state information of the master node as the master node state information, and transmits One cycle is sent to the slave node.
通过以上方案可知,本发明实施例提供的一种基于paxos算法的分布式服务器系统的一致性更新方法及系统,包括:主节点向从节点发送主节点状态信息;从节点根据所述主节点状态信息判断所述主节点的状态是否为最新状态;若否,则向所述主节点发送从节点自身的从节点状态信息;若是,则将所述主节点状态信息设置为从节点自身结点的状态信息;其中,所述主节点状态信息和从节点状态信息均为携带时间标号的状态信息;所述主节点从所有从节点状态信息中确定最新状态信息,并将所述最新状态信息设定为所述主节点的当前状态信息,并向从节点发送所述当前状态信息;从节点根据所述当前状态信息更新自身节点的状态信息。可见,通过本实施例提供的一致性更新方案,能随时更新系统中不同节点的状态,保证系统的一致性。It can be seen from the above scheme that a consistent update method and system of a distributed server system based on paxos algorithm provided by the embodiment of the present invention includes: the master node sends the master node status information to the slave node; information to determine whether the state of the master node is the latest state; if not, then send the slave node status information of the slave node itself to the master node; if so, set the master node status information as the slave node’s own node State information; wherein, the state information of the master node and the state information of the slave node are state information carrying time labels; the master node determines the latest state information from all the state information of the slave nodes, and sets the latest state information is the current state information of the master node, and sends the current state information to the slave node; the slave node updates the state information of its own node according to the current state information. It can be seen that, through the consistency update solution provided by this embodiment, the states of different nodes in the system can be updated at any time to ensure the consistency of the system.
附图说明Description of drawings
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only These are some embodiments of the present invention. Those skilled in the art can also obtain other drawings based on these drawings without creative work.
图1为本发明实施例公开的一种基于paxos算法的分布式服务器系统的一致性更新方法流程示意图;Fig. 1 is a schematic flow chart of a consistent update method for a distributed server system based on the paxos algorithm disclosed in an embodiment of the present invention;
图2为本发明实施例公开的boss广播自身状态信息示意图;Fig. 2 is a schematic diagram of the boss broadcasting its own state information disclosed in the embodiment of the present invention;
图3为本发明实施例公开的common回复信息示意图;Fig. 3 is a schematic diagram of the common reply information disclosed by the embodiment of the present invention;
图4为本发明实施例公开的boss更新系统状态示意图;Fig. 4 is a schematic diagram of the status of the boss update system disclosed in the embodiment of the present invention;
图5为本发明实施例公开的一种基于paxos算法的分布式服务器系统的一致性更新系统结构框图。FIG. 5 is a structural block diagram of a consistency update system of a distributed server system based on the paxos algorithm disclosed in an embodiment of the present invention.
具体实施方式Detailed ways
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some, not all, embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without creative efforts fall within the protection scope of the present invention.
本发明实施例公开了一种基于paxos算法的分布式服务器系统的一致性更新方法及系统,以实现维持数据的一致性。The embodiment of the invention discloses a consistent update method and system of a distributed server system based on a paxos algorithm, so as to maintain data consistency.
参见图1,本发明实施例提供的一种基于paxos算法的分布式服务器系统的一致性更新方法,包括:Referring to Fig. 1, a kind of consistency update method of the distributed server system based on paxos algorithm provided by the embodiment of the present invention, comprises:
S101、主节点向从节点发送主节点状态信息;S101. The master node sends master node status information to the slave node;
其中,主节点向从节点发送主节点状态信息之后,还包括:Among them, after the master node sends the master node status information to the slave node, it also includes:
启动定时器开始计时;Start the timer to start timing;
当计时器的计时时间达到预定时长后,检测是否接收到从节点发送的从节点状态信息;When the timing time of the timer reaches the predetermined duration, detect whether the slave node status information sent by the slave node is received;
若接收到,则执行所述主节点从所有的从节点状态信息中确定最新状态信息的步骤;若没有接收到,则判定所述主节点状态信息为最新的状态信息。If received, execute the step of the master node determining the latest status information from all slave node status information; if not received, then determine that the master node status information is the latest status information.
具体的,本实施例为一种改进paxos算法的分布式系统一致性设计,在分布式服务器系统中,多个控制器node分为两种角色:主节点boss和从节点common。任何时候,主节点boss只有一个,剩余控制器为从节点common。在初始状态下,分布式系统中各个控制器node均为初始状态。系统中每个控制器node均可接收外界消息,与外界交互。每个控制器node根据接收的消息,作出反应改变状态,并随时更新各自的状态信息meg。该状态信息meg中含有以接收消息时间为标记的时间标号。这样,经过一段时间,系统中的控制器node状态便会发生分化。因此,在本方案中,为保证整个分布式系统状态始终保持一致性,并随时更新,由boss来统一更新系统状态。Specifically, this embodiment is a distributed system consistency design of an improved paxos algorithm. In a distributed server system, multiple controller nodes are divided into two roles: master node boss and slave node common. At any time, there is only one master node boss, and the remaining controller is the slave node common. In the initial state, each controller node in the distributed system is in the initial state. Each controller node in the system can receive external messages and interact with the external world. Each controller node reacts to change the state according to the received message, and updates its own state information meg at any time. The state information meg contains a time stamp marked with the time of receiving the message. In this way, after a period of time, the state of the controller node in the system will be differentiated. Therefore, in this solution, in order to ensure that the state of the entire distributed system is always consistent and updated at any time, the boss will update the system state uniformly.
具体的,在本实施例中分布式系统中唯一的boss定时向多个common广播发送自己的状态信息meg_boss,该信息中含有时间标号。参见图2,为一个lease内,boss控制器将自身的状态信息meg_boss广播发送给系统中的common控制器,该状态信息meg_boss中带有时间标号。Specifically, in this embodiment, the only boss in the distributed system regularly broadcasts its state information meg_boss to multiple commons, and the information includes a time stamp. Referring to Fig. 2, in a lease, the boss controller broadcasts its own state information meg_boss to the common controller in the system, and the state information meg_boss has a time stamp.
S102、从节点根据所述主节点状态信息判断所述主节点的状态是否为最新状态;若否,则向所述主节点发送从节点自身的从节点状态信息;若是,则将所述主节点状态信息设置为从节点自身结点的状态信息;其中,所述主节点状态信息和从节点状态信息均为携带时间标号的状态信息;S102. The slave node judges whether the status of the master node is the latest state according to the status information of the master node; if not, send the status information of the slave node itself to the master node; The state information is set as the state information of the slave node itself; wherein, the master node state information and the slave node state information are state information carrying time labels;
其中,所述从节点根据所述主节点状态信息判断所述主节点的状态是否为最新状态,包括:Wherein, the slave node judges whether the state of the master node is the latest state according to the state information of the master node, including:
从节点根据主节点状态信息中的时间标号与自身存储的状态信息的时间标号进行比较;The slave node compares the time stamp in the state information of the master node with the time stamp of the state information stored by itself;
若主节点状态信息中的时间标号为最新的,则判定所述主节点的状态为最新状态;若主节点状态信息中的时间标号不是最新的,则判定所述主节点的状态不是最新状态。If the timestamp in the status information of the master node is the latest, it is determined that the status of the master node is the latest state; if the timestamp in the status information of the master node is not the latest, it is determined that the status of the master node is not the latest state.
具体的,对单个common来说,它会将收到的状态信息meg_boss的时间标号与自身存储的状态信息meg时间标号进行比较。若common收到的状态消息meg_boss相对自身存储的状态消息meg不是最新的,则将自身存储的meg发送给boss;若meg_boss相对common的meg是最新的,则common用meg_boss来替代更新自身存储的meg,不向boss返回信息。Specifically, for a single common, it will compare the time stamp of the state information meg_boss received with the state information meg time stamp stored by itself. If the status message meg_boss received by common is not up-to-date compared to the status message meg stored by itself, then the meg stored by itself will be sent to boss; if meg_boss is up-to-date relative to common’s meg, common will use meg_boss instead to update the meg stored by itself , do not return information to the boss.
具体如图3所示,common控制器对接收到的meg_boss作出相应反应。其中,commonnode1收到的状态消息meg_boss相对自身存储的状态消息meg是最新的,则用meg_boss来替代更新自身存储的meg_1,不向boss返回信息。common node2收到的meg_boss相对自身meg_2不是最新的,则将meg_2发送给boss。common node3收到的meg_boss相对自身meg_3也不是最新的,也将meg_3发送给boss。Specifically as shown in Figure 3, the common controller responds to the received meg_boss accordingly. Among them, the state message meg_boss received by commonnode1 is the latest compared to the state message meg stored by itself, so meg_boss is used to replace and update the meg_1 stored by itself, and no information is returned to the boss. The meg_boss received by common node2 is not up-to-date relative to its own meg_2, so it sends meg_2 to the boss. The meg_boss received by common node3 is not up-to-date compared to its own meg_3, and it also sends meg_3 to the boss.
S103、所述主节点从所有从节点状态信息中确定最新状态信息,并将所述最新状态信息设定为所述主节点的当前状态信息,并向从节点发送所述当前状态信息;S103. The master node determines the latest state information from the state information of all slave nodes, sets the latest state information as the current state information of the master node, and sends the current state information to the slave nodes;
其中,所述主节点从所有从节点状态信息中确定最新状态信息,包括:Wherein, the master node determines the latest status information from all slave node status information, including:
所述主节点从所有的从节点状态信息中获取对应的时间标号;The master node obtains corresponding time labels from all slave node state information;
将最新的时间标号所对应的从节点状态信息作为最新状态信息。The slave node state information corresponding to the latest time label is taken as the latest state information.
具体的,参见图4,boss控制器会将收到的meg_2与meg_3进行比较,由于meg_3较为新,boss控制器选定meg_3来更新自身的状态信息。如图4所示,下一个lease,boss控制器将最新的状态信息meg_3广播发送给系统中的common控制器;各个common控制器根据meg_3再次进行状态更新。Specifically, referring to Fig. 4, the boss controller will compare the received meg_2 with meg_3, and since meg_3 is relatively new, the boss controller selects meg_3 to update its own state information. As shown in Figure 4, in the next lease, the boss controller broadcasts the latest status information meg_3 to the common controllers in the system; each common controller updates the status again according to meg_3.
S104、从节点根据所述当前状态信息更新自身节点的状态信息。S104. The slave node updates the state information of its own node according to the current state information.
其中,所述向从节点发送所述当前状态信息,包括:Wherein, the sending the current state information to the slave node includes:
所述主节点将所述最新状态信息设定为所述主节点的当前状态信息后,将所述主节点的当前状态信息作为主节点状态信息,并在下一个周期向从节点发送。After the master node sets the latest state information as the current state information of the master node, it uses the current state information of the master node as the master node state information, and sends it to the slave node in the next period.
具体的,若boss在规定时间lease内接收到common的回复消息,则多个common回复的meg中,时间最新的内容即被定为boss的状态信息meg_boss。若lease到期,boss未收到任一common的回复消息,则说明此时系统中的控制器均更新为最新状态meg_boss。下一个lease周期内,boss再次将自己的状态信息meg_boss广播给系统中的common。通过这样的方式,保证整个系统随时更新,并具有一致性。Specifically, if the boss receives the reply message from the common within the specified time lease, then among the meg replies from multiple commons, the latest content is determined as the state information meg_boss of the boss. If the lease expires and the boss does not receive a reply message from any common, it means that all the controllers in the system are updated to the latest status meg_boss. In the next lease period, the boss broadcasts its state information meg_boss to the common in the system again. In this way, the entire system is guaranteed to be updated and consistent at any time.
具体的,在本方案中,主节点向从节点发送主节点状态信息之后,启动定时器开始计时,这里定时器的定时时间可以为上述的规定时间lease。则在本方案中再次向从节点发送主节点的当前状态信息的时间,即下一个周期为主节点再次向从节点发送状态信息的时刻。Specifically, in this solution, after the master node sends the master node status information to the slave nodes, a timer is started to start timing, where the timing time of the timer may be the above-mentioned specified time lease. Then in this scheme, the time to send the current status information of the master node to the slave node again is the time when the master node sends the status information to the slave node again in the next cycle.
下面对本发明实施例提供的一致性更新系统进行介绍,下文描述的一致性更新系统与上文描述的一致性更新方法可以相互参照。The consistency update system provided by the embodiment of the present invention is introduced below, and the consistency update system described below and the consistency update method described above may refer to each other.
参见图5,本发明实施例提供的一种基于paxos算法的分布式服务器系统的一致性更新系统,包括主节点100和从节点200;Referring to FIG. 5 , a consistent update system of a distributed server system based on the paxos algorithm provided by an embodiment of the present invention includes a master node 100 and a slave node 200;
所述主节点包括100:The master nodes consist of 100:
第一发送模块101,用于向从节点发送主节点状态信息;The first sending module 101 is configured to send the master node status information to the slave node;
当前状态信息确定模块102,用于从所有从节点状态信息中确定最新状态信息,并将所述最新状态信息设定为所述主节点的当前状态信息,并触发所述发送模块向从节点发送所述当前状态信息;The current state information determination module 102 is used to determine the latest state information from all slave node state information, and set the latest state information as the current state information of the master node, and trigger the sending module to send the slave node said current state information;
所述从节点200包括:The slave node 200 includes:
判断模块201,用于根据所述主节点状态信息判断所述主节点的状态是否为最新状态;若否,则触发第二发送模块;若是,则触发设置模块;Judging module 201, configured to judge whether the state of the master node is the latest state according to the state information of the master node; if not, trigger the second sending module; if so, trigger the setting module;
所述第二发送模块202,用于向所述主节点发送从节点自身的从节点状态信息;The second sending module 202 is configured to send the slave node status information of the slave node itself to the master node;
所述设置模块203,用于将所述主节点状态信息设置为从节点自身结点的状态信息,并根据所述当前状态信息更新自身节点的状态信息;其中,所述主节点状态信息和从节点状态信息均为携带时间标号的状态信息。The setting module 203 is used to set the state information of the master node as the state information of its own node of the slave node, and update the state information of its own node according to the current state information; wherein, the state information of the master node and the state information of the slave node The node state information is state information carrying a time stamp.
基于上述技术方案,所述判断模块根据主节点状态信息中的时间标号与从节点自身存储的状态信息的时间标号进行比较;若主节点状态信息中的时间标号为最新的,则判定所述主节点的状态为最新状态;若主节点状态信息中的时间标号不是最新的,则判定所述主节点的状态不是最新状态。Based on the above technical solution, the judging module compares the time stamp in the state information of the master node with the time stamp of the state information stored in the slave node itself; if the time stamp in the state information of the master node is the latest, then it is determined that the master The state of the node is the latest state; if the time stamp in the state information of the master node is not the latest, it is determined that the state of the master node is not the latest state.
基于上述技术方案,所述当前状态信息确定模块从所有从节点状态信息中获取对应的时间标号,并将最新的时间标号所对应的从节点状态信息作为最新状态信息。Based on the above technical solution, the current state information determination module obtains corresponding time labels from all slave node state information, and uses the slave node state information corresponding to the latest time label as the latest state information.
基于上述技术方案,所述主节点还包括:Based on the above technical solution, the master node also includes:
计时模块,用于启动定时器开始计时;Timing module, used to start the timer to start counting;
检测模块,用于当计时器的计时时间达到预定时长后,检测是否接收到从节点发送的从节点状态信息;若接收到,则执行所述主节点从所有的从节点状态信息中确定最新状态信息的步骤;若没有接收到,则判定所述主节点状态信息为最新的状态信息。The detection module is used to detect whether the slave node status information sent by the slave node is received when the timing time of the timer reaches a predetermined duration; if received, the master node determines the latest status from all slave node status information information step; if not received, then determine that the master node state information is the latest state information.
基于上述技术方案,所述当前状态信息确定模块将所述最新状态信息设定为所述主节点的当前状态信息之后,将所述主节点的当前状态信息作为主节点状态信息,并通过所述发送模块在下一个周期向从节点发送。Based on the above technical solution, after the current state information determination module sets the latest state information as the current state information of the master node, it uses the current state information of the master node as the master node state information, and through the The sending module sends to the slave node in the next cycle.
本发明实施例提供的一种基于paxos算法的分布式服务器系统的一致性更新方法及系统,包括:主节点向从节点发送主节点状态信息;从节点根据所述主节点状态信息判断所述主节点的状态是否为最新状态;若否,则向所述主节点发送从节点自身的从节点状态信息;若是,则将所述主节点状态信息设置为从节点自身结点的状态信息;其中,所述主节点状态信息和从节点状态信息均为携带时间标号的状态信息;所述主节点从所有从节点状态信息中确定最新状态信息,并将所述最新状态信息设定为所述主节点的当前状态信息,并向从节点发送所述当前状态信息;从节点根据所述当前状态信息更新自身节点的状态信息。可见,通过本实施例提供的一致性更新方案,能随时更新系统中不同节点的状态,保证系统的一致性。A consistent update method and system for a distributed server system based on the paxos algorithm provided by an embodiment of the present invention includes: the master node sends master node status information to the slave node; the slave node judges the master node status information according to the master node status information Whether the status of the node is the latest status; if not, then send the slave node status information of the slave node itself to the master node; if so, then set the master node status information as the status information of the slave node itself; wherein, Both the master node status information and the slave node status information are status information carrying time labels; the master node determines the latest status information from all slave node status information, and sets the latest status information as the master node and send the current state information to the slave node; the slave node updates the state information of its own node according to the current state information. It can be seen that, through the consistency update solution provided by this embodiment, the states of different nodes in the system can be updated at any time to ensure the consistency of the system.
本说明书中各个实施例采用递进的方式描述,每个实施例重点说明的都是与其他实施例的不同之处,各个实施例之间相同相似部分互相参见即可。Each embodiment in this specification is described in a progressive manner, each embodiment focuses on the difference from other embodiments, and the same and similar parts of each embodiment can be referred to each other.
对所公开的实施例的上述说明,使本领域专业技术人员能够实现或使用本发明。对这些实施例的多种修改对本领域的专业技术人员来说将是显而易见的,本文中所定义的一般原理可以在不脱离本发明的精神或范围的情况下,在其它实施例中实现。因此,本发明将不会被限制于本文所示的这些实施例,而是要符合与本文所公开的原理和新颖特点相一致的最宽的范围。The above description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the present invention will not be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610658584.0A CN106302700B (en) | 2016-08-11 | 2016-08-11 | Distributed system consistent update method and system based on paxos algorithm |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610658584.0A CN106302700B (en) | 2016-08-11 | 2016-08-11 | Distributed system consistent update method and system based on paxos algorithm |
Publications (2)
Publication Number | Publication Date |
---|---|
CN106302700A CN106302700A (en) | 2017-01-04 |
CN106302700B true CN106302700B (en) | 2019-09-24 |
Family
ID=57668753
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201610658584.0A Active CN106302700B (en) | 2016-08-11 | 2016-08-11 | Distributed system consistent update method and system based on paxos algorithm |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106302700B (en) |
Families Citing this family (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106802832B (en) * | 2017-01-06 | 2020-04-17 | 网易(杭州)网络有限公司 | Jenkins node state management method and device |
CN107707595B (en) * | 2017-03-17 | 2018-06-15 | 贵州白山云科技有限公司 | A kind of member organizes variation and device |
CN107330035B (en) * | 2017-06-26 | 2020-08-07 | 宁波图灵奇点智能科技有限公司 | Operation log synchronization method in database, mobile terminal and computer readable storage medium |
CN107273169A (en) * | 2017-06-30 | 2017-10-20 | 郑州云海信息技术有限公司 | The on-line software updating method and system of a kind of storage control cluster |
CN109240840B (en) * | 2017-07-11 | 2022-04-19 | 阿里巴巴集团控股有限公司 | Disaster recovery method and device for cluster system and machine readable medium |
CN109144737A (en) * | 2018-10-09 | 2019-01-04 | 郑州云海信息技术有限公司 | Controller management method, apparatus and storage medium in a kind of distributed cluster system |
CN110753005A (en) * | 2019-10-17 | 2020-02-04 | 腾讯科技(深圳)有限公司 | Speed limiting method, device and system, electronic equipment and computer readable storage medium |
CN112202687B (en) * | 2020-12-03 | 2021-05-25 | 苏州浪潮智能科技有限公司 | Node synchronization method, device, equipment and storage medium |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
EP0931422A1 (en) * | 1997-03-21 | 1999-07-28 | Nokia Telecommunications Oy | Method of preventing data inconsistency between master exchange data and backup exchange data |
CN1852198A (en) * | 2005-10-27 | 2006-10-25 | 华为技术有限公司 | Method and system for realizing communication between nodes |
CN102693324A (en) * | 2012-01-09 | 2012-09-26 | 西安电子科技大学 | Distributed database synchronization system, synchronization method and node management method |
CN102821114A (en) * | 2011-06-07 | 2012-12-12 | 南京中兴新软件有限责任公司 | Distributed memory system and implementation method of timestamps thereof |
CN103152221A (en) * | 2013-02-27 | 2013-06-12 | 鸿富锦精密工业(深圳)有限公司 | Multi-equipment self-checking method, monitoring system for equipment state and equipment group |
CN104094248A (en) * | 2012-02-02 | 2014-10-08 | 微软公司 | Self-Update Function in Distributed System |
CN104395891A (en) * | 2012-06-22 | 2015-03-04 | 株式会社东芝 | Distributed database system and its method |
-
2016
- 2016-08-11 CN CN201610658584.0A patent/CN106302700B/en active Active
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
EP0931422A1 (en) * | 1997-03-21 | 1999-07-28 | Nokia Telecommunications Oy | Method of preventing data inconsistency between master exchange data and backup exchange data |
CN1852198A (en) * | 2005-10-27 | 2006-10-25 | 华为技术有限公司 | Method and system for realizing communication between nodes |
CN102821114A (en) * | 2011-06-07 | 2012-12-12 | 南京中兴新软件有限责任公司 | Distributed memory system and implementation method of timestamps thereof |
CN102693324A (en) * | 2012-01-09 | 2012-09-26 | 西安电子科技大学 | Distributed database synchronization system, synchronization method and node management method |
CN104094248A (en) * | 2012-02-02 | 2014-10-08 | 微软公司 | Self-Update Function in Distributed System |
CN104395891A (en) * | 2012-06-22 | 2015-03-04 | 株式会社东芝 | Distributed database system and its method |
CN103152221A (en) * | 2013-02-27 | 2013-06-12 | 鸿富锦精密工业(深圳)有限公司 | Multi-equipment self-checking method, monitoring system for equipment state and equipment group |
Also Published As
Publication number | Publication date |
---|---|
CN106302700A (en) | 2017-01-04 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN106302700B (en) | Distributed system consistent update method and system based on paxos algorithm | |
US11687555B2 (en) | Conditional master election in distributed databases | |
JP6688835B2 (en) | Multi-database log with multi-item transaction support | |
US20200104222A1 (en) | Systems and methods for managing server cluster environments and providing failure recovery therein | |
EP3553669B1 (en) | Failure recovery method and device, and system | |
CN104503845B (en) | A kind of task distribution method and system | |
US20080281938A1 (en) | Selecting a master node in a multi-node computer system | |
CN111538763B (en) | Method for determining master node in cluster, electronic equipment and storage medium | |
US20080071878A1 (en) | Method and system for strong-leader election in a distributed computer system | |
US20140156598A1 (en) | Replication control using eventually consistent meta-data | |
CN115904520B (en) | Configuration preservation method based on PCIE topology state change and related equipment | |
CN103118100A (en) | Guarantee method and guarantee system for improving usability of virtual machine application | |
CN106886450A (en) | Method for scheduling task and system | |
CN107577780A (en) | A data center cloud resource synchronization method and device | |
CN108845872B (en) | Method for implementing software timer for embedded system | |
CN106331081A (en) | A method and device for information synchronization | |
CN112000735B (en) | A data processing method, device and system | |
CN112068940A (en) | Real-time task scheduling method, device, scheduling system and storage medium | |
US9311379B2 (en) | Utilization of data structures to synchronize copies of a resource | |
CN106326042B (en) | Method and device for determining running state | |
CN117312448A (en) | Cluster data synchronization method, system, storage medium and device | |
CN114647448B (en) | A method, device, equipment and storage medium for wake-up communication between multiple single-chip computers | |
CN116418896B (en) | Task execution method, device, equipment and medium based on timer | |
CN115174447B (en) | Network communication method, device, system, equipment and storage medium | |
CN118785204A (en) | Functional module updating method and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |