CN114448843A - A kind of adaptive heartbeat detection method and device, electronic equipment - Google Patents
A kind of adaptive heartbeat detection method and device, electronic equipment Download PDFInfo
- Publication number
- CN114448843A CN114448843A CN202111592662.9A CN202111592662A CN114448843A CN 114448843 A CN114448843 A CN 114448843A CN 202111592662 A CN202111592662 A CN 202111592662A CN 114448843 A CN114448843 A CN 114448843A
- Authority
- CN
- China
- Prior art keywords
- heartbeat message
- heartbeat
- arrival time
- current moment
- message queue
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L43/00—Arrangements for monitoring or testing data switching networks
- H04L43/10—Active monitoring, e.g. heartbeat, ping or trace-route
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L43/00—Arrangements for monitoring or testing data switching networks
- H04L43/50—Testing arrangements
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Health & Medical Sciences (AREA)
- Cardiology (AREA)
- General Health & Medical Sciences (AREA)
- Debugging And Monitoring (AREA)
Abstract
Description
技术领域technical field
本发明涉及云数据库集群系统技术领域,具体涉及一种自适应的心跳检测方法及装置、电子设备。The invention relates to the technical field of cloud database cluster systems, in particular to an adaptive heartbeat detection method and device, and electronic equipment.
背景技术Background technique
随着移动互联网、云计算的时代的到来,各行业应用对数据存储的要求越来越高,传统的单机数据库不足于满足应用在性能、可靠性、可用性等方面的需求,催生了高可用数据库集群系统。一般的高可用数据库集群采用一主多备的集中式管理,集群中一般会设置协调节点、数据节点、代理(Agent)节点三种角色,数据节点主要存储数据,Agent节点监听上报数据节点的健康状态、资源状态,协调节点负责依据Agent上报的状态信息进行集群的维护和任务下发,由Agent处理主备切换、复制搭建、数据备份恢复等任务。一般Agent定时上报心跳,节点的超时时间是固定,在规模化的集群中,存在网络抖动、通信延迟、通信阻塞等情况,特别是在云计算虚拟化环境下尤为明显,会导致节点被误认为是失效的,进而导致集群状态误判触发主备切换等,极大影响应用的读写使用。With the advent of the era of mobile Internet and cloud computing, applications in various industries have higher and higher requirements for data storage. The traditional stand-alone database is not enough to meet the needs of applications in terms of performance, reliability, availability, etc., giving birth to high-availability databases. cluster system. A general high-availability database cluster adopts a centralized management of one master and multiple backups. Generally, three roles of coordination node, data node, and agent node are set in the cluster. The data node mainly stores data, and the agent node monitors and reports the health of the data node. Status, resource status, the coordinating node is responsible for cluster maintenance and task delivery based on the status information reported by the Agent, and the Agent handles tasks such as master-standby switchover, replication setup, data backup and recovery, and so on. Generally, the agent reports the heartbeat regularly, and the timeout time of the node is fixed. In a large-scale cluster, there are network jitter, communication delay, communication blockage, etc., especially in the cloud computing virtualization environment, which will cause the node to be mistaken for It is invalid, which leads to misjudgment of cluster status and triggers active/standby switchover, which greatly affects the read and write usage of applications.
发明内容SUMMARY OF THE INVENTION
因此,本发明要解决的技术问题在于由于在规模化云数据库集群系统中存在网络抖动、通信延迟、通信阻塞等情况导致集群状态误判触发自动切换的问题,从而提供一种自适应的心跳检测方法及装置、电子设备。Therefore, the technical problem to be solved by the present invention is that due to network jitter, communication delay, communication congestion and other conditions in the large-scale cloud database cluster system, the cluster state misjudgment triggers automatic switching problems, thereby providing an adaptive heartbeat detection. Method and device, electronic device.
根据第一方面,本发明实施例公开了一种自适应的心跳检测方法,该方法包括:获取当前时刻的心跳消息队列;根据所述当前时刻的心跳消息队列,确定自适应模型算法方程;根据所述自适应模型算法方程,确定下一心跳消息的预测到达时间;根据所述下一心跳消息的预测到达时间和当前时刻的心跳消息队列,确定下一心跳消息的超时间隔;基于所述下一心跳消息的超时间隔进行下一心跳消息的心跳检测。According to a first aspect, an embodiment of the present invention discloses an adaptive heartbeat detection method. The method includes: acquiring a heartbeat message queue at the current moment; determining an adaptive model algorithm equation according to the heartbeat message queue at the current moment; The algorithm equation of the adaptive model determines the predicted arrival time of the next heartbeat message; according to the predicted arrival time of the next heartbeat message and the heartbeat message queue at the current moment, the timeout interval of the next heartbeat message is determined; The heartbeat detection of the next heartbeat message is performed at the timeout interval of one heartbeat message.
可选地,所述获取当前时刻的心跳消息队列,包括:获取心跳消息到达时间;根据所述心跳消息到达时间进行排列,组成原始心跳消息队列;在当前时刻的心跳消息到达时,将所述当前时刻的心跳消息存储至所述原始心跳消息队列末端并剔除所述原始心跳消息队列中首端的心跳消息,组成当前时刻的心跳消息队列。Optionally, the obtaining the heartbeat message queue at the current moment includes: obtaining the arrival time of the heartbeat message; arranging according to the arrival time of the heartbeat message to form an original heartbeat message queue; when the heartbeat message at the current moment arrives, storing the The heartbeat message at the current moment is stored at the end of the original heartbeat message queue, and the heartbeat message at the head end of the original heartbeat message queue is eliminated to form a heartbeat message queue at the current moment.
可选地,所述根据所述当前时刻的心跳消息队列,确定自适应模型算法方程,包括:根据所述当前时刻的心跳消息队列,将所述心跳消息队列中每一时刻心跳消息的到达时间与该时刻之前的全部心跳消息的到达时间累加计算得到该时刻的累加心跳时间;基于所述当前时刻的心跳消息队列中每一时刻的累加心跳时间,确定第一序列;根据所述第一序列,确定所述自适应模型算法方程。Optionally, determining the adaptive model algorithm equation according to the heartbeat message queue at the current moment includes: according to the heartbeat message queue at the current moment, assigning the arrival time of the heartbeat message at each moment in the heartbeat message queue. Accumulate the arrival time of all heartbeat messages before this moment to obtain the cumulative heartbeat time at this moment; determine the first sequence based on the cumulative heartbeat time at each moment in the heartbeat message queue at the current moment; according to the first sequence , determine the adaptive model algorithm equation.
可选地,所述根据所述自适应模型算法方程,确定下一时刻心跳消息的预测到达时间,包括:对所述自适应模型算法方程求解,确定下一时刻心跳消息到达的预测时间;将所述下一时刻心跳消息到达的预测时间与预设的修正值相加,确定所述下一时刻心跳消息的预测到达时间。Optionally, determining the predicted arrival time of the heartbeat message at the next moment according to the adaptive model algorithm equation includes: solving the adaptive model algorithm equation to determine the predicted arrival time of the heartbeat message at the next moment; The predicted arrival time of the heartbeat message at the next moment is added to a preset correction value to determine the predicted arrival time of the heartbeat message at the next moment.
可选地,所述根据所述下一心跳消息的预测到达时间和当前时刻的心跳消息队列,确定下一心跳消息的超时间隔,包括:将所述下一时刻心跳消息的预测到达时间与所述当前时刻的心跳消息队列中末端心跳消息的到达时间相减,得到所述下一心跳消息的超时间隔。Optionally, determining the time-out interval of the next heartbeat message according to the predicted arrival time of the next heartbeat message and the heartbeat message queue at the current moment includes: comparing the predicted arrival time of the next heartbeat message with all the heartbeat messages. The arrival time of the terminal heartbeat message in the heartbeat message queue at the current moment is subtracted to obtain the timeout interval of the next heartbeat message.
可选地,所述基于所述下一心跳消息的超时间隔进行下一心跳消息的心跳检测,包括:根据所述下一心跳消息的超时间隔,调整下一心跳消息的预计到达时间;当所述下一心跳消息到达后,获取所述下一心跳消息到达时间;当所述下一心跳消息到达时间与所述下一心跳消息的预计到达时间不相同时,确定所述节点失效。Optionally, performing the heartbeat detection of the next heartbeat message based on the timeout interval of the next heartbeat message includes: adjusting the expected arrival time of the next heartbeat message according to the timeout interval of the next heartbeat message; After the next heartbeat message arrives, the arrival time of the next heartbeat message is obtained; when the arrival time of the next heartbeat message is different from the expected arrival time of the next heartbeat message, it is determined that the node is invalid.
可选地,所述基于所述下一心跳消息的超时间隔进行下一心跳消息的心跳检测,还包括:当所述下一心跳消息到达时间与所述下一心跳消息的预计到达时间相同时,确定所述节点为有效节点并更新所述心跳消息队列。Optionally, performing the heartbeat detection of the next heartbeat message based on the timeout interval of the next heartbeat message further includes: when the arrival time of the next heartbeat message is the same as the expected arrival time of the next heartbeat message , determine that the node is a valid node and update the heartbeat message queue.
根据第二方面,本发明实施例还公开了一种自适应的心跳检测装置,该装置包括:获取模块,用于获取当前时刻的心跳消息队列;算法方程确定模块,用于根据所述当前时刻的心跳消息队列,确定自适应模型算法方程;According to a second aspect, an embodiment of the present invention further discloses an adaptive heartbeat detection device, the device includes: an acquisition module for acquiring the heartbeat message queue at the current moment; an algorithm equation determination module for according to the current moment The heartbeat message queue, determine the adaptive model algorithm equation;
到达时间确定模块,用于根据所述自适应模型算法方程,确定下一心跳消息的预测到达时间;A time-of-arrival determination module for determining the predicted arrival time of the next heartbeat message according to the adaptive model algorithm equation;
超时间隔确定模块,用于根据所述下一心跳消息的预测到达时间和当前时刻的心跳消息队列,确定下一心跳消息的超时间隔;检测模块,用于基于所述下一心跳消息的超时间隔进行下一心跳消息的心跳检测。A timeout interval determination module is used to determine the timeout interval of the next heartbeat message according to the predicted arrival time of the next heartbeat message and the heartbeat message queue at the current moment; the detection module is used to determine the timeout interval of the next heartbeat message based on the timeout interval of the next heartbeat message Perform heartbeat detection for the next heartbeat message.
根据第三方面,本发明实施例还公开了一种电子设备,包括:至少一个处理器;以及与所述至少一个处理器通信连接的存储器;其中,所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器执行如第一方面或第一方面任一可选实施方式任一所述的自适应的心跳检测方法的步骤。According to a third aspect, an embodiment of the present invention further discloses an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores data that can be used by the at least one processor. Instructions executed by the processor, the instructions being executed by the at least one processor to cause the at least one processor to execute the adaptive heartbeat according to the first aspect or any of the optional embodiments of the first aspect The steps of the detection method.
根据第四方面,本发明实施方式还公开了一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现如第一方面或第一方面任一可选实施方式所述的自适应的心跳检测方法的步骤。According to a fourth aspect, an embodiment of the present invention further discloses a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, implements the first aspect or any optional implementation of the first aspect The steps of the adaptive heartbeat detection method described in the method.
本发明技术方案,具有如下优点:The technical scheme of the present invention has the following advantages:
1.本发明提供的自适应的心跳检测方法,通过获取当前时刻的心跳消息队列,并根据当前时刻的心跳消息队列,确定自适应模型算法方程,再根据自适应模型算法方程,确定下一心跳消息的预测到达时间,根据下一心跳消息的预测到达时间和当前时刻的心跳消息队列,确定下一心跳消息的超时间隔,并基于下一心跳消息的超时间隔进行下一心跳消息的心跳检测。本发明通过历史心跳信息进行下一次心跳的预测,并通过修正值进行修正,动态调整心跳超时间隔,极大提高了节点检测的灵活性、准确性,极大减少了因为网络抖动、通信延时、通信阻塞等情况出现节点失效误判的情况。1. The self-adaptive heartbeat detection method provided by the present invention, by obtaining the heartbeat message queue at the current moment, and according to the heartbeat message queue at the current moment, determine the adaptive model algorithm equation, then according to the adaptive model algorithm equation, determine the next heartbeat The predicted arrival time of the message, according to the predicted arrival time of the next heartbeat message and the heartbeat message queue at the current moment, determine the timeout interval of the next heartbeat message, and perform the heartbeat detection of the next heartbeat message based on the timeout interval of the next heartbeat message. The present invention predicts the next heartbeat through the historical heartbeat information, and corrects it through the correction value, dynamically adjusts the heartbeat timeout interval, greatly improves the flexibility and accuracy of node detection, and greatly reduces network jitter and communication delay. , communication congestion, etc., the situation of node failure and misjudgment occurs.
2.本发明通过使用心跳消息队列,以滑动窗口的形式保证使用最近最新的心跳信息作为样本进行预测及修正,极大减小了预测误差,提高了节点检测的实时性、准确性。2. The present invention uses the heartbeat message queue to ensure that the latest heartbeat information is used as a sample for prediction and correction in the form of a sliding window, which greatly reduces the prediction error and improves the real-time and accuracy of node detection.
附图说明Description of drawings
为了更清楚地说明本发明具体实施方式或现有技术中的技术方案,下面将对具体实施方式或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施方式,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to illustrate the specific embodiments of the present invention or the technical solutions in the prior art more clearly, the following briefly introduces the accompanying drawings that need to be used in the description of the specific embodiments or the prior art. Obviously, the accompanying drawings in the following description The drawings are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can also be obtained based on these drawings without creative efforts.
图1为本发明实施例中自适应的心跳检测方法的一个流程示意图;1 is a schematic flowchart of an adaptive heartbeat detection method in an embodiment of the present invention;
图2为本发明实施例中自适应的心跳检测方法的一个具体流程图;2 is a specific flowchart of an adaptive heartbeat detection method in an embodiment of the present invention;
图3为本发明实施例中自适应的心跳检测装置的一个结构示意图;3 is a schematic structural diagram of an adaptive heartbeat detection device in an embodiment of the present invention;
图4为本发明实施例中电子设备的一个具体示例图。FIG. 4 is a diagram of a specific example of an electronic device in an embodiment of the present invention.
具体实施方式Detailed ways
下面将结合附图对本发明的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are a part of the embodiments of the present invention, but not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
在本发明的描述中,需要说明的是,术语“中心”、“上”、“下”、“左”、“右”、“竖直”、“水平”、“内”、“外”等指示的方位或位置关系为基于附图所示的方位或位置关系,仅是为了便于描述本发明和简化描述,而不是指示或暗示所指的装置或元件必须具有特定的方位、以特定的方位构造和操作,因此不能理解为对本发明的限制。此外,术语“第一”、“第二”、“第三”仅用于描述目的,而不能理解为指示或暗示相对重要性。In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc. The indicated orientation or positional relationship is based on the orientation or positional relationship shown in the accompanying drawings, which is only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the indicated device or element must have a specific orientation or a specific orientation. construction and operation, and therefore should not be construed as limiting the invention. Furthermore, the terms "first", "second", and "third" are used for descriptive purposes only and should not be construed to indicate or imply relative importance.
在本发明的描述中,需要说明的是,除非另有明确的规定和限定,术语“安装”、“相连”、“连接”应做广义理解,例如,可以是固定连接,也可以是可拆卸连接,或一体地连接;可以是机械连接,也可以是电连接;可以是直接相连,也可以通过中间媒介间接相连,还可以是两个元件内部的连通,可以是无线连接,也可以是有线连接。对于本领域的普通技术人员而言,可以具体情况理解上述术语在本发明中的具体含义。In the description of the present invention, it should be noted that the terms "installed", "connected" and "connected" should be understood in a broad sense, unless otherwise expressly specified and limited, for example, it may be a fixed connection or a detachable connection connection, or integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, or it can be the internal connection of two components, which can be a wireless connection or a wired connection connect. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood in specific situations.
在本发明的描述中,需要说明的是,在本申请说明书和所附权利要求书中使用的术语“及/和/或”是指相关联列出的项中的一个或多个的任何组合以及所有可能组合,并且包括这些组合。此外,下面所描述的本发明不同实施方式中所涉及的技术特征只要彼此之间未构成冲突就可以相互结合。In the description of the invention, it is to be understood that, as used in this specification and the appended claims, the term "and/and/or" refers to any combination of one or more of the associated listed items and all possible combinations, and including those combinations. In addition, the technical features involved in the different embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.
本发明实施例公开了一种自适应的心跳检测方法,如图1所示,该方法包括如下步骤:An embodiment of the present invention discloses an adaptive heartbeat detection method. As shown in FIG. 1 , the method includes the following steps:
步骤101,获取当前时刻的心跳消息队列。Step 101: Obtain the heartbeat message queue at the current moment.
具体的,通过获取历史一定数量的心跳消息到达时间,根据心跳消息到达时间进行排列,将与当前时刻最接近的心跳消息依次放在心跳消息队列的末端,组成原始心跳消息队列,在当前时刻的心跳消息到达时,将所述当前时刻的心跳消息存储至原始心跳消息队列末端并剔除原始心跳消息队列中首端的心跳消息,组成当前时刻的心跳消息队列。Specifically, by obtaining the arrival time of a certain number of heartbeat messages in history, sorting them according to the arrival time of the heartbeat messages, and placing the heartbeat messages closest to the current moment at the end of the heartbeat message queue in order to form the original heartbeat message queue. When the heartbeat message arrives, the heartbeat message at the current moment is stored at the end of the original heartbeat message queue, and the heartbeat message at the head end of the original heartbeat message queue is eliminated to form a heartbeat message queue at the current moment.
示例性的,作为本发明的一种可选实施方式,例如从心跳消息记录队列中取出其最近的k次心跳,假设为m1,m2,...,mk,到达时间分别为t0(1),t0(2),…,t0(k),根据到达时间进行排列组成原始序列t0=(t0(1),t0(2),…,t0(k))。Exemplarily, as an optional implementation of the present invention, for example, the latest k heartbeats are taken from the heartbeat message record queue, assuming m 1 , m 2 , ..., m k , and the arrival times are respectively t 0 (1),t 0 (2),…,t 0 (k), arranged according to the arrival time to form the original sequence t 0 =(t 0 (1),t 0 (2),…,t 0 (k) ).
本发明通过滑动窗口的方法存储心跳消息队列,保证使用最近最新的心跳信息作为样本进行预测及修正,极大减小了预测误差,提高了节点检测的实时性、准确性。The invention stores the heartbeat message queue by the sliding window method, ensures that the latest heartbeat information is used as a sample for prediction and correction, greatly reduces the prediction error, and improves the real-time performance and accuracy of node detection.
步骤102,根据所述当前时刻的心跳消息队列,确定自适应模型算法方程。Step 102: Determine an adaptive model algorithm equation according to the heartbeat message queue at the current moment.
步骤103,根据所述自适应模型算法方程,确定下一心跳消息的预测到达时间。Step 103: Determine the predicted arrival time of the next heartbeat message according to the adaptive model algorithm equation.
步骤104,根据所述下一心跳消息的预测到达时间和当前时刻的心跳消息队列,确定下一心跳消息的超时间隔。Step 104: Determine the timeout interval of the next heartbeat message according to the predicted arrival time of the next heartbeat message and the heartbeat message queue at the current moment.
具体的,根据当前时刻的心跳消息队列,将当前时刻的心跳消息队列中每一时刻心跳消息的到达时间与该时刻之前的全部心跳消息的到达时间累加计算得到该时刻的累加心跳时间,并基于当前时刻的心跳消息队列中每一时刻的累加心跳时间结果按原有顺序组成第一序列,再根据第一序列,确定自适应模型算法方程。并对该自适应模型算法方程求解,得到下一时刻心跳消息到达的预测时间,最终将所述下一时刻心跳消息到达的预测时间和预设的修正值相加,得到下一时刻心跳消息的预测到达时间。最终将下一时刻心跳消息的预测到达时间与当前时刻的心跳消息队列中末端心跳消息的到达时间相减,得到下一心跳消息的超时间隔。Specifically, according to the heartbeat message queue at the current moment, the arrival time of the heartbeat message at each moment in the heartbeat message queue at the current moment and the arrival times of all the heartbeat messages before the moment are cumulatively calculated to obtain the cumulative heartbeat time at the moment, and based on The accumulated heartbeat time results at each moment in the heartbeat message queue at the current moment form a first sequence according to the original sequence, and then determine the adaptive model algorithm equation according to the first sequence. And solve the algorithm equation of the adaptive model, obtain the predicted time of the arrival of the heartbeat message at the next moment, and finally add the predicted time of the arrival of the heartbeat message at the next moment with the preset correction value to obtain the next moment of the heartbeat message. Predicted arrival time. Finally, the predicted arrival time of the heartbeat message at the next moment is subtracted from the arrival time of the heartbeat message at the end of the heartbeat message queue at the current moment to obtain the timeout interval of the next heartbeat message.
示例性的,作为本发明的一种可选实施方式,如图2所示,首先取一定数量最近的历史心跳数据构建成初始序列t0,进而从初始序列t0中通过累加生成法生成第一序列t1,进而对序列t1建立自适应模型算法的微分方程GM(1,1),再对该自适应模型算法的微分方程GM(1,1)求解,求出心跳预测达到时间的第一序列,第一序列中每一个到达时间值加上一个预设的固定的修正值,进而得到最终的心跳消息到达时间预测序列tn,再将该序列tn减去初始序列t0,进而得到超时间隔序列,超时间隔序列中末端的预测超时间隔则为节点下一次心跳的超时间隔。Exemplarily, as an optional embodiment of the present invention, as shown in FIG. 2 , first, a certain number of recent historical heartbeat data are taken to construct an initial sequence t 0 , and then the first sequence t 0 is generated from the initial sequence t 0 by an accumulation generation method. A sequence t 1 , and then the differential equation GM(1,1) of the adaptive model algorithm is established for the sequence t 1 , and then the differential equation GM(1,1) of the adaptive model algorithm is solved to obtain the heartbeat prediction arrival time. In the first sequence, a preset fixed correction value is added to each arrival time value in the first sequence to obtain the final heartbeat message arrival time prediction sequence tn, and then the sequence tn is subtracted from the initial sequence t 0 , and then The timeout interval sequence is obtained, and the predicted timeout interval at the end of the timeout interval sequence is the timeout interval of the next heartbeat of the node.
例如,先构建初始序列:取最近的p次心跳,并将这些心跳道德实践作为初始序列t0,即For example, construct the initial sequence first: take the nearest p heartbeats, and use these heartbeat moral practices as the initial sequence t 0 , i.e.
t0=(t0(1),t0(2),…,t0(p))t 0 =(t 0 (1),t 0 (2),…,t 0 (p))
进而采用累加生成的方法,对初始序列中每一个时间的心跳消息的到达时间与之前的全部心跳消息的到达时间进行累加计算,可以得到每一个时刻的心跳消息累加时间,Then, the method of cumulative generation is used to accumulate the arrival time of the heartbeat message at each time in the initial sequence and the arrival time of all previous heartbeat messages, and the cumulative time of the heartbeat messages at each moment can be obtained.
进而根据心跳消息队列中全部时刻的心跳消息累加时间,生成序列t1,即Then, according to the heartbeat message accumulation time at all times in the heartbeat message queue, a sequence t 1 is generated, that is,
t1=(t1(1),t1(2),…,t1(p))t 1 =(t 1 (1),t 1 (2),...,t 1 (p))
再对序列t1进行积分计算,Then integrate the sequence t 1 ,
dt1(k)=t0(k1)=t1(k)-t1(k-1)dt 1 (k)=t 0 (k1)=t 1 (k)-t 1 (k-1)
进而建立出自适应模型算法的微分方程,Then the differential equation of the adaptive model algorithm is established,
dt1(k)+az1(k)=b,dt 1 (k)+az 1 (k)=b,
其中, in,
再对该自适应模型算法的微分方程求解计算出心跳到达时间预测序列,具体计算过程如下,Then, the differential equation of the adaptive model algorithm is solved to calculate the heartbeat arrival time prediction sequence. The specific calculation process is as follows:
先将k=2,…,p代入微分方程中,得到自适应模型算法的微分方程组,First, substitute k=2,...,p into the differential equation to obtain the differential equation system of the adaptive model algorithm,
通过将该公式转化为y=Bu的形式,其中,By transforming this formula into the form y=Bu, where,
求解a和b得到 Solve for a and b to get
得到预测值 get the predicted value
再加固定修正值c,得到下一次心跳的到达时间,Add a fixed correction value c to get the arrival time of the next heartbeat,
最终通过将计算的心跳到达时间预测序列分别减去初始序列t0的值,得到超时间隔序列,其中超时间隔序列的最后一个值即为节点下一心跳的超时间隔Δt。Finally, by subtracting the value of the initial sequence t 0 from the calculated heartbeat arrival time prediction sequence, the timeout interval sequence is obtained, where the last value of the timeout interval sequence is the timeout interval Δt of the next heartbeat of the node.
其中,a和b为自适应算法模型参数,由历史心跳消息到的的时间确定。Among them, a and b are adaptive algorithm model parameters, which are determined by the arrival time of historical heartbeat messages.
步骤105,基于所述下一心跳消息的超时间隔进行下一心跳消息的心跳检测。
具体的,根据下一心跳消息的超时间隔,调整下一心跳消息的预计到达时间,当下一心跳消息到达后,获取下一心跳消息实际到达时间,将该实际到达时间和预计到达时间进行比较,当下一心跳消息实际到达时间与下一心跳消息的预计到达时间不相同时,确定该节点为失效节点。当下一心跳消息实际到达时间与下一心跳消息的预计到达时间相同时,将该次的心跳消息实际到达时间存储至当前心跳消息队列的末端,再通过新的心跳消息队列预测下一次的心跳消息到达时间,通过不断地持续这种计算方式,可以随时对节点是否失效进行动态检测。Specifically, according to the timeout interval of the next heartbeat message, the expected arrival time of the next heartbeat message is adjusted, and after the next heartbeat message arrives, the actual arrival time of the next heartbeat message is obtained, and the actual arrival time is compared with the expected arrival time, When the actual arrival time of the next heartbeat message is different from the expected arrival time of the next heartbeat message, it is determined that the node is a failed node. When the actual arrival time of the next heartbeat message is the same as the expected arrival time of the next heartbeat message, the actual arrival time of the heartbeat message is stored at the end of the current heartbeat message queue, and the next heartbeat message is predicted through the new heartbeat message queue. Arrival time, by continuously continuing this calculation method, can dynamically detect whether the node fails at any time.
其中,本发明不仅可以应用于云数据库集群系统内节点失效检测,例如高可用数据库系统TELEDB,可以减少因为网络抖动、通信延时、通信阻塞等情况出现节点失效误判的情况,提高了集群的可用性,也可以推广到其他集群系统或者分布式系统领域用于对节点是否失效进行检测。Among them, the present invention can not only be applied to node failure detection in a cloud database cluster system, such as the high-availability database system TELEDB, it can reduce the misjudgment of node failure due to network jitter, communication delay, communication congestion, etc., and improve the cluster performance. Availability can also be extended to other cluster systems or distributed systems to detect whether nodes fail.
本发明通过历史心跳信息进行下一次心跳的预测,并通过修正值进行修正,动态调整心跳超时间隔,极大提高了节点检测的灵活性、准确性,极大减少了因为网络抖动、通信延时、通信阻塞等情况出现节点失效误判的情况,提高了集群的可用性。The present invention predicts the next heartbeat through the historical heartbeat information, and corrects it through the correction value, dynamically adjusts the heartbeat timeout interval, greatly improves the flexibility and accuracy of node detection, and greatly reduces network jitter and communication delay. , communication congestion, etc., the node failure and misjudgment occur, which improves the availability of the cluster.
本发明实施例还公开了一种自适应的心跳检测装置,如图3所示,该装置包括:The embodiment of the present invention also discloses an adaptive heartbeat detection device, as shown in FIG. 3 , the device includes:
获取模块31,用于获取当前时刻的心跳消息队列,详细内容参考步骤101所述;The obtaining module 31 is used to obtain the heartbeat message queue at the current moment, and for details, refer to step 101;
算法方程确定模块32,用于根据所述当前时刻的心跳消息队列,确定自适应模型算法方程,详细内容参考步骤102所述;The algorithm equation determination module 32 is configured to determine the algorithm equation of the adaptive model according to the heartbeat message queue at the current moment. For details, refer to step 102;
到达时间确定模块33,用于根据所述自适应模型算法方程,确定下一心跳消息的预测到达时间,详细内容参考步骤103所述;The arrival time determination module 33 is used to determine the predicted arrival time of the next heartbeat message according to the adaptive model algorithm equation, for details, refer to step 103;
超时间隔确定模块34,用于根据所述下一心跳消息的预测到达时间和当前时刻的心跳消息队列,确定下一心跳消息的超时间隔,详细内容参考步骤104所述;The timeout interval determination module 34 is used to determine the timeout interval of the next heartbeat message according to the predicted arrival time of the next heartbeat message and the heartbeat message queue at the current moment, and the details refer to the description in
检测模块35,用于基于所述下一心跳消息的超时间隔进行下一心跳消息的心跳检测,详细内容参考步骤105所述。The detection module 35 is configured to perform heartbeat detection of the next heartbeat message based on the timeout interval of the next heartbeat message. For details, refer to step 105 .
本发明实施例还提供了一种电子设备,如图4所示,该电子设备包括:处理器401和存储器402,其中处理器401和存储器402可以通过总线或者其他方式连接,图4中以通过总线连接为例;处理器401可以为中央处理器(Central Processing Unit,CPU)。处理器401还可以为其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等芯片,或者上述各类芯片的组合。An embodiment of the present invention also provides an electronic device. As shown in FIG. 4 , the electronic device includes: a
存储器402作为一种非暂态计算机可读存储介质,可用于存储非暂态软件程序、非暂态计算机可执行程序以及模块,如本发明实施例中的自适应的心跳检测方法对应的程序指令/模块。处理器401通过运行存储在存储器402中的非暂态软件程序、指令以及模块,从而执行处理器的各种功能应用以及数据处理,即实现上述方法实施例中的自适应的心跳检测方法。As a non-transitory computer-readable storage medium, the
存储器402可以包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需要的应用程序;存储数据区可存储处理器401所创建的数据等。此外,存储器402可以包括高速随机存取存储器,还可以包括非暂态存储器,例如至少一个磁盘存储器件、闪存器件、或其他非暂态固态存储器件。在一些实施例中,存储器402可选包括相对于处理器401远程设置的存储器,这些远程存储器可以通过网络连接至处理器401。上述网络的实例包括但不限于互联网、企业内部网、局域网、移动通信网及其组合。The
所述一个或者多个模块存储在所述存储器402中,当被所述处理器401执行时,执行如图1-2所示实施例中的自适应的心跳检测方法。The one or more modules are stored in the
上述自适应的心跳检测系统具体细节可以对应参阅图1-2所示的实施例中对应的相关描述和效果进行理解,此处不再赘述。The specific details of the above-mentioned adaptive heartbeat detection system can be understood by referring to the corresponding descriptions and effects in the embodiments shown in FIGS. 1-2 , and details are not repeated here.
本领域技术人员可以理解,实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,所述的程序可存储于一计算机可读取存储介质中,该程序在执行时,可包括如上述各方法的实施例的流程。其中,所述存储介质可为磁碟、光盘、只读存储记忆体(Read-Only Memory,ROM)、随机存储记忆体(RandomAccessMemory,RAM)、快闪存储器(Flash Memory)、硬盘(Hard Disk Drive,缩写:HDD)或固态硬盘(Solid-State Drive,SSD)等;所述存储介质还可以包括上述种类的存储器的组合。Those skilled in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium. During execution, the processes of the embodiments of the above-mentioned methods may be included. Wherein, the storage medium can be a magnetic disk, an optical disk, a read-only memory (Read-Only Memory, ROM), a random access memory (Random Access Memory, RAM), a flash memory (Flash Memory), a hard disk (Hard Disk Drive) , abbreviation: HDD) or solid-state drive (Solid-State Drive, SSD), etc.; the storage medium may also include a combination of the above-mentioned types of memories.
虽然结合附图描述了本发明的实施例,但是本领域技术人员可以在不脱离本发明的精神和范围的情况下作出各种修改和变型,这样的修改和变型均落入由所附权利要求所限定的范围之内。Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, various modifications and variations can be made by those skilled in the art without departing from the spirit and scope of the present invention, such modifications and variations falling within the scope of the appended claims within the limited range.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111592662.9A CN114448843A (en) | 2021-12-23 | 2021-12-23 | A kind of adaptive heartbeat detection method and device, electronic equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111592662.9A CN114448843A (en) | 2021-12-23 | 2021-12-23 | A kind of adaptive heartbeat detection method and device, electronic equipment |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114448843A true CN114448843A (en) | 2022-05-06 |
Family
ID=81363214
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111592662.9A Pending CN114448843A (en) | 2021-12-23 | 2021-12-23 | A kind of adaptive heartbeat detection method and device, electronic equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114448843A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115333983A (en) * | 2022-08-16 | 2022-11-11 | 超聚变数字技术有限公司 | Heartbeat management method and node |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104918267A (en) * | 2014-03-12 | 2015-09-16 | 国家电网公司 | Heartbeat detection method of wireless sensor network and apparatus thereof |
CN108778106A (en) * | 2016-03-11 | 2018-11-09 | 欧利景无线有限公司 | Method, apparatus, server and the system for detecting and monitoring for vital sign |
WO2019161611A1 (en) * | 2018-02-24 | 2019-08-29 | 乐普(北京)医疗器械股份有限公司 | Ecg information processing method and ecg workstation |
CN110535704A (en) * | 2019-08-30 | 2019-12-03 | 西安邮电大学 | A kind of SDN multi-controller fault detection algorithm based on Grey -- Markov algorithm |
US20200057686A1 (en) * | 2018-08-14 | 2020-02-20 | Industrial Technology Research Institute | Compute node, failure detection method thereof and cloud data processing system |
CN112235151A (en) * | 2020-08-27 | 2021-01-15 | 北京计算机技术及应用研究所 | Self-adaptive heartbeat detection method based on time series prediction |
-
2021
- 2021-12-23 CN CN202111592662.9A patent/CN114448843A/en active Pending
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104918267A (en) * | 2014-03-12 | 2015-09-16 | 国家电网公司 | Heartbeat detection method of wireless sensor network and apparatus thereof |
CN108778106A (en) * | 2016-03-11 | 2018-11-09 | 欧利景无线有限公司 | Method, apparatus, server and the system for detecting and monitoring for vital sign |
WO2019161611A1 (en) * | 2018-02-24 | 2019-08-29 | 乐普(北京)医疗器械股份有限公司 | Ecg information processing method and ecg workstation |
US20200057686A1 (en) * | 2018-08-14 | 2020-02-20 | Industrial Technology Research Institute | Compute node, failure detection method thereof and cloud data processing system |
CN110535704A (en) * | 2019-08-30 | 2019-12-03 | 西安邮电大学 | A kind of SDN multi-controller fault detection algorithm based on Grey -- Markov algorithm |
CN112235151A (en) * | 2020-08-27 | 2021-01-15 | 北京计算机技术及应用研究所 | Self-adaptive heartbeat detection method based on time series prediction |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115333983A (en) * | 2022-08-16 | 2022-11-11 | 超聚变数字技术有限公司 | Heartbeat management method and node |
CN115333983B (en) * | 2022-08-16 | 2023-10-10 | 超聚变数字技术有限公司 | Heartbeat management method and node |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10785350B2 (en) | Heartbeat in failover cluster | |
WO2021008285A1 (en) | Data synchronization method and apparatus for distributed system, medium, and electronic device | |
US20180176300A1 (en) | Cross-data center hierarchical consensus scheme with geo-aware leader election | |
TW201742403A (en) | Method and apparatus for node processing in distributed system | |
CN105357069A (en) | Distributed node service state monitoring method, device and system | |
CN104618466A (en) | System for balancing load and controlling overload based on message transfer and control method of system | |
CN114448843A (en) | A kind of adaptive heartbeat detection method and device, electronic equipment | |
CN110750425A (en) | Database monitoring method, device and system and storage medium | |
US20070078809A1 (en) | Robust data availability system having decentralized storage and multiple access paths | |
CN113055203B (en) | Method and device for recovering exception of SDN control plane | |
CN106331081A (en) | A method and device for information synchronization | |
CN113518367B (en) | Fault diagnosis method and system based on service characteristics under 5G network slice | |
CN114844809A (en) | Multi-factor arbitration method and device based on network heartbeat and kernel disk heartbeat | |
CN108833189A (en) | A storage node management system and method | |
JP6551111B2 (en) | Information processing apparatus, down determination method, cluster system, and program | |
CN117675492A (en) | Cluster flow control method, device, equipment and medium | |
EP3391217A1 (en) | Long-running storage manageability operation management | |
CN104580498B (en) | A kind of adaptive cloud management platform | |
CN114297026A (en) | Cloud storage service timeout value optimization method and related equipment for self-adaptive chaotic environment | |
CN113596195A (en) | Public IP address management method, device, main node and storage medium | |
CN107463484B (en) | A method and system for collecting monitoring records | |
CN106302726A (en) | The monitoring method of the management node of a kind of distributed type assemblies data and module | |
CN114448850B (en) | Dialing control method, electronic equipment and dialing control system | |
CN118606357B (en) | Cloud-edge collaborative distributed storage method and device based on double-layer Raft consensus protocol | |
CN113467982B (en) | Abnormal client device determination method and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20220506 |