[go: up one dir, main page]

CN117081912A - A method, device, equipment and medium for host switching with source address translation - Google Patents

A method, device, equipment and medium for host switching with source address translation Download PDF

Info

Publication number
CN117081912A
CN117081912A CN202311117529.7A CN202311117529A CN117081912A CN 117081912 A CN117081912 A CN 117081912A CN 202311117529 A CN202311117529 A CN 202311117529A CN 117081912 A CN117081912 A CN 117081912A
Authority
CN
China
Prior art keywords
service node
service
node
response
priority table
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311117529.7A
Other languages
Chinese (zh)
Inventor
杨欣雨
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Inspur Jinan data Technology Co ltd
Original Assignee
Inspur Jinan data 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 Inspur Jinan data Technology Co ltd filed Critical Inspur Jinan data Technology Co ltd
Priority to CN202311117529.7A priority Critical patent/CN117081912A/en
Publication of CN117081912A publication Critical patent/CN117081912A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/06Management of faults, events, alarms or notifications
    • H04L41/0654Management of faults, events, alarms or notifications using network fault recovery
    • H04L41/0663Performing the actions predefined by failover planning, e.g. switching to standby network elements
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/08Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters
    • H04L43/0805Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters by checking availability
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/50Queue scheduling
    • H04L47/62Queue scheduling characterised by scheduling criteria
    • H04L47/625Queue scheduling characterised by scheduling criteria for service slots or service orders
    • H04L47/6275Queue scheduling characterised by scheduling criteria for service slots or service orders based on priority

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Environmental & Geological Engineering (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention provides a method, a device, equipment and a readable medium for host switching of source address conversion, wherein the method comprises the following steps: creating a priority table entry in response to the number of service nodes in the cluster being greater than a threshold, and ordering the service nodes in the priority table entry; a BFD bidirectional forwarding detection mechanism is established between every two service nodes, and source address conversion is started in the service node of the first bit of the priority list item; in response to detecting a service node failure, the failed service node is placed in the last bit of the priority table entry, and other service nodes in the priority table entry are shifted forward, and source address translation is initiated in the service node of the first bit of the priority table entry. By using the scheme of the invention, the high availability of the snat function can be improved, and technical staff is not required to be arranged for processing under the condition that the service node fails, so that the manpower resource is effectively reduced.

Description

一种源地址转换的主机切换的方法、装置、设备及介质A method, device, equipment and medium for host switching with source address translation

技术领域Technical field

本发明涉及计算机领域,并且更具体地涉及一种源地址转换的主机切换的方法、装置、设备及可读介质。The present invention relates to the field of computers, and more specifically to a method, device, equipment and readable medium for source address translation and host switching.

背景技术Background technique

随着科技进步与时代发展的不断发展,各个大型企业和组织对云计算的需求量也是越来越大,云计算能够为信息系统运行提供更为高效、灵活、安全、可靠的基础设施,适应运营管理中的海量信息存储、处理、交换及实时数据分析,有效协同各个环节业务,实现信息流、业务流、的高度一体化,极大地提高企业的资源优化配置能力,促进管理运营的高效、安全。With the continuous development of science and technology and the development of the times, various large enterprises and organizations have an increasing demand for cloud computing. Cloud computing can provide a more efficient, flexible, secure and reliable infrastructure for the operation of information systems and adapt to Massive information storage, processing, exchange and real-time data analysis in operation management can effectively coordinate the business in all aspects, achieve a high degree of integration of information flow and business flow, greatly improve the enterprise's ability to optimize resource allocation, and promote the efficiency and efficiency of management operations. Safety.

云计算中的计算和存储资源分别由计算虚拟化和存储虚拟化提供,而网络作为IT的重要资源也有相应的虚拟化技术,网络资源则是由网络虚拟化提供。在虚拟化网络中的Snat(Source Network Address Translation,源地址转换)技术需依附于各个服务计算节点,通过虚拟网络的桥接网络链接虚拟交换机上行链路链接物理交换机来实现与外部网络的通信,当宿主机发生故障或其他通信故障发生时,会导致Snat功能不可用,届时将会导致相关业务受阻,需排除运维人员进行维护与排查。Computing and storage resources in cloud computing are provided by computing virtualization and storage virtualization respectively. As an important IT resource, the network also has corresponding virtualization technology, and network resources are provided by network virtualization. Snat (Source Network Address Translation, source address translation) technology in the virtualized network needs to be attached to each service computing node, and communicates with the external network through the bridge network of the virtual network, the virtual switch uplink link, and the physical switch link. When the host fails or other communication failures occur, the Snat function will be unavailable, which will cause related businesses to be blocked, and operation and maintenance personnel will need to be excluded for maintenance and troubleshooting.

发明内容Contents of the invention

有鉴于此,本发明实施例的目的在于提出一种源地址转换的主机切换的方法、装置、设备及可读介质,通过使用本发明的技术方案,能够提高snat功能高可用性,在服务节点发生故障的情况下无需安排技术人员处理,有效减少人力资源。In view of this, the purpose of the embodiments of the present invention is to propose a method, device, equipment and readable medium for host switching of source address translation. By using the technical solution of the present invention, the high availability of the snat function can be improved. In the event of a failure, there is no need to arrange technical personnel to handle it, effectively reducing human resources.

基于上述目的,本发明的实施例的一个方面提供了一种源地址转换的主机切换的方法,包括以下步骤:Based on the above objectives, one aspect of the embodiment of the present invention provides a method for host switching of source address translation, which includes the following steps:

响应于集群中服务节点的数量大于阈值,创建优先级表项,并将各个服务节点在优先级表项中排序;In response to the number of service nodes in the cluster being greater than the threshold, create a priority table entry and sort each service node in the priority table entry;

在每两个服务节点之间建立BFD(Bidirectional Forwarding Detection,用于检测两个转发点之间故障的网络协议双向转发检测机制),并在优先级表项的第一位的服务节点中开启源地址转换;Establish BFD (Bidirectional Forwarding Detection, a network protocol bidirectional forwarding detection mechanism used to detect failures between two forwarding points) between each two service nodes, and open the source in the service node with the first priority entry address translation;

响应于检测到服务节点故障,将故障的服务节点放置在优先级表项的最后一位,并将优先级表项中其他服务节点向前移位,并在优先级表项的第一位的服务节点中开启源地址转换。In response to detecting a service node failure, the failed service node is placed at the last position of the priority table entry, and other service nodes in the priority table entry are shifted forward and placed at the first position of the priority table entry. Enable source address translation in the service node.

根据本发明的一个实施例,还包括:According to an embodiment of the present invention, it further includes:

基于BFD双向转发检测机制判断服务节点是否发生故障。Determine whether the service node has failed based on the BFD bidirectional forwarding detection mechanism.

根据本发明的一个实施例,基于BFD双向转发检测机制判断服务节点是否发生故障包括:According to an embodiment of the present invention, determining whether a service node fails based on the BFD bidirectional forwarding detection mechanism includes:

BFD双向转发检测机制连接的两个服务节点中的第一服务节点接收第二服务节点发送的数据包;The first service node among the two service nodes connected by the BFD bidirectional forwarding detection mechanism receives the data packet sent by the second service node;

判断在预设时间内第一服务节点是否能够接收到第二服务节点发送的预设数量的数据包;Determine whether the first service node can receive a preset number of data packets sent by the second service node within a preset time;

响应于在预设时间内第一服务节点不能够接收到第二服务节点发送的预设数量的数据包,判断第二服务节点是否为主节点;In response to the first service node being unable to receive the preset number of data packets sent by the second service node within the preset time, determine whether the second service node is the master node;

响应于第二服务节点是主节点,确定主节点发生故障;In response to the second service node being the primary node, determining that the primary node has failed;

响应于第二服务节点不是主节点,确定第二节点未发生故障。In response to the second service node not being the primary node, it is determined that the second node has not failed.

根据本发明的一个实施例,基于BFD双向转发检测机制判断服务节点是否发生故障包括:According to an embodiment of the present invention, determining whether a service node fails based on the BFD bidirectional forwarding detection mechanism includes:

BFD双向转发检测机制连接的两个服务节点中的第一服务节点接收第二服务节点发送的数据包;The first service node among the two service nodes connected by the BFD bidirectional forwarding detection mechanism receives the data packet sent by the second service node;

判断在预设时间内第一服务节点是否能够接收到第二服务节点发送的预设数量的数据包;Determine whether the first service node can receive a preset number of data packets sent by the second service node within a preset time;

响应于在预设时间内第一服务节点不能够接收到第二服务节点发送的预设数量的数据包,判断与第二服务节点建立BFD双向转发检测机制的其他服务节点在预设时间内是否能够接收到第二服务节点发送的预设数量的数据包;In response to the first service node being unable to receive the preset number of data packets sent by the second service node within the preset time, it is determined whether other service nodes that have established a BFD bidirectional forwarding detection mechanism with the second service node within the preset time. Able to receive a preset number of data packets sent by the second service node;

响应于其他服务节点在预设时间内不能够接收到第二服务节点发送的预设数量的数据包,获取在预设时间内不能够接收到第二服务节点发送的预设数量的数据包的其他服务节点的数量;In response to other service nodes being unable to receive the preset number of data packets sent by the second service node within the preset time, obtaining the information that the preset number of data packets sent by the second service node cannot be received within the preset time. The number of other service nodes;

响应于其他服务节点的数量加1的值大于预设值,确定第二服务节点发生故障。In response to the value of the number of other service nodes plus 1 being greater than the preset value, it is determined that the second service node fails.

根据本发明的一个实施例,还包括:According to an embodiment of the present invention, it further includes:

响应于集群中服务节点的数量为2,为每个服务节点配置仲裁IP;In response to the number of service nodes in the cluster being 2, configure the arbitration IP for each service node;

在第一服务节点中开启源地址转换;Enable source address translation in the first service node;

每经过预设时间经由第一服务节点ping仲裁IP;Ping the arbitration IP via the first service node every preset time;

响应于第一服务节点在预设时间内没有接收到预设数量的应答报文,将第一服务节点的源地址转换切换到第二服务节点。In response to the first service node not receiving a preset number of response messages within a preset time, the source address translation of the first service node is switched to the second service node.

根据本发明的一个实施例,响应于第一服务节点在预设时间内没有接收到预设数量的应答报文,将第一服务节点的源地址转换切换到第二服务节点包括:According to an embodiment of the present invention, in response to the first service node not receiving a preset number of response messages within a preset time, switching the source address translation of the first service node to the second service node includes:

响应于第一服务节点在五秒内收到回送请求消息返回的ICMP_ECH0_RELAY(回送响应消息)应答报文小于五个,将第一节点的源地址转换切换到第二服务节点;In response to the first service node receiving less than five ICMP_ECHO_RELAY (echo response message) response messages returned within five seconds from the echo request message, switch the source address translation of the first node to the second service node;

每经过预设时间经由第二服务节点ping仲裁IP。The arbitration IP is pinged through the second service node every preset time.

根据本发明的一个实施例,响应于集群中服务节点的数量超过阈值,建立优先级表项,并将各个服务节点在优先级表项中排序包括:According to an embodiment of the present invention, in response to the number of service nodes in the cluster exceeding a threshold, establishing a priority table entry, and sorting each service node in the priority table entry includes:

获取集群中服务节点的数量,并将获取的数量与阈值进行比较;Obtain the number of service nodes in the cluster and compare the obtained number with the threshold;

响应于获取的数量大于阈值,在集群中创建优先级表项,并将主节点放置在优先级表项的第一位;In response to the number obtained being greater than the threshold, create a priority entry in the cluster and place the master node first in the priority entry;

其余的服务节点通过随机排序的方式在优先级表项中排序。The remaining service nodes are sorted in the priority table entries in a random order.

本发明的实施例的另一个方面,还提供了一种源地址转换的主机切换的装置,装置包括:Another aspect of the embodiment of the present invention also provides a device for source address translation and host switching. The device includes:

创建模块,创建模块配置为响应于集群中服务节点的数量大于阈值,创建优先级表项,并将各个服务节点在优先级表项中排序;Create a module configured to respond to the number of service nodes in the cluster being greater than a threshold, create a priority table entry, and sort each service node in the priority table entry;

建立模块,建立模块配置为在每两个服务节点之间建立BFD双向转发检测机制,并在优先级表项的第一位的服务节点中开启源地址转换;Establish a module. The establishment module is configured to establish a BFD bidirectional forwarding detection mechanism between every two service nodes, and enable source address translation in the service node with the first priority entry;

切换模块,切换模块配置为响应于检测到服务节点故障,将故障的服务节点放置在优先级表项的最后一位,并将优先级表项中其他服务节点向前移位,并在优先级表项的第一位的服务节点中开启源地址转换。The switching module is configured to, in response to detecting a service node failure, place the failed service node at the last position of the priority table entry, and shift other service nodes in the priority table entry forward and place them in the priority table. Enable source address translation in the first service node of the table entry.

本发明的实施例的另一个方面,还提供了一种计算机设备,该计算机设备包括:Another aspect of the embodiments of the present invention also provides a computer device, the computer device includes:

至少一个处理器;以及at least one processor; and

存储器,存储器存储有可在处理器上运行的计算机指令,指令由处理器执行时实现上述任意一项方法的步骤。The memory stores computer instructions that can be run on the processor. When the instructions are executed by the processor, the steps of any of the above methods are implemented.

本发明的实施例的另一个方面,还提供了一种计算机可读存储介质,计算机可读存储介质存储有计算机程序,计算机程序被处理器执行时实现上述任意一项方法的步骤。Another aspect of the embodiments of the present invention also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program. When the computer program is executed by a processor, the steps of any of the above methods are implemented.

本发明具有以下有益技术效果:本发明实施例提供的源地址转换主机切换的方法,通过响应于集群中服务节点的数量大于阈值,创建优先级表项,并将各个服务节点在优先级表项中排序;在每两个服务节点之间建立BFD双向转发检测机制,并在优先级表项的第一位的服务节点中开启源地址转换;响应于检测到服务节点故障,将故障的服务节点放置在优先级表项的最后一位,并将优先级表项中其他服务节点向前移位,并在优先级表项的第一位的服务节点中开启源地址转换的技术方案,能够提高snat功能高可用性,在服务节点发生故障的情况下无需安排技术人员处理,有效减少人力资源。The present invention has the following beneficial technical effects: The source address conversion host switching method provided by the embodiment of the present invention creates a priority table entry in response to the number of service nodes in the cluster being greater than the threshold, and places each service node in the priority table entry. Sort in the middle; establish a BFD bidirectional forwarding detection mechanism between each two service nodes, and enable source address translation in the service node with the first priority entry; in response to detecting a service node failure, the failed service node The technical solution of placing it at the last position of the priority table entry, shifting other service nodes in the priority table entry forward, and enabling source address translation in the first service node of the priority table entry can improve The snat function is highly available. When a service node fails, there is no need to arrange technical personnel to handle it, effectively reducing human resources.

附图说明Description of the drawings

为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的实施例。In order to explain the embodiments of the present invention or the technical solutions in the prior art more clearly, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings in the following description are only These are some embodiments of the present invention. For those of ordinary skill in the art, other embodiments can be obtained based on these drawings without exerting creative efforts.

图1为根据本发明一个实施例的源地址转换主机切换的方法的示意性流程图;Figure 1 is a schematic flow chart of a method for source address translation and host switching according to an embodiment of the present invention;

图2为根据本发明一个实施例的服务节点故障优先级表项变动的示意图;Figure 2 is a schematic diagram of changes in service node failure priority table entries according to an embodiment of the present invention;

图3为根据本发明一个实施例的服务主节点故障Snat宿主机切换的示意图;Figure 3 is a schematic diagram of Snat host switching when the service master node fails according to an embodiment of the present invention;

图4为根据本发明一个实施例的2个服务节点Snat宿主机切换的示意图;Figure 4 is a schematic diagram of Snat host switching between two service nodes according to an embodiment of the present invention;

图5为根据本发明一个实施例的服务节点建立BFD的示意图;Figure 5 is a schematic diagram of a service node establishing BFD according to an embodiment of the present invention;

图6为根据本发明一个实施例的源地址转换主机切换的装置的示意图;Figure 6 is a schematic diagram of a device for source address translation and host switching according to an embodiment of the present invention;

图7为根据本发明一个实施例的计算机设备的示意图;Figure 7 is a schematic diagram of a computer device according to an embodiment of the present invention;

图8为根据本发明一个实施例的计算机可读存储介质的示意图。Figure 8 is a schematic diagram of a computer-readable storage medium according to one embodiment of the present invention.

具体实施方式Detailed ways

为使本发明的目的、技术方案和优点更加清楚明白,以下结合具体实施例,并参照附图,对本发明实施例进一步详细说明。In order to make the purpose, technical solutions and advantages of the present invention more clear, the embodiments of the present invention will be further described in detail below with reference to specific embodiments and the accompanying drawings.

基于上述目的,本发明的实施例的第一个方面,提出了一种源地址转换主机切换的方法的一个实施例。图1示出的是该方法的示意性流程图。Based on the above purpose, a first aspect of the embodiment of the present invention provides an embodiment of a source address translation host switching method. Figure 1 shows a schematic flow chart of the method.

如图1中所示,该方法可以包括以下步骤:As shown in Figure 1, the method may include the following steps:

S1响应于集群中服务节点的数量大于阈值,创建优先级表项,并将各个服务节点在优先级表项中排序。获取集群中服务节点的数量,并将获取的数量与阈值进行比较,在一个实施例中,阈值可以设置为2,如果获取的数量大于阈值,则在集群中创建优先级表项,并将主节点放置在优先级表项的第一位,其余的服务节点通过随机排序的方式在优先级表项中排序。In response to the number of service nodes in the cluster being greater than the threshold, S1 creates a priority table entry and sorts each service node in the priority table entry. Obtain the number of service nodes in the cluster and compare the obtained number with the threshold. In one embodiment, the threshold can be set to 2. If the obtained number is greater than the threshold, create a priority table entry in the cluster and set the primary The node is placed first in the priority table entry, and the remaining service nodes are sorted in the priority table entry in a random order.

S2在每两个服务节点之间建立BFD双向转发检测机制,并在优先级表项的第一位的服务节点中开启源地址转换。S2 establishes a BFD bidirectional forwarding detection mechanism between each two service nodes, and enables source address translation in the service node with the first priority entry.

S3响应于检测到服务节点故障,将故障的服务节点放置在优先级表项的最后一位,并将优先级表项中其他服务节点向前移位,并在优先级表项的第一位的服务节点中开启源地址转换。当发现有主机被断定为发生故障后,所有主机会将优先级表项中该节点标识移放到最后一位,其他节点的主机向前移位,同时保证优先级表项中第一位的服务节点开启源地址转换。如图2所示,最开始的优先级表项为ACDB,当D服务节点的主机发生故障后,将D移动到最后,优先级表项变为ACBD。如图3所示,当Snat宿主节点发生故障后,该节点标识位更新为表项最后位,标识位为C的主机作为第一位,因此标识位为C的主机识别到后开启Snat,标识位为A的主机关闭Snat功能,此时标识位为C的主机为Snat宿主机。In response to detecting a service node failure, S3 places the failed service node at the last position of the priority table entry, and shifts other service nodes forward in the priority table entry, and places it at the first position of the priority table entry. Enable source address translation in the service node. When it is found that a host is judged to be faulty, all hosts will move the node ID in the priority table entry to the last position, and the hosts of other nodes will be moved forward, while ensuring that the first position in the priority table entry is The service node enables source address translation. As shown in Figure 2, the first priority entry is ACDB. When the host of the D service node fails, D is moved to the end and the priority entry becomes ACBD. As shown in Figure 3, when the Snat host node fails, the node identification bit is updated to the last bit of the entry, and the host with the identification bit C is the first. Therefore, the host with the identification bit C is recognized and starts Snat. The host with bit A turns off the Snat function. At this time, the host with the flag bit C is the Snat host.

通过使用本发明的技术方案,能够提高snat功能高可用性,在服务节点发生故障的情况下无需安排技术人员处理,有效减少人力资源。By using the technical solution of the present invention, the high availability of the snat function can be improved, and when the service node fails, there is no need to arrange technical personnel to handle it, effectively reducing human resources.

在本发明的一个优选实施例中,还包括:In a preferred embodiment of the present invention, it also includes:

基于BFD双向转发检测机制判断服务节点是否发生故障。通过BFD双向转发检测可以实现链路的快速检测,BFD通过与上层路由协议联动,可以实现路由的快速收敛,确保业务的永续性。BFD能够与相邻节点建立对等关系,然后每个节点以协商的速率监测来自其他节点的BFD速率,监测速率能够以毫秒级增量设定,当对等节点没有接到预先设定数量的数据包时,则它推断BFD保护的软件或硬件基础设施发生故障。Determine whether the service node has failed based on the BFD bidirectional forwarding detection mechanism. BFD bidirectional forwarding detection can achieve rapid detection of links. BFD can achieve rapid route convergence by linking with upper-layer routing protocols to ensure business continuity. BFD can establish a peer relationship with neighboring nodes, and then each node monitors the BFD rate from other nodes at a negotiated rate. The monitoring rate can be set in millisecond increments. When the peer node does not receive a preset number of packet, it infers that the BFD-protected software or hardware infrastructure has failed.

在本发明的一个优选实施例中,基于BFD双向转发检测机制判断服务节点是否发生故障包括:In a preferred embodiment of the present invention, determining whether a service node fails based on the BFD bidirectional forwarding detection mechanism includes:

BFD双向转发检测机制连接的两个服务节点中的第一服务节点接收第二服务节点发送的数据包;The first service node among the two service nodes connected by the BFD bidirectional forwarding detection mechanism receives the data packet sent by the second service node;

判断在预设时间内第一服务节点是否能够接收到第二服务节点发送的预设数量的数据包;Determine whether the first service node can receive a preset number of data packets sent by the second service node within a preset time;

响应于在预设时间内第一服务节点不能够接收到第二服务节点发送的预设数量的数据包,判断第二服务节点是否为主节点;In response to the first service node being unable to receive the preset number of data packets sent by the second service node within the preset time, determine whether the second service node is the master node;

响应于第二服务节点是主节点,确定主节点发生故障;In response to the second service node being the primary node, determining that the primary node has failed;

响应于第二服务节点不是主节点,确定第二节点未发生故障。每两台服务节点的主机之间建立BFD双向转发检测机制,这两个主机之间相互接收对方发送的数据包,如果在预设时间内接收到的数据包的数量少于预设值,则可以认为对方主机可能存在异常。如果是与主节点连接的服务节点没有接收到预设数量的数据包,则直接认为主节点故障,此时需要将主节点从优先级表项中第一位移动到最后一位,然后将第二位移动到第一位,第三位移动到第二位,依次类推,让后将当前在第一位的主机上开启Snat。如果不是主节点,则不认为服务节点发生故障。在另一个实施例中,如果与服务节点连接的所有其他服务节点在预设时间内都没有接收到预设数量的数据包,则认为该服务节点发生故障。In response to the second service node not being the primary node, it is determined that the second node has not failed. A BFD bidirectional forwarding detection mechanism is established between the hosts of every two service nodes. The two hosts receive data packets sent by each other. If the number of data packets received within the preset time is less than the preset value, then It can be considered that there may be an abnormality in the other party's host. If the service node connected to the master node does not receive the preset number of data packets, it is directly considered that the master node is faulty. At this time, the master node needs to be moved from the first to the last position in the priority table, and then the No. The second position is moved to the first position, the third position is moved to the second position, and so on, and Snat is enabled on the host currently in the first position. A service node is not considered to have failed if it is not the master node. In another embodiment, if all other service nodes connected to a service node do not receive a preset number of data packets within a preset time, the service node is considered to have failed.

在本发明的一个优选实施例中,基于BFD双向转发检测机制判断服务节点是否发生故障包括:In a preferred embodiment of the present invention, determining whether a service node fails based on the BFD bidirectional forwarding detection mechanism includes:

BFD双向转发检测机制连接的两个服务节点中的第一服务节点接收第二服务节点发送的数据包;The first service node among the two service nodes connected by the BFD bidirectional forwarding detection mechanism receives the data packet sent by the second service node;

判断在预设时间内第一服务节点是否能够接收到第二服务节点发送的预设数量的数据包;Determine whether the first service node can receive a preset number of data packets sent by the second service node within a preset time;

响应于在预设时间内第一服务节点不能够接收到第二服务节点发送的预设数量的数据包,判断与第二服务节点建立BFD双向转发检测机制的其他服务节点在预设时间内是否能够接收到第二服务节点发送的预设数量的数据包;In response to the first service node being unable to receive the preset number of data packets sent by the second service node within the preset time, it is determined whether other service nodes that have established a BFD bidirectional forwarding detection mechanism with the second service node within the preset time. Able to receive a preset number of data packets sent by the second service node;

响应于其他服务节点在预设时间内不能够接收到第二服务节点发送的预设数量的数据包,获取在预设时间内不能够接收到第二服务节点发送的预设数量的数据包的其他服务节点的数量;In response to other service nodes being unable to receive the preset number of data packets sent by the second service node within the preset time, obtaining the information that the preset number of data packets sent by the second service node cannot be received within the preset time. The number of other service nodes;

响应于其他服务节点的数量加1的值大于预设值,确定第二服务节点发生故障。在判断节点是否发生故障时,可以根据与该服务节点连接到其他服务节点通信异常的服务节点的数量来确定,具体的,例如,与第一节点连接的有5个节点,这5个节点中有3个节点在预设时间内没有接收到预设数量的数据包时,就认为第一节点发生了故障,此时可以不用区分第一节点是否为主节点。并且上述示例中的具体数值可以根据需要进行设定。In response to the value of the number of other service nodes plus 1 being greater than the preset value, it is determined that the second service node fails. When determining whether a node has failed, it can be determined based on the number of service nodes with abnormal communication between the service node and other service nodes. Specifically, for example, there are 5 nodes connected to the first node, and among these 5 nodes When three nodes do not receive the preset number of data packets within the preset time, the first node is considered to have failed. At this time, there is no need to distinguish whether the first node is the master node. And the specific values in the above examples can be set as needed.

在本发明的一个优选实施例中,还包括:In a preferred embodiment of the present invention, it also includes:

响应于集群中服务节点的数量为2,为每个服务节点配置仲裁IP;In response to the number of service nodes in the cluster being 2, configure the arbitration IP for each service node;

在第一服务节点中开启源地址转换;Enable source address translation in the first service node;

每经过预设时间经由第一服务节点ping仲裁IP;Ping the arbitration IP via the first service node every preset time;

响应于第一服务节点在预设时间内没有接收到预设数量的应答报文,将第一服务节点的源地址转换切换到第二服务节点。In response to the first service node not receiving a preset number of response messages within a preset time, the source address translation of the first service node is switched to the second service node.

在本发明的一个优选实施例中,响应于第一服务节点在预设时间内没有接收到预设数量的应答报文,将第一服务节点的源地址转换切换到第二服务节点包括:In a preferred embodiment of the present invention, in response to the first service node not receiving a preset number of response messages within a preset time, switching the source address of the first service node to the second service node includes:

响应于第一服务节点在五秒内收到回送请求消息返回的ICMP_ECH0_RELAY应答报文小于五个,将第一节点的源地址转换切换到第二服务节点;In response to the first service node receiving less than five ICMP_ECHO_RELAY response messages returned within five seconds from the echo request message, switch the source address translation of the first node to the second service node;

每经过预设时间经由第二服务节点ping仲裁IP。如图4所示,当服务集群中服务节点为2时,为两节点主机配置添加仲裁IP,仲裁IP需要与Snat地址三层可达,且必须是稳定、可靠的、可以ping通的IP,通过仲裁IP连通性决定Snat是否切换,检查机制为五秒内至少收到五个及其以上的浮动IP地址收到ICMP_ECHO_REQUEST返回的ICMP_ECH0_RELAY应答报文,如果没有,则切换Snat宿主机继续检测。The arbitration IP is pinged through the second service node every preset time. As shown in Figure 4, when there are 2 service nodes in the service cluster, add an arbitration IP to the two-node host configuration. The arbitration IP needs to be reachable at three layers with the Snat address, and must be a stable, reliable, and pingable IP. The arbitration IP connectivity is used to determine whether Snat switches. The checking mechanism is to receive ICMP_ECH0_RELAY response messages returned by ICMP_ECHO_REQUEST from at least five floating IP addresses within five seconds. If not, the Snat host is switched to continue detection.

在本发明的一个优选实施例中,响应于集群中服务节点的数量超过阈值,建立优先级表项,并将各个服务节点在优先级表项中排序包括:In a preferred embodiment of the present invention, in response to the number of service nodes in the cluster exceeding the threshold, establishing a priority table, and sorting each service node in the priority table includes:

获取集群中服务节点的数量,并将获取的数量与阈值进行比较;Obtain the number of service nodes in the cluster and compare the obtained number with the threshold;

响应于获取的数量大于阈值,在集群中创建优先级表项,并将主节点放置在优先级表项的第一位;In response to the number obtained being greater than the threshold, create a priority entry in the cluster and place the master node first in the priority entry;

其余的服务节点通过随机排序的方式在优先级表项中排序。如图5所示,阈值可以设置为2,当服务集群中服务节点超过2台时,主节点自动创建优先级表项并与其他互通主机进行周期同步,各节点的主机通过BFD双向转发检测机制提供毫秒级的检测对主节点上报,将主节点优先级排在第一位,然后通过随机排序方式为所有当前检测通信正常的节点进行排序,由当前优先级最高的主机生成优先级表项并同步下发给其他主机,此时每个节点的主机判断优先级表项第一位是否为本机,如果是则开启Snat。The remaining service nodes are sorted in the priority table entries in a random order. As shown in Figure 5, the threshold can be set to 2. When there are more than 2 service nodes in the service cluster, the master node automatically creates a priority table entry and performs periodic synchronization with other interoperable hosts. The hosts of each node pass the BFD bidirectional forwarding detection mechanism. Provides millisecond-level detection and reporting to the master node, ranks the master node priority first, and then sorts all nodes currently detecting normal communication through random sorting. The host with the highest current priority generates a priority table entry and Synchronously deliver it to other hosts. At this time, the host of each node determines whether the first priority entry is the local machine. If so, Snat is enabled.

通过使用本发明的技术方案,能够提高snat功能高可用性,在服务节点发生故障的情况下无需安排技术人员处理,有效减少人力资源。By using the technical solution of the present invention, the high availability of the snat function can be improved, and when the service node fails, there is no need to arrange technical personnel to handle it, effectively reducing human resources.

需要说明的是,本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,可以通过计算机程序来指令相关硬件来完成,上述的程序可存储于计算机可读取存储介质中,该程序在执行时,可包括如上述各方法的实施例的流程。其中存储介质可为磁碟、光盘、只读存储器(Read-Only Memory,ROM)或随机存取存储器(Random AccessMemory,RAM)等。上述计算机程序的实施例,可以达到与之对应的前述任意方法实施例相同或者相类似的效果。It should be noted that those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be implemented by instructing relevant hardware through computer programs. The above programs can be stored in computer-readable storage media. When the program is executed, it may include the processes of the above method embodiments. The storage medium may be a magnetic disk, an optical disk, a read-only memory (Read-Only Memory, ROM) or a random access memory (Random Access Memory, RAM), etc. The foregoing computer program embodiments can achieve the same or similar effects as any of the corresponding foregoing method embodiments.

此外,根据本发明实施例公开的方法还可以被实现为由CPU执行的计算机程序,该计算机程序可以存储在计算机可读存储介质中。在该计算机程序被CPU执行时,执行本发明实施例公开的方法中限定的上述功能。In addition, the method disclosed according to the embodiment of the present invention can also be implemented as a computer program executed by a CPU, and the computer program can be stored in a computer-readable storage medium. When the computer program is executed by the CPU, the above functions defined in the method disclosed in the embodiment of the present invention are performed.

基于上述目的,本发明的实施例的第二个方面,提出了一种源地址转换主机切换的装置,如图6所示,装置200包括:Based on the above purpose, a second aspect of the embodiment of the present invention proposes a device for source address translation and host switching. As shown in Figure 6, the device 200 includes:

创建模块,创建模块配置为响应于集群中服务节点的数量大于阈值,创建优先级表项,并将各个服务节点在优先级表项中排序;Create a module configured to respond to the number of service nodes in the cluster being greater than a threshold, create a priority table entry, and sort each service node in the priority table entry;

建立模块,建立模块配置为在每两个服务节点之间建立BFD双向转发检测机制,并在优先级表项的第一位的服务节点中开启源地址转换;Establish a module. The establishment module is configured to establish a BFD bidirectional forwarding detection mechanism between every two service nodes, and enable source address translation in the service node with the first priority entry;

切换模块,切换模块配置为响应于检测到服务节点故障,将故障的服务节点放置在优先级表项的最后一位,并将优先级表项中其他服务节点向前移位,并在优先级表项的第一位的服务节点中开启源地址转换。The switching module is configured to, in response to detecting a service node failure, place the failed service node at the last position of the priority table entry, and shift other service nodes in the priority table entry forward and place them in the priority table. Enable source address translation in the first service node of the table entry.

基于上述目的,本发明实施例的第三个方面,提出了一种计算机设备。图7示出的是本发明提供的计算机设备的实施例的示意图。如图7所示,本发明实施例包括如下装置:至少一个处理器21;以及存储器22,存储器22存储有可在处理器上运行的计算机指令23,指令由处理器执行时实现以下方法:Based on the above objectives, a third aspect of the embodiments of the present invention provides a computer device. FIG. 7 shows a schematic diagram of an embodiment of a computer device provided by the present invention. As shown in Figure 7, the embodiment of the present invention includes the following device: at least one processor 21; and a memory 22. The memory 22 stores computer instructions 23 that can be run on the processor. When the instructions are executed by the processor, the following methods are implemented:

响应于集群中服务节点的数量大于阈值,创建优先级表项,并将各个服务节点在优先级表项中排序;In response to the number of service nodes in the cluster being greater than the threshold, create a priority table entry and sort each service node in the priority table entry;

在每两个服务节点之间建立BFD双向转发检测机制,并在优先级表项的第一位的服务节点中开启源地址转换;Establish a BFD bidirectional forwarding detection mechanism between each two service nodes, and enable source address translation in the service node with the first priority entry;

响应于检测到服务节点故障,将故障的服务节点放置在优先级表项的最后一位,并将优先级表项中其他服务节点向前移位,并在优先级表项的第一位的服务节点中开启源地址转换。In response to detecting a service node failure, the failed service node is placed at the last position of the priority table entry, and other service nodes in the priority table entry are shifted forward and placed at the first position of the priority table entry. Enable source address translation in the service node.

在本发明的一个优选实施例中,还包括:In a preferred embodiment of the present invention, it also includes:

基于BFD双向转发检测机制判断服务节点是否发生故障。Determine whether the service node has failed based on the BFD bidirectional forwarding detection mechanism.

在本发明的一个优选实施例中,基于BFD双向转发检测机制判断服务节点是否发生故障包括:In a preferred embodiment of the present invention, determining whether a service node fails based on the BFD bidirectional forwarding detection mechanism includes:

BFD双向转发检测机制连接的两个服务节点中的第一服务节点接收第二服务节点发送的数据包;The first service node among the two service nodes connected by the BFD bidirectional forwarding detection mechanism receives the data packet sent by the second service node;

判断在预设时间内第一服务节点是否能够接收到第二服务节点发送的预设数量的数据包;Determine whether the first service node can receive a preset number of data packets sent by the second service node within a preset time;

响应于在预设时间内第一服务节点不能够接收到第二服务节点发送的预设数量的数据包,判断第二服务节点是否为主节点;In response to the first service node being unable to receive the preset number of data packets sent by the second service node within the preset time, determine whether the second service node is the master node;

响应于第二服务节点是主节点,确定主节点发生故障;In response to the second service node being the primary node, determining that the primary node has failed;

响应于第二服务节点不是主节点,确定第二节点未发生故障。In response to the second service node not being the primary node, it is determined that the second node has not failed.

在本发明的一个优选实施例中,基于BFD双向转发检测机制判断服务节点是否发生故障包括:In a preferred embodiment of the present invention, determining whether a service node fails based on the BFD bidirectional forwarding detection mechanism includes:

BFD双向转发检测机制连接的两个服务节点中的第一服务节点接收第二服务节点发送的数据包;The first service node among the two service nodes connected by the BFD bidirectional forwarding detection mechanism receives the data packet sent by the second service node;

判断在预设时间内第一服务节点是否能够接收到第二服务节点发送的预设数量的数据包;Determine whether the first service node can receive a preset number of data packets sent by the second service node within a preset time;

响应于在预设时间内第一服务节点不能够接收到第二服务节点发送的预设数量的数据包,判断与第二服务节点建立BFD双向转发检测机制的其他服务节点在预设时间内是否能够接收到第二服务节点发送的预设数量的数据包;In response to the first service node being unable to receive the preset number of data packets sent by the second service node within the preset time, it is determined whether other service nodes that have established a BFD bidirectional forwarding detection mechanism with the second service node within the preset time. Able to receive a preset number of data packets sent by the second service node;

响应于其他服务节点在预设时间内不能够接收到第二服务节点发送的预设数量的数据包,获取在预设时间内不能够接收到第二服务节点发送的预设数量的数据包的其他服务节点的数量;In response to other service nodes being unable to receive the preset number of data packets sent by the second service node within the preset time, obtaining the information that the preset number of data packets sent by the second service node cannot be received within the preset time. The number of other service nodes;

响应于其他服务节点的数量加1的值大于预设值,确定第二服务节点发生故障。In response to the value of the number of other service nodes plus 1 being greater than the preset value, it is determined that the second service node fails.

在本发明的一个优选实施例中,还包括:In a preferred embodiment of the present invention, it also includes:

响应于集群中服务节点的数量为2,为每个服务节点配置仲裁IP;In response to the number of service nodes in the cluster being 2, configure the arbitration IP for each service node;

在第一服务节点中开启源地址转换;Enable source address translation in the first service node;

每经过预设时间经由第一服务节点ping仲裁IP;Ping the arbitration IP via the first service node every preset time;

响应于第一服务节点在预设时间内没有接收到预设数量的应答报文,将第一服务节点的源地址转换切换到第二服务节点。In response to the first service node not receiving a preset number of response messages within a preset time, the source address translation of the first service node is switched to the second service node.

在本发明的一个优选实施例中,响应于第一服务节点在预设时间内没有接收到预设数量的应答报文,将第一服务节点的源地址转换切换到第二服务节点包括:In a preferred embodiment of the present invention, in response to the first service node not receiving a preset number of response messages within a preset time, switching the source address of the first service node to the second service node includes:

响应于第一服务节点在五秒内收到回送请求消息返回的ICMP_ECH0_RELAY应答报文小于五个,将第一节点的源地址转换切换到第二服务节点;In response to the first service node receiving less than five ICMP_ECHO_RELAY response messages returned within five seconds from the echo request message, switch the source address translation of the first node to the second service node;

每经过预设时间经由第二服务节点ping仲裁IP。The arbitration IP is pinged through the second service node every preset time.

在本发明的一个优选实施例中,响应于集群中服务节点的数量超过阈值,建立优先级表项,并将各个服务节点在优先级表项中排序包括:In a preferred embodiment of the present invention, in response to the number of service nodes in the cluster exceeding the threshold, establishing a priority table, and sorting each service node in the priority table includes:

获取集群中服务节点的数量,并将获取的数量与阈值进行比较;Obtain the number of service nodes in the cluster and compare the obtained number with the threshold;

响应于获取的数量大于阈值,在集群中创建优先级表项,并将主节点放置在优先级表项的第一位;In response to the number obtained being greater than the threshold, create a priority entry in the cluster and place the master node first in the priority entry;

其余的服务节点通过随机排序的方式在优先级表项中排序。The remaining service nodes are sorted in the priority table entries in a random order.

基于上述目的,本发明实施例的第四个方面,提出了一种计算机可读存储介质。图8示出的是本发明提供的计算机可读存储介质的实施例的示意图。如图8所示,计算机可读存储介质31存储有被处理器执行时执行如下方法的计算机程序32:Based on the above objectives, a fourth aspect of the embodiments of the present invention provides a computer-readable storage medium. FIG. 8 shows a schematic diagram of an embodiment of a computer-readable storage medium provided by the present invention. As shown in Figure 8, the computer-readable storage medium 31 stores a computer program 32 that performs the following methods when executed by a processor:

响应于集群中服务节点的数量大于阈值,创建优先级表项,并将各个服务节点在优先级表项中排序;In response to the number of service nodes in the cluster being greater than the threshold, create a priority table entry and sort each service node in the priority table entry;

在每两个服务节点之间建立BFD双向转发检测机制,并在优先级表项的第一位的服务节点中开启源地址转换;Establish a BFD bidirectional forwarding detection mechanism between each two service nodes, and enable source address translation in the service node with the first priority entry;

响应于检测到服务节点故障,将故障的服务节点放置在优先级表项的最后一位,并将优先级表项中其他服务节点向前移位,并在优先级表项的第一位的服务节点中开启源地址转换。In response to detecting a service node failure, the failed service node is placed at the last position of the priority table entry, and other service nodes in the priority table entry are shifted forward and placed at the first position of the priority table entry. Enable source address translation in the service node.

在本发明的一个优选实施例中,还包括:In a preferred embodiment of the present invention, it also includes:

基于BFD双向转发检测机制判断服务节点是否发生故障。Determine whether the service node has failed based on the BFD bidirectional forwarding detection mechanism.

在本发明的一个优选实施例中,基于BFD双向转发检测机制判断服务节点是否发生故障包括:In a preferred embodiment of the present invention, determining whether a service node fails based on the BFD bidirectional forwarding detection mechanism includes:

BFD双向转发检测机制连接的两个服务节点中的第一服务节点接收第二服务节点发送的数据包;The first service node among the two service nodes connected by the BFD bidirectional forwarding detection mechanism receives the data packet sent by the second service node;

判断在预设时间内第一服务节点是否能够接收到第二服务节点发送的预设数量的数据包;Determine whether the first service node can receive a preset number of data packets sent by the second service node within a preset time;

响应于在预设时间内第一服务节点不能够接收到第二服务节点发送的预设数量的数据包,判断第二服务节点是否为主节点;In response to the first service node being unable to receive the preset number of data packets sent by the second service node within the preset time, determine whether the second service node is the master node;

响应于第二服务节点是主节点,确定主节点发生故障;In response to the second service node being the primary node, determining that the primary node has failed;

响应于第二服务节点不是主节点,确定第二节点未发生故障。In response to the second service node not being the primary node, it is determined that the second node has not failed.

在本发明的一个优选实施例中,基于BFD双向转发检测机制判断服务节点是否发生故障包括:In a preferred embodiment of the present invention, determining whether a service node fails based on the BFD bidirectional forwarding detection mechanism includes:

BFD双向转发检测机制连接的两个服务节点中的第一服务节点接收第二服务节点发送的数据包;The first service node among the two service nodes connected by the BFD bidirectional forwarding detection mechanism receives the data packet sent by the second service node;

判断在预设时间内第一服务节点是否能够接收到第二服务节点发送的预设数量的数据包;Determine whether the first service node can receive a preset number of data packets sent by the second service node within a preset time;

响应于在预设时间内第一服务节点不能够接收到第二服务节点发送的预设数量的数据包,判断与第二服务节点建立BFD双向转发检测机制的其他服务节点在预设时间内是否能够接收到第二服务节点发送的预设数量的数据包;In response to the first service node being unable to receive the preset number of data packets sent by the second service node within the preset time, it is determined whether other service nodes that have established a BFD bidirectional forwarding detection mechanism with the second service node within the preset time. Able to receive a preset number of data packets sent by the second service node;

响应于其他服务节点在预设时间内不能够接收到第二服务节点发送的预设数量的数据包,获取在预设时间内不能够接收到第二服务节点发送的预设数量的数据包的其他服务节点的数量;In response to other service nodes being unable to receive the preset number of data packets sent by the second service node within the preset time, obtaining the information that the preset number of data packets sent by the second service node cannot be received within the preset time. The number of other service nodes;

响应于其他服务节点的数量加1的值大于预设值,确定第二服务节点发生故障。In response to the value of the number of other service nodes plus 1 being greater than the preset value, it is determined that the second service node fails.

在本发明的一个优选实施例中,还包括:In a preferred embodiment of the present invention, it also includes:

响应于集群中服务节点的数量为2,为每个服务节点配置仲裁IP;In response to the number of service nodes in the cluster being 2, configure the arbitration IP for each service node;

在第一服务节点中开启源地址转换;Enable source address translation in the first service node;

每经过预设时间经由第一服务节点ping仲裁IP;Ping the arbitration IP via the first service node every preset time;

响应于第一服务节点在预设时间内没有接收到预设数量的应答报文,将第一服务节点的源地址转换切换到第二服务节点。In response to the first service node not receiving a preset number of response messages within a preset time, the source address translation of the first service node is switched to the second service node.

在本发明的一个优选实施例中,响应于第一服务节点在预设时间内没有接收到预设数量的应答报文,将第一服务节点的源地址转换切换到第二服务节点包括:In a preferred embodiment of the present invention, in response to the first service node not receiving a preset number of response messages within a preset time, switching the source address of the first service node to the second service node includes:

响应于第一服务节点在五秒内收到回送请求消息返回的ICMP_ECH0_RELAY应答报文小于五个,将第一节点的源地址转换切换到第二服务节点;In response to the first service node receiving less than five ICMP_ECHO_RELAY response messages returned within five seconds from the echo request message, switch the source address translation of the first node to the second service node;

每经过预设时间经由第二服务节点ping仲裁IP。The arbitration IP is pinged through the second service node every preset time.

在本发明的一个优选实施例中,响应于集群中服务节点的数量超过阈值,建立优先级表项,并将各个服务节点在优先级表项中排序包括:In a preferred embodiment of the present invention, in response to the number of service nodes in the cluster exceeding the threshold, establishing a priority table, and sorting each service node in the priority table includes:

获取集群中服务节点的数量,并将获取的数量与阈值进行比较;Obtain the number of service nodes in the cluster and compare the obtained number with the threshold;

响应于获取的数量大于阈值,在集群中创建优先级表项,并将主节点放置在优先级表项的第一位;In response to the number obtained being greater than the threshold, create a priority entry in the cluster and place the master node first in the priority entry;

其余的服务节点通过随机排序的方式在优先级表项中排序。The remaining service nodes are sorted in the priority table entries in a random order.

此外,根据本发明实施例公开的方法还可以被实现为由处理器执行的计算机程序,该计算机程序可以存储在计算机可读存储介质中。在该计算机程序被处理器执行时,执行本发明实施例公开的方法中限定的上述功能。In addition, the method disclosed according to the embodiment of the present invention can also be implemented as a computer program executed by a processor, and the computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the above functions defined in the method disclosed in the embodiment of the present invention are performed.

此外,上述方法步骤以及系统单元也可以利用控制器以及用于存储使得控制器实现上述步骤或单元功能的计算机程序的计算机可读存储介质实现。In addition, the above-mentioned method steps and system units can also be implemented using a controller and a computer-readable storage medium for storing a computer program that enables the controller to implement the above-mentioned steps or unit functions.

本领域技术人员还将明白的是,结合这里的公开所描述的各种示例性逻辑块、模块、电路和算法步骤可以被实现为电子硬件、计算机软件或两者的组合。为了清楚地说明硬件和软件的这种可互换性,已经就各种示意性组件、方块、模块、电路和步骤的功能对其进行了一般性的描述。这种功能是被实现为软件还是被实现为硬件取决于具体应用以及施加给整个系统的设计约束。本领域技术人员可以针对每种具体应用以各种方式来实现的功能,但是这种实现决定不应被解释为导致脱离本发明实施例公开的范围。Those of skill would further appreciate that the various illustrative logical blocks, modules, circuits, and algorithm steps described in connection with the disclosure herein may be implemented as electronic hardware, computer software, or combinations of both. To clearly illustrate this interchangeability of hardware and software, various illustrative components, blocks, modules, circuits and steps have been described generally in terms of their functionality. Whether this functionality is implemented as software or hardware depends on the specific application and the design constraints imposed on the overall system. Those skilled in the art may implement the functionality in various ways for each specific application, but such implementation decisions should not be interpreted as causing a departure from the scope of the disclosed embodiments of the present invention.

在一个或多个示例性设计中,功能可以在硬件、软件、固件或其任意组合中实现。如果在软件中实现,则可以将功能作为一个或多个指令或代码存储在计算机可读介质上或通过计算机可读介质来传送。计算机可读介质包括计算机存储介质和通信介质,该通信介质包括有助于将计算机程序从一个位置传送到另一个位置的任何介质。存储介质可以是能够被通用或专用计算机访问的任何可用介质。作为例子而非限制性的,该计算机可读介质可以包括RAM、ROM、EEPROM、CD-ROM或其它光盘存储设备、磁盘存储设备或其它磁性存储设备,或者是可以用于携带或存储形式为指令或数据结构的所需程序代码并且能够被通用或专用计算机或者通用或专用处理器访问的任何其它介质。此外,任何连接都可以适当地称为计算机可读介质。例如,如果使用同轴线缆、光纤线缆、双绞线、数字用户线路(DSL)或诸如红外线、无线电和微波的无线技术来从网站、服务器或其它远程源发送软件,则上述同轴线缆、光纤线缆、双绞线、DSL或诸如红外线、无线电和微波的无线技术均包括在介质的定义。如这里所使用的,磁盘和光盘包括压缩盘(CD)、激光盘、光盘、数字多功能盘(DVD)、软盘、蓝光盘,其中磁盘通常磁性地再现数据,而光盘利用激光光学地再现数据。上述内容的组合也应当包括在计算机可读介质的范围内。In one or more example designs, functionality may be implemented in hardware, software, firmware, or any combination thereof. If implemented in software, the functionality may be stored on or transmitted over as one or more instructions or code on a computer-readable medium. Computer-readable media includes computer storage media and communication media including any medium that facilitates transfer of a computer program from one place to another. Storage media can be any available media that can be accessed by a general purpose or special purpose computer. By way of example and not limitation, the computer-readable medium may include RAM, ROM, EEPROM, CD-ROM or other optical disk storage devices, magnetic disk storage devices or other magnetic storage devices, or may be used to carry or store instructions in the form of or any other medium containing the required program code for the data structures and capable of being accessed by a general-purpose or special-purpose computer or a general-purpose or special-purpose processor. Also, any connection is properly termed a computer-readable medium. For example, if coaxial cable, fiber optic cable, twisted pair, digital subscriber line (DSL), or wireless technologies such as infrared, radio, and microwave are used to deliver software from a website, server, or other remote source, the coaxial cable Cable, fiber optic cable, twisted pair, DSL or wireless technologies such as infrared, radio and microwave are included in the definition of media. As used herein, disks and optical disks include compact disks (CDs), laser disks, optical disks, digital versatile disks (DVDs), floppy disks, and Blu-ray disks, where disks typically reproduce data magnetically, while optical disks reproduce data optically using lasers. . Combinations of the above should also be included within the scope of computer-readable media.

以上是本发明公开的示例性实施例,但是应当注意,在不背离权利要求限定的本发明实施例公开的范围的前提下,可以进行多种改变和修改。根据这里描述的公开实施例的方法权利要求的功能、步骤和/或动作不需以任何特定顺序执行。此外,尽管本发明实施例公开的元素可以以个体形式描述或要求,但除非明确限制为单数,也可以理解为多个。The above are exemplary embodiments disclosed by the present invention, but it should be noted that various changes and modifications can be made without departing from the scope of the disclosed embodiments of the present invention defined by the claims. The functions, steps and/or actions of the method claims in accordance with the disclosed embodiments described herein need not be performed in any particular order. In addition, although the elements disclosed in the embodiments of the present invention may be described or claimed in individual form, they may also be understood as plural unless expressly limited to the singular.

应当理解的是,在本文中使用的,除非上下文清楚地支持例外情况,单数形式“一个”旨在也包括复数形式。还应当理解的是,在本文中使用的“和/或”是指包括一个或者一个以上相关联地列出的项目的任意和所有可能组合。It will be understood that, as used herein, the singular form "a" and "an" are intended to include the plural form as well, unless the context clearly supports an exception. It will also be understood that as used herein, "and/or" is meant to include any and all possible combinations of one or more of the associated listed items.

上述本发明实施例公开实施例序号仅仅为了描述,不代表实施例的优劣。The embodiment numbers disclosed in the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

本领域普通技术人员可以理解实现上述实施例的全部或部分步骤可以通过硬件来完成,也可以通过程序来指令相关的硬件完成,程序可以存储于一种计算机可读存储介质中,上述提到的存储介质可以是只读存储器,磁盘或光盘等。Those of ordinary skill in the art can understand that all or part of the steps to implement the above embodiments can be completed by hardware, or can be completed by instructing the relevant hardware through a program. The program can be stored in a computer-readable storage medium. The above-mentioned The storage medium can be a read-only memory, a magnetic disk or an optical disk, etc.

所属领域的普通技术人员应当理解:以上任何实施例的讨论仅为示例性的,并非旨在暗示本发明实施例公开的范围(包括权利要求)被限于这些例子;在本发明实施例的思路下,以上实施例或者不同实施例中的技术特征之间也可以进行组合,并存在如上的本发明实施例的不同方面的许多其它变化,为了简明它们没有在细节中提供。因此,凡在本发明实施例的精神和原则之内,所做的任何省略、修改、等同替换、改进等,均应包含在本发明实施例的保护范围之内。Those of ordinary skill in the art should understand that the above discussion of any embodiments is only illustrative, and is not intended to imply that the scope of the disclosure of the embodiments of the present invention (including the claims) is limited to these examples; under the thinking of the embodiments of the present invention , the above embodiments or technical features in different embodiments can also be combined, and there are many other changes in different aspects of the above embodiments of the present invention, which are not provided in details for the sake of simplicity. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the embodiments of the present invention shall be included in the protection scope of the embodiments of the present invention.

Claims (10)

1.一种源地址转换的主机切换的方法,其特征在于,包括以下步骤:1. A method of host switching for source address translation, characterized by comprising the following steps: 响应于集群中服务节点的数量大于阈值,创建优先级表项,并将各个服务节点在优先级表项中排序;In response to the number of service nodes in the cluster being greater than the threshold, create a priority table entry and sort each service node in the priority table entry; 在每两个服务节点之间建立BFD双向转发检测机制,并在优先级表项的第一位的服务节点中开启源地址转换;Establish a BFD bidirectional forwarding detection mechanism between each two service nodes, and enable source address translation in the service node with the first priority entry; 响应于检测到服务节点故障,将故障的服务节点放置在优先级表项的最后一位,并将优先级表项中其他服务节点向前移位,并在优先级表项的第一位的服务节点中开启源地址转换。In response to detecting a service node failure, the failed service node is placed at the last position of the priority table entry, and other service nodes in the priority table entry are shifted forward and placed at the first position of the priority table entry. Enable source address translation in the service node. 2.根据权利要求1所述的方法,其特征在于,还包括:2. The method of claim 1, further comprising: 基于BFD双向转发检测机制判断服务节点是否发生故障。Determine whether the service node has failed based on the BFD bidirectional forwarding detection mechanism. 3.根据权利要求2所述的方法,其特征在于,基于BFD双向转发检测机制判断服务节点是否发生故障包括:3. The method according to claim 2, wherein determining whether the service node fails based on the BFD bidirectional forwarding detection mechanism includes: BFD双向转发检测机制连接的两个服务节点中的第一服务节点接收第二服务节点发送的数据包;The first service node among the two service nodes connected by the BFD bidirectional forwarding detection mechanism receives the data packet sent by the second service node; 判断在预设时间内第一服务节点是否能够接收到第二服务节点发送的预设数量的数据包;Determine whether the first service node can receive a preset number of data packets sent by the second service node within a preset time; 响应于在预设时间内第一服务节点不能够接收到第二服务节点发送的预设数量的数据包,判断第二服务节点是否为主节点;In response to the first service node being unable to receive the preset number of data packets sent by the second service node within the preset time, determine whether the second service node is the master node; 响应于第二服务节点是主节点,确定主节点发生故障;In response to the second service node being the primary node, determining that the primary node has failed; 响应于第二服务节点不是主节点,确定第二节点未发生故障。In response to the second service node not being the primary node, it is determined that the second node has not failed. 4.根据权利要求2所述的方法,其特征在于,基于BFD双向转发检测机制判断服务节点是否发生故障包括:4. The method according to claim 2, wherein determining whether the service node fails based on the BFD bidirectional forwarding detection mechanism includes: BFD双向转发检测机制连接的两个服务节点中的第一服务节点接收第二服务节点发送的数据包;The first service node among the two service nodes connected by the BFD bidirectional forwarding detection mechanism receives the data packet sent by the second service node; 判断在预设时间内第一服务节点是否能够接收到第二服务节点发送的预设数量的数据包;Determine whether the first service node can receive a preset number of data packets sent by the second service node within a preset time; 响应于在预设时间内第一服务节点不能够接收到第二服务节点发送的预设数量的数据包,判断与第二服务节点建立BFD双向转发检测机制的其他服务节点在预设时间内是否能够接收到第二服务节点发送的预设数量的数据包;In response to the first service node being unable to receive the preset number of data packets sent by the second service node within the preset time, it is determined whether other service nodes that have established a BFD bidirectional forwarding detection mechanism with the second service node within the preset time. Able to receive a preset number of data packets sent by the second service node; 响应于其他服务节点在预设时间内不能够接收到第二服务节点发送的预设数量的数据包,获取在预设时间内不能够接收到第二服务节点发送的预设数量的数据包的其他服务节点的数量;In response to other service nodes being unable to receive the preset number of data packets sent by the second service node within the preset time, obtaining the information that the preset number of data packets sent by the second service node cannot be received within the preset time. The number of other service nodes; 响应于其他服务节点的数量加1的值大于预设值,确定第二服务节点发生故障。In response to the value of the number of other service nodes plus 1 being greater than the preset value, it is determined that the second service node fails. 5.根据权利要求1所述的方法,其特征在于,还包括:5. The method of claim 1, further comprising: 响应于集群中服务节点的数量为2,为每个服务节点配置仲裁IP;In response to the number of service nodes in the cluster being 2, configure the arbitration IP for each service node; 在第一服务节点中开启源地址转换;Enable source address translation in the first service node; 每经过预设时间经由第一服务节点ping仲裁IP;Ping the arbitration IP via the first service node every preset time; 响应于第一服务节点在预设时间内没有接收到预设数量的应答报文,将第一服务节点的源地址转换切换到第二服务节点。In response to the first service node not receiving a preset number of response messages within a preset time, the source address translation of the first service node is switched to the second service node. 6.根据权利要求5所述的方法,其特征在于,响应于第一服务节点在预设时间内没有接收到预设数量的应答报文,将第一服务节点的源地址转换切换到第二服务节点包括:6. The method according to claim 5, characterized in that, in response to the first service node not receiving a preset number of response messages within a preset time, switching the source address translation of the first service node to the second Service nodes include: 响应于第一服务节点在五秒内收到回送请求消息返回的ICMP_ECH0_RELAY应答报文小于五个,将第一节点的源地址转换切换到第二服务节点;In response to the first service node receiving less than five ICMP_ECHO_RELAY response messages returned within five seconds from the echo request message, switch the source address translation of the first node to the second service node; 每经过预设时间经由第二服务节点ping仲裁IP。The arbitration IP is pinged through the second service node every preset time. 7.根据权利要求1所述的方法,其特征在于,响应于集群中服务节点的数量超过阈值,建立优先级表项,并将各个服务节点在优先级表项中排序包括:7. The method according to claim 1, characterized in that, in response to the number of service nodes in the cluster exceeding a threshold, establishing a priority table entry, and sorting each service node in the priority table entry includes: 获取集群中服务节点的数量,并将获取的数量与阈值进行比较;Obtain the number of service nodes in the cluster and compare the obtained number with the threshold; 响应于获取的数量大于阈值,在集群中创建优先级表项,并将主节点放置在优先级表项的第一位;In response to the number obtained being greater than the threshold, create a priority entry in the cluster and place the master node first in the priority entry; 其余的服务节点通过随机排序的方式在优先级表项中排序。The remaining service nodes are sorted in the priority table entries in a random order. 8.一种源地址转换的主机切换的装置,其特征在于,所述装置包括:8. A device for source address translation and host switching, characterized in that the device includes: 创建模块,所述创建模块配置为响应于集群中服务节点的数量大于阈值,创建优先级表项,并将各个服务节点在优先级表项中排序;Create a module, the creation module is configured to create a priority table entry in response to the number of service nodes in the cluster being greater than a threshold, and sort each service node in the priority table entry; 建立模块,所述建立模块配置为在每两个服务节点之间建立BFD双向转发检测机制,并在优先级表项的第一位的服务节点中开启源地址转换;Establishing a module, the establishing module is configured to establish a BFD bidirectional forwarding detection mechanism between every two service nodes, and enable source address translation in the service node with the first priority entry; 切换模块,所述切换模块配置为响应于检测到服务节点故障,将故障的服务节点放置在优先级表项的最后一位,并将优先级表项中其他服务节点向前移位,并在优先级表项的第一位的服务节点中开启源地址转换。A switching module, the switching module is configured to, in response to detecting a service node failure, place the failed service node in the last position of the priority table entry, and shift other service nodes forward in the priority table entry, and place the failed service node in the last position of the priority table entry. Enable source address translation on the service node with the first priority entry. 9.一种计算机设备,其特征在于,包括:9. A computer device, characterized in that it includes: 至少一个处理器;以及at least one processor; and 存储器,所述存储器存储有可在所述处理器上运行的计算机指令,所述指令由所述处理器执行时实现权利要求1-7任意一项所述方法的步骤。A memory that stores computer instructions executable on the processor, and when executed by the processor, the instructions implement the steps of the method of any one of claims 1-7. 10.一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现权利要求1-7任意一项所述方法的步骤。10. A computer-readable storage medium, the computer-readable storage medium stores a computer program, characterized in that, when the computer program is executed by a processor, the steps of the method described in any one of claims 1-7 are implemented.
CN202311117529.7A 2023-08-31 2023-08-31 A method, device, equipment and medium for host switching with source address translation Pending CN117081912A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311117529.7A CN117081912A (en) 2023-08-31 2023-08-31 A method, device, equipment and medium for host switching with source address translation

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311117529.7A CN117081912A (en) 2023-08-31 2023-08-31 A method, device, equipment and medium for host switching with source address translation

Publications (1)

Publication Number Publication Date
CN117081912A true CN117081912A (en) 2023-11-17

Family

ID=88719421

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311117529.7A Pending CN117081912A (en) 2023-08-31 2023-08-31 A method, device, equipment and medium for host switching with source address translation

Country Status (1)

Country Link
CN (1) CN117081912A (en)

Similar Documents

Publication Publication Date Title
JP4256825B2 (en) Automatic network configuration for monitoring
CN105024855B (en) Distributed type assemblies manage system and method
CN100452759C (en) Ip redundancy with improved failover notification
US8270306B2 (en) Fault management apparatus and method for identifying cause of fault in communication network
TWI383616B (en) Method and system for assigning a plurality of macs to a plurality of processors
US8438307B2 (en) Method and device of load-sharing in IRF stack
CN106330475B (en) A method and device for managing active and standby nodes in a communication system and a high-availability cluster
US9385944B2 (en) Communication system, path switching method and communication device
CN112787960B (en) Stack splitting processing method, device and equipment and storage medium
CN103036702B (en) A kind of N+1 backup method of cross-network segment and device
CN104283780A (en) Method and device for establishing data transmission route
CN108769199A (en) A kind of distributed file storage system host node management method and device
EP4029203B1 (en) Determining connectivity between compute nodes in multi-hop paths
US10819628B1 (en) Virtual link trunking control of virtual router redundancy protocol master designation
CN115604160A (en) Network detection processing method and device, electronic equipment and storage medium
CN104935614A (en) A data transmission method and device
WO2020177471A1 (en) Message transmission method, apparatus and storage medium
CN116248581B (en) Cloud scene gateway cluster master-slave switching method and system based on SDN
CN117081912A (en) A method, device, equipment and medium for host switching with source address translation
CN114268581B (en) Method for realizing high availability and load sharing of network equipment
CN109361781B (en) Message forwarding method, device, server, system and storage medium
CN114124803A (en) Device management method, device, electronic device and storage medium
CN113805788A (en) A distributed storage system and its exception handling method and related device
JPH11331231A (en) Multiplex network system and its communication equipment
CN104796276B (en) A kind of link switch-over method and system

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