Disclosure of Invention
In view of this, the present invention provides a method, apparatus, computer device and storage medium for binding a network port, so as to solve the problem that a large number of network ports are idle in the related art, resulting in waste of network port resources, and cannot fully utilize the network port resources.
In a first aspect, the present invention provides a portal binding method, where the method includes:
Under the condition that any target virtual switch needs to bind network ports, acquiring network card information of a plurality of network cards in a virtualized environment;
determining a plurality of network ports included in each network card based on the network card information;
Screening two target network cards from the network cards, screening a first network port from a plurality of network ports of one target network card, and screening a second network port from a plurality of network ports of the other target network card;
Determining that the network port configuration information of the target virtual switch is that the first network port is used as a main network port of the target virtual switch and the second network port is used as a standby network port of the target virtual switch based on the first network port and the second network port;
And performing portal binding on the target virtual switch based on the portal configuration information under the condition that the main portal of the target virtual switch in the portal configuration information is not the main portal of other virtual switches except the target virtual switch.
According to the network port binding method, the network port binding is performed on the target virtual switch based on the network port configuration information under the condition that the main network port of the target virtual switch is not the main network port of other virtual switches except the target virtual switch in the network port configuration information. The method and the device realize that any network port can be used as the main network port of the target virtual switch for bearing the flow of the corresponding function of the target virtual switch under the condition that any network port is not the main network port of other virtual switches in the main-standby mode. The idle network port on the server is fully utilized, and the idle network port comprises the standby network port bound by the virtual switch, so that the effect of maximally utilizing the network port resources on the server is realized.
In an alternative embodiment, the method further comprises:
And under the condition that the main network port of the target virtual switch in the network port configuration information is the main network port of any virtual switch in other virtual switches except the target virtual switch, returning to execute the step of screening two target network cards from a plurality of network cards or returning to execute the step of screening a first network port from a plurality of network ports of one target network card and screening a second network port from a plurality of network ports of the other target network card until the main network port of the target virtual switch in the network port configuration information is not the main network port of the other virtual switch.
According to the network port binding method, in the case that any network port is not the master network port of the other virtual switch in the master-slave mode, the network port can be used as the master network port of the target virtual switch, and the effect of utilizing network port resources on the server is achieved to the greatest extent.
In an alternative embodiment, the method further comprises:
under the condition that any network port fails, determining the network port as a failed network port;
Judging whether a virtual switch binding the fault network port takes the fault network port as a main network port or not;
Under the condition that any virtual switch binding the fault network port takes the fault network port as a main network port, determining the virtual switch taking the fault network port as the main network port as a fault virtual switch;
Taking the standby network port of the fault virtual switch as a new main network port of the fault virtual switch, and carrying out network port binding update on the fault virtual switch based on the new main network port of the fault virtual switch;
Judging whether a new main network port of the fault virtual switch is used as a main network port in the virtual switch which is not subjected to network port binding update;
Under the condition that any virtual switch in the virtual switches which do not perform network port binding update takes a new main network port of the fault virtual switch as a main network port, determining the virtual switch taking the new main network port of the fault virtual switch as the main network port as the virtual switch to be updated;
Taking the main network port of the virtual switch to be updated as a new standby network port of the virtual switch to be updated, taking the standby network port of the virtual switch to be updated as a new main network port of the virtual switch to be updated, and binding and updating the network port of the virtual switch to be updated based on the new main network port and the new standby network port of the virtual switch to be updated;
judging whether the new main network port of the virtual switch to be updated is used as a main network port in the virtual switch which is not subjected to network port binding update;
And under the condition that any virtual switch in the virtual switches which do not perform network port binding update takes the new main network port of the virtual switch to be updated as the main network port, determining that the virtual switch taking the new main network port of the virtual switch to be updated as the main network port is the new virtual switch to be updated, returning to execute the step of taking the main network port of the virtual switch to be updated as the new standby network port of the virtual switch to be updated, taking the standby network port of the virtual switch to be updated as the new main network port of the virtual switch to be updated, and performing the step of network port binding update on the virtual switch to be updated based on the new main network port and the new standby network port of the virtual switch to be updated until no virtual switch which does not perform network port binding update or virtual switch which does not perform network port binding update takes the new main network port of the virtual switch to be updated as the main network port.
According to the network port binding method, the main network port and the standby network port bound by the virtual switch are updated under the condition that any network port fails, so that normal operation of the virtual switch is ensured, and the network interruption risk caused by single network port failure is reduced.
And under the condition that any network port fails, the network port binding of the virtual switch taking the network port as the main network port is updated, and whether the updated main network port is taken as the main network port by the virtual switch which does not perform network port binding update is judged according to the updated main network port of the failed virtual switch, so that the network port binding update is performed on the virtual switch taking the updated main network port as the main network port, the situation that one network port is simultaneously the main network port in different virtual switches is avoided or reduced as much as possible, and the situation that the network response is influenced by too large network port flow caused by the same network port bearing different virtual switch flows is avoided.
In an alternative embodiment, after portal binding is performed on the target virtual switch based on the portal configuration information, the method further includes:
performing communication test on the main network port and the standby network port bound by the target virtual switch;
And under the condition that the communication test is passed, determining that the network port binding of the target virtual switch is normal.
According to the network port binding method, communication tests are conducted on the main network port and the standby network port bound by the target virtual switch, so that normal communication between the main network port and the standby network port of the target virtual switch and normal external communication between the main network port and the standby network port are ensured.
In an alternative embodiment, the performing a communication test on the primary network port and the standby network port bound by the target virtual switch includes:
acquiring a physical address of a main network port and a physical address of a standby network port bound by the target virtual switch;
Taking the physical address of the main network port as a first physical address to be tested, and taking the physical address of the standby network port as a first target physical address;
generating a first test data packet based on the first physical address to be tested and the first destination physical address;
The first test data packet is sent to a physical switch corresponding to the target virtual switch through a main network port, so that the physical switch sends the first test data packet to the standby network port based on a first target physical address in the first test data packet;
under the condition that the standby network port receives the first test data packet, determining that the communication test of the main network port passes;
taking the physical address of the main network port as a second target physical address, and taking the physical address of the standby network port as a second physical address to be detected;
generating a second test data packet based on the second physical address to be tested and a second destination physical address;
the second test data packet is sent to a physical switch corresponding to the target virtual switch through a standby network port, so that the physical switch sends the second test data packet to the main network port based on a second target physical address in the second test data packet;
and under the condition that the main network port receives the second test data packet, determining that the communication test of the standby network port passes.
According to the network port binding method, communication tests are conducted on the main network port and the standby network port bound by the target virtual switch, so that normal communication between the main network port and the standby network port of the target virtual switch and normal external communication between the main network port and the standby network port are ensured.
In an alternative embodiment, the method further comprises:
And under the condition that the communication test is not passed, determining the network port binding abnormality of the target virtual switch, and displaying the network port binding abnormality information so that a user can confirm the abnormality of the main network port and the standby network port bound by the target virtual switch based on the network port binding abnormality information.
According to the network port binding method, when the communication test fails, the existence of abnormality of the network port binding of the target virtual switch can be rapidly determined, the potential network problem can be found timely, and the efficiency of fault detection is improved.
In an alternative embodiment, the method further comprises:
And after the network port binding is carried out on the target virtual switch based on the network port configuration information, storing the corresponding relation between the target virtual switch and the network port bound by the target virtual switch into a virtual switch and network port binding relation table.
According to the network port binding method, the corresponding relation between the target virtual switch and the binding network port is stored in the virtual switch and network port binding relation table, network configuration is convenient to manage and inquire, and the network port binding condition of each virtual switch can be rapidly acquired.
In a second aspect, the present invention provides a portal binding device, the device comprising:
the acquisition module is used for acquiring network card information of a plurality of network cards in the virtualized environment under the condition that any target virtual switch needs to bind network ports;
the first determining module is used for determining a plurality of network ports included in each network card based on the network card information;
The screening module is used for screening two target network cards from the plurality of network cards, screening a first network port from a plurality of network ports of one target network card, and screening a second network port from a plurality of network ports of the other target network card;
The second determining module is used for determining that the network port configuration information of the target virtual switch is that the first network port is used as a main network port of the target virtual switch and the second network port is used as a standby network port of the target virtual switch based on the first network port and the second network port;
and the binding module is used for carrying out network port binding on the target virtual switch based on the network port configuration information under the condition that the main network port of the target virtual switch is not the main network port of other virtual switches except the target virtual switch in the network port configuration information.
In a third aspect, the present invention provides a computer device, including a memory and a processor, where the memory and the processor are communicatively connected to each other, and the memory stores computer instructions, and the processor executes the computer instructions, thereby executing the network port binding method according to the first aspect or any implementation manner corresponding to the first aspect.
In a fourth aspect, the present invention provides a computer readable storage medium, where computer instructions are stored, where the computer instructions are configured to cause a computer to perform the network port binding method according to the first aspect or any one of the embodiments corresponding to the first aspect.
In a fifth aspect, the present invention provides a computer program product, including computer instructions for causing a computer to perform the portal binding method of the first aspect or any of the embodiments corresponding thereto.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments of the present invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
When a server is selected and purchased according to service requirements in a virtualized environment, redundancy of network cards or network ports is generally considered in network card configuration, namely a plurality of network cards are generally configured, different network cards are bound and used through a virtualized platform, and therefore service continuity can be effectively ensured even if one network card fails. Different types of functional data traffic in the virtualized environment will generate corresponding network traffic. Functions in the virtualized environment may include traffic, virtual machine migration, distributed storage, and so forth. In order to ensure that the network traffic of each function is not affected, the network ports of different network cards are generally bound and then assigned to different functions for use, so that the different functions transmit corresponding traffic by using different binding network ports. Wherein one function corresponds to one virtual switch.
It should be noted that virtualization generally refers to the operation of a computing element on a virtual basis rather than a real basis in terms of a computer. The virtualization technology can expand the capacity of hardware and simplify the reconfiguration process of software. The virtualization technology of the CPU can simulate multi-CPU parallelism by a single CPU, allows one platform to simultaneously run a plurality of operating systems, and can be run in mutually independent spaces without mutual influence by application programs, so that the working efficiency of the computer is remarkably improved.
Virtual machines refer to complete computer systems that run in a completely isolated environment with complete hardware system functionality through software emulation. Work that can be done in a physical computer can be done in a virtual machine. When creating a virtual machine in a computer, a part of hard disk and memory capacity of the physical machine are required to be used as the hard disk and memory capacity of the virtual machine. Each virtual machine has a separate CMOS, hard disk and operating system, and can operate as if it were a physical machine.
The virtualization platform is a platform system for running the virtual machine, such as a Linux KVM system, manages and runs a plurality of virtual machines and is responsible for normal running of the virtual machines, physical memory of a host is divided into memory used by the virtual machines and used by the virtual machines, and reading and writing of the memory of the virtual machines are converted into reading and writing of the physical memory when the memory is used by the virtual machines. The platform is the basis for running and managing the virtual machine, is the host of the virtual machine and is responsible for virtual memory and physical memory address conversion and the like of the virtual machine.
The virtual switch refers to vswitch virtual switches or virtual network switches, works on a two-layer data network, and realizes the two-layer (and part three-layer) network functions of the physical switch in a software mode.
Virtual switch binding portals typically bind two portals. In order to enable two bound ports to have traffic transmission at the same time, a physical switch and a virtualization platform are required to perform configuration of dynamic link aggregation, but in many environments, the physical switch may not support dynamic link aggregation, so that only a primary mode and a standby mode can be selected when a binding mode is selected by a virtualization layer binding port, only one of two bound ports in the virtual switch is used as a primary port to provide traffic, and the other one is not used as a standby use standby port (only when the primary port has a fault, the primary port can transmit traffic).
The main and standby modes enable a half of network ports in the virtualized environment to be in an idle state without providing flow, and the standby idle network ports cannot be effectively utilized. The waste of network port resources is caused, and the functions of each network port cannot be fully found.
And when the network ports are completely distributed, the network ports are distributed to the virtual switches corresponding to the new functions, the network ports can be realized only by adding new network cards, and extra hardware investment is generated.
The embodiment of the invention provides a network port binding method, which carries out network port binding on a target virtual switch based on network port configuration information under the condition that a main network port of the target virtual switch in the network port configuration information is not a main network port of other virtual switches except the target virtual switch so as to fully utilize an idle network port on a server and realize the effect of maximally utilizing network port resources on the server.
According to an embodiment of the present invention, there is provided a portal binding method embodiment, it should be noted that the steps illustrated in the flowchart of the drawings may be performed in a computer system such as a set of computer executable instructions, and that although a logical order is illustrated in the flowchart, in some cases the steps illustrated or described may be performed in an order other than that illustrated herein.
In this embodiment, a portal binding method is provided, which may be used in a mobile terminal, such as a server, fig. 1 is a flowchart of a portal binding method according to an embodiment of the present invention, and as shown in fig. 1, the flowchart includes the following steps:
step S101, under the condition that any target virtual switch needs to bind network ports, network card information of a plurality of network cards in a virtualized environment is obtained.
The target virtual switch needs to bind the network port, which may be the case of distributing the network port to the virtual switch corresponding to the new function. That is, the target virtual switch is a virtual switch corresponding to a new function in the virtualized environment. Of course, the target virtual switch may be any virtual switch in the virtualized environment that needs to perform portal binding.
Under the condition that the target virtual switch needs to bind network interfaces, the server acquires network interface information of a plurality of network cards in the virtualized environment, and the network interface information of the plurality of network cards on the server is acquired substantially.
It will be appreciated that a plurality of network cards may be configured on the server.
Step S102, a plurality of network ports included in each network card are determined based on the network card information.
After network card information of a plurality of network cards in the virtualized environment is obtained, a plurality of network ports included in each network card are determined according to the network card information of the plurality of network cards.
It should be noted that each network card may include a plurality of ports, and in general, each network card may include two ports. The number of network interfaces included in each network card is not particularly limited herein.
Step S103, two target network cards are screened out from the plurality of network cards, a first network port is screened out from the plurality of network ports of one target network card, and a second network port is screened out from the plurality of network ports of the other target network card.
Under the condition that a plurality of network ports included in each network card are determined, two target network cards are screened out from the plurality of network cards in the virtualized environment, a first network port is screened out from the plurality of network ports of one target network card, and a second network port is screened out from the plurality of network ports of the other target network card.
It should be noted that the screening process may be a random screening.
Step S104, based on the first network port and the second network port, determining that the network port configuration information of the target virtual switch is the main network port of the target virtual switch, and the second network port is the standby network port of the target virtual switch.
According to the first and second net openings, net opening configuration information of the target virtual switch is determined, wherein the net opening configuration information is that the first net opening is used as a main net opening, and the second net opening is used as a standby net opening.
In step S105, in the case that the master port of the target virtual switch in the port configuration information is not the master port of the virtual switch other than the target virtual switch, port binding is performed on the target virtual switch based on the port configuration information.
After determining the port configuration information of the target virtual switch, determining a master port of the target virtual switch in the port configuration information, specifically determining whether the master port of the target virtual switch in the port configuration information is a master port of other virtual switches except the target virtual switch in the virtualized environment, and if the master port of the target virtual switch in the port configuration information is not a master port of any one of the other virtual switches except the target virtual switch, performing port binding on the target virtual switch based on the port configuration information. That is, the primary port of the target virtual switch may be a standby port of another virtual switch.
When any virtual switch performs portal binding, the corresponding relationship between the virtual switch and the portal bound by the virtual switch needs to be stored in a table of the virtual switch and the portal binding relationship in the virtualized system.
Judging whether the main port of the target virtual switch in the port configuration information is the main port of other virtual switches except the target virtual switch in the virtualized environment, specifically judging whether the main port of the target virtual switch in the port configuration information is the main port of other virtual switches except the target virtual switch in the virtualized environment by traversing the corresponding relation between the virtual switch which is subjected to port binding and the port binding in the port binding relation table.
According to the network port binding method, network port binding is achieved by the method, if any target virtual switch needs to be subjected to network port binding in a virtualized environment with a master/slave mode only, network port information of multiple network cards in the virtualized environment is obtained, multiple network ports included in each network card are determined based on the network port information, two target network cards are screened out of the multiple network cards, a first network port is screened out of multiple network ports of one target network card, a second network port is screened out of multiple network ports of the other target network card, based on the first network port and the second network port, network port configuration information of the target virtual switch is determined to be the master network port of the target virtual switch, the second network port is taken as the standby network port of the target virtual switch, and the network port binding is performed on the target virtual switch based on the network port configuration information under the condition that the master network port of the target virtual switch is not the master network port of other virtual switches except the target virtual switch. The network port on standby in different virtual switches is bound again and used for bearing the traffic of other functions, the idle network port on the server is fully utilized, the network port resource on the server is effectively utilized to the maximum extent, the network traffic of the server is improved, and the availability and performance of the virtualized environment are improved.
And when the network ports are completely distributed to the virtual switches corresponding to the new functions, the network ports of the virtual switches corresponding to the new functions can be distributed by using the standby network ports of other virtual switches as the main network ports, so that the additional hardware investment is reduced.
In this embodiment, a portal binding method is provided, which may be used in a mobile terminal, such as a server, and fig. 2 is a flowchart of a portal binding method according to an embodiment of the present invention, as shown in fig. 2, where the flowchart includes the following steps:
step S201, under the condition that any target virtual switch needs to bind network ports, network card information of a plurality of network cards in the virtualized environment is obtained. Please refer to step S101 in the embodiment shown in fig. 1 in detail, which is not described herein.
Step S202, a plurality of network ports included in each network card are determined based on the network card information. Please refer to step S102 in the embodiment shown in fig. 1 in detail, which is not described herein.
Step S203, two target network cards are screened out from the plurality of network cards, a first network port is screened out from the plurality of network ports of one target network card, and a second network port is screened out from the plurality of network ports of the other target network card. Please refer to step S103 in the embodiment shown in fig. 1 in detail, which is not described herein.
Step S204, based on the first network port and the second network port, determining that the network port configuration information of the target virtual switch is the main network port of the target virtual switch, and the second network port is the standby network port of the target virtual switch. Please refer to step S104 in the embodiment shown in fig. 1 in detail, which is not described herein.
In step S205, in the case that the master port of the target virtual switch in the port configuration information is not the master port of the virtual switch other than the target virtual switch, port binding is performed on the target virtual switch based on the port configuration information. Please refer to step S105 in the embodiment shown in fig. 1 in detail, which is not described herein.
Step S206, under the condition that any network port fails, determining the network port as a failed network port.
If any network port of the network cards on the server fails, determining that the failed network port is a failed network port.
Step S207, judging whether the virtual switch binding the fault network port takes the fault network port as a main network port.
Fig. 3 is a flowchart of performing portal binding update in the case of a portal failure according to an embodiment of the present invention, and as shown in fig. 3, it is determined whether the failed portal is a primary portal in a certain virtual switch, that is, whether the virtual switch binding the failed portal uses the failed portal as the primary portal.
The virtual switch binding the fault network port can be determined by traversing the virtual switch and network port binding relation table, so that whether the virtual switch binding the fault network port takes the fault network port as a main network port or not is judged.
Step S208, when any virtual switch binding the fault network port takes the fault network port as the main network port, determining the virtual switch taking the fault network port as the main network port as the fault virtual switch.
If the virtual switch with the fault network port as the main network port exists in the virtual switch with the fault network port, determining the virtual switch with the fault network port as the main network port in the virtual switch with the fault network port as the main network port as the fault virtual switch.
Step S209, the standby port of the fault virtual switch is used as a new main port of the fault virtual switch, and the network port binding update is performed on the fault virtual switch based on the new main port of the fault virtual switch.
As shown in fig. 3, when the failed port is a master port in a certain virtual switch, the backup port corresponding to the failed port is set as the master port. After the fault virtual switch is determined, the network port binding update is carried out on the fault virtual switch, namely, the standby network port bound by the fault virtual switch is used as a new main network port to be bound.
It can be understood that the fault network port bound by the fault virtual switch is idle, and the fault information of the fault network port is logged, so that a user can timely perform fault processing.
Step S210, judging whether the new main network port of the fault virtual switch is used as the main network port in the virtual switch which is not updated by network port binding.
It can be understood that the new primary port of the failed virtual switch, that is, the new primary port bound by the failed virtual switch, may be the primary port in other virtual switches, and then it needs to be determined whether the virtual switch that does not perform the update of the binding of the primary port uses the new primary port of the failed virtual switch as the primary port.
It should be noted that, the virtual switch that does not perform the network port binding update is a virtual switch that solves the problem that the network port binding update is not performed in the current network port failure process under the condition that a network port failure occurs once.
It can be understood that it is possible to determine whether a new master port of the failed virtual switch is a master port in the virtual switch that is not updated by the port binding by traversing the virtual switch and port binding relationship table. Corresponding to the traversed virtual switch and network port binding relation table in fig. 3, judging whether the rest network ports paired with the fault network port are main network ports in a certain virtual switch. The residual network port configured by the fault network port is the new main network port bound by the fault virtual switch.
Step S211, when any virtual switch of the virtual switches that do not perform the portal binding update uses the new primary portal of the failed virtual switch as the primary portal, determining that the virtual switch that uses the new primary portal of the failed virtual switch as the primary portal is the virtual switch to be updated.
Any virtual switch of the virtual switches which do not perform network port binding update takes a new main network port of the fault virtual switch as a main network port, and one network port serves as the main network port in different virtual switches.
Step S212, the main network port of the virtual switch to be updated is used as a new standby network port of the virtual switch to be updated, the standby network port of the virtual switch to be updated is used as a new main network port of the virtual switch to be updated, and network port binding update is performed on the virtual switch to be updated based on the new main network port and the new standby network port of the virtual switch to be updated.
In order to avoid or reduce the situation that one network port is a main network port in different virtual switches as much as possible, and avoid the situation that the network port flow is too large to influence network response caused by the fact that the same network port bears different virtual switch flows, the main network port and the standby network port exchange roles of the virtual switch to be updated are to be used for carrying out main-standby role exchange on the main network port and the standby network port in other virtual switches taking the new main network port bound by the fault virtual switch as the main network port, namely the main network port of the virtual switch to be updated is used as the new standby network port of the virtual switch to be updated, and the standby network port of the virtual switch to be updated is used as the new main network port of the virtual switch to be updated, so that network port binding update of the virtual switch to be updated is realized.
Step S213, judging whether the new main port of the virtual switch to be updated is used as the main port in the virtual switch which is not updated by the port binding.
The virtual switch with the role of the main and standby network ports being newly adjusted, that is, the new main network port in the virtual switch to be updated, may be the main network port of other virtual switches which do not perform network port binding update, so that whether the new main network port of the virtual switch which is just adjusted is used as the main network port in other virtual switches which do not perform network port binding update is continuously searched, that is, whether the new main network port of the virtual switch to be updated is used as the main network port in the virtual switch which does not perform network port binding update is judged.
It can be understood that it is possible to determine whether a new master portal of the virtual switch to be updated is a master portal in the virtual switch that is not updated by portal binding by traversing the virtual switch and portal binding relationship table. And judging whether the exchanged main network port is the main network port of other virtual switches.
In step S214, when any virtual switch of the virtual switches that do not perform the network port binding update uses the new main network port of the virtual switch to be updated as the main network port, determining that the virtual switch that uses the new main network port of the virtual switch to be updated as the main network port is the new virtual switch to be updated, returning to execute the new standby network port that uses the main network port of the virtual switch to be updated as the new standby network port of the virtual switch to be updated, and performing the network port binding update on the virtual switch to be updated based on the new main network port and the new standby network port of the virtual switch to be updated until no virtual switch that does not perform the network port binding update or the virtual switch that does not perform the network port binding update uses the new main network port of the virtual switch to be updated as the main network port.
If any virtual switch in the virtual switches which do not perform network port binding update takes a new main network port of the virtual switch to be updated as a main network port, taking the new main network port of the virtual switch to be updated as the virtual switch of the main network port in the virtual switch which does not perform network port binding update as the new virtual switch to be updated, and exchanging roles of the main network port and the standby network port of the new virtual switch to be updated, namely, exchanging the main network port and the standby network port in other virtual switches taking the exchanged main network port as the main network port, and performing network port binding update on the new virtual switch to be updated.
And continuing to execute the step of judging whether the new main network port of the new virtual switch to be updated is used as the main network port in the virtual switch which is not subjected to network port binding update or not according to the new main network port of the new virtual switch to be updated and the subsequent steps. And taking a new main network port of the virtual switch to be updated as a main network port until no virtual switch which does not perform network port binding update or no virtual switch which does not perform network port binding update exists. That is, until the searching and adjustment of all the network ports are completed, all the virtual switch main/standby network ports complete one-time exchange or the virtual switch which does not perform network port binding update does not take the new main network port of the virtual switch to be updated as the main network port, and exit all the exchange operation flows.
It will be appreciated that after the process of steps S206-S214 is completed, it is also possible that the network ports simultaneously play the role of the master port in different virtual switches, but if the network ports are enough, the above logic may implement that the same master port does not appear repeatedly in each virtual switch.
In order to more clearly illustrate the procedure of performing portal binding update in the event of a portal failure, the following embodiments are described.
Fig. 4 is a schematic diagram of a virtual switch performing primary and backup port binding according to an embodiment of the present invention. As shown in fig. 4, the server includes three network cards, namely a network card a, a network card B and a network card C. The network card A comprises an A1 network port and an A2 network port, the network card B comprises a B1 network port and a B2 network port, and the network card C comprises a C1 network port and a C2 network port. The A1 network port and the B1 network port are used as the network ports of the same virtual switch to perform main and standby binding, wherein the A1 network port is the main network port, and the B1 network port is the standby network port. The A2 network port and the C1 network port are used as the network ports of the same virtual switch to perform main and standby binding, wherein the A2 network port is the main network port, and the C1 network port is the standby network port. And the B2 network port and the C2 network port are used as the network ports of the same virtual switch to perform main and standby binding, wherein the B2 network port is the main network port, and the C2 network port is the standby network port.
It can be understood that the B1 network port and the C2 network port are both standby network ports, and then the B1 network port and the C2 network port can be used as the network ports of the same virtual switch to perform main-standby binding, where the B1 network port is the main network port and the C2 network port is the standby network port. Of course, the C2 port may be a main port, the B1 port may be a standby port, and the embodiment describes using the B1 port as the main port and the C2 port as the standby port.
The binding relationship table corresponding to binding in the above binding manner may be as shown in table 1.
TABLE 1
| Main network port |
Spare network port |
| A1 |
B1 |
| B2 |
C2 |
| A2 |
C1 |
| B1 |
C2 |
The primary and standby network ports corresponding to each row in table 1 are primary and standby network ports bound by the same virtual switch.
Assuming that the A1 network port fails, because the A1 network port is a main network port in the virtual switch, the standby network port B1 network port in binding relation with the A1 network port is set as a new main network port of the virtual switch. Because the B1 network port is the main network port in the binding relationship between B1 and C2, the main and standby relationships in the binding relationship between B1 and C2 are exchanged, namely B1 is used as a new standby network port, and C2 is used as a new main network port to perform network port binding update. And if the binding relation taking C2 as the main network port is not in the binding relation without the network port binding update, the network port binding update under the condition of network port fault is determined to be completed. The updated binding table is shown in table 2.
TABLE 2
| Main network port |
Spare network port |
| B1 |
|
| B2 |
C2 |
| A2 |
C1 |
| C2 |
B1 |
According to the network port binding method, the main network port and the standby network port bound by the virtual switch are updated under the condition that any network port fails, so that normal operation of the virtual switch is ensured, and the network interruption risk caused by single network port failure is reduced.
And under the condition that any network port fails, the network port binding of the virtual switch taking the network port as the main network port is updated, and whether the updated main network port is taken as the main network port by the virtual switch which does not perform network port binding update is judged according to the updated main network port of the failed virtual switch, so that the network port binding update is performed on the virtual switch taking the updated main network port as the main network port, the situation that one network port is simultaneously the main network port in different virtual switches is avoided or reduced as much as possible, and the situation that the network response is influenced by too large network port flow caused by the same network port bearing different virtual switch flows is avoided.
In some optional embodiments, the portal binding method further includes:
And a1, when the main network port of the target virtual switch in the network port configuration information is the main network port of any virtual switch in other virtual switches except the target virtual switch, returning to execute the step of screening two target network cards from the plurality of network cards or returning to execute the step of screening a first network port from the plurality of network ports of one target network card and screening a second network port from the plurality of network ports of the other target network card until the main network port of the target virtual switch in the network port configuration information is not the main network port of the other virtual switch.
The network port binding method comprises the steps of traversing the corresponding relation between a virtual switch which is subjected to network port binding and a network port binding in a network port binding relation table and a network port which is subjected to network port binding, determining that a main network port of a target virtual switch in network port configuration information is a main network port of any virtual switch except the target virtual switch, and then, needing to re-screen two target network cards or re-screen the network port in the target network card until the main network port in the network port configuration information is not the main network port of the other virtual switch, and then, carrying out network port binding on the target virtual switch based on the network port configuration information.
According to the network port binding method, in the case that any network port is not the master network port of the other virtual switch in the master-slave mode, the network port can be used as the master network port of the target virtual switch, and the effect of utilizing network port resources on the server is achieved to the greatest extent. And under the condition that the main network port in the network configuration information is the main network port of other virtual switches, the network port is screened again to bind the network port of the target virtual switch, so that the condition that the same network port serves as the main network port in different virtual switches is avoided.
That is, after two network cards are selected as the primary and secondary network cards of one virtual switch, the other virtual switch can still select the two network cards as the primary and secondary network cards, and only the primary network ports designated by the two virtual switches are different (for example, two network ports E1 and E2 are provided in the virtual switch a, E1 is the primary network port, E2 is the secondary network port, and the other virtual switch B can also be two network ports E2 and E1, only E2 is the primary network port, and E1 is the secondary network port). The system only limits the main network port which can not be the main network port in other virtual switches when the main network port is selected for the virtual switch (in order to avoid that the same network port bears the flow pressure brought by the main network port in different virtual switches).
In some optional embodiments, after portal binding is performed on the target virtual switch based on the portal configuration information, the portal binding method further includes:
and b1, performing communication test on the main network port and the standby network port bound by the target virtual switch.
The physical switch sets a trunk relay mode or an access common mode for the network port according to the purpose of the network port, and if the trunk relay mode is the trunk mode, a VLAN number for response is set for the network port, so that the network isolation function is also realized. The mode of the network ports bound under the same virtual switch is the same, namely, the network ports are all the trunk ports which use the same VLAN number or the access ports, so that any network port in the virtual switch can be ensured to communicate outwards. If the modes used by different ports in the same virtual switch are different, or are both trunk modes but different VLAN numbers, the ports in the same virtual switch cannot communicate.
In order to avoid the situation, when the virtual switch binds the network port or the network port fails, the communication test is performed on the network port bound by the virtual switch to determine whether the bound network port uses the same mode, that is, whether the bound network port can normally communicate.
And b2, under the condition that the communication test passes, determining that the network port binding of the target virtual switch is normal.
If the communication test passes, it indicates that the network port binding of the target virtual switch is normal, and the main network port and the standby network port bound by the target virtual switch can communicate normally.
According to the network port binding method, communication tests are conducted on the main network port and the standby network port bound by the target virtual switch, so that normal communication between the main network port and the standby network port of the target virtual switch and normal external communication between the main network port and the standby network port are ensured.
In some alternative embodiments, step b1 includes:
And b11, acquiring the physical address of the main network port and the physical address of the standby network port bound by the target virtual switch.
The communication test is carried out on the network port bound by the target virtual switch, wherein the communication test is carried out on the main network port bound by the target virtual switch and the communication test is carried out on the standby network port bound by the target virtual switch, and the network port binding of the target virtual switch is determined to be normal under the condition that the communication tests of the main network port and the standby network port are passed.
The virtualization platform acquires a physical Address (MEDIA ACCESS Control Address, abbreviated as mac Address) of a main network port and a physical Address of a standby network port in the target virtual switch.
And b12, taking the physical address of the main network port as a first physical address to be tested, and taking the physical address of the standby network port as a first destination physical address.
And the communication test is carried out on the main network port, wherein the physical address of the main network port is used as a first physical address to be tested, namely, the mac address of the local network port, and the physical address of the standby network port is used as a first destination physical address, namely, the mac address of the opposite network port.
Step b13, generating a first test data packet based on the first to-be-tested physical address and the first destination physical address.
It should be noted that the first test data packet includes the test content, the first physical address to be tested and the first destination physical address. The test content comprises the steps of carrying out receiving and transmitting test on each network port bound by the virtual switch, and detecting whether the network port can be received or not, as long as the network port mode indicating the binding under the virtual switch can be received.
And step b14, the first test data packet is sent to the physical switch corresponding to the target virtual switch through the main network port, so that the physical switch sends the first test data packet to the standby network port based on the first destination physical address in the first test data packet.
The physical switch corresponding to the target virtual switch is the physical switch connected with the target virtual switch.
And b15, under the condition that the standby network port receives the first test data packet, determining that the communication test of the main network port passes.
The virtualization platform receives the first test data packet through the standby network port, receives the first test data packet at the standby network port, and determines that the communication test of the main network port passes. If the standby network port does not receive the first test data packet, determining that the main network port bound by the virtual switch cannot communicate.
And b16, taking the physical address of the main network port as a second destination physical address, and taking the physical address of the standby network port as a second physical address to be detected.
And the communication test is carried out on the standby network port, wherein the physical address of the standby network port is used as a second physical address to be tested, namely, the local network port mac address, and the physical address of the main network port is used as a second destination physical address, namely, the opposite end network port mac address.
And b17, generating a second test data packet based on the second physical address to be tested and the second destination physical address.
It should be noted that the second test packet includes the test content, the second physical address to be tested and the second destination physical address.
And b18, transmitting the second test data packet to a physical switch corresponding to the target virtual switch through the standby network port, so that the physical switch transmits the second test data packet to the main network port based on a second destination physical address in the second test data packet.
And b19, under the condition that the main network port receives the second test data packet, determining that the communication test of the standby network port passes.
If the main network port does not receive the second test data packet, determining that the standby network port bound by the virtual switch cannot communicate.
The main network port receives the second test data packet, and the standby network port receives the first test data packet, which indicates that the mode of the main network port and the standby network port bound by the target virtual switch is the same, and the main network port and the standby network port can normally communicate with each other, so that the network port binding of the target virtual switch is normal.
According to the network port binding method, communication tests are conducted on the main network port and the standby network port bound by the target virtual switch, so that normal communication between the main network port and the standby network port of the target virtual switch and normal external communication between the main network port and the standby network port are ensured.
In some optional embodiments, the portal binding method further includes:
Step c1, determining that the network port binding of the target virtual switch is abnormal under the condition that the communication test is not passed, and displaying network port binding abnormal information so that a user can confirm the abnormality of the main network port and the standby network port bound by the target virtual switch based on the network port binding abnormal information.
The communication test failing may be that the communication test of the main network port fails or that the communication test of the standby network port fails or that both the communication test of the main network port and the communication test of the standby network port fail.
The network port binding abnormal information can be information about whether the network port modes of the main network port and the standby network port are consistent or not and whether the VLAN is the same or not, so that a user can check and confirm the network port binding abnormal information, namely, the main network port and the standby network port bound by the target virtual switch are abnormal and confirmed, and corresponding measures are taken to process the abnormality.
According to the network port binding method, when the communication test fails, the existence of abnormality of the network port binding of the target virtual switch can be rapidly determined, the potential network problem can be found timely, and the efficiency of fault detection is improved.
In some optional embodiments, the portal binding method further includes:
And d1, after the network port binding is carried out on the target virtual switch based on the network port configuration information, storing the corresponding relation between the target virtual switch and the network port bound by the target virtual switch into a virtual switch and network port binding relation table.
It can be understood that after the network port binding is performed on the target virtual switch based on the network port configuration information, the corresponding relationship between the target virtual switch and the network port bound by the target virtual switch is stored in the virtual switch and network port binding relationship table for subsequent query.
According to the network port binding method, the corresponding relation between the target virtual switch and the binding network port is stored in the virtual switch and network port binding relation table, network configuration is convenient to manage and inquire, and the network port binding condition of each virtual switch can be rapidly acquired.
In some optional embodiments, selecting two target network cards from the plurality of network cards, selecting a first network port from the plurality of network ports of one target network card, and selecting a second network port from the plurality of network ports of the other target network card, includes:
judging whether unbound network cards exist in the plurality of network cards.
The network card which is not bound is a network card of which at least one network port is not bound by the virtual switch.
If the unbound network cards exist and the number of the unbound network cards is at least two, randomly screening two target network cards from the unbound network cards, randomly screening a first network port from the network ports of one target network card, which are not bound by the virtual switch, and randomly screening a second network port from the network ports of the other target network card, which are not bound by the virtual switch.
If the unbound network cards exist and the number of the unbound network cards is one, randomly screening a first network port from the network ports of the unbound network cards, which are not bound by the virtual switch, and randomly screening a second network port from a plurality of network ports of any target network card bound in the plurality of network cards.
The bound target network card is a network card in which a plurality of network ports are bound by the virtual switch.
Screening the second network port from the multiple network ports in any one of the bound target network cards comprises screening any one of the multiple network ports in any one of the bound target network cards as a second network port for standby.
The network port is used as a standby network port, namely, a network port used as a standby network port in other virtual switches.
If the unbound network card does not exist, two target network cards are randomly screened out from the plurality of network cards, any first network port serving as a standby network port is screened out from the plurality of network ports of one target network card, and any second network port serving as the standby network port is screened out from the plurality of network ports of the other target network card.
That is, the target virtual switch selects two network ports in standby roles for binding, and the two network ports are respectively designated as a main network port and a main standby mode of the standby network port in the virtual switch, and the network card comprising the main network port bears the traffic use of the information virtual switch.
The network port binding method provided by the embodiment solves the problems that network card resources are idle and network cards cannot be fully utilized when only a master-slave mode is used for binding the network cards in a virtualized environment. When the virtual switch is configured to select the network card and the binding mode of the network card is configured to be the master-slave mode, the newly configured virtual switch selects two network ports in the virtualized environment to bind, the two network ports are respectively designated as the master-slave mode of the master network port and the slave network port in the virtual switch (as long as the designated master network port is not the master network port in other virtual switches), and the network card at the master port will bear the traffic use on the new virtual switch. The newly configured virtual switch reasonably screens the network ports in the unbound network card and the bound network ports in the bound network card by judging the binding condition of the network card, so that the screening efficiency is improved, the network port binding efficiency of the virtual switch is further improved, network port resources are utilized to the greatest extent, and the network port resource waste is avoided.
The present embodiment provides a portal binding device, as shown in fig. 5, including:
the obtaining module 501 is configured to obtain network card information of a plurality of network cards in the virtualized environment when any target virtual switch needs to perform network port binding.
The first determining module 502 is configured to determine a plurality of network ports included in each network card based on the network card information.
The screening module 503 is configured to screen two target network cards from the plurality of network cards, screen a first network port from a plurality of network ports of one of the target network cards, and screen a second network port from a plurality of network ports of another of the target network cards.
The second determining module 504 is configured to determine, based on the first port and the second port, that the port configuration information of the target virtual switch is a primary port of the target virtual switch, and that the second port is a standby port of the target virtual switch.
A binding module 505, configured to bind, in the case where the primary port of the target virtual switch in the port configuration information is not the primary port of the virtual switch other than the target virtual switch, the port to the target virtual switch based on the port configuration information.
In some optional embodiments, the portal binding device further includes:
the first return execution module is configured to return to execute the step of screening two target network cards from the plurality of network cards or return to execute the step of screening a first network port from the plurality of network ports of one target network card and screen a second network port from the plurality of network ports of the other target network card when the main network port of the target virtual switch in the network port configuration information is the main network port of any virtual switch other than the target virtual switch, until the main network port of the target virtual switch in the network port configuration information is not the main network port of the other virtual switch.
In some optional embodiments, the portal binding device further includes:
and the third determining module is used for determining that any network port is a fault network port under the condition that the network port fails.
The first judging module is used for judging whether the virtual switch binding the fault network port takes the fault network port as a main network port.
And the fourth determining module is used for determining that the virtual switch taking the fault network port as the main network port is the fault virtual switch under the condition that any virtual switch binding the fault network port takes the fault network port as the main network port.
The first updating module is used for taking the standby network port of the fault virtual switch as a new main network port of the fault virtual switch and carrying out network port binding updating on the fault virtual switch based on the new main network port of the fault virtual switch.
And the second judging module is used for judging whether the new main network port of the fault virtual switch is used as the main network port in the virtual switch which is not subjected to network port binding update.
And a fifth determining module, configured to determine, when any virtual switch of the virtual switches that do not perform the portal binding update uses the new primary portal of the failed virtual switch as the primary portal, that the virtual switch that uses the new primary portal of the failed virtual switch as the primary portal is the virtual switch to be updated.
The second updating module is used for taking the main network port of the virtual switch to be updated as a new standby network port of the virtual switch to be updated, taking the standby network port of the virtual switch to be updated as a new main network port of the virtual switch to be updated, and carrying out network port binding updating on the virtual switch to be updated based on the new main network port and the new standby network port of the virtual switch to be updated.
And the third judging module is used for judging whether the new main network port of the virtual switch to be updated is used as the main network port in the virtual switch which is not subjected to network port binding update.
And the second return execution module is used for determining that the virtual switch taking the new main port of the virtual switch to be updated as the main port is the new virtual switch to be updated when any virtual switch in the virtual switches which are not subjected to the port binding update takes the new main port of the virtual switch to be updated as the main port, returning to execute the new standby port taking the main port of the virtual switch to be updated as the new main port of the virtual switch to be updated, and carrying out the step of port binding update on the virtual switch to be updated based on the new main port and the new standby port of the virtual switch to be updated until no virtual switch which is not subjected to the port binding update or the virtual switch which is not subjected to the port binding update takes the new main port of the virtual switch to be updated as the main port.
In some optional embodiments, the portal binding device further includes:
And the test module is used for carrying out communication test on the main network port and the standby network port bound by the target virtual switch.
And the sixth determining module is used for determining that the network port binding of the target virtual switch is normal under the condition that the communication test is passed.
In some alternative embodiments, the test module includes:
The first acquisition unit is used for acquiring the physical address of the main network port and the physical address of the standby network port bound by the target virtual switch.
The first address determining unit is configured to take a physical address of the main network port as a first to-be-tested physical address, and take a physical address of the standby network port as a first destination physical address.
The first generating unit is used for generating a first test data packet based on the first physical address to be tested and the first destination physical address.
The first sending unit is used for sending the first test data packet to the physical switch corresponding to the target virtual switch through the main network port, so that the physical switch sends the first test data packet to the standby network port based on the first destination physical address in the first test data packet.
The first test determining unit is used for determining that the communication test of the main network port passes under the condition that the standby network port receives the first test data packet.
The second address determining unit is configured to use the physical address of the main network port as a second destination physical address, and use the physical address of the standby network port as a second physical address to be tested.
And the second generating unit is used for generating a second test data packet based on the second physical address to be tested and the second destination physical address.
And the second sending unit is used for sending the second test data packet to the physical switch corresponding to the target virtual switch through the standby network port, so that the physical switch sends the second test data packet to the main network port based on the second destination physical address in the second test data packet.
And the second test determining unit is used for determining that the communication test of the standby network port passes under the condition that the main network port receives the second test data packet.
In some optional embodiments, the portal binding device further includes:
And the seventh determining module is used for determining that the network port binding of the target virtual switch is abnormal under the condition that the communication test is not passed, and displaying the network port binding abnormal information so that a user can confirm the abnormality of the main network port and the standby network port bound by the target virtual switch based on the network port binding abnormal information.
In some optional embodiments, the portal binding device further includes:
The storage module is used for storing the corresponding relation between the target virtual switch and the network port bound by the target virtual switch into the virtual switch and network port binding relation table after the network port binding is carried out on the target virtual switch based on the network port configuration information.
Further functional descriptions of the above respective modules and units are the same as those of the above corresponding embodiments, and are not repeated here.
The portal binding device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application SPECIFIC INTEGRATED Circuit) Circuit, a processor and a memory that execute one or more software or firmware programs, and/or other devices that can provide the above functions.
The embodiment of the invention also provides computer equipment, which is provided with the network port binding device shown in the figure 5.
Referring to fig. 6, fig. 6 is a schematic structural diagram of a computer device according to an alternative embodiment of the present invention, and as shown in fig. 6, the computer device includes one or more processors 601, a memory 602, and interfaces for connecting components, including a high-speed interface and a low-speed interface. The various components are communicatively coupled to each other using different buses and may be mounted on a common motherboard or in other manners as desired. The processor may process instructions executing within the computer device, including instructions stored in or on memory to display graphical information of the GUI on an external input/output device, such as a display device coupled to the interface. In some alternative embodiments, multiple processors and/or multiple buses may be used, if desired, along with multiple memories and multiple memories. Also, multiple computer devices may be connected, each providing a portion of the necessary operations (e.g., as a server array, a set of blade servers, or a multiprocessor system). One processor 601 is illustrated in fig. 6.
The processor 601 may be a central processor, a network processor, or a combination thereof. The processor 601 may further comprise a hardware chip, among other things. The hardware chip may be an application specific integrated circuit, a programmable logic device, or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general-purpose array logic, or any combination thereof.
Wherein the memory 602 stores instructions executable by the at least one processor 601 to cause the at least one processor 601 to perform a method for implementing the embodiments described above.
The memory 602 may include a storage program area that may store an operating system, application programs required for at least one function, and a storage data area that may store data created according to the use of the computer device, etc. In addition, the memory 602 may include high-speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid-state storage device. In some alternative embodiments, memory 602 may optionally include memory located remotely from processor 601, such remote memory being connectable to the computer device through a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The memory 602 may include volatile memory, such as random access memory, nonvolatile memory, such as flash memory, hard disk, or solid state disk, and the memory 602 may also include combinations of the above.
The computer device also includes a communication interface 603 for the computer device to communicate with other devices or communication networks.
The embodiments of the present invention also provide a computer readable storage medium, and the method according to the embodiments of the present invention described above may be implemented in hardware, firmware, or as a computer code which may be recorded on a storage medium, or as original stored in a remote storage medium or a non-transitory machine readable storage medium downloaded through a network and to be stored in a local storage medium, so that the method described herein may be stored on such software process on a storage medium using a general purpose computer, a special purpose processor, or programmable or special purpose hardware. The storage medium may be a magnetic disk, an optical disk, a read-only memory, a random-access memory, a flash memory, a hard disk, a solid state disk, or the like, and further, the storage medium may further include a combination of the above types of memories. It will be appreciated that a computer, processor, microprocessor controller or programmable hardware includes a storage element that can store or receive software or computer code that, when accessed and executed by the computer, processor or hardware, implements the methods illustrated by the above embodiments.
Portions of the present invention may be implemented as a computer program product, such as computer program instructions, which when executed by a computer, may invoke or provide methods and/or aspects in accordance with the present invention by way of operation of the computer. Those skilled in the art will appreciate that the existence of computer program instructions in a computer-readable medium includes, but is not limited to, source files, executable files, installation package files, and the like, and accordingly, the manner in which computer program instructions are executed by a computer includes, but is not limited to, the computer directly executing the instructions, or the computer compiling the instructions and then executing the corresponding compiled programs, or the computer reading and executing the instructions, or the computer reading and installing the instructions and then executing the corresponding installed programs. Herein, a computer-readable medium may be any available computer-readable storage medium or communication medium that can be accessed by a computer.
Although embodiments of the present invention have been described in connection with the accompanying drawings, various modifications and variations may be made by those skilled in the art without departing from the spirit and scope of the invention, and such modifications and variations fall within the scope of the invention as defined by the appended claims.