WO2021098259A1 - 一种集群网卡的确定方法、装置、设备及可读存储介质 - Google Patents
一种集群网卡的确定方法、装置、设备及可读存储介质 Download PDFInfo
- Publication number
- WO2021098259A1 WO2021098259A1 PCT/CN2020/103698 CN2020103698W WO2021098259A1 WO 2021098259 A1 WO2021098259 A1 WO 2021098259A1 CN 2020103698 W CN2020103698 W CN 2020103698W WO 2021098259 A1 WO2021098259 A1 WO 2021098259A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- cluster
- network segment
- network
- data
- network card
- Prior art date
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
- H04L67/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/10—Protocols in which an application is distributed across nodes in the network
- H04L67/104—Peer-to-peer [P2P] networks
- H04L67/1044—Group management mechanisms
- H04L67/1048—Departure or maintenance mechanisms
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L69/00—Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
- H04L69/40—Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass for recovering from a failure of a protocol instance or entity, e.g. service redundancy protocols, protocol state redundancy or protocol service redirection
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L2101/00—Indexing scheme associated with group H04L61/00
- H04L2101/60—Types of network addresses
- H04L2101/618—Details of network addresses
- H04L2101/659—Internet protocol version 6 [IPv6] addresses
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L2101/00—Indexing scheme associated with group H04L61/00
- H04L2101/60—Types of network addresses
- H04L2101/668—Internet protocol [IP] address subnets
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L2101/00—Indexing scheme associated with group H04L61/00
- H04L2101/60—Types of network addresses
- H04L2101/695—Types of network addresses using masks or ranges of 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/5007—Internet protocol [IP] addresses
Definitions
- This application relates to the technical field of distributed storage clusters, and more specifically, to a method, device, equipment, and computer-readable storage medium for determining a cluster network card.
- a distributed storage cluster is a cluster composed of multiple storage node servers, which supports a piece of data to be stored on multiple nodes, and each node can obtain complete data through inter-node communication. When the node is down, the complete data can be restored according to the configuration strategy.
- each node contains CTDB, which is a high-availability management software used to monitor the status of cluster nodes and the allocation of virtual IP.
- CTDB is a high-availability management software used to monitor the status of cluster nodes and the allocation of virtual IP.
- the virtual IP assigned to the node will be Drift to other nodes, the read and write services of the failed node will correspondingly drift to other nodes, so that the cluster constitutes a highly available cluster.
- CTDB starts and monitors the cluster network card
- each node needs to find the cluster network card of the node to facilitate real-time monitoring of the cluster network card, so that CTDB can promptly notify the cluster to perform failover when the cluster network card fails. Reduce the impact on client services.
- the cluster network card is the network card used for communication among the various modules (mainly OSD modules) in the cluster, that is, the network card where the Cluster IP (the IP used for the communication of the OSD module in the cluster) is located.
- the Cluster IP the IP used for the communication of the OSD module in the cluster
- the purpose of this application is to provide a method, device, equipment, and computer-readable storage medium for determining cluster network cards, which are used to automatically and accurately determine the cluster network card of the node, so as to facilitate real-time monitoring of the cluster network card.
- a method for determining a cluster network card includes:
- obtaining the IP and network card corresponding to the type of the network segment of the Cluster IP on the current node includes:
- the network segment of each IP is calculated, the network segment of each IP is compared with the address string, and the IP corresponding to the network segment that is the same as the address string is determined as Cluster IP, include:
- the first value is compared with the second value, and when the first value is the same as the second value, the IP corresponding to the first value is determined as the Cluster IP; wherein, the first value
- the second value is the bitwise AND operation of the third integer data and the converted mask.
- the third integer data is the shift processing and pressing of the address string in the network segment of the Cluster IP. It is obtained by bitwise AND operation.
- obtaining the IP and network card corresponding to the type of the network segment of the Cluster IP on the current node includes:
- the method further includes:
- the network segment of each IP is calculated, and the network segment of each IP is compared with the address character The string is compared, and the IP corresponding to the same network segment as the address string is determined as the Cluster IP, including:
- the second data is the IP address of the Cluster IP Obtained by converting the mask in the network segment, the second data prefix is in the form of a continuous 1 and contains four elements;
- the first data after the operation is compared with the third data. If the data in the first data after the operation is the same as the data in the second data after the operation, then the first data after the operation is corresponding to the The IP is determined as the Cluster IP; wherein, the third data is the conversion of the address string in the network segment of the Cluster IP into IP address data, and the conversion and storage of the IP address data into four integer data Got in.
- a device for determining a cluster network card includes:
- the reading module is used to read the network segment of the Cluster IP from the configuration file of the current node;
- the first determining module is configured to determine the type of the network segment of the Cluster IP through the address string in the network segment of the Cluster IP;
- An obtaining module configured to obtain an IP and a network card corresponding to the type of the network segment of the Cluster IP on the current node;
- the second determining module is used to calculate the network segment of each IP, compare the network segment of each IP with the address string, and determine the IP corresponding to the network segment that is the same as the address string Is the Cluster IP, and the network card where the Cluster IP is located is determined as the cluster network card.
- the acquisition module includes:
- the first obtaining unit is configured to obtain the IP and network card corresponding to the IPv4 network segment on the current node through an ioctl function when the type of the network segment of the Cluster IP is an IPv4 network segment.
- a determination device for a cluster network card including:
- Memory used to store computer programs
- the processor is configured to implement the steps of the method for determining a cluster network card as described in any one of the foregoing when executing the computer program.
- This application provides a method, device, device, and computer-readable storage medium for determining a cluster network card, where the method includes: reading the network segment of the Cluster IP from the configuration file of the current node; passing the network segment of the Cluster IP The address string determines the type of the network segment of the Cluster IP; obtains the IP and network card corresponding to the type of the network segment of the Cluster IP on the current node; calculates the network segment of each IP, and compares the network segment of each IP with the address string , And determine the IP determined by the network segment that is the same as the address string as the Cluster IP, and determine the network card where the Cluster IP is located as the cluster network card.
- the above technical solution disclosed in this application reads the network segment of the Cluster IP, determines the type of the network segment of the Cluster IP through the address string in the network segment of the Cluster IP, and obtains the IP corresponding to the type of the network segment of the Cluster IP And the network segment, and then calculate the network segment of each IP, and determine the IP corresponding to the network segment with the same address string in the network segment of the Cluster IP as the Cluster IP, and determine the network card where the Cluster IP is located as the cluster network card , In order to realize automatically find the cluster network card according to the configuration file, and accurately determine the Cluster IP and the cluster network card by comparing the network segment of each IP in the current node with the address string in the network segment of the Cluster IP, so as to facilitate the real-time performance of the cluster network card
- the monitoring of the cluster makes it easy to notify the cluster in time and perform failover when the cluster network card fails to ensure the high availability of the cluster.
- FIG. 1 is a flowchart of a method for determining a cluster network card according to an embodiment of the application
- FIG. 2 is a flowchart of filtering out the cluster network card from the IP of the current section in the IPv4 environment according to an embodiment of the application;
- FIG. 3 is a flowchart of filtering out the cluster network card from the IP of the current section in the IPv6 environment according to an embodiment of the application;
- FIG. 4 is a schematic structural diagram of an apparatus for determining a cluster network card provided by an embodiment of the application
- Figure 5 is a schematic structural diagram of a cluster network card determining device provided by an embodiment of the application.
- FIG. 1 shows a flowchart of a method for determining a cluster network card provided by an embodiment of the present application, which may include:
- the network segment of the Cluster IP is read from the configuration file of the current node, where the network segment includes the address string addrstr and the mask length mask_len (or mask, mask string), Specifically, the network segment form of Cluster IP is as follows: 192.168.2.0/24, where 192.168.2.0 is the address string addrstr, and 24 is the mask length mask_len.
- S12 Determine the type of the network segment of the Cluster IP through the address string in the network segment of the Cluster IP.
- the network segment of the Cluster IP After reading the network segment of the Cluster IP, the network segment of the Cluster IP is parsed to obtain the address string addrstr and the mask length mask_len respectively, and then the address string addrstr in the cluster IP network segment is used to determine the cluster IP
- the type of the network segment is an IPv4 network segment or an IPv6 network segment.
- IPv4 can be expressed as a format such as 100.7.4.2, which occupies a total of 32 bits, that is, the length of an integer data
- IPv6 can be expressed as a format such as 4444:AABB:1A4B::40, which occupies a total of 128 bits, that is The length of the four integer data. Therefore, when using the address string addrstr in the cluster IP network segment to determine whether the type of the cluster IP network segment is an IPv4 network segment or an IPv6 network segment, if the address string addrstr contains ":", it can be considered as IPv6 Network segment, otherwise it is considered to be an IPv4 network segment.
- IPv4 After determining the type of the cluster IP network segment is IPv4, you can find all the IPv4 corresponding IPs in the current node and the network card where it is located (specifically, you can obtain the network card name of the network card where you are located). Similarly, when determining the type of the network segment of the Cluster IP After it is IPv6, you can find all the IPv6 corresponding IPs in the current node and the network card where it is located (specifically, you can obtain the network card name of the network card where it is located).
- S14 Calculate the network segment of each IP, compare the network segment of each IP with the address string, and determine the IP corresponding to the network segment that is the same as the address string as the Cluster IP, and determine the network card where the Cluster IP is located as Cluster network card.
- the above method can not only automatically filter the cluster network card, but also accurately determine the cluster network card. Therefore, it is not only convenient for subsequent real-time monitoring of the cluster network card, so that the cluster can be notified in time when the cluster network card fails. And perform failover to ensure the high availability and stability of the cluster, and make users do not need to manually configure the cluster network card when using the CTDB cluster network card monitoring function, and also avoid the various verification problems that may be caused by the manual configuration of the cluster network card.
- the problem of configuration errors is that the above method simplifies the configuration steps of the cluster network card monitoring function, and the method of automatically determining the cluster network card supports both IPv4 and IPv6.
- the above technical solution disclosed in this application reads the network segment of the Cluster IP, determines the type of the network segment of the Cluster IP through the address string in the network segment of the Cluster IP, and obtains the IP corresponding to the type of the network segment of the Cluster IP And the network segment, and then calculate the network segment of each IP, and determine the IP corresponding to the network segment with the same address string in the network segment of the Cluster IP as the Cluster IP, and determine the network card where the Cluster IP is located as the cluster network card , In order to realize automatically find the cluster network card according to the configuration file, and accurately determine the Cluster IP and the cluster network card by comparing the network segment of each IP in the current node with the address string in the network segment of the Cluster IP, so as to facilitate the real-time performance of the cluster network card
- the monitoring of the cluster makes it easy to notify the cluster in time and perform failover when the cluster network card fails to ensure the high availability of the cluster.
- obtaining the IP and network card corresponding to the type of the network segment of the Cluster IP on the current node may include:
- the IP and network card corresponding to the IPv4 network segment on the current node can be obtained through the ioctl function to improve the efficiency and accuracy of obtaining the IP and network card.
- the method for determining the cluster network card calculates the network segment of each IP, compares the network segment of each IP with the address string, and determines the IP corresponding to the network segment that is the same as the address string as Cluster IP can include:
- the first value is compared with the second value.
- the IP corresponding to the first value is determined as the Cluster IP; where the second value is the third integer data and the converted IP
- the mask is obtained by bitwise AND operation, and the third integer data is obtained by shifting and bitwise AND operation on the address string in the network segment of the Cluster IP.
- an IPv4 address (that is, an IP) can uniquely obtain an integer data
- the shift operation 0xFFFFFFFF ⁇ (32-mask_len) converts the mask in the network segment of the Cluster IP into a form with a prefix of continuous 1, to obtain the converted mask, and mark it as mask.
- the above is to combine src_val with The mask obtains a unique integer value (ie value1) corresponding to a network segment by bitwise AND operation, that is, according to the calculation characteristics, a network segment can uniquely obtain an integer value;
- the IP corresponding to the first value value1 is determined as the Cluster IP
- the network card where the IP is located is determined as the cluster network card .
- the second value value2 is obtained by bitwise AND operation of the third integer data dst_val and mask (that is, the converted mask), where the third integer data dst_val is the address string in the network segment of the Cluster IP addrstr is obtained by shifting and bitwise AND operation. Specifically, the four parts of the address string addrstr are sequentially left-shifted by 24 bits, 16 bits, 8 bits, and 0 bits from left to right to obtain four integers. Type data, and then perform bitwise AND operation of these four integer data to obtain an integer data (denoted as dst_val).
- FIG. 2 shows a flowchart of screening cluster network cards from the IP of the current section in an IPv4 environment provided by an embodiment of the present application.
- obtaining the IP and network card corresponding to the type of the network segment of the Cluster IP on the current node may include:
- the getifaddrs function can be used to obtain the IP and network card corresponding to the IPv6 network segment on the current node to improve the efficiency and accuracy of IP and network card acquisition.
- the method for determining a cluster network card when obtaining the IP and network card corresponding to the IPv6 network segment on the current node through the getifaddrs function, may further include:
- the getifaddrs function can be used to obtain the mask of each IP at the same time, and then the mask length of each IP can be calculated and recorded as mask_len_item. After that, you can compare the mask length mask_len_item of each IP with the mask length mask_len in the network segment of the Cluster IP. If the two are inconsistent, it is determined that the IP is not a Cluster IP. In this case, the IP can be directly removed , In order to improve the efficiency of Cluster IP and cluster network card determination.
- the method for determining the cluster network card provided by the embodiment of this application, if the length of the mask of the IP is the same as the length of the mask in the network segment of the Cluster IP, the network segment of each IP is calculated, and the network segment and address of each IP The string is compared, and the IP corresponding to the same network segment as the address string is determined as the Cluster IP, which can include:
- the second data is the conversion of the mask in the network segment of the Cluster IP Obtained, the second data prefix is in the form of a continuous 1 and contains four elements;
- the first data after the operation is compared with the second data. If the data in the first data corresponds to the data in the second data after the operation, the IP corresponding to the first data after the operation is determined as the Cluster IP; where, The second data is obtained by converting the address string in the network segment of Cluster IP into IP address data, and converting and storing the IP address data into four integer data.
- the specific process of determining the Cluster IP and the cluster network card is as follows:
- IP corresponding to the IPv6 network segment and whose mask length mask_len_item is the same as the mask length mask_len in the cluster IP network segment is recorded as ip_item, and the network segment of this ip_item is calculated.
- the second data dest_mask[4] is obtained by converting the mask in the network segment of the Cluster IP.
- the second data dest_mask[4] is prefixed with a continuous 1 and contains four elements, specifically,
- the second data dest_mask[4] is obtained by converting the mask with length mask_len in the network segment of Cluster IP into a form with a continuous 1 prefix.
- Each element is an integer data.
- the acquisition process of dest_mask[4] is roughly As follows: First, initialize each element of dest_mask to 0xFFFFFF, and then arrange the four elements in sequence, and shift the length of mask_len to the left as a whole to obtain the second data dest_mask[4] in the form of a continuous 1 prefix.
- the second data dest_mask[4] can also be obtained in other ways, which is not limited in this application;
- the third data dst_addr_netseg[i] is obtained by converting the address string addrstr in the network segment of the Cluster IP into IP address data dst_addr, and converting the IP address data dst_addr into four integer data, and storing it Denoted as dst_addr_netseg[4].
- FIG. 3 shows a flowchart of filtering out cluster network cards from the IP of the current section in an IPv6 environment provided by an embodiment of the present application.
- An embodiment of the present application also provides an apparatus for determining a cluster network card. See FIG. 4, which shows a schematic structural diagram of an apparatus for determining a cluster network card provided by an embodiment of the present application, which may include:
- the reading module 41 is used to read the network segment of the Cluster IP from the configuration file of the current node;
- the first determining module 42 is configured to determine the type of the network segment of the Cluster IP through the address string in the network segment of the Cluster IP;
- the obtaining module 43 is used to obtain the IP and network card corresponding to the type of the network segment of the Cluster IP on the current node;
- the second determining module 44 is used to calculate the network segment of each IP, compare the network segment of each IP with the address string, and determine the IP corresponding to the network segment that is the same as the address string as the Cluster IP, and the Cluster IP
- the network card where the IP is located is determined to be the cluster network card.
- the obtaining module 43 may include:
- the first obtaining unit is used to obtain the IP and network card corresponding to the IPv4 network segment on the current node through the ioctl function when the type of the network segment of the Cluster IP is an IPv4 network segment.
- the second determining module 44 may include:
- the shift processing unit is used to perform shift processing on the four parts of each IP corresponding to the IPv4 network segment to obtain four first integer data, and perform bitwise processing on the four first integer data AND operation to get a second integer data;
- the bit AND operation unit is used to perform bitwise AND operation between the second integer data and the converted mask to obtain the first value; where the converted mask is left shifting the mask in the network segment of the Cluster IP Calculated
- the first comparison unit is used to compare the first value with the second value.
- the IP corresponding to the first value is determined as the Cluster IP; where the second value is the first value
- the three integer data and the converted mask are obtained by bitwise AND operation.
- the third integer data is obtained by shifting and bitwise AND operation on the address string in the network segment of the Cluster IP.
- the obtaining module 43 may include:
- the second obtaining unit is used to obtain the IP and network card corresponding to the IPv6 network segment on the current node through the getifaddrs function when the type of the network segment of the Cluster IP is an IPv6 network segment.
- the calculation module is used to obtain the mask of each IP when obtaining the IP and network card corresponding to the IPv6 network segment on the current node through the getifaddrs function, and calculate the mask length of each IP;
- the elimination module is used to compare the length of the mask of each IP with the length of the mask in the network segment of Cluster IP. If the length of the mask of the IP is inconsistent with the length of the mask in the network segment of Cluster IP, it will be eliminated IP.
- the second determining module 44 may include:
- the first data unit which is used to if the length of the IP mask is the same as the length of the mask in the cluster IP network segment, it will correspond to the IPv6 network segment and the mask length will be the same as the length of the mask in the Cluster IP network segment
- the consistent IP conversion is stored in four integer data to obtain the first data
- the first data unit after the operation is obtained, and is used to perform an AND operation on the first data and the second data, and place the operation result in the first data correspondingly to obtain the first data after the operation;
- the second data is the cluster
- the mask in the IP network segment is converted, and the second data prefix is in the form of a continuous 1 and contains four elements;
- the second comparison unit is used to compare the first data after the operation with the third data. If each data in the first data corresponds to the same data in the second data after the operation, then the IP corresponding to the first data after the operation is It is determined to be Cluster IP; the third data is obtained by converting the address string in the network segment of the Cluster IP into IP address data, and converting the IP address data into four integer data.
- FIG. 5 shows a schematic structural diagram of a cluster network card determining device provided in an embodiment of the present application, which may include:
- the memory 51 is used to store computer programs
- the processor 52 is configured to execute the computer program stored in the memory 51 and can implement the following steps:
- the embodiments of the present application also provide a computer-readable storage medium, and a computer program is stored on the computer-readable storage medium.
- a computer program is stored on the computer-readable storage medium.
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Computer Security & Cryptography (AREA)
- Physics & Mathematics (AREA)
- Computing Systems (AREA)
- Mathematical Physics (AREA)
- Theoretical Computer Science (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
一种集群网卡的确定方法、装置、设备及计算机可读存储介质,方法包括:从当前节点的配置文件中读取Cluster IP的网段;通过Cluster IP的网段中的地址字符串确定Cluster IP的网段的类型;获取当前节点上与Cluster IP的网段的类型对应的IP及网卡;计算各IP的网段,将与地址字符串相同的网段所对应的IP确定为Cluster IP,且将该IP所在的网卡确定为集群网卡。本申请公开的上述技术方案,将与Cluster IP的网段中的地址字符串相同的网段对应的IP确定为Cluster IP,且将该IP所在的网卡确定为集群网卡,以实现根据配置文件自动且准确地找到集群网卡。
Description
本申请要求于2019年11月24日提交中国专利局、申请号为201911161173.0、发明名称为“一种集群网卡的确定方法、装置、设备及可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
本申请涉及分布式存储集群技术领域,更具体地说,涉及一种集群网卡的确定方法、装置、设备及计算机可读存储介质。
分布式存储集群是由多个存储节点服务器构成的集群,其支持一份数据存储在多个节点上,每个节点通过节点间通信都可以获取到完整的数据。当节点出现宕机时可以根据配置策略进行完整数据的恢复。
在分布式存储集群中,每个节点中均包含有CTDB,其为一种高可用管理软件,用于监控集群节点状态和虚拟IP的分配,当集群节点故障时分配在该节点的虚拟IP会漂移到其他节点,故障节点的读写业务也会相应地漂移到其他节点,从而使集群构成高可用集群。在节点CTDB启动并监控集群网卡时,每个节点均需要找到本节点的集群网卡,以便于对该集群网卡进行实时监控,从而便于在集群网卡发生故障时CTDB能够及时通知集群进行故障切换,以减少对客户端业务的影响,其中,集群网卡即为集群内部各模块(主要是OSD模块)通信用的网卡,即为Cluster IP(集群内部OSD模块通信用的IP)所在的网卡。但是,目前尚没有一个配置文件指明当前节点上的哪个网卡是集群网卡,只是知道Cluster IP的网段,而OSD在运行时会随机选取使用该网段的任意IP。
综上所述,如何自动且准确地确定出本节点的集群网卡,以便于对该集群网卡进行实时监控,是目前本领域技术人员亟待解决的技术问题。
发明内容
有鉴于此,本申请的目的是提供一种集群网卡的确定方法、装置、设备及计算机可读存储介质,用于自动且准确地确定出本节点的集群网卡,以便于对集群网卡进行实时监控。
为了实现上述目的,本申请提供如下技术方案:
一种集群网卡的确定方法,包括:
从当前节点的配置文件中读取Cluster IP的网段;
通过所述Cluster IP的网段中的地址字符串确定所述Cluster IP的网段的类型;
获取所述当前节点上与所述Cluster IP的网段的类型对应的IP及网卡;
计算各所述IP的网段,将各所述IP的网段与所述地址字符串进行比较,并将与所述地址字符串相同的网段所对应的IP确定为Cluster IP,且将所述Cluster IP所在的网卡确定为集群网卡。
优选的,当所述Cluster IP的网段的类型为IPv4网段时,获取所述当前节点上与所述Cluster IP的网段的类型对应的IP及网卡,包括:
通过ioctl函数获取所述当前节点上与所述IPv4网段对应的IP及网卡。
优选的,计算各所述IP的网段,将各所述IP的网段与所述地址字符串进行比较,并将与所述地址字符串相同的网段所对应的IP确定为Cluster IP,包括:
对与所述IPv4网段对应的每个所述IP中的四个部分分别进行移位处理,以得到四个第一整型数据,并对四个所述第一整型数据进行按位与运算,以得到一个第二整型数据;
将所述第二整型数据与转换后掩码按位与运算,以得到第一值;其中,所述转换后掩码为对所述Cluster IP的网段中的掩码进行左移位运算得到的;
将所述第一值与第二值进行比较,当所述第一值与所述第二值相同时,则将所述第一值对应的IP确定为所述Cluster IP;其中,所述第二值为将第三整型数据与所述转换后掩码按位与运算得到的,所述第三整型数据为对所述Cluster IP的网段中的地址字符串进行移位处理和按位与运算得到的。
优选的,当所述Cluster IP的网段的类型为IPv6网段时,获取所述当前节点上与所述Cluster IP的网段的类型对应的IP及网卡,包括:
通过getifaddrs函数得到所述当前节点上与所述IPv6网段对应的IP及网卡。
优选的,在通过getifaddrs函数得到所述当前节点上与所述IPv6网段对应的IP及网卡时,还包括:
获取每个所述IP的掩码,并计算每个所述IP的掩码长度;
将每个所述IP的掩码长度与所述Cluster IP的网段中的掩码的长度进行比较,若所述IP的掩码长度与所述Cluster IP的网段中的掩码的长度不一致,则剔除所述IP。
优选的,若所述IP的掩码长度与所述Cluster IP的网段中的掩码的长度一致,则计算各所述IP的网段,将各所述IP的网段与所述地址字符串进行比较,并将与地址字符串相同的网段所对应的IP确定为Cluster IP,包括:
将与所述IPv6网段对应且掩码长度与所述Cluster IP的网段中的掩码的长度一致的所述IP转换存储到四个整型数据中,以得到第一数据;
将所述第一数据与第二数据进行与运算,并将运算结果对应放置到所述第一数据中,以得到运算后第一数据;其中,所述第二数据为对所述Cluster IP的网段中的掩码进行转换得到的,所述第二数据前缀为连续1的形式且包含四个元素;
将所述运算后第一数据与第三数据对应进行比较,若所述运算后第一数据中各数据与所述第二数据中各数据对应相同,则将所述运算后第一数据对应的IP确定为所述Cluster IP;其中,所述第三数据为将所述Cluster IP的网段中的地址字符串转换成IP地址数据,且将所述IP地址数据转换存储到四个整型数据中得到的。
一种集群网卡的确定装置,包括:
读取模块,用于从当前节点的配置文件中读取Cluster IP的网段;
第一确定模块,用于通过所述Cluster IP的网段中的地址字符串确定所述Cluster IP的网段的类型;
获取模块,用于获取所述当前节点上与所述Cluster IP的网段的类型对应的IP及网卡;
第二确定模块,用于计算各所述IP的网段,将各所述IP的网段与所述地址字符串进行比较,并将与所述地址字符串相同的网段所对应的IP确定为Cluster IP,且将所述Cluster IP所在的网卡确定为集群网卡。
优选的,所述获取模块包括:
第一获取单元,用于当所述Cluster IP的网段的类型为IPv4网段时,通过ioctl函数获取所述当前节点上与所述IPv4网段对应的IP及网卡。
一种集群网卡的确定设备,包括:
存储器,用于存储计算机程序;
处理器,用于执行所述计算机程序时实现如上述任一项所述的集群网卡的确定方法的步骤。
一种计算机可读存储介质,所述计算机可读存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现如上述任一项所述的集群网卡的确定方法的步骤。
本申请提供了一种集群网卡的确定方法、装置、设备及计算机可读存储介质,其中,该方法包括:从当前节点的配置文件中读取Cluster IP的网段;通过Cluster IP的网段中的地址字符串确定Cluster IP的网段的类型;获取当前节点上与Cluster IP的网段的类型对应的IP及网卡;计算各IP的网段,将各IP的网段与地址字符串进行比较,并将与地址字符串相同的网段所确定的IP确定为Cluster IP,且将Cluster IP所在的网卡确定为集群网卡。
本申请公开的上述技术方案,读取Cluster IP的网段,并通过Cluster IP的网段中的地址字符串确定Cluster IP的网段的类型,且获取与Cluster IP的网段的类型对应的IP及网段,然后,计算各IP的网段,并将与Cluster IP的网段中的地址字符串相同的网段所对应的IP确定为Cluster IP,且将Cluster IP所在的网卡确定为集群网卡,以实现根据配置文件自动找到集群网卡,并通过当前节点中各IP的网段与Cluster IP的网段中的地址字符串的比较准确地确定Cluster IP及集群网卡,从而便于对集群网卡进行实时的监控,进而便于在集群网卡出现故障时能够及时通知集群并进行故障切换,以保证 集群的高可用性。
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据提供的附图获得其他的附图。
图1为本申请实施例提供的一种集群网卡的确定方法的流程图;
图2为本申请实施例提供的在IPv4环境下从当前节的IP中筛选出集群网卡的流程图;
图3为本申请实施例提供的在IPv6环境下从当前节的IP中筛选出集群网卡的流程图;
图4为本申请实施例提供的一种集群网卡的确定装置的结构示意图;
图5为本申请实施例提供的集群网卡的确定设备的结构示意图。
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。
参见图1,其示出了本申请实施例提供的一种集群网卡的确定方法的流程图,可以包括:
S11:从当前节点的配置文件中读取Cluster IP的网段。
在集群各节点CTDB启动时,从当前节点的配置文件中读取Cluster IP的网段,其中,该网段包括地址字符串addrstr和掩码长度mask_len(或称掩码、掩码字符串),具体地,Cluster IP的网段形式如:192.168.2.0/24,其中,192.168.2.0即为地址字符串addrstr,24即为掩码长度mask_len。
S12:通过Cluster IP的网段中的地址字符串确定Cluster IP的网段的类型。
在读取到Cluster IP的网段之后,对Cluster IP的网段进行解析,分别得到地址字符串addrstr和掩码长度mask_len,然后,通过Cluster IP的网段中的地址字符串addrstr确定Cluster IP的网段的类型是IPv4网段还是IPv6网段。
其中,IPv4可以表示为如100.7.4.2这样的格式,共占32位,即一个整型数据的长度,IPv6可以表示为如4444:AABB:1A4B::40这样的格式,共占128位,即四个整型数据的长度。因此,在通过Cluster IP的网段中的地址字符串addrstr确定Cluster IP的网段的类型是IPv4网段还是IPv6网段时,如该地址字符串addrstr中有“:”,则可认为是IPv6网段,否则则认为是IPv4网段。
S13:获取当前节点上与Cluster IP的网段的类型对应的IP及网卡。
在确定Cluster IP的网段的类型为IPv4之后,可以找到当前节点中所有的IPv4对应的IP及所在网卡(具体可以获取所在网卡的网卡名),同样地,在确定Cluster IP的网段的类型为IPv6之后,可以找到当前节点中所有的IPv6对应的IP及所在网卡(具体可以获取所在网卡的网卡名)。
S14:计算各IP的网段,将各IP的网段与地址字符串进行比较,并将与地址字符串相同的网段所对应的IP确定为Cluster IP,且将Cluster IP所在的网卡确定为集群网卡。
计算各IP的网段,并将所计算出的各IP的网段与Cluster IP的网段中的地址字符串addrstr进行比较,然后,将与地址字符串addrstr相同所对应的IP确定为Cluster IP,并将该IP(即Cluster IP)所在的网卡确定为集群网卡。考虑到在对节点进行网络划分时,正常情况下不会设置同网段的IP到不同的网卡上,所以,筛选出的集群网卡是唯一的。
由此可知,通过上述方式不仅可以对集群网卡进行自动筛选,而且可以准确地确定出集群网卡,因此,不仅可以便于后续对集群网卡进行实时监控,以便于在集群网卡出现故障时能够及时通知集群并进行故障切换,从而保证集群的高可用性和稳定性,而且使得用户在使用CTDB集群网卡 监控功能时无需手动配置集群网卡,同时也避免了手动配置集群网卡可能带来的各种校验问题及配置错误问题,即上述方式简化了集群网卡监控功能的使用配置步骤,且该自动确定集群网卡的方式同时支持IPv4和IPv6。
本申请公开的上述技术方案,读取Cluster IP的网段,并通过Cluster IP的网段中的地址字符串确定Cluster IP的网段的类型,且获取与Cluster IP的网段的类型对应的IP及网段,然后,计算各IP的网段,并将与Cluster IP的网段中的地址字符串相同的网段所对应的IP确定为Cluster IP,且将Cluster IP所在的网卡确定为集群网卡,以实现根据配置文件自动找到集群网卡,并通过当前节点中各IP的网段与Cluster IP的网段中的地址字符串的比较准确地确定Cluster IP及集群网卡,从而便于对集群网卡进行实时的监控,进而便于在集群网卡出现故障时能够及时通知集群并进行故障切换,以保证集群的高可用性。
本申请实施例提供的一种集群网卡的确定方法,当Cluster IP的网段的类型为IPv4网段时,获取当前节点上与Cluster IP的网段的类型对应的IP及网卡,可以包括:
通过ioctl函数获取当前节点上与IPv4网段对应的IP及网卡。
当确定Cluster IP的网段的类型为IPv4时,则可以通过ioctl函数获取当前节点上与IPv4网段对应的IP及网卡,以提高IP和网卡获取的效率和准确性。
本申请实施例提供的一种集群网卡的确定方法,计算各IP的网段,将各IP的网段与地址字符串进行比较,并将与地址字符串相同的网段所对应的IP确定为Cluster IP,可以包括:
对与IPv4网段对应的每个IP中的四个部分分别进行移位处理,以得到四个第一整型数据,并对四个第一整型数据进行按位与运算,以得到一个第二整型数据;
将第二整型数据与转换后掩码按位与运算,以得到第一值;其中,转换后掩码为对Cluster IP的网段中的掩码进行左移位运算得到的;
将第一值与第二值进行比较,当第一值与第二值相同时,则将第一值 对应的IP确定为Cluster IP;其中,第二值为将第三整型数据与转换后掩码按位与运算得到的,第三整型数据为对Cluster IP的网段中的地址字符串进行移位处理和按位与运算得到的。
当确定Cluster IP的网段的类型为IPv4时,Cluster IP及集群网卡的确定过程具体如下:
循环遍历每个当前节点找到的IPv4所对应的IP,并将每个IP均记为ip_item(其中,该IP形式如:100.3.2.40),然后,从左到右将ip_item的四个部分依次左移位24位、16位、8位、0位(即分别进行移位处理),以得到四个第一整型数据,然后,再将这四个整型数据按位与运算,以得到一个第二整型数据,并记为src_val。其中,根据计算特性,一个IPv4地址(即一个IP)能唯一得到一个整型数据;
将src_val与转换后掩码按位与运算,以得到第一值value1;其中,转换后掩码为对Cluster IP的网段中的掩码进行左移位运算得到的,具体地,可以通过左移位运算0xFFFFFFFF<<(32-mask_len)把Cluster IP的网段中的掩码转换成前缀为连续1的形式,以得到转换后掩码,并记为mask,相应地,上述是将src_val与mask按位与运算而得到一个和一个网段对应的唯一整型值(即value1),也即根据计算特性,一个网段能唯一得到一个整型值;
将第一值value1与第二值value2进行比较,当第一值value1与第二值value2相同时,将第一值value1对应的IP确定为Cluster IP,并将该IP所在的网卡确定为集群网卡。其中,第二值value2是将第三整型数据dst_val与mask(即转换后掩码)按位与运算得到的,其中,第三整型数据dst_val为对Cluster IP的网段中的地址字符串addrstr进行移位处理和按位与运算得到的,具体地,是从左到右将地址字符串addrstr的四个部分依次左移位24位、16位、8位、0位,得到四个整型数据,再将这四个整型数据按位与运算,得到一个整型数据(记为dst_val)。
上述过程具体可以对应参见图2,其示出了本申请实施例提供的在IPv4环境下从当前节的IP中筛选出集群网卡的流程图。
本申请实施例提供的一种集群网卡的确定方法,当Cluster IP的网段的 类型为IPv6网段时,获取当前节点上与Cluster IP的网段的类型对应的IP及网卡,可以包括:
通过getifaddrs函数得到当前节点上与IPv6网段对应的IP及网卡。
当确定Cluster IP的网段的类型为IPv6网段时,可以通过getifaddrs函数得到当前节点上与IPv6网段对应的IP及网卡,以提高IP和网卡获取的效率和准确性。
本申请实施例提供的一种集群网卡的确定方法,在通过getifaddrs函数得到当前节点上与所述IPv6网段对应的IP及网卡时,还可以包括:
获取每个IP的掩码,并计算每个IP的掩码长度;
将每个IP的掩码长度与Cluster IP的网段中的掩码的长度进行比较,若IP的掩码长度与Cluster IP的网段中的掩码的长度不一致,则剔除IP。
在通过getifaddrs函数得到当前节点上与所述IPv6网段对应的IP及网卡时,可以同时利用getifaddrs函数获取每个IP的掩码,然后,可以计算出每个IP的掩码长度,并记为mask_len_item。之后,则可以将每个IP的掩码长度mask_len_item与Cluster IP的网段中的掩码的长度mask_len进行比较,若二者不一致,则确定该IP不是Cluster IP,此时,可以直接剔除该IP,以提高Cluster IP和集群网卡的确定效率。
本申请实施例提供的一种集群网卡的确定方法,若IP的掩码长度与Cluster IP的网段中的掩码的长度一致,则计算各IP的网段,将各IP的网段与地址字符串进行比较,并将与地址字符串相同的网段所对应的IP确定为Cluster IP,可以包括:
将与IPv6网段对应且掩码长度与Cluster IP的网段中的掩码的长度一致的IP转换存储到四个整型数据中,以得到第一数据;
将第一数据与第二数据进行与运算,并将运算结果对应放置到第一数据中,以得到运算后第一数据;其中,第二数据为对Cluster IP的网段中的掩码进行转换得到的,第二数据前缀为连续1的形式且包含四个元素;
将运算后第一数据与第二数据对应进行比较,若运算后第一数据中各数据与第二数据中各数据对应相同,则将运算后第一数据对应的IP确定为Cluster IP;其中,第二数据为将Cluster IP的网段中的地址字符串转换成 IP地址数据,且将IP地址数据转换存储到四个整型数据中得到的。
若IP的掩码长度mask_len_item与Cluster IP的网段中的掩码的长度mask_len一致,则Cluster IP及集群网卡的确定过程具体为:
将与IPv6网段对应且掩码长度mask_len_item与Cluster IP的网段中的掩码的长度mask_len一致的IP记为ip_item,并计算该ip_item的网段,其网段计算过程为:将ip_item转换存储到四个整型数据中,以得到第一数据(记为src_addr_netseg[4],其中,这里的“4”代表有四个元素),然后,将第一数据src_addr_netseg[i]和第二数据dest_mask[i]进行与运算(0<=i<4),并将运算结果对应放置到第一数据src_addr_netseg[i]中,以得到运算后第一数据(这里仍然用src_addr_netseg[i]表示),即得到该IP对应的网段。其中,第二数据dest_mask[4]为对Cluster IP的网段中的掩码进行转换得到的,第二数据dest_mask[4]前缀为连续1的形式且包含四个元素,具体地,即为将Cluster IP的网段中长度为mask_len的掩码转换成前缀为连续1的形式而得到第二数据dest_mask[4],每个元素都是一个整型数据,其中,dest_mask[4]的获取过程大致为:首先,将dest_mask的每个元素初始化为0xFFFFFFFF,之后可以将四个元素依次排列,整体向左移位mask_len的长度,以得到前缀为连续1的形式第二数据dest_mask[4]。当然,也可以通过其他方式得到第二数据dest_mask[4],本申请对此不做任何限定;
然后,将运算后第一数据src_addr_netseg[i]与第三数据dst_addr_netseg[i]进行比较(其中,0<=i<4),若对应元素全都相同,则认为运算后第一数据对应的IP为Cluster IP,且该IP所在的网卡为集群网卡。其中,第三数据dst_addr_netseg[i]为将Cluster IP的网段中的地址字符串addrstr转换成IP地址数据dst_addr,且将IP地址数据dst_addr转换存储到四个整型数据中得到的,且将其记为dst_addr_netseg[4]。
上述过程具体可以对应参见图3,其示出了本申请实施例提供的在IPv6环境下从当前节的IP中筛选出集群网卡的流程图。
本申请实施例还提供了一种集群网卡的确定装置,参见图4,其示出 了本申请实施例提供的一种集群网卡的确定装置的结构示意图,可以包括:
读取模块41,用于从当前节点的配置文件中读取Cluster IP的网段;
第一确定模块42,用于通过Cluster IP的网段中的地址字符串确定Cluster IP的网段的类型;
获取模块43,用于获取当前节点上与Cluster IP的网段的类型对应的IP及网卡;
第二确定模块44,用于计算各IP的网段,将各IP的网段与地址字符串进行比较,并将与地址字符串相同的网段所对应的IP确定为Cluster IP,且将Cluster IP所在的网卡确定为集群网卡。
本申请实施例提供的一种集群网卡的确定装置,获取模块43可以包括:
第一获取单元,用于当Cluster IP的网段的类型为IPv4网段时,通过ioctl函数获取当前节点上与IPv4网段对应的IP及网卡。
本申请实施例提供的一种集群网卡的确定装置,第二确定模块44可以包括:
移位处理单元,用于对与IPv4网段对应的每个IP中的四个部分分别进行移位处理,以得到四个第一整型数据,并对四个第一整型数据进行按位与运算,以得到一个第二整型数据;
位与运算单元,用于将第二整型数据与转换后掩码按位与运算,以得到第一值;其中,转换后掩码为对Cluster IP的网段中的掩码进行左移位运算得到的;
第一比较单元,用于将第一值与第二值进行比较,当第一值与第二值相同时,则将第一值对应的IP确定为Cluster IP;其中,第二值为将第三整型数据与转换后掩码按位与运算得到的,第三整型数据为对Cluster IP的网段中的地址字符串进行移位处理和按位与运算得到的。
本申请实施例提供的一种集群网卡的确定装置,获取模块43可以包括:
第二获取单元,用于当Cluster IP的网段的类型为IPv6网段时,通过getifaddrs函数得到当前节点上与IPv6网段对应的IP及网卡。
本申请实施例提供的一种集群网卡的确定装置,还可以包括:
计算模块,用于在通过getifaddrs函数得到当前节点上与所述IPv6网段对应的IP及网卡时,获取每个IP的掩码,并计算每个IP的掩码长度;
剔除模块,用于将每个IP的掩码长度与Cluster IP的网段中的掩码的长度进行比较,若IP的掩码长度与Cluster IP的网段中的掩码的长度不一致,则剔除IP。
本申请实施例提供的一种集群网卡的确定装置,第二确定模块44可以包括:
得到第一数据单元,用于若IP的掩码长度与Cluster IP的网段中的掩码的长度一致,将与IPv6网段对应且掩码长度与Cluster IP的网段中的掩码的长度一致的IP转换存储到四个整型数据中,以得到第一数据;
得到运算后第一数据单元,用于将第一数据与第二数据进行与运算,并将运算结果对应放置到第一数据中,以得到运算后第一数据;其中,第二数据为对Cluster IP的网段中的掩码进行转换得到的,第二数据前缀为连续1的形式且包含四个元素;
第二比较单元,用于将运算后第一数据与第三数据对应进行比较,若运算后第一数据中各数据与第二数据中各数据对应相同,则将运算后第一数据对应的IP确定为Cluster IP;其中,第三数据为将Cluster IP的网段中的地址字符串转换成IP地址数据,且将IP地址数据转换存储到四个整型数据中得到的。
本申请实施例提供了一种集群网卡的确定设备,参见图5,其示出了本申请实施例提供的一种集群网卡的确定设备的结构示意图,可以包括:
存储器51,用于存储计算机程序;
处理器52,用于执行存储器51存储的计算机程序时可实现如下步骤:
从当前节点的配置文件中读取Cluster IP的网段;通过Cluster IP的网段中的地址字符串确定Cluster IP的网段的类型;获取当前节点上与Cluster IP的网段的类型对应的IP及网卡;计算各IP的网段,将各IP的网段与地址字符串进行比较,并将与地址字符串相同的网段所对应的IP确定为 Cluster IP,且将Cluster IP所在的网卡确定为集群网卡。
本申请实施例还提供了一种计算机可读存储介质,计算机可读存储介质上存储有计算机程序,计算机程序被处理器执行时可实现如下步骤:
从当前节点的配置文件中读取Cluster IP的网段;通过Cluster IP的网段中的地址字符串确定Cluster IP的网段的类型;获取当前节点上与Cluster IP的网段的类型对应的IP及网卡;计算各IP的网段,将各IP的网段与地址字符串进行比较,并将与地址字符串相同的网段所对应的IP确定为Cluster IP,且将Cluster IP所在的网卡确定为集群网卡。
本申请实施例提供的一种集群网卡的确定装置、设备及计算机可读存储介质中相关部分的说明可以参见本申请实施例提供的一种集群网卡的确定方法中对应部分的详细说明,在此不再赘述。
需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。另外,本申请实施例提供的上述技术方案中与现有技术中对应技术方案实现原理一致的部分并未详细说明,以免过多赘述。
对所公开的实施例的上述说明,使本领域技术人员能够实现或使用本申请。对这些实施例的多种修改对本领域技术人员来说将是显而易见的,本文中所定义的一般原理可以在不脱离本申请的精神或范围的情况下,在其它实施例中实现。因此,本申请将不会被限制于本文所示的这些实施例,而是要符合与本文所公开的原理和新颖特点相一致的最宽的范围。
Claims (10)
- 一种集群网卡的确定方法,其特征在于,包括:从当前节点的配置文件中读取Cluster IP的网段;通过所述Cluster IP的网段中的地址字符串确定所述Cluster IP的网段的类型;获取所述当前节点上与所述Cluster IP的网段的类型对应的IP及网卡;计算各所述IP的网段,将各所述IP的网段与所述地址字符串进行比较,并将与所述地址字符串相同的网段所对应的IP确定为Cluster IP,且将所述Cluster IP所在的网卡确定为集群网卡。
- 根据权利要求1所述的集群网卡的确定方法,其特征在于,当所述Cluster IP的网段的类型为IPv4网段时,获取所述当前节点上与所述Cluster IP的网段的类型对应的IP及网卡,包括:通过ioctl函数获取所述当前节点上与所述IPv4网段对应的IP及网卡。
- 根据权利要求2所述的集群网卡的确定方法,其特征在于,计算各所述IP的网段,将各所述IP的网段与所述地址字符串进行比较,并将与所述地址字符串相同的网段所对应的IP确定为Cluster IP,包括:对与所述IPv4网段对应的每个所述IP中的四个部分分别进行移位处理,以得到四个第一整型数据,并对四个所述第一整型数据进行按位与运算,以得到一个第二整型数据;将所述第二整型数据与转换后掩码按位与运算,以得到第一值;其中,所述转换后掩码为对所述Cluster IP的网段中的掩码进行左移位运算得到的;将所述第一值与第二值进行比较,当所述第一值与所述第二值相同时,则将所述第一值对应的IP确定为所述Cluster IP;其中,所述第二值为将第三整型数据与所述转换后掩码按位与运算得到的,所述第三整型数据为对所述Cluster IP的网段中的地址字符串进行移位处理和按位与运算得到的。
- 根据权利要求1所述的集群网卡的确定方法,其特征在于,当所述Cluster IP的网段的类型为IPv6网段时,获取所述当前节点上与所述Cluster IP的网段的类型对应的IP及网卡,包括:通过getifaddrs函数得到所述当前节点上与所述IPv6网段对应的IP及网卡。
- 根据权利要求4所述的集群网卡的确定方法,其特征在于,在通过getifaddrs函数得到所述当前节点上与所述IPv6网段对应的IP及网卡时,还包括:获取每个所述IP的掩码,并计算每个所述IP的掩码长度;将每个所述IP的掩码长度与所述Cluster IP的网段中的掩码的长度进行比较,若所述IP的掩码长度与所述Cluster IP的网段中的掩码的长度不一致,则剔除所述IP。
- 根据权利要求4所述的集群网卡的确定方法,其特征在于,若所述IP的掩码长度与所述Cluster IP的网段中的掩码的长度一致,则计算各所述IP的网段,将各所述IP的网段与所述地址字符串进行比较,并将与地址字符串相同的网段所对应的IP确定为Cluster IP,包括:将与所述IPv6网段对应且掩码长度与所述Cluster IP的网段中的掩码的长度一致的所述IP转换存储到四个整型数据中,以得到第一数据;将所述第一数据与第二数据进行与运算,并将运算结果对应放置到所述第一数据中,以得到运算后第一数据;其中,所述第二数据为对所述Cluster IP的网段中的掩码进行转换得到的,所述第二数据前缀为连续1的形式且包含四个元素;将所述运算后第一数据与第三数据对应进行比较,若所述运算后第一数据中各数据与所述第二数据中各数据对应相同,则将所述运算后第一数据对应的IP确定为所述Cluster IP;其中,所述第三数据为将所述Cluster IP的网段中的地址字符串转换成IP地址数据,且将所述IP地址数据转换存储到四个整型数据中得到的。
- 一种集群网卡的确定装置,其特征在于,包括:读取模块,用于从当前节点的配置文件中读取Cluster IP的网段;第一确定模块,用于通过所述Cluster IP的网段中的地址字符串确定所述Cluster IP的网段的类型;获取模块,用于获取所述当前节点上与所述Cluster IP的网段的类型对应的IP及网卡;第二确定模块,用于计算各所述IP的网段,将各所述IP的网段与所述地址字符串进行比较,并将与所述地址字符串相同的网段所对应的IP确定为Cluster IP,且将所述Cluster IP所在的网卡确定为集群网卡。
- 根据权利要求7所述的集群网卡的确定装置,其特征在于,所述获取模块包括:第一获取单元,用于当所述Cluster IP的网段的类型为IPv4网段时,通过ioctl函数获取所述当前节点上与所述IPv4网段对应的IP及网卡。
- 一种集群网卡的确定设备,其特征在于,包括:存储器,用于存储计算机程序;处理器,用于执行所述计算机程序时实现如权利要求1至6任一项所述的集群网卡的确定方法的步骤。
- 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现如权利要求1至6任一项所述的集群网卡的确定方法的步骤。
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
US17/779,356 US11979368B2 (en) | 2019-11-24 | 2020-07-23 | Method, apparatus and device for determining cluster network card, and readable storage medium |
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911161173.0 | 2019-11-24 | ||
CN201911161173.0A CN110995805B (zh) | 2019-11-24 | 2019-11-24 | 一种集群网卡的确定方法、装置、设备及可读存储介质 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2021098259A1 true WO2021098259A1 (zh) | 2021-05-27 |
Family
ID=70086113
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2020/103698 WO2021098259A1 (zh) | 2019-11-24 | 2020-07-23 | 一种集群网卡的确定方法、装置、设备及可读存储介质 |
Country Status (3)
Country | Link |
---|---|
US (1) | US11979368B2 (zh) |
CN (1) | CN110995805B (zh) |
WO (1) | WO2021098259A1 (zh) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110995805B (zh) | 2019-11-24 | 2022-02-18 | 浪潮电子信息产业股份有限公司 | 一种集群网卡的确定方法、装置、设备及可读存储介质 |
CN112866408B (zh) * | 2021-02-09 | 2022-08-09 | 山东英信计算机技术有限公司 | 一种集群中业务切换方法、装置、设备及存储介质 |
CN114205333B (zh) * | 2021-12-09 | 2024-02-27 | 北京奇妙时光科技有限公司 | Ip配置方法、集群构建方法、计算机设备及存储介质 |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106412039A (zh) * | 2016-09-19 | 2017-02-15 | 郑州云海信息技术有限公司 | 一种分布式存储的网络集成的方法及系统 |
US20170048223A1 (en) * | 2015-08-15 | 2017-02-16 | Microsoft Technology Licensing, Llc | Domain joined virtual names on domainless servers |
CN106559246A (zh) * | 2015-09-30 | 2017-04-05 | 杭州华三通信技术有限公司 | 集群的实现方法和服务器 |
CN107222320A (zh) * | 2016-03-22 | 2017-09-29 | 中兴通讯股份有限公司 | 云服务器集群建立高可用连接的方法和装置 |
CN108989476A (zh) * | 2018-06-12 | 2018-12-11 | 新华三技术有限公司 | 一种地址分配方法以及装置 |
CN109167687A (zh) * | 2018-09-05 | 2019-01-08 | 山东浪潮云投信息科技有限公司 | 一种批量初始化物理服务器集群网络配置的方法及系统 |
CN110995805A (zh) * | 2019-11-24 | 2020-04-10 | 浪潮电子信息产业股份有限公司 | 一种集群网卡的确定方法、装置、设备及可读存储介质 |
Family Cites Families (24)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7219160B1 (en) * | 1999-08-27 | 2007-05-15 | At&T Corp. | Method for fast network-aware clustering |
US7296089B2 (en) * | 1999-08-27 | 2007-11-13 | At&T Corp. | Method for improving web performance by adapting servers based on client cluster characterization |
US6928485B1 (en) * | 1999-08-27 | 2005-08-09 | At&T Corp. | Method for network-aware clustering of clients in a network |
US6636499B1 (en) * | 1999-12-02 | 2003-10-21 | Cisco Technology, Inc. | Apparatus and method for cluster network device discovery |
US7131031B2 (en) * | 2003-05-22 | 2006-10-31 | Dell Products L.P. | System and method for on-line diagnosing of network interface cards |
US7577670B2 (en) * | 2004-03-08 | 2009-08-18 | Hewlett-Packard Development Company, L.P. | Method and apparatus for inferring address and subnet relationships |
US20050268151A1 (en) * | 2004-04-28 | 2005-12-01 | Nokia, Inc. | System and method for maximizing connectivity during network failures in a cluster system |
US9794237B2 (en) * | 2005-01-31 | 2017-10-17 | Unisys Corporation | Secured networks and endpoints applying internet protocol security |
US8331263B2 (en) * | 2006-01-23 | 2012-12-11 | Microsoft Corporation | Discovery of network nodes and routable addresses |
US7725603B1 (en) * | 2008-04-30 | 2010-05-25 | Network Appliance, Inc. | Automatic network cluster path management |
CN102223289B (zh) * | 2010-04-15 | 2014-04-16 | 杭州华三通信技术有限公司 | 一种存储IPv4地址和IPv6地址的方法和装置 |
JP5483029B2 (ja) * | 2011-03-29 | 2014-05-07 | 日本電気株式会社 | クラスタシステムの結線作業の煩雑さを軽減するシステム及び方法 |
US9077635B2 (en) * | 2012-02-27 | 2015-07-07 | Xerox Corporation | Method and apparatus for network subnet discovery |
US9098264B2 (en) * | 2012-07-18 | 2015-08-04 | Netronome Systems, Inc. | Transactional memory that performs a direct 24-BIT lookup operation |
US8937955B2 (en) * | 2012-12-05 | 2015-01-20 | Cisco Technology, Inc. | System and method for scaling IPv6 addresses in a network environment |
US9331910B2 (en) * | 2013-06-19 | 2016-05-03 | Cumulus Networks, Inc. | Methods and systems for automatic generation of routing configuration files |
US9515929B2 (en) * | 2013-06-28 | 2016-12-06 | Netronome Systems, Inc. | Traffic data pre-filtering |
US9203753B2 (en) * | 2013-11-25 | 2015-12-01 | Cisco Technology, Inc. | Traffic optimization using network address and port translation in a computer cluster |
US9479475B1 (en) * | 2014-03-17 | 2016-10-25 | Michael E. Mazarick | System and method for IPv4 to IPv6 transition rather than an outage |
CN104935676A (zh) * | 2014-03-17 | 2015-09-23 | 阿里巴巴集团控股有限公司 | 确定ip地址段及其对应的经纬度的方法及装置 |
JP6575318B2 (ja) * | 2015-11-18 | 2019-09-18 | 富士通株式会社 | ネットワーク制御装置、クラスタシステムおよび制御プログラム |
CN109039723A (zh) * | 2018-07-23 | 2018-12-18 | 郑州云海信息技术有限公司 | 基于数据库集群的网络维护方法及系统 |
CN109474683A (zh) * | 2018-11-15 | 2019-03-15 | 郑州云海信息技术有限公司 | 一种节点配置方法及相关装置 |
CN110233767A (zh) * | 2019-07-26 | 2019-09-13 | 苏州浪潮智能科技有限公司 | 分布式集群的服务配置方法、系统、装置及可读存储介质 |
-
2019
- 2019-11-24 CN CN201911161173.0A patent/CN110995805B/zh active Active
-
2020
- 2020-07-23 US US17/779,356 patent/US11979368B2/en active Active
- 2020-07-23 WO PCT/CN2020/103698 patent/WO2021098259A1/zh active Application Filing
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20170048223A1 (en) * | 2015-08-15 | 2017-02-16 | Microsoft Technology Licensing, Llc | Domain joined virtual names on domainless servers |
CN106559246A (zh) * | 2015-09-30 | 2017-04-05 | 杭州华三通信技术有限公司 | 集群的实现方法和服务器 |
CN107222320A (zh) * | 2016-03-22 | 2017-09-29 | 中兴通讯股份有限公司 | 云服务器集群建立高可用连接的方法和装置 |
CN106412039A (zh) * | 2016-09-19 | 2017-02-15 | 郑州云海信息技术有限公司 | 一种分布式存储的网络集成的方法及系统 |
CN108989476A (zh) * | 2018-06-12 | 2018-12-11 | 新华三技术有限公司 | 一种地址分配方法以及装置 |
CN109167687A (zh) * | 2018-09-05 | 2019-01-08 | 山东浪潮云投信息科技有限公司 | 一种批量初始化物理服务器集群网络配置的方法及系统 |
CN110995805A (zh) * | 2019-11-24 | 2020-04-10 | 浪潮电子信息产业股份有限公司 | 一种集群网卡的确定方法、装置、设备及可读存储介质 |
Also Published As
Publication number | Publication date |
---|---|
US11979368B2 (en) | 2024-05-07 |
US20220407839A1 (en) | 2022-12-22 |
CN110995805B (zh) | 2022-02-18 |
CN110995805A (zh) | 2020-04-10 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2021098259A1 (zh) | 一种集群网卡的确定方法、装置、设备及可读存储介质 | |
WO2018001269A1 (zh) | 处理云资源的方法和物理节点 | |
US11216187B2 (en) | Data writing and reading method and apparatus, and distributed object storage cluster | |
US9043461B2 (en) | Firewall event reduction for rule use counting | |
US9621511B2 (en) | Method and system for auto-provisioning network devices in a data center using network device location in network topology | |
CN109218301B (zh) | 多协议间软件定义的帧头映射的方法和装置 | |
US10637798B2 (en) | Packet control method and packet control device | |
US20140032753A1 (en) | Computer system and node search method | |
US20170270119A1 (en) | Systems and methods for distributed storage of data across multiple hash tables | |
WO2016082156A1 (zh) | 元数据的恢复方法及装置 | |
CN113794605A (zh) | 一种基于eBPF的内核丢包检测方法、系统和装置 | |
CN107181636B (zh) | 一种负载均衡系统中的健康检查方法及装置 | |
WO2020253102A1 (zh) | 线上背书签名方法、装置、设备和存储介质 | |
WO2019057081A1 (zh) | 数据存储方法、数据查询方法、计算机设备及存储介质 | |
CN111901451A (zh) | 一种梳理专线用户域和地址池引用关系的方法及装置 | |
US8537692B2 (en) | Network failure detecting method and device | |
WO2021139240A1 (zh) | 一种域名压缩方法及其相关产品 | |
JP7056207B2 (ja) | トポロジ決定装置、トポロジ決定方法、トポロジ決定プログラムおよび通信システム | |
JP2006190173A (ja) | 環境設定情報管理プログラムおよび環境設定情報管理方法 | |
US11431656B2 (en) | Switch identification method and non-transitory computer-readable recording medium | |
CN106993036B (zh) | 运行环境信息处理方法及交换机 | |
WO2020103578A1 (zh) | 域名查询方法及相关产品 | |
CN112468606A (zh) | 一种互备地址池ip地址数统计修正方法及装置 | |
TWI686066B (zh) | 利用區塊鏈的日誌資料保全方法 | |
US20200328942A1 (en) | Advanced Device Matching System |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 20889195 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 20889195 Country of ref document: EP Kind code of ref document: A1 |