CN116938881B - Method, system, equipment and readable storage medium for realizing dynamic IP pool - Google Patents
Method, system, equipment and readable storage medium for realizing dynamic IP pool Download PDFInfo
- Publication number
- CN116938881B CN116938881B CN202311196972.8A CN202311196972A CN116938881B CN 116938881 B CN116938881 B CN 116938881B CN 202311196972 A CN202311196972 A CN 202311196972A CN 116938881 B CN116938881 B CN 116938881B
- Authority
- CN
- China
- Prior art keywords
- node
- nodes
- auxiliary
- abnormal
- unit
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 61
- 230000002159 abnormal effect Effects 0.000 claims abstract description 52
- 238000001514 detection method Methods 0.000 claims abstract description 41
- 230000003993 interaction Effects 0.000 claims abstract description 13
- 230000008859 change Effects 0.000 claims abstract description 11
- 238000013515 script Methods 0.000 claims abstract description 10
- 230000000737 periodic effect Effects 0.000 claims abstract description 6
- 238000012545 processing Methods 0.000 claims abstract description 5
- 230000008569 process Effects 0.000 claims description 12
- 238000004590 computer program Methods 0.000 claims description 9
- 230000007246 mechanism Effects 0.000 claims description 9
- 230000026676 system process Effects 0.000 claims description 8
- 125000004122 cyclic group Chemical group 0.000 claims description 3
- 238000004891 communication Methods 0.000 abstract description 11
- 238000012544 monitoring process Methods 0.000 abstract description 2
- 238000005516 engineering process Methods 0.000 abstract 1
- 238000010586 diagram Methods 0.000 description 3
- 230000006872 improvement Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 230000003068 static effect Effects 0.000 description 2
- 238000006467 substitution reaction Methods 0.000 description 2
- KLDZYURQCUYZBL-UHFFFAOYSA-N 2-[3-[(2-hydroxyphenyl)methylideneamino]propyliminomethyl]phenol Chemical compound OC1=CC=CC=C1C=NCCCN=CC1=CC=CC=C1O KLDZYURQCUYZBL-UHFFFAOYSA-N 0.000 description 1
- 241000699670 Mus sp. Species 0.000 description 1
- 230000005856 abnormality Effects 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 201000001098 delayed sleep phase syndrome Diseases 0.000 description 1
- 208000033921 delayed sleep phase type circadian rhythm sleep disease Diseases 0.000 description 1
- 230000001419 dependent effect Effects 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 235000019800 disodium phosphate Nutrition 0.000 description 1
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L61/00—Network arrangements, protocols or services for addressing or naming
- H04L61/50—Address allocation
- H04L61/5007—Internet protocol [IP] addresses
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L61/00—Network arrangements, protocols or services for addressing or naming
- H04L61/50—Address allocation
- H04L61/5061—Pools of addresses
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
- H04L67/1097—Protocols in which an application is distributed across nodes in the network for distributed storage of data in networks, e.g. transport arrangements for network file system [NFS], storage area networks [SAN] or network attached storage [NAS]
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/133—Protocols for remote procedure calls [RPC]
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
本发明提供了一种实现动态IP池的方法、系统、设备及可读存储介质,涉及通信处理技术领域,包括:各节点同时竞争ETCD分布式锁选举出主节点;主节点与副节点通过gRPC进行周期性交互,检测主节点和副节点是否异常,若主节点异常,则重新选举主节点;若副节点异常,则主节点接管副节点IP或将该副节点IP分配给其他正常副节点接管;主节点与副节点分别执行预设检测循环脚本,若自身业务执行异常,则根据预设IP变化处理该节点。本发明基于gRPC+ETCD构架,由ETCD进行主节点竞选,状态监控;通过gRPC通信,将业务检测内容进行规划,明确各类型异常IP接管,使节点出现故障或IP丢失时,本发明仍能实现NAS高可用业务。
The invention provides a method, system, equipment and readable storage medium for realizing a dynamic IP pool, and relates to the field of communication processing technology, including: each node competes for the ETCD distributed lock to elect a master node at the same time; the master node and the slave node pass gRPC Perform periodic interactions to detect whether the primary node and secondary node are abnormal. If the primary node is abnormal, re-elect the primary node; if the secondary node is abnormal, the primary node takes over the secondary node IP or assigns the secondary node IP to other normal secondary nodes to take over. ; The primary node and the secondary node execute the preset detection cycle script respectively. If their own business execution is abnormal, the node will be processed according to the preset IP change. The present invention is based on the gRPC+ETCD architecture, and ETCD performs master node election and status monitoring; through gRPC communication, the business detection content is planned, and various types of abnormal IP takeovers are clarified, so that when a node fails or the IP is lost, the present invention can still be implemented NAS high availability business.
Description
技术领域Technical field
本发明涉及通信处理技术领域,具体而言,涉及一种实现动态IP池的方法、系统、设备及可读存储介质。The present invention relates to the technical field of communication processing, and specifically to a method, system, equipment and readable storage medium for realizing a dynamic IP pool.
背景技术Background technique
现有基于统一分布式存储(UDS)的网络附属存储(NAS)高可用设计架构高度依赖于分布式键值存储系统(ETCD),并且在集群部署的过程中ETCD数据库和NAS存储会混合部署到相同的节点上,ETCD出现故障时伴随着集群节点出现异常,无法完全实现NAS高可用业务和高可用NAS IP的漂移和接管。并且此架构高度绑定ETCD,发现ETCD故障或者集群节点异常后,难以对相关业务进行增加和修改。The existing network-attached storage (NAS) high-availability design architecture based on unified distributed storage (UDS) is highly dependent on the distributed key-value storage system (ETCD), and during the cluster deployment process, the ETCD database and NAS storage will be deployed in a mixed manner. On the same node, when ETCD fails, the cluster node becomes abnormal, and the drift and takeover of the NAS high-availability business and high-availability NAS IP cannot be fully realized. Moreover, this architecture is highly bound to ETCD. After discovering ETCD failure or cluster node abnormality, it is difficult to add and modify related services.
发明内容Contents of the invention
本发明的目的在于提供一种实现动态IP池的方法、系统、设备及可读存储介质,以解决上述问题。为了实现上述目的,本发明采取的技术方案如下:The purpose of the present invention is to provide a method, system, equipment and readable storage medium for realizing a dynamic IP pool, so as to solve the above problems. In order to achieve the above objects, the technical solutions adopted by the present invention are as follows:
第一方面,本申请提供了一种实现动态IP池的方法,用于节点端,包括:集群节点连接分布式键值存储系统,各节点同时竞争分布式键值存储系统的分布式锁选举主节点,获得分布式锁的节点为主节点,其他节点为副节点;通过谷歌远程过程调用协议,主节点与副节点进行周期性交互,检测主节点和副节点是否异常,若主节点异常,则重新选举主节点,得到新的主节点;若副节点异常,则主节点接管副节点IP或将该副节点IP分配给其他正常副节点接管;主节点与副节点分别执行预设检测循环脚本,判断自身业务是否执行异常,若自身业务执行异常,则根据预设IP变化处理该节点。In the first aspect, this application provides a method for implementing a dynamic IP pool for the node side, including: cluster nodes are connected to a distributed key-value storage system, and each node simultaneously competes for the distributed lock of the distributed key-value storage system to elect the master. Node, the node that obtains the distributed lock is the master node, and the other nodes are the slave nodes; through the Google remote procedure call protocol, the master node and the slave node interact periodically to detect whether the master node and the slave node are abnormal. If the master node is abnormal, then Re-elect the primary node to obtain a new primary node; if the secondary node is abnormal, the primary node takes over the secondary node IP or assigns the secondary node IP to other normal secondary nodes to take over; the primary node and the secondary node execute the preset detection cycle scripts respectively. Determine whether its own business execution is abnormal. If its own business execution is abnormal, the node will be processed according to the preset IP change.
第二方面,本申请还提供了一种实现动态IP池的系统,包括:节点选举单元、节点交互单元、接口单元和业务检测单元。所述节点选举单元用于各节点同时竞争分布式键值存储系统的分布式锁选举主节点。所述节点交互单元用于通过谷歌远程过程调用协议,主节点与副节点进行周期性交互。所述接口单元用于输入预设检测循环脚本。所述业务检测单元用于主节点与副节点分别执行预设检测循环脚本,判断自身业务是否执行异常。In the second aspect, this application also provides a system for realizing a dynamic IP pool, including: a node election unit, a node interaction unit, an interface unit and a service detection unit. The node election unit is used for each node to simultaneously compete for the distributed lock of the distributed key-value storage system to elect the master node. The node interaction unit is used for periodic interaction between the primary node and the secondary node through the Google remote procedure call protocol. The interface unit is used to input a preset detection cycle script. The business detection unit is used for the primary node and the secondary node to respectively execute preset detection loop scripts to determine whether their own business execution is abnormal.
第三方面,本申请还提供了一种实现动态IP池的设备,包括:In the third aspect, this application also provides a device for implementing a dynamic IP pool, including:
存储器,用于存储计算机程序;Memory, used to store computer programs;
处理器,用于执行所述计算机程序时实现所述实现动态IP池的方法的步骤。A processor, configured to implement the steps of the method for implementing a dynamic IP pool when executing the computer program.
第四方面,本申请还提供了一种可读存储介质,包括,所述可读存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现所述实现动态IP池的方法的步骤。In a fourth aspect, the present application also provides a readable storage medium, including a computer program stored on the readable storage medium, and when the computer program is executed by a processor, the steps of the method for implementing a dynamic IP pool are implemented. .
本发明的有益效果为:The beneficial effects of the present invention are:
本发明通过基于谷歌远程过程调用协议(gRPC)的分布式键值存储系统(ETCD)架构,由ETCD进行主节点竞选,状态监控,服务发现,负载均衡;通过gRPC框架,将业务检测内容进行规划,明确解决各类型异常接管问题,当节点出现故障或IP丢失时,本发明仍能实现NAS高可用业务。This invention uses a distributed key-value storage system (ETCD) architecture based on Google Remote Procedure Call Protocol (gRPC), and uses ETCD to perform master node election, status monitoring, service discovery, and load balancing; through the gRPC framework, the business detection content is planned , clearly solves various types of abnormal takeover problems. When a node fails or the IP is lost, the present invention can still realize NAS high-availability services.
本发明的其他特征和优点将在随后的说明书阐述,并且,部分地从说明书中变得显而易见,或者通过实施本发明实施例了解。本发明的目的和其他优点可通过在所写的说明书、权利要求书,以及附图中所特别指出的结构来实现和获得。Additional features and advantages of the invention will be set forth in the description which follows, and in part will be apparent from the description, or may be learned by practice of embodiments of the invention. The objectives and other advantages of the invention may be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.
附图说明Description of drawings
为了更清楚地说明本发明实施例的技术方案,下面将对实施例中所需要使用的附图作简单的介绍,应当理解,以下附图仅示出了本发明的某些实施例,因此不应被看作是对范围的限定,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他相关的附图。In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required to be used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and therefore do not It should be regarded as a limitation of the scope. For those of ordinary skill in the art, other relevant drawings can be obtained based on these drawings without exerting creative efforts.
图1为本发明实施中实现动态IP池的方法步骤S100的流程图;Figure 1 is a flow chart of step S100 of the method for implementing a dynamic IP pool in the implementation of the present invention;
图2为本发明实施中实现动态IP池的方法步骤S200的流程图;Figure 2 is a flow chart of step S200 of the method for implementing a dynamic IP pool in the implementation of the present invention;
图3为本发明实施中实现动态IP池的方法步骤S300的流程图;Figure 3 is a flow chart of step S300 of the method for implementing a dynamic IP pool in the implementation of the present invention;
图4为本发明实施中实现动态IP池的系统结构示意图;Figure 4 is a schematic structural diagram of a system for realizing a dynamic IP pool in the implementation of the present invention;
图5为本发明实施中实现动态IP池的设备结构示意图。Figure 5 is a schematic structural diagram of a device for implementing a dynamic IP pool in the implementation of the present invention.
图中标记:Markings in the picture:
400、节点选举单元;500、节点交互单元;600、接口单元;700、业务检测单元;410、创租单元;420、修订单元;430、第一比较单元;440、续租单元;510、上报单元;520、角色提升单元;530、第二比较单元;540、第三比较单元;550、告知单元;560、收集单元;570、分配单元;580、归还单元;710、检测单元;711、业务规划单元;720、第一判断单元;730、第二判断单元;731、IP变化单元;800、实现动态IP池的设备;801、处理器;802、存储器;803、指令输入端口;804、I/O接口;805、通信组件。400. Node election unit; 500. Node interaction unit; 600. Interface unit; 700. Business detection unit; 410. Rent creation unit; 420. Revision unit; 430. First comparison unit; 440. Lease renewal unit; 510. Reporting Unit; 520, role improvement unit; 530, second comparison unit; 540, third comparison unit; 550, notification unit; 560, collection unit; 570, distribution unit; 580, return unit; 710, detection unit; 711, business Planning unit; 720, first judgment unit; 730, second judgment unit; 731, IP change unit; 800, device for realizing dynamic IP pool; 801, processor; 802, memory; 803, instruction input port; 804, I /O interface; 805, communication component.
具体实施方式Detailed ways
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整的描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。通常在此处附图中描述和示出的本发明实施例的组件可以以各种不同的配置来布置和设计。因此,以下对在附图中提供的本发明的实施例的详细描述并非旨在限制要求保护的本发明的范围,而是仅仅表示本发明的选定实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention. Obviously, the described embodiments These are some embodiments of the present invention, rather than all embodiments. The components of the embodiments of the invention generally described and illustrated in the figures herein may be arranged and designed in a variety of different configurations. Therefore, the following detailed description of the embodiments of the invention provided in the appended drawings is not intended to limit the scope of the claimed invention, but rather to represent selected embodiments of the invention. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without making creative efforts fall within the scope of protection of the present invention.
应注意到:相似的标号和字母在下面的附图中表示类似项,因此,一旦某一项在一个附图中被定义,则在随后的附图中不需要对其进行进一步定义和解释。同时,在本发明的描述中,术语“第一”“第二”等仅用于区分描述,而不能理解为指示或暗示相对重要性。It should be noted that similar reference numerals and letters represent similar items in the following figures, therefore, once an item is defined in one figure, it does not need further definition and explanation in subsequent figures. Meanwhile, in the description of the present invention, the terms "first", "second", etc. are only used to differentiate the description and cannot be understood as indicating or implying relative importance.
实施例1:Example 1:
本实施例提供了一种实现动态IP池的方法,用于节点端,包括:This embodiment provides a method for implementing a dynamic IP pool, which is used on the node side and includes:
S100、集群节点连接分布式键值存储系统,各节点同时竞争分布式键值存储系统的分布式锁选举主节点,获得分布式锁的节点为主节点,其他节点为副节点。所述主节点在集群节点中是唯一的,拥有同步、调度分配特权,选举出主节点后,各节点开始执行自身业务。S100, the cluster nodes are connected to the distributed key-value storage system, and each node competes for the distributed lock of the distributed key-value storage system at the same time to elect the master node. The node that obtains the distributed lock is the master node, and the other nodes are deputy nodes. The master node is unique among the cluster nodes and has synchronization, scheduling and distribution privileges. After the master node is elected, each node starts to perform its own business.
S200、通过谷歌远程过程调用协议,主节点与副节点进行周期性交互,检测主节点和副节点是否异常,若主节点异常,则重新选举主节点,得到新的主节点;若副节点异常,则主节点接管副节点IP或将该副节点IP分配给其他正常副节点接管;S200. Through the Google remote procedure call protocol, the primary node and the secondary node interact periodically to detect whether the primary node and the secondary node are abnormal. If the primary node is abnormal, the primary node will be re-elected to obtain a new primary node; if the secondary node is abnormal, Then the primary node takes over the secondary node IP or assigns the secondary node IP to other normal secondary nodes to take over;
S300、主节点与副节点分别执行预设检测循环脚本,判断自身业务是否执行异常,若自身业务执行异常,则根据预设IP变化处理该节点。S300, the primary node and the secondary node respectively execute the preset detection cycle script to determine whether their own business execution is abnormal. If their own business execution is abnormal, the node will be processed according to the preset IP change.
如图1所示,在一些具体实施例中,步骤S100包括步骤S110、步骤S120、步骤S130和步骤S140。As shown in Figure 1, in some specific embodiments, step S100 includes step S110, step S120, step S130 and step S140.
S110、将各节点的机器ID作为相对应的唯一标识符,各节点分别为自己的唯一标识符创建租约;S110. Use the machine ID of each node as the corresponding unique identifier, and each node creates a lease for its own unique identifier;
S120、各节点将自己的标识符和租约写入分布式键值存储系统,根据分布式键值存储系统的修订机制,得到返回的修订值,各节点记录自己的修订值;S120. Each node writes its own identifier and lease into the distributed key-value storage system, obtains the returned revised value according to the revision mechanism of the distributed key-value storage system, and each node records its own revised value;
S130、比较各节点修订值的大小,选取修订值最小的节点获得分布式锁,该节点为主节点,其他节点为副节点;S130. Compare the revision values of each node, and select the node with the smallest revision value to obtain the distributed lock. This node is the primary node and the other nodes are secondary nodes;
S140、主节点通过心跳机制对租约进行续约。S140. The master node renews the lease through the heartbeat mechanism.
步骤S200中所述周期性交互包括副节点定期向主节点上报自身信息和主节点定期收集副节点信息。如图2所示,在一些具体实施例中,步骤S200包括步骤S210、步骤S220、步骤S230、步骤S240、步骤S250、步骤S260、步骤S270和步骤S280。The periodic interaction described in step S200 includes the secondary node regularly reporting its own information to the primary node and the primary node regularly collecting secondary node information. As shown in Figure 2, in some specific embodiments, step S200 includes step S210, step S220, step S230, step S240, step S250, step S260, step S270 and step S280.
S210、当副节点周期性通过谷歌远程过程调用协议向主节点上报自己角色为副节点并且在线时,若上报超时,则判断主节点异常,副节点发起选举;S210. When the secondary node periodically reports to the primary node through the Google remote procedure call protocol that its role is the secondary node and is online, if the report times out, it is determined that the primary node is abnormal and the secondary node initiates an election;
S220、副节点将自身角色提升为竞选者,任期号加1,得到更新任期号;S220. The deputy node promotes its role to a candidate, adds 1 to the term number, and obtains an updated term number;
S230、获取其他节点的任期号,比较更新任期号与其他节点的任期号是否一致,若不一致,则竞选者作为新主节点;S230. Obtain the term number of other nodes, and compare whether the updated term number is consistent with the term number of other nodes. If they are inconsistent, the candidate will be the new primary node;
S240、若一致,则竞选者与其他节点比较IP大小,选取IP大的节点作为新主节点,IP小的节点自动将角色降为副节点;S240. If they are consistent, the candidate compares the IP size with other nodes and selects the node with the larger IP as the new primary node. The node with the smaller IP automatically reduces its role to the deputy node;
需要说明的是,本申请架构为异步模型,存在多个节点同时成为竞选者,且获取到对方尚未更新任期号的情况,因此出现这种情况时,需要集群节点再度竞争分布式锁来避免产生多个主节点。It should be noted that the architecture of this application is an asynchronous model. There are situations where multiple nodes become candidates at the same time and the other party has not updated the term number. Therefore, when this happens, the cluster nodes need to compete for the distributed lock again to avoid the occurrence of Multiple master nodes.
S250、选举出新主节点后,新主节点告知其他节点新主节点的任期号,同步其他节点任期;S250. After the new master node is elected, the new master node informs other nodes of the term number of the new master node and synchronizes the terms of other nodes;
S260、主节点通过谷歌远程过程调用协议定期收集副节点信息;S260, the primary node regularly collects secondary node information through the Google remote procedure call protocol;
S270、若步骤S260中主节点收集某副节点信息超时,则判断该副节点异常,主节点接管副节点IP或将该副节点IP分配给其他正常副节点接管;S270. If the master node times out in collecting a certain slave node information in step S260, it is determined that the slave node is abnormal, and the master node takes over the slave node IP or assigns the slave node IP to other normal slave nodes to take over;
S280、主节点通过步骤S260再次收集该副节点信息,若收集该副节点信息正常,则该副节点IP被接管节点自动归还。S280. The master node collects the secondary node information again through step S260. If the collection of the secondary node information is normal, the secondary node IP is automatically returned by the taken over node.
如图3所示,在一些具体实施例中,步骤S300包括步骤S310、步骤S320和步骤S330。As shown in Figure 3, in some specific embodiments, step S300 includes step S310, step S320 and step S330.
S310、检测节点角色,根据不同的角色调用对应的谷歌远程过程调用协议对节点业务进行循环检测;所述检测包括高可用服务节点状态、高可用配置网卡状态、物理设备状态、网络文件系统进程和信息服务块进程。S310. Detect node roles, and call the corresponding Google remote procedure call protocol according to different roles to perform cyclic detection of node services; the detection includes high-availability service node status, high-availability configuration network card status, physical device status, network file system processes, and Information service block process.
S320、若步骤S310主节点上的检测出现异常,则判断主节点业务执行异常,重新选举主节点;S320. If the detection on the master node in step S310 is abnormal, it is determined that the service execution of the master node is abnormal, and the master node is re-elected;
S330、若步骤S310副节点上的检测出现异常,则判断副节点业务执行异常,主节点根据预设IP变化处理该副节点。S330. If the detection on the secondary node in step S310 is abnormal, it is determined that the service execution of the secondary node is abnormal, and the primary node processes the secondary node according to the preset IP change.
需要说明的是,所述预设IP变化具体包括:It should be noted that the preset IP changes specifically include:
当高可用服务节点暂停时,该节点IP被其他正常节点接管;高可用服务节点恢复时,该节点IP被接管节点自动归还;高可用配置网卡断开时,该节点IP被其他正常节点接管;高可用配置网卡重连时,该节点IP被接管节点自动归还;节点对应的物理设备关机或者重启或者断电时,该节点IP被其他正常节点接管;节点对应的物理设备开机正常运行时,该节点IP被接管节点自动归还;网络文件系统进程停止或者异常时,该节点IP被其他正常节点接管;信息服务块进程停止或者异常时该节点IP被其他正常节点接管。When the high-availability service node is suspended, the node IP is taken over by other normal nodes; when the high-availability service node is restored, the node IP is automatically returned by the taken-over node; when the high-availability configured network card is disconnected, the node IP is taken over by other normal nodes; When the high-availability configuration network card is reconnected, the node IP is automatically returned by the node that took over; when the physical device corresponding to the node is shut down, restarted, or powered off, the node IP is taken over by other normal nodes; when the physical device corresponding to the node is powered on and running normally, the node IP The node IP is automatically returned by the node that is taken over; when the network file system process stops or becomes abnormal, the node IP is taken over by other normal nodes; when the information service block process stops or becomes abnormal, the node IP is taken over by other normal nodes.
在一些具体的实施例中,步骤S140包括步骤S141和步骤S142。In some specific embodiments, step S140 includes step S141 and step S142.
S141、当主节点持有分布式锁的期间节点崩溃,心跳机制停止,唯一标识符将因租约到期而被删除,主节点释放分布式锁,避免死锁;S141. When the master node holds the distributed lock, the node crashes, the heartbeat mechanism stops, the unique identifier will be deleted due to the expiration of the lease, and the master node releases the distributed lock to avoid deadlock;
S142、其余节点竞争分布式锁,选出新的主节点。S142. The remaining nodes compete for the distributed lock and select a new master node.
实施例2:Example 2:
如图4所示,本实施例提供了一种实现动态IP池的系统,包括:As shown in Figure 4, this embodiment provides a system for implementing a dynamic IP pool, including:
节点选举单元400,用于各节点同时竞争分布式键值存储系统的分布式锁选举主节点;The node election unit 400 is used for each node to simultaneously compete for the distributed lock election master node of the distributed key-value storage system;
节点交互单元500,用于通过谷歌远程过程调用协议,主节点与副节点进行周期性交互;The node interaction unit 500 is used for periodic interaction between the primary node and the secondary node through the Google remote procedure call protocol;
接口单元600,用于输入预设检测循环脚本;The interface unit 600 is used to input a preset detection cycle script;
业务检测单元700,用于主节点与副节点分别执行预设检测循环脚本,判断自身业务是否执行异常。The service detection unit 700 is used for the primary node and the secondary node to respectively execute preset detection loop scripts to determine whether their own services are abnormally executed.
在一些具体的实施例中,节点选举单元400包括:In some specific embodiments, the node election unit 400 includes:
创租单元410,用于将各节点的机器ID作为相对应的唯一标识符,各节点分别为自己的唯一标识符创建租约;The rent creation unit 410 is used to use the machine ID of each node as the corresponding unique identifier, and each node creates a lease for its own unique identifier;
修订单元420,用于各节点将自己的标识符和租约写入分布式键值存储系统,根据分布式键值存储系统的修订机制,得到返回的修订值,各节点记录自己的修订值;The revision unit 420 is used for each node to write its own identifier and lease into the distributed key-value storage system, obtain the returned revision value according to the revision mechanism of the distributed key-value storage system, and each node records its own revision value;
第一比较单元430,用于比较各节点修订值的大小,选取修订值最小的节点获得分布式锁,该节点为主节点,其他节点为副节点;The first comparison unit 430 is used to compare the size of the revised value of each node, and select the node with the smallest revised value to obtain the distributed lock. This node is the primary node and the other nodes are secondary nodes;
续租单元440,用于主节点通过心跳机制对租约进行续约。The lease renewal unit 440 is used by the master node to renew the lease through the heartbeat mechanism.
在一些具体的实施例中,节点交互单元500包括:In some specific embodiments, the node interaction unit 500 includes:
上报单元510,用于副节点周期性通过谷歌远程过程调用协议向主节点上报自己角色为副节点并且在线;The reporting unit 510 is used for the secondary node to periodically report to the primary node through the Google remote procedure call protocol that its role is a secondary node and that it is online;
角色提升单元520,用于副节点将自身角色提升为竞选者,任期号加1,得到更新任期号;The role promotion unit 520 is used by the deputy node to promote its own role to a candidate, and the term number is increased by 1 to obtain an updated term number;
第二比较单元530,用于获取其他节点的任期号,比较更新任期号与其他节点的任期号是否一致,若不一致,则竞选者作为新主节点;The second comparison unit 530 is used to obtain the term number of other nodes, and compare whether the updated term number is consistent with the term number of other nodes. If they are inconsistent, the candidate will be regarded as the new master node;
第三比较单元540,用于当所述第二比较单元结果若一致时,竞选者与其他节点比较IP大小,选取IP大的节点作为新主节点,IP小的节点自动将角色降为副节点;The third comparison unit 540 is used to compare the IP size of the candidate with other nodes when the results of the second comparison unit are consistent, and select the node with the larger IP as the new primary node. The node with the smaller IP automatically reduces its role to a secondary node. ;
告知单元550,用于选举出新主节点后,新主节点告知其他节点新主节点的任期号,同步其他节点任期;The notification unit 550 is used to notify other nodes of the term number of the new master node after the new master node is elected, and synchronize the terms of other nodes;
收集单元560,用于主节点通过谷歌远程过程调用协议定期收集副节点信息;Collection unit 560, used by the primary node to regularly collect secondary node information through the Google remote procedure call protocol;
分配单元570,用于当主节点收集某副节点信息超时,主节点接管副节点IP或将该副节点IP分配给其他正常副节点接管;The allocation unit 570 is used for when the master node times out to collect a certain slave node information, the master node takes over the slave node IP or allocates the slave node IP to other normal slave nodes to take over;
归还单元580,用于主节点通过谷歌远程过程调用协议再次收集该副节点信息,当收集该副节点信息正常,则该副节点IP被接管节点自动归还。The return unit 580 is used by the master node to collect the secondary node information again through the Google remote procedure call protocol. When the collection of the secondary node information is normal, the secondary node IP is automatically returned to the taken over node.
在一些具体的实施例中,业务检测单元700包括:In some specific embodiments, the service detection unit 700 includes:
检测单元710,用于检测节点角色,根据不同的角色调用对应的谷歌远程过程调用协议对节点业务进行循环检测;The detection unit 710 is used to detect node roles, and call the corresponding Google remote procedure call protocol according to different roles to perform cyclic detection of node services;
第一判断单元720,用于当主节点上的检测出现异常时,判断主节点业务执行异常,重新选举主节点;The first judgment unit 720 is used to judge that when the detection on the master node is abnormal, the service execution of the master node is abnormal, and the master node is re-elected;
第二判断单元730,用于当副节点上的检测出现异常时,判断副节点业务执行异常,主节点根据预设IP变化处理该副节点。The second judgment unit 730 is used to judge that the service execution of the slave node is abnormal when the detection on the slave node is abnormal, and the master node processes the slave node according to the preset IP change.
在一些具体的实时例中,检测单元710包括:In some specific real-time examples, the detection unit 710 includes:
业务规划单元711,用于规划检测内容,所述检测包括高可用服务节点状态、高可用配置网卡状态、物理设备状态、网络文件系统进程和信息服务块进程;The business planning unit 711 is used to plan detection content. The detection includes high availability service node status, high availability configuration network card status, physical device status, network file system process and information service block process;
在一些具体的实时例中,第二判断单元730包括:In some specific real-time examples, the second judgment unit 730 includes:
IP变化单元731,用于当高可用服务节点暂停时,该节点IP被其他正常节点接管;高可用服务节点恢复时,该节点IP被接管节点自动归还;高可用配置网卡断开时,该节点IP被其他正常节点接管;高可用配置网卡重连时,该节点IP被接管节点自动归还;节点对应的物理设备关机或者重启或者断电时,该节点IP被其他正常节点接管;节点对应的物理设备开机正常运行时,该节点IP被接管节点自动归还;网络文件系统进程停止或者异常时,该节点IP被其他正常节点接管;信息服务块进程停止或者异常时该节点IP被其他正常节点接管。IP change unit 731 is used to when the high availability service node is suspended, the node IP is taken over by other normal nodes; when the high availability service node is restored, the node IP is automatically returned by the taken over node; when the high availability configuration network card is disconnected, the node IP is automatically returned The IP is taken over by other normal nodes; when the high-availability configured network card is reconnected, the node IP is automatically returned by the node that took over; when the physical device corresponding to the node is shut down or restarted or powered off, the node IP is taken over by other normal nodes; the node's corresponding physical When the device is powered on and running normally, the node IP will be automatically returned by the node that has taken over; when the network file system process stops or becomes abnormal, the node IP will be taken over by other normal nodes; when the information service block process stops or becomes abnormal, the node IP will be taken over by other normal nodes.
实施例3:Example 3:
相应于上面的方法实施例,本实施例中还提供了一种实现动态IP池的设备,下文描述的实现动态IP池的设备与上文描述的实现动态IP池的方法可相互对应参照。Corresponding to the above method embodiment, this embodiment also provides a device for implementing a dynamic IP pool. The device for implementing a dynamic IP pool described below and the method for implementing a dynamic IP pool described above may correspond to each other.
图5是根据示例性实施例示出的一种实现动态IP池的设备的框图。如图5所示,该实现动态IP池的设备800包括:处理器801,存储器802。该实现动态IP池的设备还可以包括指令输入端口803,I/O接口804以及通信组件805中的一者或多者。FIG. 5 is a block diagram of a device for implementing a dynamic IP pool according to an exemplary embodiment. As shown in Figure 5, the device 800 for implementing a dynamic IP pool includes: a processor 801 and a memory 802. The device for implementing a dynamic IP pool may also include one or more of an instruction input port 803, an I/O interface 804, and a communication component 805.
其中,处理器801用于控制实现动态IP池的设备的整体操作,以完成上述的实现动态IP池的方法中的全部或部分步骤。存储器802用于存储各种类型的数据以支持在该实现动态IP池的设备的操作,这些数据例如可以包括用于在该实现动态IP池的设备上操作的任何应用程序或方法的指令,以及应用程序相关的数据。该存储器802可以由任何类型的易失性或非易失性存储设备或者它们的组合实现,例如静态随机存取存储器(Static RandomAccess Memory,简称SRAM),电可擦除可编程只读存储器(Electrically ErasableProgrammable Read-Only Memory,简称EEPROM),可擦除可编程只读存储器(ErasableProgrammable Read-Only Memory,简称EPROM),可编程只读存储器(Programmable Read-Only Memory,简称PROM),只读存储器(Read-Only Memory,简称ROM),磁存储器,快闪存储器,磁盘或光盘。指令输入端口803可以包括屏幕和键盘。其中屏幕例如可以是触摸屏,键盘用于输出和/或输入程序指令。所接收的程序指令可以被进一步存储在存储器802或通过通信组件805发送。I/O接口804为处理器801和其他接口模块之间提供接口,上述其他接口模块可以是鼠标,按钮等。这些按钮可以是虚拟按钮或者实体按钮。通信组件805用于该实现动态IP池的设备与其他设备之间进行有线或无线通信。无线通信,例如Wi-Fi,蓝牙,近场通信(Near FieldCommunication,简称NFC),2G、3G或4G,或它们中的一种或几种的组合,因此相应的该通信组件805可以包括:Wi-Fi模块,蓝牙模块,NFC模块。The processor 801 is used to control the overall operation of the device that implements the dynamic IP pool, so as to complete all or part of the steps in the above method for implementing the dynamic IP pool. The memory 802 is used to store various types of data to support operations on the device implementing the dynamic IP pool, which data may include, for example, instructions for any application or method operating on the device implementing the dynamic IP pool, and Application-related data. The memory 802 can be implemented by any type of volatile or non-volatile storage device or their combination, such as static random access memory (Static Random Access Memory, SRAM for short), electrically erasable programmable read-only memory (Electrically erasable programmable read-only memory) ErasableProgrammable Read-Only Memory (EEPROM for short), Erasable Programmable Read-Only Memory (EPROM for short), Programmable Read-Only Memory (PROM for short), Read-Only Memory (Read -Only Memory (ROM for short), magnetic memory, flash memory, magnetic disk or optical disk. The instruction input port 803 may include a screen and a keyboard. The screen may be a touch screen, for example, and the keyboard is used to output and/or input program instructions. The received program instructions may be further stored in memory 802 or sent via communications component 805 . The I/O interface 804 provides an interface between the processor 801 and other interface modules. The other interface modules may be mice, buttons, etc. These buttons can be virtual buttons or physical buttons. The communication component 805 is used for wired or wireless communication between the device that implements the dynamic IP pool and other devices. Wireless communication, such as Wi-Fi, Bluetooth, Near Field Communication (NFC), 2G, 3G or 4G, or one or a combination of them, so the corresponding communication component 805 can include: Wi -Fi module, Bluetooth module, NFC module.
在一示例性实施例中,实现动态IP池的设备800可以被一个或多个应用专用集成电路(Application Specific Integrated Circuit,简称ASIC)、数字信号处理器(DigitalSignal Processor,简称DSP)、数字信号处理设备(Digital Signal ProcessingDevice,简称DSPD)、可编程逻辑器件(Programmable Logic Device,简称PLD)、现场可编程门阵列(Field Programmable Gate Array,简称FPGA)、控制器、微控制器、微处理器或其他电子元件实现,用于执行上述的实现动态IP池的方法。In an exemplary embodiment, the device 800 that implements the dynamic IP pool may be configured by one or more Application Specific Integrated Circuits (ASICs for short), Digital Signal Processors (Digital Signal Processors for short, DSPs for short), digital signal processing Equipment (Digital Signal Processing Device, DSPD for short), Programmable Logic Device (PLD for short), Field Programmable Gate Array (FPGA for short), controller, microcontroller, microprocessor or others Electronic components are implemented for executing the above method of implementing a dynamic IP pool.
实施例4:Example 4:
相应于上面的方法实施例,本实施例中还提供了一种存储介质,所述存储介质为可读存储介质,下文描述的一种可读存储介质与上文描述的实现动态IP池的方法可相互对应参照。Corresponding to the above method embodiment, this embodiment also provides a storage medium, the storage medium is a readable storage medium, a readable storage medium described below and the method for implementing a dynamic IP pool described above can be referenced to each other.
一种可读存储介质,可读存储介质上存储有计算机程序,计算机程序被处理器801执行时实现上述方法实施例的实现动态IP池的方法的步骤。A readable storage medium. A computer program is stored on the readable storage medium. When the computer program is executed by the processor 801, the steps of the method for implementing a dynamic IP pool in the above method embodiment are implemented.
该可读存储介质具体可以为U盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可存储程序代码的可读存储介质。The readable storage medium can specifically be a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (Random Access Memory, RAM), a magnetic disk or an optical disk that can store program codes. readable storage media.
以上所述仅为本发明的优选实施例而已,并不用于限制本发明,对于本领域的技术人员来说,本发明可以有各种更改和变化。凡在本发明的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。The above descriptions are only preferred embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and changes. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention shall be included in the protection scope of the present invention.
以上所述,仅为本发明的具体实施方式,但本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应以权利要求的保护范围为准。The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any person familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed by the present invention. should be covered by the protection scope of the present invention. Therefore, the protection scope of the present invention should be subject to the protection scope of the claims.
Claims (8)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311196972.8A CN116938881B (en) | 2023-09-18 | 2023-09-18 | Method, system, equipment and readable storage medium for realizing dynamic IP pool |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311196972.8A CN116938881B (en) | 2023-09-18 | 2023-09-18 | Method, system, equipment and readable storage medium for realizing dynamic IP pool |
Publications (2)
Publication Number | Publication Date |
---|---|
CN116938881A CN116938881A (en) | 2023-10-24 |
CN116938881B true CN116938881B (en) | 2024-02-09 |
Family
ID=88382907
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202311196972.8A Active CN116938881B (en) | 2023-09-18 | 2023-09-18 | Method, system, equipment and readable storage medium for realizing dynamic IP pool |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116938881B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117573282A (en) * | 2023-11-17 | 2024-02-20 | 中电云计算技术有限公司 | A node election method, device, equipment and storage medium |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111258771A (en) * | 2020-01-16 | 2020-06-09 | 青木数字技术股份有限公司 | Method and system for realizing distributed lock based on Raft algorithm |
CN112866408A (en) * | 2021-02-09 | 2021-05-28 | 山东英信计算机技术有限公司 | Service switching method, device, equipment and storage medium in cluster |
CN113434279A (en) * | 2021-07-14 | 2021-09-24 | 上海浦东发展银行股份有限公司 | Task execution method, device, equipment and storage medium |
CN113596195A (en) * | 2021-08-23 | 2021-11-02 | 重庆紫光华山智安科技有限公司 | Public IP address management method, device, main node and storage medium |
CN113949691A (en) * | 2021-10-15 | 2022-01-18 | 湖南麒麟信安科技股份有限公司 | ETCD-based virtual network address high-availability implementation method and system |
CN114764380A (en) * | 2021-01-15 | 2022-07-19 | 国电南瑞科技股份有限公司 | Distributed cluster control method and device based on ETCD |
CN116319280A (en) * | 2023-03-23 | 2023-06-23 | 中电云数智科技有限公司 | Method for electing master and slave nodes based on kubernetes distributed lock |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20080281938A1 (en) * | 2007-05-09 | 2008-11-13 | Oracle International Corporation | Selecting a master node in a multi-node computer system |
-
2023
- 2023-09-18 CN CN202311196972.8A patent/CN116938881B/en active Active
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111258771A (en) * | 2020-01-16 | 2020-06-09 | 青木数字技术股份有限公司 | Method and system for realizing distributed lock based on Raft algorithm |
CN114764380A (en) * | 2021-01-15 | 2022-07-19 | 国电南瑞科技股份有限公司 | Distributed cluster control method and device based on ETCD |
CN112866408A (en) * | 2021-02-09 | 2021-05-28 | 山东英信计算机技术有限公司 | Service switching method, device, equipment and storage medium in cluster |
CN113434279A (en) * | 2021-07-14 | 2021-09-24 | 上海浦东发展银行股份有限公司 | Task execution method, device, equipment and storage medium |
CN113596195A (en) * | 2021-08-23 | 2021-11-02 | 重庆紫光华山智安科技有限公司 | Public IP address management method, device, main node and storage medium |
CN113949691A (en) * | 2021-10-15 | 2022-01-18 | 湖南麒麟信安科技股份有限公司 | ETCD-based virtual network address high-availability implementation method and system |
CN116319280A (en) * | 2023-03-23 | 2023-06-23 | 中电云数智科技有限公司 | Method for electing master and slave nodes based on kubernetes distributed lock |
Also Published As
Publication number | Publication date |
---|---|
CN116938881A (en) | 2023-10-24 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US8055735B2 (en) | Method and system for forming a cluster of networked nodes | |
CN109656742B (en) | Node exception handling method and device and storage medium | |
CN114064414A (en) | High-availability cluster state monitoring method and system | |
CN109308227A (en) | Fault detection control method and relevant device | |
CN103699420A (en) | System recovery method and system recovery device | |
CN116938881B (en) | Method, system, equipment and readable storage medium for realizing dynamic IP pool | |
CN113377535A (en) | Distributed timing task allocation method, device, equipment and readable storage medium | |
CN112199240A (en) | Method for switching nodes during node failure and related equipment | |
CN115562911B (en) | Virtual machine data backup method, device, system, electronic equipment and storage medium | |
CN110971439A (en) | Policy decision method and device, system, storage medium, policy decision unit and cluster | |
CN113157411B (en) | Celery-based reliable configurable task system and device | |
CN113515316A (en) | Novel edge cloud operating system | |
CN117573306A (en) | Batch task scheduling system, method, device, computer equipment and storage medium | |
CN116055563B (en) | Raft protocol-based task scheduling method, raft protocol-based task scheduling system, electronic equipment and medium | |
JP4796086B2 (en) | Cluster system and method for selecting master node in the same system | |
CN112612635B (en) | Multi-level protection method for application program | |
CN114020279A (en) | Application software distributed deployment method, system, terminal and storage medium | |
CN111291063B (en) | Master and backup copy election method, system, computer equipment and storage medium | |
CN111897626A (en) | Cloud computing scene-oriented virtual machine high-reliability system and implementation method | |
CN115150253B (en) | Fault root cause determining method and device and electronic equipment | |
CN115190052A (en) | Long connection management method, system and control unit | |
CN114764379A (en) | Access switching method and device for application software and computer readable storage medium | |
CN115714713B (en) | Method and device for switching multiple group service instances of electric power monitoring system | |
CN116991591B (en) | Data scheduling method, device and storage medium | |
WO2024119777A1 (en) | Communication link anomaly processing method for frame-based device, frame-based device, and medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
PP01 | Preservation of patent right |
Effective date of registration: 20241115 Granted publication date: 20240209 |
|
PP01 | Preservation of patent right |