Address allocation methods, devices, electronic devices and readable storage media

By writing preset values ​​and sequence numbers to the physical network cards of service nodes to generate unique MAC addresses and assigning IP addresses to virtual network cards, the communication problem caused by duplicate MAC addresses in the cluster is solved, and normal communication of containers is realized.

CN116886667BActive Publication Date: 2026-03-13INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-06-29
Publication Date
2026-03-13

AI Technical Summary

Technical Problem

In a cluster where service nodes contain containers, randomly generating MAC addresses may result in duplicates, causing containers to be unable to communicate properly.

Method used

By identifying the service nodes in the service cluster, a unique MAC address is generated by writing preset values, sequence numbers, and service node sequence numbers to different bytes in the MAC address for each physical network card, and IP addresses are assigned to virtual network cards based on these addresses to ensure a one-to-one correspondence.

Benefits of technology

This ensures normal communication between containers in the cluster, avoids the many-to-one IP address problem caused by duplicate MAC addresses, and improves communication efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116886667B_ABST
    Figure CN116886667B_ABST
Patent Text Reader

Abstract

This invention provides an address allocation method, apparatus, electronic device, and readable storage medium. The method includes: for each physical network interface card (NIC) in a service cluster, writing a first preset number of preset values, the serial number of the physical NIC, and the serial number of the service node where the physical NIC resides into the first preset number of preset byte bits, the second preset byte bits, and the third preset byte bits of the MAC address to be configured, respectively, to obtain a first preset number of MAC addresses that are different from each physical NIC; and allocating multiple different IP addresses and multiple MAC addresses corresponding to each physical NIC to the first virtual NIC of the corresponding target container. Since the multiple MAC addresses and multiple IP addresses corresponding to each physical NIC are different from each other, allocating MAC addresses and IP addresses to the first virtual NICs of the target containers ensures that the MAC addresses and IP addresses allocated to each first virtual NIC are different from each other, thus ensuring normal communication for the corresponding target containers.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to an address allocation method, apparatus, electronic device, and readable storage medium. Background Technology

[0002] In a cluster where service nodes contain containers, each container needs to be assigned a one-to-one physical address (Media Access Control Address, MAC address) and an Internet Protocol address (IP address) to ensure normal communication between containers in the cluster.

[0003] In related technologies, multiple MAC addresses are generated randomly, and multiple IP addresses are obtained. Then, the generated MAC addresses and IP addresses are assigned to the various virtual network interfaces of the container.

[0004] However, the method of randomly generating MAC addresses in related technologies may result in duplicate MAC addresses, causing multiple virtual network interfaces assigned to containers to have the same MAC address. During container communication, multiple corresponding IP addresses will be determined based on the duplicate MAC addresses, making it impossible for containers in the cluster to communicate normally. Summary of the Invention

[0005] In view of the above problems, embodiments of the present invention are proposed to provide an address allocation method, apparatus, electronic device, and readable storage medium that overcomes or at least partially solves the above problems.

[0006] In a first aspect, embodiments of this application disclose an address allocation method, which is applied to a cluster management service node, and the method includes:

[0007] Identify at least one service node in the service cluster, each service node includes at least one physical network card and at least one container, each container loads at least one first virtual network card, and the first virtual network card and the physical network card correspond one-to-one;

[0008] For each physical network interface card (NIC), the preset value of the first preset number is written into the first preset byte of the first preset number of MAC addresses to be configured, the serial number of the physical NIC is written into the second preset byte of each MAC address to be configured, and the serial number of the service node where the physical NIC is located is written into the third preset byte of each MAC address to be configured, thereby obtaining the first preset number of MAC addresses corresponding to the physical NIC.

[0009] Based on multiple IP addresses and multiple MAC addresses corresponding to each physical network interface card, an IP address and a MAC address are assigned to each first virtual network interface card in the target container; the target container is a container in the service node where the corresponding physical network interface card is located, and the multiple IP addresses are different from each other.

[0010] Secondly, embodiments of this application disclose an address allocation device, the device comprising:

[0011] An identification module is used to identify at least one service node in a service cluster. Each service node includes at least one physical network card and at least one container. Each container is loaded with at least one first virtual network card. The first virtual network card and the physical network card correspond one-to-one.

[0012] The first acquisition module is used to, for each physical network card, write a preset value of a first preset number into the first preset byte position of the first preset number of MAC addresses to be configured, write the serial number of the physical network card into the second preset byte position of each MAC address to be configured, and write the serial number of the service node where the physical network card is located into the third preset byte position of each MAC address to be configured, so as to obtain the first preset number of MAC addresses corresponding to the physical network card.

[0013] The first allocation module is used to allocate an IP address and a MAC address to each first virtual network card in the target container based on multiple IP addresses and multiple MAC addresses corresponding to each physical network card; the target container is a container in the service node where the corresponding physical network card is located, and the multiple IP addresses are different from each other.

[0014] Thirdly, embodiments of this application also disclose an electronic device, including a processor and a memory, wherein the memory stores a program or instructions that can run on the processor, and the program or instructions, when executed by the processor, implement the steps of the method described in the first aspect.

[0015] Fourthly, embodiments of this application also disclose a readable storage medium storing a program or instructions that, when executed by a processor, implement the steps of the method described in the first aspect.

[0016] In this embodiment, each service node in the service cluster is identified. For each physical network interface card (NIC) in the service node, a first preset number of MAC addresses corresponding to the physical NIC are obtained by writing a preset value of a first preset number to the first preset number of MAC addresses to be configured, writing the NIC's serial number to the second preset number of MAC addresses to be configured, and writing the serial number of the service node to which the NIC resides to the third preset number of MAC addresses to be configured. Multiple MAC addresses corresponding to each physical NIC are obtained by writing the preset value of the first preset number to the first preset number of MAC addresses. The data in the first preset number of MAC addresses obtained are different from each other, therefore, the multiple MAC addresses corresponding to each physical NIC are also different from each other. For different physical NICs in the same service node, the corresponding MAC addresses are obtained by writing the NIC's serial number to the second preset number of MAC addresses to be configured. Therefore, the data in the second preset number of MAC addresses corresponding to different physical NICs are also different, thus the MAC addresses corresponding to different physical NICs are also different from each other. For different service nodes, the service node's sequence number is written into the third preset byte of the MAC address to be configured, thus ensuring that the MAC addresses corresponding to each physical network card in different service nodes are different. In other words, the multiple MAC addresses corresponding to the same physical network card obtained using this method are different from each other, and the multiple MAC addresses corresponding to different physical network cards are also different from each other; that is, the multiple MAC addresses in the cluster obtained using this method are different from each other. Based on the multiple different IP addresses and multiple MAC addresses corresponding to each physical network card, an IP address and a MAC address are assigned to each first virtual network card in the target container located in the service node where the corresponding physical network card is located. Because the obtained MAC addresses corresponding to each physical network card are different from each other, and the corresponding IP addresses are also different from each other, after assigning an IP address and a MAC address to the first virtual network card of the target container, the MAC addresses corresponding to different first virtual network cards are different from each other, and the corresponding IP addresses are also different from each other, satisfying the one-to-one relationship between MAC addresses and IP addresses. During container communication in the cluster, a unique IP address can be determined based on the MAC address, thereby ensuring normal communication between containers in the cluster. In other words, the method of this application will not result in one MAC address corresponding to multiple IP addresses. This solves the problem in related technologies where MAC addresses are generated by random generation, and the resulting multiple MAC addresses may be the same, causing the MAC addresses assigned to multiple first virtual network cards in the container to be duplicated, which in turn causes the container to be unable to communicate normally. Attached Figure Description

[0017] Figure 1This is a flowchart illustrating the steps of an address allocation method provided in an embodiment of the present invention;

[0018] Figure 2 This is a schematic diagram illustrating the correspondence between physical network cards and virtual network cards provided in an embodiment of the present invention;

[0019] Figure 3 This is a flowchart illustrating the steps of another address allocation method provided in an embodiment of the present invention;

[0020] Figure 4 This is a flowchart of another address allocation method provided in an embodiment of the present invention;

[0021] Figure 5 This is a block diagram of an address allocation device provided in an embodiment of the present invention;

[0022] Figure 6 This is a block diagram of an electronic device provided in an embodiment of the present invention;

[0023] Figure 7 This is a block diagram of another electronic device provided in an embodiment of the present invention. Detailed Implementation

[0024] Exemplary embodiments of the invention will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the invention are shown in the drawings, it should be understood that the invention may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this invention will be thorough and complete, and will fully convey the scope of the invention to those skilled in the art.

[0025] First, some of the nouns or terms appearing in this application shall be interpreted as follows:

[0026] Kubernetes is an open-source container orchestration project.

[0027] Remote Direct Data Access over Converged Ethernet (ROCE) is a network protocol that allows remote direct memory access over Ethernet.

[0028] ROCE network interface card (NIC), a physical NIC that supports the ROCE protocol.

[0029] Single Root I / O Virtualization (SRIOV) is a technology that virtualizes a physical network card into multiple lightweight PCI-e (peripheral component interconnect express, a high-speed serial computer expansion bus standard) physical devices, and then allocates these lightweight PCI-e devices to containers or virtual machines.

[0030] The switch's Address Resolution Protocol (ARP) table stores IP addresses and the MAC addresses associated with those IP addresses. When a host connected to the switch communicates with a service node container, it can look up the MAC address corresponding to the IP address based on the data stored in the switch's ARP table, thus enabling communication between the service node container and the host.

[0031] refer to Figure 1 The document illustrates a flowchart of the address allocation method provided in this embodiment. The method is applied to a cluster management service node. The cluster management service node can generate corresponding MAC addresses for the physical network cards of each service node in the cluster and allocate IP addresses and MAC addresses to the first virtual network card in the corresponding target container. The method may include:

[0032] Step 101: Identify at least one service node in the service cluster. Each service node includes at least one physical network card and at least one container. Each container is loaded with at least one first virtual network card. The first virtual network card and the physical network card correspond one-to-one.

[0033] In this embodiment of the invention, the type of service cluster and the service node types of each service node included in the service cluster can be set according to user needs. For example, for a service cluster used for AI training, the service cluster can be a Kubernetes cluster created based on Kubernetes, and each service node managed by the Kubernetes cluster can be a graphics processing unit (GPU) service node or other service nodes that can meet the requirements of AI training.

[0034] In this embodiment of the invention, the service cluster can be a cluster suitable for AI training scenarios or a cluster suitable for other application scenarios; no limitation is made here. There can be various types of physical network interface cards (NICs), such as ROCE NICs or other NICs capable of enabling container communication within cluster service nodes. For example, in an AI training application scenario, the cluster can choose to use a ROCE network that can reuse existing Ethernet infrastructure for communication. In this case, the physical NICs in the cluster service nodes can choose to use ROCE NICs to meet the communication needs of containers within the cluster's service nodes in AI training scenarios with heavy training tasks.

[0035] In this embodiment of the invention, each server service node may include at least one physical network interface card (NIC). For each physical NIC, a first virtual NIC corresponding to the physical NIC is obtained by loading one of at least one second virtual NIC associated with the physical NIC into a container.

[0036] The following reference Figure 2 The correspondence between the first virtual network interface card (NIC) and the physical NIC is illustrated below: In this embodiment, the first container is one of multiple containers created by the service cluster management service node within a certain service node in the cluster. This service node includes two physical NICs: physical NIC A and physical NIC B. Both physical NIC A and physical NIC B are associated with two second virtual NICs. The two second virtual NICs associated with physical NIC A are second virtual NIC A1 and second virtual NIC A2, respectively, and the two second virtual NICs associated with physical NIC B are second virtual NIC B1 and second virtual NIC B2, respectively. The first virtual NIC A and the first virtual NIC B are loaded into the first container. The first virtual NIC A is loaded based on the second virtual NIC A2 corresponding to physical NIC A; the first virtual NIC B is loaded based on the second virtual NIC B1 corresponding to physical NIC B. The first virtual NIC B corresponds to physical NIC B.

[0037] In this embodiment of the invention, the second virtual network interface card (NIC) associated with the physical NIC is obtained by virtualizing the physical NIC. For example, in a service cluster built for a ROCE network, the physical NIC can be a ROCE NIC. The ROCE NIC in the service cluster can be virtualized using SRIOV technology to obtain multiple second virtual NICs corresponding to the ROCE NIC. These second virtual NICs are then loaded into containers that execute corresponding processing tasks to obtain corresponding first virtual NICs. It should be noted that the ROCE NIC implements Remote Direct Memory Access (RDMA) communication based on the User Datagram Protocol (UDP). Therefore, IP information needs to be configured for the first virtual NIC in the target container corresponding to the ROCE NIC, and then communication between different first virtual NICs is achieved based on a physical switch.

[0038] The number of second virtual network interfaces associated with each physical network interface card (NIC) can be set according to user needs. For example, if the service node where the physical NIC resides includes multiple containers, the number of second virtual NICs associated with the physical NIC can be determined based on the number of containers included in the service node. Further illustratively, the number of second virtual NICs associated with the physical NIC can be equal to or greater than the number of containers included in the service node where the physical NIC resides.

[0039] It should be noted that, in the embodiments of the present invention, the container can be a single container or a group of containers containing multiple containers, and there is no limitation here.

[0040] Step 102: For each physical network interface card (NIC), write the preset value of the first preset number into the first preset byte position of the first preset number of MAC addresses to be configured, write the sequence number of the physical NIC into the second preset byte position of each MAC address to be configured, and write the sequence number of the service node where the physical NIC is located into the third preset byte position of each MAC address to be configured, thereby obtaining the first preset number of MAC addresses corresponding to the physical NIC.

[0041] In this embodiment of the invention, the MAC address to be configured refers to the MAC address for which data needs to be configured for each preset byte, or in other words, the MAC address to be configured is the MAC address for which corresponding data needs to be written to the corresponding preset byte.

[0042] In this embodiment of the invention, the MAC address is formatted as a 6-byte binary code. It should be noted that the terms "first," "second," and "third" in the first, second, and third preset byte bits are merely to distinguish the byte bits used to write the corresponding data and do not limit the order of these byte bits within the multiple bytes of the MAC address. Furthermore, each preset byte bit in the first, second, and third preset byte bits can correspond to one byte in the MAC address, or it can correspond to multiple bytes in the MAC address. The number of bytes corresponding to each preset byte bit can be equal or unequal.

[0043] In this embodiment of the invention, when a preset byte corresponds to the first byte in a MAC address, it is necessary to ensure that the data written into that preset byte is even to ensure that the generated MAC address is a unicast address. When the first preset byte corresponds to the first byte in a MAC address, the preset values ​​of the first preset number are all different even values. When the second or third preset byte corresponds to the first byte in a MAC address, the sequence number values ​​used to write to the corresponding preset byte can be multiplied by the same even coefficient to ensure that the data written to the corresponding preset byte is even. For example, if the second preset byte corresponds to the first byte in a MAC address, the actual sequence number of the physical network card written to the second preset byte of each MAC address to be configured is multiplied by the same even coefficient, and the processed sequence number is determined as the sequence number of the physical network card, ensuring that the sequence number of the physical network card written to the second preset byte is even, and also ensuring that the data written to the second preset byte is all different. For example, if the third preset byte corresponds to the first byte in the MAC address, then the actual sequence number of the service node where the physical network card is located is multiplied by an even coefficient, and the processed sequence number is determined as the sequence number of the service node where the physical network card is located.

[0044] In this embodiment of the invention, the first preset number corresponding to different physical network cards can be the same or different. The first preset number corresponding to each physical network card can be set according to user needs. The method for determining the first preset number is described below by way of example. In one embodiment, a physical network card is associated with multiple second virtual network cards. The number of second virtual network cards associated with the physical network card can be obtained, and the first preset number can be determined based on the number of second virtual network cards. Further by way of example, the number of second virtual network cards can be determined as the first preset number, or a number greater than the number of second virtual network cards can be determined as the first preset number.

[0045] In this embodiment of the invention, the preset values ​​of the first preset number are different from each other. This ensures that after writing the corresponding data to each preset byte of the MAC address to be configured, the resulting MAC addresses corresponding to the same physical network card are different from each other. The preset values ​​can be set according to user needs. For example, the sequence number of multiple second virtual network cards associated with the physical network card can be used as the preset value. Different random values ​​for the first preset number can be randomly generated and used as the preset value of the first preset number. Other methods can also be used to obtain different preset values ​​for the first preset number; the method for obtaining the preset value is not limited here.

[0046] In this embodiment of the invention, there are various methods for determining the sequence number of a physical network interface card (NIC). For example, the sequence number of the physical NIC among all physical NICs included in the corresponding service node can be determined, and this sequence number is determined as the sequence number of the physical NIC. In this embodiment of the invention, the sequence number of the service node is the sequence number of the service node among all service nodes in the cluster.

[0047] Step 103: Based on the multiple IP addresses and multiple MAC addresses corresponding to each physical network card, assign an IP address and a MAC address to each first virtual network card in the target container.

[0048] The target container is the container in the service node where the corresponding physical network card is located; the multiple IP addresses are different from each other.

[0049] In this embodiment of the invention, the multiple IP addresses corresponding to the physical network card are multiple IP addresses generated based on the subnet information of the subnet corresponding to the physical network card.

[0050] In this embodiment of the invention, the multiple MAC addresses corresponding to the physical network cards are MAC addresses for which corresponding data is written into each preset data bit according to the method shown in step 102, representing a first preset number of MAC addresses. The number of MAC addresses corresponding to different physical network cards may be equal or unequal.

[0051] In this embodiment of the invention, each physical network card is located in a service node that includes multiple target containers. Each target container has at least one first virtual network card. The multiple first virtual network cards in the same target container correspond one-to-one with the multiple physical network cards in the corresponding service node. In other words, each first virtual network card in the target container has a corresponding physical network card.

[0052] In this embodiment of the invention, for each first virtual network interface card (NIC), a corresponding physical NIC is determined. Based on the multiple IP addresses and multiple MAC addresses of the corresponding physical NIC, an IP address and a MAC address are allocated to the first virtual NIC. That is, the IP address allocated to the first virtual NIC is one of the multiple IP addresses corresponding to the physical NIC, and the MAC address allocated to the first virtual NIC is one of the multiple MAC addresses corresponding to the physical NIC.

[0053] In this embodiment, each service node in the service cluster is identified. For each physical network interface card (NIC) in the service node, a first preset number of MAC addresses corresponding to the physical NIC are obtained by writing a preset value of a first preset number to the first preset number of MAC addresses to be configured, writing the NIC's serial number to the second preset number of MAC addresses to be configured, and writing the serial number of the service node to which the NIC resides to the third preset number of MAC addresses to be configured. Multiple MAC addresses corresponding to each physical NIC are obtained by writing the preset value of the first preset number to the first preset number of MAC addresses. The data in the first preset number of MAC addresses obtained are different from each other, therefore, the multiple MAC addresses corresponding to each physical NIC are also different from each other. For different physical NICs in the same service node, the corresponding MAC addresses are obtained by writing the NIC's serial number to the second preset number of MAC addresses to be configured. Therefore, the data in the second preset number of MAC addresses corresponding to different physical NICs are also different, thus the MAC addresses corresponding to different physical NICs are also different from each other. For different service nodes, the service node's sequence number is written into the third preset byte of the MAC address to be configured, thus ensuring that the MAC addresses corresponding to each physical network card in different service nodes are different. In other words, the multiple MAC addresses corresponding to the same physical network card obtained using this method are different from each other, and the multiple MAC addresses corresponding to different physical network cards are also different from each other; that is, the multiple MAC addresses in the cluster obtained using this method are different from each other. Based on the multiple different IP addresses and multiple MAC addresses corresponding to each physical network card, an IP address and a MAC address are assigned to each first virtual network card in the target container located in the service node where the corresponding physical network card is located. Because the obtained MAC addresses corresponding to each physical network card are different from each other, and the corresponding IP addresses are also different from each other, after assigning an IP address and a MAC address to the first virtual network card of the target container, the MAC addresses corresponding to different first virtual network cards are different from each other, and the corresponding IP addresses are also different from each other, satisfying the one-to-one relationship between MAC addresses and IP addresses. During container communication in the cluster, a unique IP address can be determined based on the MAC address, thereby ensuring normal communication between containers in the cluster. In other words, the method of this application will not result in one MAC address corresponding to multiple IP addresses. This solves the problem in related technologies where MAC addresses are generated by random generation, and the resulting multiple MAC addresses may be the same, causing the MAC addresses assigned to multiple first virtual network cards in the container to be duplicated, which in turn causes the container to be unable to communicate normally.

[0054] refer to Figure 3The diagram illustrates a flowchart of another address allocation method provided in this application embodiment, which is applied to a cluster management service node.

[0055] Address allocation methods may include the following steps:

[0056] Step 201: Identify at least one service node in the service cluster.

[0057] Each service node includes at least one physical network interface card (NIC) and at least one container. Each container contains at least one first virtual NIC, and the first virtual NIC corresponds one-to-one with the physical NIC.

[0058] This step can be referred to in step 101, and will not be repeated here.

[0059] Step 202: For each physical network interface card (NIC), write the preset value of the first preset number into the first preset byte of the first preset number of MAC addresses to be configured, write the serial number of the physical NIC into the second preset byte of each MAC address to be configured, and write the serial number of the service node where the physical NIC is located into the third preset byte of each MAC address to be configured, thereby obtaining the first preset number of MAC addresses corresponding to the physical NIC.

[0060] This step can be referred to in step 102, and will not be repeated here.

[0061] Step 203: Determine the target data. The target data is data that is different from the fourth preset byte of the MAC address of all physical network cards in the cluster.

[0062] In this embodiment of the invention, as long as the obtained target data is different from the fourth preset byte of the MAC address of all physical network cards in the cluster, the method for generating the target data is not limited. For example, the target data can be obtained by random generation, or it can be generated using other methods.

[0063] Step 204: Write the target data into the fourth preset byte of the MAC address to be configured to obtain the first preset number of MAC addresses corresponding to the physical network card.

[0064] Each physical network interface card (NIC) in the service cluster has a unique MAC address, meaning that the MAC addresses of different physical NICs in the service cluster are different from each other.

[0065] It should be noted that, in this embodiment of the invention, there is no order restriction between step 202, which is used to write corresponding data in the first preset byte, the second preset byte, and the third preset byte, and steps 203 and 204, which are used to write corresponding data in the fourth preset byte. That is, there is no order restriction between the step of writing target data in the fourth byte in steps 203 and 204 and the step of writing corresponding data in the first preset byte, the second preset byte, and the third preset byte in step 202. Furthermore, there is no order restriction when writing corresponding data in the first preset byte, the second preset byte, the third preset byte, and the fourth preset byte.

[0066] In this embodiment of the invention, the first preset byte bit, the second preset byte bit, the third preset byte bit, and the fourth preset byte bit are only for distinguishing byte bits and are not used to limit the order of multiple byte bits in the MAC address. Each preset byte bit may correspond to one byte in the MAC address or multiple bytes in the MAC address.

[0067] The following example illustrates how to obtain the MAC address corresponding to a physical network card, using the first preset byte as the 6th byte of the MAC address, the second preset byte as the 5th byte, the third preset byte as bytes 2 to 4, and the fourth preset byte as the 1st byte.

[0068] In this embodiment, the first service node in the service cluster includes two physical network interface cards (NICs), each NIC being associated with eight second virtual NICs. The number of MAC addresses corresponding to each physical NIC is equal to the number of corresponding second virtual NICs. Taking the MAC address corresponding to the first physical NIC in this service node as an example, the method for obtaining the MAC address corresponding to this physical NIC includes the following steps:

[0069] Step 2041: Randomly obtain an even value of 14. The first byte of the MAC address of each physical network card in the cluster is not equal to 14. Write the even value 14 as the target data into the first byte of the MAC address to be configured.

[0070] Step 2042: Write the sequence number "00" of the service node where the physical network card is located into the second byte of the MAC address to be configured.

[0071] In this embodiment of the invention, the data written to each preset byte can be data encoded in hexadecimal. For example, after hexadecimal encoding of sequence number 1, the data obtained is "00", and after hexadecimal encoding of sequence number 256, the data obtained is "ff".

[0072] It should be noted that when writing a sequence number in one byte of a MAC address, up to 256 sequence numbers can be written. When the corresponding sequence number exceeds 256, other bytes in the corresponding preset byte position can be used to extend the sequence number writing. For example, the third preset byte position corresponds to the second to fourth bytes of the MAC address. The data written to the third preset byte is the sequence number of the service node where the physical network card is located. When the number of service nodes in the cluster exceeds 256, the third word and the second byte of the MAC address to be configured can be used to write the sequence number, or the third byte, the fourth byte, and the second byte can be used to write the sequence number. When the number of service nodes is not large enough, and only some of the three service nodes need to be used to write the sequence number, preset fixed values ​​can be written in the other service nodes. For example, in this embodiment, the number of service nodes does not exceed 256, and only the second byte of the MAC address to be configured is used to write the sequence number, then the preset fixed values ​​"11" and "f5" are written in the third and fourth bytes, respectively. The fixed values ​​written to the free byte positions can be randomly generated data or generated by other methods, which are not limited here.

[0073] Specifically, for each physical network interface card (NIC) within the same service node, the data used to write the third preset byte of the MAC address to be configured is the sequence number of the corresponding service node. Therefore, for each physical NIC within the same service node, the sequence number of the service node to which the physical NIC is located can be used as a global variable for the third preset byte of all MAC addresses to be configured corresponding to that service node, and this global variable can be written into the third preset byte of all MAC addresses to be configured corresponding to that service node.

[0074] Step 2043: Write the physical network card serial number "00" into the 5th byte of the MAC address to be configured.

[0075] Step 2044: Write the eight preset values ​​“3a”, “3b”, “3c”, “3d”, “3e”, “3f”, “40”, and “41” into the sixth bit of the eight MAC addresses to be configured.

[0076] Based on steps 2041 to 2043, eight MAC addresses corresponding to the first physical network card of the first service node in the cluster are obtained. The eight MAC addresses obtained are: 14:00:11:f5:00:3a, 14:00:11:f5:00:3b, 14:00:11:f5:00:3c, 14:00:11:f5:00:3d, 14:00:11:f5:00:3e, 14:00:11:f5:00:3f, 14:00:11:f5:00:40, and 14:00:11:f5:00:41.

[0077] Step 205: Associate the multiple IP addresses and multiple MAC addresses corresponding to each physical network card one-to-one to obtain address pairs corresponding to the multiple IP addresses and multiple MAC addresses corresponding to each physical network card.

[0078] Among them, the IP addresses corresponding to the same physical network card are different from each other, and the IP addresses corresponding to different physical network cards are also different from each other.

[0079] In this optional embodiment, the number of IP addresses generated based on the subnet information of the physical network interface card (NIC) may be more or less than the number of MAC addresses corresponding to the NIC. When performing a one-to-one association between IP addresses and MAC addresses, the smaller of the number of IP addresses and MAC addresses is determined as the number of IP address and MAC address pairs obtained. If the number of IP addresses exceeds the number of MAC addresses, the excess IP addresses cannot obtain unassociated MAC addresses, and therefore, IP address and MAC address association is not performed on these excess IP addresses. Similarly, if the number of MAC addresses exceeds the number of IP addresses, the excess MAC addresses cannot obtain unassociated IP addresses, and therefore, IP address and MAC address association is not performed on these excess MAC addresses.

[0080] Step 206: Based on the multiple IP address and MAC address pairs corresponding to each physical network card, assign an IP address and MAC address pair to each first virtual network card corresponding to the physical network card.

[0081] The allocation method is illustrated below: The IP address corresponding to the physical network card is 192.168.10.2, and the MAC address in the address pair associated with this IP address is 14:00:11:f5:00:3a. When the IP address 192.168.10.2 is allocated to the first virtual network card corresponding to the physical network card, the MAC address 14:00:11:f5:00:3a will also be allocated to the first virtual network card at the same time.

[0082] Optionally, after obtaining multiple IP address and MAC address pairs corresponding to each physical network interface card (NIC), an association table of IP addresses and MAC addresses can be generated based on the obtained address pairs. The switch's ARP table is then determined based on this association table, and the determined switch ARP table is stored in the corresponding switch. For example, determining the switch's ARP table based on this association table includes writing the contents of the association table into the switch's ARP table. Therefore, after the IP addresses and MAC addresses are reclaimed and reallocated, the mapping between IP addresses and MAC addresses stored in the switch will not change.

[0083] After obtaining the association table of IP addresses and MAC addresses, when the service cluster management service node allocates IP address and MAC address pairs to the first virtual network card, it can determine from the association table the address pairs corresponding to the physical network card of the first virtual network card that are currently unused, and allocate any one of the determined unused address pairs to the first virtual network card.

[0084] In this embodiment of the invention, the multiple IP addresses corresponding to each network interface card (NIC) are different from each other, and the multiple MAC addresses obtained according to steps 201 to 204 are also different from each other. Therefore, after associating the multiple IP addresses and multiple MAC addresses corresponding to each physical NIC one-to-one, multiple different address pairs can be obtained, and there will be no situation where the same MAC address is associated with different IP addresses, nor will there be a situation where the same IP address is associated with different MAC addresses. Thus, after assigning an IP address pair and a MAC address pair to the first virtual NIC corresponding to each physical NIC, it can be ensured that the IP addresses and MAC addresses assigned to the multiple first virtual NICs are different from each other, ensuring normal communication.

[0085] In related technologies, in some clusters, containers can be created and recycled rapidly. After a container is recycled, the IP address assigned to the virtual network interface card (NIC) within it is also recycled. These recycled IP addresses are then reassigned to newly created containers. After the IP address is assigned to the newly created container, the MAC address corresponding to that IP address becomes the MAC address assigned to the newly created container. In this case, the MAC address corresponding to the IP address may be different from the MAC address corresponding to the IP address before the IP address was recycled. In practical applications, the speed of container recycling and creation is often faster than the update speed of the switch ARP table stored in the switch. This can lead to the following situation: the MAC address corresponding to the reassigned IP address after recycling has actually changed, while the IP address and its corresponding MAC address stored in the switch ARP table have not been updated. The MAC address stored in the switch ARP table is still the MAC address corresponding to the IP address before recycling. This inconsistency between the IP address and MAC address mapping stored in the switch and the actual IP address and MAC address mapping will cause communication failures when containers in the cluster communicate, as the correct MAC address cannot be found based on the IP address stored in the switch ARP table.

[0086] In this embodiment of the invention, multiple IP addresses and multiple MAC addresses are associated one-to-one, and the obtained IP address and MAC address pairs are assigned to the corresponding first virtual network interface card in the target container. Therefore, during container creation and recycling, IP addresses and MAC addresses are recycled and reallocated in the form of one-to-one associated address pairs, preventing changes in the correspondence between IP addresses and MAC addresses after recycling and reallocation. In other words, through the method of this embodiment, the MAC address determined based on the IP address remains unique and unchanged before and after IP address recycling and reallocation, solving the problem in related technologies where communication failures occur due to changes in the MAC address determined based on the IP address during container recycling and reconstruction.

[0087] In this embodiment, a first preset number of MAC addresses corresponding to physical network cards are obtained by writing a preset value of a first preset number of MAC addresses to be configured into the first preset byte bits of each of the first preset number of MAC addresses to be configured, writing the serial number of the physical network card into the second preset byte bits of each of the MAC addresses to be configured, writing the serial number of the service node where the physical network card is located into the third preset byte bits of each of the MAC addresses to be configured, and writing target data that is different from the data in the fourth preset byte bits of the MAC addresses of all physical network cards in the cluster into the fourth preset byte bits of the MAC addresses to be configured. Since the data in the first preset byte bits of each MAC address obtained is different from each other, the first preset number of MAC addresses corresponding to each physical network card obtained based on the method of this embodiment are also different from each other. The data in the second preset byte bits of the MAC addresses corresponding to different physical network cards are also different, thus the MAC addresses corresponding to different physical network cards are also different. The data in the third preset byte bits of the MAC addresses corresponding to different service nodes are also different, thus the MAC addresses corresponding to each physical network card in different service nodes are also different. The data in the fourth preset byte of each obtained MAC address is different from the data in the fourth preset byte of the MAC addresses of all physical network cards in the cluster. Therefore, the obtained MAC addresses are also different from the MAC addresses of all physical network cards in the cluster. In other words, the multiple MAC addresses obtained using this method are different from each other, and each obtained MAC address is different from the MAC address of each physical network card in the cluster. This method associates multiple IP addresses and multiple MAC addresses corresponding to each physical network card one-to-one, and then assigns the associated address pairs to the corresponding first virtual network card. Because the multiple IP addresses are different from each other, and the multiple MAC addresses obtained using this method are also different from each other, the resulting address pairs are different from each other. This avoids the problem of the same MAC address being associated with multiple IP addresses, which would lead to the allocation of the same MAC address to different target containers and cause communication failures due to identical MAC addresses between different target containers. Furthermore, since the multiple MAC addresses obtained using this method are different from the MAC addresses of the physical network cards in the cluster, the problem of communication failures due to identical MAC addresses can be avoided. In other words, the method based on this application will not result in one MAC address corresponding to multiple IP addresses. This solves the problem in related technologies where multiple MAC addresses generated may be the same, which may lead to the same MAC address being assigned to multiple virtual network cards, resulting in a one-to-many situation between MAC addresses and IP addresses in the cluster container, thus causing the containers to be unable to communicate normally.

[0088] Optionally, after step 205, the method further includes:

[0089] Step 207: Store multiple IP address and MAC address pairs in the switch so that after assigning IP address and MAC address pairs to each second virtual network interface card in the target container, the target container can perform network communication based on the multiple IP address and MAC address pairs stored in the switch.

[0090] For example, the obtained IP address and MAC address pair is stored in the switch's ARP table.

[0091] In this embodiment of the invention, after obtaining multiple IP address and MAC address pairs corresponding to each physical network interface card (NIC), the address pairs are stored in the switch. This ensures that the target container performs network communication based on the address pairs stored in the switch. Furthermore, the switch stores IP address and MAC address pairs obtained through a one-to-one association between IP address and MAC address. In this case, when containers in the cluster are recycled and created, the recycled IP address and its corresponding MAC address are reassigned to the created container in the form of associated address pairs. During this process, the mapping between IP address and MAC address stored in the switch's ARP table is identical to the mapping between IP address and MAC address actually assigned to the container. This solves the problem in related technologies where, because the mapping between IP address and MAC address stored in the switch's ARP table differs from the mapping between IP address and MAC address actually assigned to the container, the correct MAC address cannot be found based on the IP address in the switch's ARP table, causing containers in the cluster to be unable to communicate.

[0092] Optionally, step 203 specifically includes:

[0093] Sub-step 2031: Obtain a random number.

[0094] It should be noted that, when the fourth preset byte corresponds to the first byte of the MAC address, the obtained random number is even. This ensures that after determining the target data based on the random number and writing the target data into the fourth preset byte, the resulting MAC address is a unicast address. There are various methods for generating random numbers, which are not limited here.

[0095] Sub-step 2032: Obtain the MAC addresses of all physical network cards in the service cluster.

[0096] In this embodiment of the invention, the service cluster includes multiple service nodes, each service node includes at least one physical network interface card (NIC), and each physical NIC in the cluster has a unique MAC address.

[0097] In this embodiment of the invention, each service node of the service cluster is equipped with a MAC address acquisition component for obtaining the MAC address of each physical network card of the corresponding service node. The service cluster management service node sends an instruction to each MAC address acquisition component for extracting the MAC address. In response to the instruction, the MAC address acquisition component sends the MAC address of the corresponding physical network card stored therein to the service cluster management service node.

[0098] Sub-step 2033: Obtain the fourth preset byte of the MAC address of each physical network card in the service cluster.

[0099] In this embodiment of the invention, for each physical network card's MAC address, the data of the fourth preset byte is extracted from its fourth preset byte.

[0100] Sub-step 2034: Compare the random number with the data in the fourth preset byte of the MAC address of each physical network card in the cluster to determine whether the random number is different from the data in the fourth preset byte of the MAC address of all physical network cards in the cluster.

[0101] Specifically, the MAC address of each physical network card is obtained, and the data of the fourth preset byte of the corresponding MAC address is extracted from the fourth preset byte of the physical network card MAC address.

[0102] Sub-step 2035: If the data in the fourth preset byte of the random number and the MAC address of all physical network cards in the cluster are different, then the random number is determined to be the target data.

[0103] The data in the fourth preset byte of the random number and the MAC address of all physical network cards in the cluster are different, which can ensure that the MAC address obtained after writing the random number into the fourth preset byte of the MAC address to be configured is different from the MAC address of the physical network card.

[0104] Sub-step 2036: If it is determined that the random number is the same as the data in the fourth preset byte of the MAC address of any physical network card in the cluster, then a new random number is obtained, and it is determined whether the new random number is different from the data in the fourth preset byte of the MAC address of all physical network cards in the cluster. If they are all different, then the new random number is determined as the target data.

[0105] In this embodiment of the invention, a random number is obtained and compared with the data in the fourth preset byte of the MAC address of each physical network card in the cluster. The random number that is different from the data in the fourth preset byte of the MAC address of all physical network cards is determined as the target data. If the random number is the same as the data in the fourth preset byte of the MAC address of any physical network card, a new random number is obtained and compared again. Therefore, target data that is different from the data in the fourth preset byte of the MAC address of each physical network card in the cluster can be quickly obtained. This ensures that after the target data is written into the fourth preset byte of the MAC address to be configured, the resulting MAC address is different from the MAC addresses of all physical network cards in the cluster.

[0106] Prior to step 205, the following may also be included:

[0107] Step 208: Obtain multiple IP addresses corresponding to each physical network card.

[0108] The multiple IP addresses corresponding to each physical network card are generated based on the subnet information corresponding to the physical network card. The multiple IP addresses match the network segments in the classless inter-domain routing information of the corresponding subnet, and are different from the corresponding gateway address.

[0109] In this embodiment of the invention, the user can plan an IP address pool for the second virtual network interface card (NIC) corresponding to each physical NIC according to the network planning of the switch. The service cluster management service node obtains the IP address pool and extracts multiple IP addresses corresponding to the physical NICs from it. For example, the IP address pool information may include the Classless Inter-Domain Routing (CIDR), gateway address, and the start and end values ​​of available IP addresses in the subnet information corresponding to each physical NIC. For example, in a cluster, each service node of the cluster includes two physical NICs, the type of which is ROCE NIC. These two ROCE NICs correspond to different subnets, and the subnet information that needs to be configured for the second virtual NICs corresponding to these two ROCE NICs is marked as netA and netB, respectively. The IP address pool information corresponding to these two ROCE NICs is shown in Table 1.

[0110] Subnet name Subnet CIDR Gateway address Available IP address starting value Available IP address end value netA 192.168.10.1 / 24 192.168.10.1 192.168.10.2 192.168.10.254 netB 192.168.20.1 / 24 192.168.20.1 192.168.20.2 192.168.20.254

[0111] Table 1

[0112] Specifically, the ROCE network interface card corresponding to netA has multiple IP addresses between 192.168.10.2 and 192.168.10.254. These IP addresses share the same network segment as the subnet CIDR segment of subnet netA, but differ from their corresponding gateway addresses. Similarly, the ROCE network interface card corresponding to netB has multiple IP addresses between 192.168.20.2 and 192.168.20.254. These IP addresses share the same network segment as the subnet CIDR segment of subnet netB, but differ from their corresponding gateway addresses.

[0113] Optionally, if a service node is added to the service cluster, the process after step 206 further includes:

[0114] Step 209: Obtain the MAC address of each physical network card in the newly added service node.

[0115] The method for obtaining the MAC address of each physical network card in the newly added service node is the same as the method for obtaining the MAC address of the physical network card in sub-step 2032, and will not be repeated here.

[0116] Step 210: If any MAC address corresponding to each physical network card is the same as the MAC address of any physical network card in the newly added service node, update the MAC address corresponding to the physical network card to obtain the updated MAC address corresponding to the physical network card.

[0117] It should be noted that the updated MAC address is different from the MAC address of each physical network card in the cluster after the addition of a service node.

[0118] In this embodiment of the invention, by comparing the MAC addresses corresponding to each physical network card with the MAC addresses of each physical network card in the newly added service node, it is determined whether each MAC address corresponding to a physical network card is different from the MAC address of each physical network card in the newly added service node based on the comparison results.

[0119] In this embodiment of the invention, if a certain MAC address corresponding to a certain physical network card is the same as the MAC address of any physical network card in the newly added service node, the data of any byte in the same MAC address corresponding to the physical network card is updated to obtain the updated MAC address corresponding to the physical network card.

[0120] In an optional embodiment, if the MAC address corresponding to each physical network card is the same as the MAC address of any physical network card in the newly added service node, target data is obtained that is different from the data of the fourth preset byte bit of the MAC address of all physical network cards in the cluster after the addition of the service node. The data of the fourth preset byte bit of all MAC addresses corresponding to all physical network cards is replaced with the target data to update all MAC addresses corresponding to all physical network cards, thereby obtaining the updated MAC address corresponding to each physical network card.

[0121] Step 211: Based on the updated MAC address, reassign the IP address and MAC address.

[0122] In this embodiment of the invention, multiple IP addresses and updated MAC addresses are associated one-to-one to obtain multiple updated address pairs corresponding to each physical network interface card (NIC). Based on these updated address pairs, address pairs are allocated to the first virtual NIC corresponding to each physical NIC. The detailed allocation method is the same as that shown in steps 205 to 206, and will not be repeated here.

[0123] In this embodiment of the invention, by comparing the MAC addresses corresponding to each physical network interface card (NIC) with the MAC address of any physical NIC in the newly added service node, and updating the MAC addresses that are identical to the MAC address of any physical NIC in the newly added service node among the multiple MAC addresses corresponding to each physical NIC, an updated MAC address corresponding to the physical NIC is obtained. Based on the updated MAC address, IP addresses and MAC addresses are reassigned. This ensures that the updated MAC address corresponding to the physical NIC is different from the MAC address of the physical NIC in the newly added service node, ensuring normal communication between containers in the service cluster.

[0124] Optionally, after step 209, the method further includes:

[0125] Step 212: Load at least one second virtual network interface card (NIC) for each container in the newly added service node, with each loaded NIC corresponding to at least one physical NIC in the newly added service node.

[0126] In this embodiment of the invention, the method for loading a second virtual network interface card (NIC) for a container in a newly added service node can refer to the method for loading a second virtual NIC in step 101, and will not be repeated here.

[0127] Step 213: Determine multiple IP addresses and multiple MAC addresses corresponding to each physical network interface card in the newly added service node, and assign an IP address and a MAC address to each second virtual network interface card corresponding to the physical network interface card in the newly added service node in each container.

[0128] In this embodiment of the invention, the method for obtaining multiple MAC addresses of each physical network card in the newly added service node can refer to the method shown in steps 202 to 204; the method for obtaining multiple IP addresses of each physical network card in the newly added service node can refer to step 208; the method for assigning IP addresses and MAC addresses to each second virtual network card corresponding to the newly added physical network card in each container can refer to the method shown in steps 205 to 206, and will not be described again here.

[0129] By assigning an IP address and a MAC address to each second virtual network interface corresponding to the physical network interface card in the newly added service node, normal communication between containers in the newly added service node can be ensured.

[0130] refer to Figure 4 In one optional embodiment, the address allocation method includes the following steps:

[0131] Step 301: Build the service cluster.

[0132] In this embodiment of the invention, a service cluster can be built based on Kubernetes. The service cluster includes multiple service nodes. Each service node includes at least one physical network interface card (NIC) and at least one container. Each physical NIC is associated with at least one second virtual NIC. Each physical NIC has a unique MAC address, and the MAC addresses of each physical NIC are different.

[0133] Step 302: Obtain the MAC addresses of all physical network cards in the service cluster.

[0134] Step 303: Obtain the preset MAC address generation rules.

[0135] In this embodiment of the invention, the preset MAC address generation rule includes: for each physical network interface card (NIC), writing a first preset number of preset values ​​into the first preset byte bits of the first preset number of MAC addresses to be configured; writing the sequence number of the physical NIC into the second preset byte bits of each MAC address to be configured; writing the sequence number of the service node where the physical NIC is located into the third preset byte bits of each MAC address to be configured; and writing the target data into the fourth preset byte bits of the MAC addresses to be configured, thereby obtaining the first preset number of MAC addresses corresponding to the physical NICs. The template data is data that is different from the data in the fourth preset byte bits of the MAC addresses of all physical NICs in the cluster.

[0136] Step 304: Obtain the preset MAC address template.

[0137] In this embodiment of the invention, a preset MAC address template is provided, which includes six bytes, and each byte is used to write data that is processed in hexadecimal encoding.

[0138] Step 305: Based on the preset MAC address generation rules and preset MAC address templates, generate multiple MAC addresses corresponding to each physical network card in the service cluster.

[0139] Step 306: Configure the IP address pool.

[0140] In this embodiment of the invention, the configured address pool includes the CIDR, the corresponding gateway address, and the start and end values ​​of available IP addresses in the subnet information corresponding to each physical network card.

[0141] Step 307: Generate multiple IP address and MAC address pairs corresponding to each physical network card.

[0142] Step 308: Generate an IP address and MAC address relationship table and store it in the switch.

[0143] Step 309: Assign IP address and MAC address pairs to the first virtual network interface card loaded by each container in each service node of the cluster.

[0144] In this embodiment of the invention, the ARP table of the switch is included based on the relationship table between IP address and MAC address, and the ARP table of the switch is stored in the switch.

[0145] Step 310: When adding a service node to the cluster, assign an IP address and MAC address pair to the new service node; when deleting a service node from the cluster, reclaim the IP address and MAC address pair corresponding to the deleted service node.

[0146] refer to Figure 5 It illustrates an address allocation device 40 provided in an embodiment of this application, the device comprising:

[0147] The identification module 401 is used to identify at least one service node in the service cluster. Each service node includes at least one physical network card and at least one container. Each container is loaded with at least one first virtual network card. The first virtual network card and the physical network card correspond one-to-one.

[0148] The first acquisition module 402 is used to, for each physical network card, write a preset value of a first preset number into the first preset byte position of the first preset number of MAC addresses to be configured, write the serial number of the physical network card into the second preset byte position of each MAC address to be configured, and write the serial number of the service node where the physical network card is located into the third preset byte position of each MAC address to be configured, so as to obtain the first preset number of MAC addresses corresponding to the physical network card.

[0149] The first allocation module 403 is used to allocate an IP address and a MAC address to each first virtual network card in the target container based on multiple IP addresses and multiple MAC addresses corresponding to each physical network card; the target container is a container in the service node where the corresponding physical network card is located, and the multiple IP addresses are different from each other.

[0150] Optionally, the first allocation module 403 includes:

[0151] The acquisition submodule is used to associate the multiple IP addresses and multiple MAC addresses corresponding to each physical network card in a one-to-one manner, so as to obtain the address pairs corresponding to the multiple IP addresses and multiple MAC addresses corresponding to each physical network card.

[0152] The allocation submodule is used to allocate an IP address and MAC address pair to each first virtual network card corresponding to a physical network card, based on multiple IP address and MAC address pairs corresponding to each physical network card.

[0153] Optionally, the address allocation device further includes: a storage module for storing multiple IP address and MAC address pairs in the switch so that after allocating IP address and MAC address pairs to each second virtual network interface card in the target container, each container can perform network communication based on the multiple IP address and MAC address pairs stored in the switch.

[0154] Optionally, the first acquisition module 402 further includes:

[0155] The determination submodule is used to determine the target data. The target data is data that is different from the fourth preset byte of the MAC address of all physical network cards in the cluster.

[0156] The write submodule is used to write the target data into the fourth preset byte of the MAC address to be configured; and to obtain the first preset number of MAC addresses corresponding to the physical network card.

[0157] Optionally, determining the submodule also includes:

[0158] The first acquisition unit is used to acquire random numbers;

[0159] The second acquisition unit is used to acquire the MAC addresses of all physical network cards in the cluster;

[0160] The third acquisition unit is used to acquire the fourth preset byte of data of the MAC address of each physical network card in the cluster;

[0161] The comparison unit is used to compare the random number with the data in the fourth preset byte of the MAC address of each physical network card in the cluster to determine whether the random number is different from the data in the fourth preset byte of the MAC address of all physical network cards in the cluster.

[0162] The first determining unit is used to determine the random number as the target data if the data in the fourth preset byte of the determined random number and the MAC address of all physical network cards in the cluster are different.

[0163] The second determining unit is used to re-acquire a random number if the data of the fourth preset byte of the MAC address of any physical network card in the cluster is the same, and to determine whether the new random number is different from the data of the fourth preset byte of the MAC address of all physical network cards in the cluster. If they are all different, the new random number is determined as the target data.

[0164] Optionally, the address allocation device further includes: a second acquisition module, which acquires multiple IP addresses corresponding to each physical network interface card; wherein the multiple IP addresses corresponding to each physical network interface card are generated based on the subnet information corresponding to the physical network interface card, and the multiple IP addresses match the network segments in the classless inter-domain routing information of the corresponding subnet, and are different from the corresponding gateway address.

[0165] Optionally, when adding service nodes to the service cluster, the address allocation device further includes:

[0166] The third acquisition module is used to acquire the MAC address of each physical network card in the newly added service node;

[0167] The fourth acquisition module is used to update the same MAC address corresponding to the physical network card when the MAC address corresponding to each physical network card is the same as the MAC address of any physical network card in the newly added service node, so as to obtain the updated MAC address corresponding to the physical network card.

[0168] The second allocation module is used to reassign IP addresses and MAC addresses based on the updated MAC addresses.

[0169] In this embodiment, each service node in the service cluster is identified. For each physical network interface card (NIC) in the service node, a first preset number of MAC addresses corresponding to the physical NIC are obtained by writing a first preset number of preset values ​​into the first preset number of preset bytes of the MAC address to be configured, writing the NIC's serial number into the first preset byte of each MAC address to be configured, and writing the serial number of the service node where the physical NIC is located into the second preset byte of each MAC address to be configured. Each MAC address of each physical NIC is obtained by writing a first preset number of preset values ​​into the first preset number of preset bytes of the MAC address. The data in the first preset bytes of each MAC address obtained in this way is different from each other. Therefore, the first preset number of MAC addresses obtained corresponding to each physical NIC are also different from each other. For different physical NICs in the same service node, the corresponding MAC address is obtained by writing the physical NIC's serial number into the second preset byte of the MAC address to be configured. Therefore, the data in the second preset byte of the MAC address corresponding to different physical NICs is also different, resulting in different MAC addresses corresponding to different physical NICs. For different service nodes, the service node's sequence number is written into the third preset byte of the MAC address to be configured, thus ensuring that the MAC addresses corresponding to each physical network card in different service nodes are different. In other words, the multiple MAC addresses obtained are all different. Based on the multiple IP addresses and multiple MAC addresses corresponding to each physical network card, an IP address and a MAC address are assigned to each first virtual network card in the target container located in the service node where the corresponding physical network card resides. Because the obtained MAC addresses are different, when assigning an IP address and a MAC address to the first virtual network card of the target container, the MAC addresses assigned to different first virtual network cards are also different, satisfying the one-to-one relationship between MAC addresses and IP addresses and ensuring normal communication between containers in the cluster. In other words, based on this application, the situation where one MAC address corresponds to multiple IP addresses will not occur, solving the problem in related technologies where multiple generated MAC addresses may be the same, leading to the same MAC address being assigned to multiple virtual network cards, resulting in a one-to-many situation between MAC addresses and IP addresses in the cluster containers, thus causing containers to be unable to communicate normally.

[0170] Figure 6 A block diagram of an electronic device 600 is shown according to an exemplary embodiment. For example, the electronic device 600 may be a mobile phone, computer, digital broadcasting terminal, messaging device, game console, tablet device, medical device, fitness equipment, personal digital assistant, etc.

[0171] Reference Figure 6The electronic device 600 may include one or more of the following components: a processing component 602, a memory 604, a power supply component 606, a multimedia component 608, an audio component 610, an input / output (I / O) interface 612, a sensor component 614, and a communication component 616.

[0172] Processing component 602 typically controls the overall operation of electronic device 600, such as operations associated with display, telephone calls, data communication, camera operation, and recording operations. Processing component 602 may include one or more processors 620 to execute instructions to perform all or part of the steps of the methods described above. Furthermore, processing component 602 may include one or more modules to facilitate interaction between processing component 602 and other components. For example, processing component 602 may include a multimedia module to facilitate interaction between multimedia component 608 and processing component 602.

[0173] Memory 604 is used to store various types of data to support the operation of electronic device 600. Examples of such data include instructions for any application or method operating on electronic device 600, contact data, phonebook data, messages, pictures, multimedia, etc. Memory 604 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.

[0174] Power supply component 606 provides power to various components of electronic device 600. Power supply component 606 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to electronic device 600.

[0175] Multimedia component 608 includes a screen that provides an output interface between electronic device 600 and user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touchscreen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors may not only sense the boundaries of touch or swipe actions but also detect the duration and pressure associated with the touch or swipe operation. In some embodiments, multimedia component 608 includes a front-facing camera and / or a rear-facing camera. When electronic device 600 is in an operating mode, such as shooting mode or multimedia mode, the front-facing camera and / or rear-facing camera may receive external multimedia data. Each front-facing camera and rear-facing camera may be a fixed optical lens system or have focal length and optical zoom capabilities.

[0176] Audio component 610 is used to output and / or input audio signals. For example, audio component 610 includes a microphone (MIC) used to receive external audio signals when electronic device 600 is in an operating mode, such as call mode, recording mode, and voice recognition mode. The received audio signals may be further stored in memory 604 or transmitted via communication component 616. In some embodiments, audio component 610 also includes a speaker for outputting audio signals.

[0177] I / O interface 612 provides an interface between processing component 602 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to, home buttons, volume buttons, power buttons, and lock buttons.

[0178] Sensor assembly 614 includes one or more sensors for providing state assessments of various aspects of electronic device 600. For example, sensor assembly 614 may detect the on / off state of electronic device 600, the relative positioning of components such as the display and keypad of electronic device 600, changes in position of electronic device 600 or a component of electronic device 600, the presence or absence of user contact with electronic device 600, orientation or acceleration / deceleration of electronic device 600, and temperature changes of electronic device 600. Sensor assembly 614 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. Sensor assembly 614 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, sensor assembly 614 may also include an accelerometer, gyroscope, magnetometer, pressure sensor, or temperature sensor.

[0179] Communication component 616 facilitates wired or wireless communication between electronic device 600 and other devices. Electronic device 600 can access wireless networks based on communication standards, such as WiFi, carrier networks (such as 2G, 3G, 4G, or 5G), or combinations thereof. In one exemplary embodiment, communication component 616 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, communication component 616 also includes a near-field communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on radio frequency identification (RFID) technology, Infrared Data Association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.

[0180] In an exemplary embodiment, the electronic device 600 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to implement a log file acquisition method provided in the embodiments of this application.

[0181] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 604 including instructions, which can be executed by a processor 620 of an electronic device 600 to perform the above-described method. For example, the non-transitory storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc.

[0182] Figure 7 A block diagram of an electronic device 700 is shown according to an exemplary embodiment. For example, the electronic device 700 may be provided as a server. (Refer to...) Figure 7 The electronic device 700 includes a processing component 722, which further includes one or more processors, and memory resources represented by a memory 732 for storing instructions, such as application programs, that can be executed by the processing component 722. The application programs stored in the memory 732 may include one or more modules, each corresponding to a set of instructions. Furthermore, the processing component 722 is configured to execute instructions to perform a log file acquisition method provided in embodiments of this application.

[0183] Electronic device 700 may also include a power supply component 726 configured to perform power management of electronic device 700, a wired or wireless network interface 750 configured to connect electronic device 700 to a network, and an input / output (I / O) interface 758. Electronic device 700 may operate on an operating system stored in memory 732, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, or similar.

[0184] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the application disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the following claims.

[0185] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.

Claims

1. An address allocation method characterized by, The method is applied to a cluster management service node, and the method comprises: identifying at least one service node in a service cluster, each of the service nodes comprising at least one physical network card and at least one container, each of the containers loading at least one first virtual network card, the first virtual network card and the physical network card corresponding to each other; for each physical network card, writing a first preset number of preset values into a first preset byte of a first preset number of to-be-configured MAC addresses, writing a serial number of the physical network card into a second preset byte of each to-be-configured MAC address, and writing a serial number of a service node where the physical network card is located into a third preset byte of the each to-be-configured MAC address, to obtain a first preset number of MAC addresses corresponding to the physical network card; based on a plurality of IP addresses and a plurality of MAC addresses corresponding to each of the physical network cards, assigning an IP address and a MAC address to each first virtual network card in a target container respectively; the target container is a container in a service node where the corresponding physical network card is located, and the plurality of IP addresses are different from each other.

2. The method of claim 1, wherein, based on a plurality of IP addresses and a plurality of MAC addresses corresponding to each of the physical network cards, assigning an IP address and a MAC address to each first virtual network card in a target container respectively, comprising: associating the plurality of IP addresses and the plurality of MAC addresses corresponding to each physical network card one by one to obtain an address pair of the plurality of IP addresses and MAC addresses corresponding to each physical network card respectively; based on the address pair of the plurality of IP addresses and MAC addresses corresponding to each physical network card respectively, assigning an address pair of an IP address and a MAC address to each first virtual network card corresponding to the physical network card respectively.

3. The method of claim 2, wherein, after obtaining the address pair of the plurality of IP addresses and MAC addresses corresponding to each physical network card respectively, further comprising: storing the address pair of the plurality of IP addresses and MAC addresses in a switch, so that after assigning an address pair of an IP address and a MAC address to each second virtual network card in a target container, the target container performs network communication based on the address pair of the plurality of IP addresses and MAC addresses stored in the switch.

4. The method of claim 1, wherein, obtaining a first preset number of MAC addresses corresponding to the physical network card further comprises: determining target data, the target data being data different from data of fourth preset byte positions of MAC addresses of all physical network cards in the cluster; writing the target data into the fourth preset byte positions of the to-be-configured MAC addresses to obtain the first preset number of MAC addresses corresponding to the physical network card.

5. The method of claim 4, wherein, the determination of the target data comprises: obtaining a random number, the random number being an even number; obtaining MAC addresses of all physical network cards in the cluster; respectively obtaining data of fourth preset byte positions of MAC addresses of each physical network card in the cluster; comparing the random number and the data of the fourth preset byte positions of the MAC addresses of each physical network card in the cluster to determine whether the random number and the data of the fourth preset byte positions of the MAC addresses of all physical network cards in the cluster are different from each other; If it is determined that the random number and the data of the fourth preset byte bit of the MAC address of all physical network cards in the cluster are not the same, it is determined that the random number is the target data; If it is determined that the random number and the data of the fourth preset byte bit of the MAC address of any physical network card in the cluster are the same, a new random number is obtained, and it is determined whether the new random number and the data of the fourth preset byte bit of the MAC address of all physical network cards in the cluster are not the same, if they are not the same, it is determined that the new random number is the target data.

6. The method of claim 1, wherein, Before allocating an IP address and a MAC address to each first virtual network card in the target container based on the plurality of IP addresses and the plurality of MAC addresses corresponding to each of the physical network cards, further comprising: Obtaining a plurality of IP addresses corresponding to each of the physical network cards; Wherein the plurality of IP addresses corresponding to each physical network card are generated according to the subnet information corresponding to the physical network card, the plurality of IP addresses match the network segment in the classless inter-domain routing information of the corresponding subnet, and are different from the corresponding gateway address.

7. The method according to any one of claims 1 to 6, characterized in that, In the case of adding a service node to the service cluster, further comprising: Obtaining the MAC address of each physical network card in the newly added service node; In the case that any of the MAC addresses corresponding to each of the physical network cards is the same as the MAC address of any physical network card in the newly added service node, updating the same MAC address corresponding to the physical network card to obtain an updated MAC address corresponding to the physical network card; Based on the updated MAC address, re-performing the allocation of IP addresses and MAC addresses.

8. An address allocation apparatus characterized by comprising: Comprising: A recognition module for recognizing at least one service node in a service cluster, each of the service nodes comprising at least one physical network card and at least one container, each container loading at least one first virtual network card, the first virtual network card corresponding to the physical network card; A first obtaining module for writing a first preset number of preset values into a first preset byte bit of a first preset number of to-be-configured MAC addresses, writing a serial number of a physical network card into a second preset byte bit of each to-be-configured MAC address, and writing a serial number of a service node where the physical network card is located into a third preset byte bit of each to-be-configured MAC address, to obtain a first preset number of MAC addresses corresponding to the physical network card; A first allocation module for allocating an IP address and a MAC address to each first virtual network card in a target container based on a plurality of IP addresses and a plurality of MAC addresses corresponding to each of the physical network cards; the target container is a container in the service node corresponding to the physical network card, and the plurality of IP addresses are different from each other.

9. An electronic device, comprising: The processor and the memory, the memory stores programs or instructions, the programs or instructions are executed by the processor, and the steps of the method of any one of claims 1-7 are implemented.

10. A readable storage medium, characterized by, The program or instruction is stored on the readable storage medium, and the program or instruction is executed by the processor to implement the steps of the method of any one of claims 1-7.

Citation Information

Patent Citations

  • Method, system and equipment for determining unique identifier of virtual machine and medium

    CN111355716A

  • Container network configuration method and apparatus, computing node, master node, and storage medium

    WO2023098645A1