A port configuration method, computing device
By storing the target machine's configuration information in the management machine and using the local database for port configuration, the problem of high port configuration resource overhead in OVS is solved, and the efficiency and performance of port configuration are improved.
Patent Information
- Application Number
- CN202210812332.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-12
- Publication Date
- 2025-10-24
- Estimated Expiration
- 2042-07-12
AI Technical Summary
In virtualization technology, when adding ports using the Open Virtual Switch (OVS), it is necessary to frequently obtain the switch's current configuration information and port information for service packaging, resulting in high system resource overhead and slow port addition performance.
The configuration information of the target machine is stored in the management machine, and the interaction between the management machine and the target machine is reduced through local database query and batch management port configuration.
By reducing the number of interactions and data transmission, the efficiency and performance of port configuration are improved and system resource overhead is reduced.
Smart Images

Figure CN117439874B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, and particularly relates to a port configuration method and a computing device. BACKGROUND
[0002] With the development of technology, virtualization technology appears in computing, and the virtualization technology can virtualize hardware platforms (central processing units, memories) in computing, storage settings and network resources.
[0003] At present, an open virtual switch (OVS) is generally used in the virtualization technology, but in the OVS mode, current configuration information of a switch needs to be acquired every time when a port is added, and in the case that port information of a service package is more and more, interactive data is large, port information in interactive information is more and more, and system resource overhead occupied when the port is added is large, and the performance of adding the port is slower and slower. SUMMARY
[0004] In order to solve the problems in the prior art, the present application provides a port configuration method and a computing device, which can reduce the resources occupied by the port and increase the performance of the port.
[0005] In a first aspect, the present application provides a port configuration method applied to a first host, the first host storing first configuration information related to a second host, the first configuration information including a first identifier. The method comprises: acquiring a first instruction, the first instruction being used to indicate that N ports are added under a target bridge in the second host, wherein N is a positive integer. In response to the first instruction, a second identifier is acquired from the second host, the second identifier indicating related configuration information of the second host. When the first identifier is consistent with the second identifier, it is determined that the first configuration information is consistent with the related configuration information of the second host, a second instruction is sent to the second host, and the second instruction is used to indicate that the second host adds N ports under the target bridge.
[0006] In this way, in the case that the configuration information related to the second host stored in the first host is the same as the configuration information in the second host, the configuration information can be directly searched from the local, the configuration information acquired from the server is reduced, and a plurality of port information can be simultaneously sent to the second host by one packaging, so that time is saved and efficiency is improved.
[0007] Exemplarily, the first host can be host 3 in Figure 5 , and the second host can be host 1 and / or host 2 in Figure 3 .
[0008] In some possible implementation manners, the method can further include: when the first identifier is inconsistent with the second identifier, determining that the first configuration information and the second configuration information are inconsistent, and the first host obtaining the second configuration information from the second host. The first host updates the first configuration information based on the second configuration information.
[0009] In this way, it can be ensured that the configuration information stored by the first host is the same as the configuration information of the second host, and the normality of port configuration is ensured.
[0010] In some possible implementation manners, the first instruction includes an identifier of the target bridge and identifiers of the N target ports.
[0011] In some possible implementation manners, after determining that the first configuration information is consistent with the related configuration information of the second host, the method further includes: storing the information of the N ports into the first configuration information.
[0012] In some possible implementation manners, before storing the information of the N target ports into the first configuration information, the method further includes: determining whether the name of the target bridge is stored in the first database. If yes, the information of the N ports is associated under the target bridge in the first configuration information.
[0013] In some possible implementation manners, the method further includes: if not, outputting prompt information, and the prompt information is used to indicate that the storage of the information of the N ports fails.
[0014] In this way, after determining that the database stores the target bridge, the storage of the port information is performed, which can reduce errors of a program.
[0015] In some possible implementation manners, storing the information of the N ports into the first database specifically includes: for any current port in the N target ports, determining that the first database does not record information related to the current port, and storing the information of the current port into the first database.
[0016] In this way, the information in the database can be matched in advance, the repeated storage of data can be reduced when the database is stored, and errors of the second host operation can be reduced.
[0017] In some possible implementation manners, the first configuration information includes one or more of an openvswitch table, a bridge table or a port table; the openvswitch table stores a database configuration version id of the second host, the bridge table stores a bridge name of the second host, and the port table stores a port name of the second host.
[0018] In some possible implementation manners, the second instruction includes all contents in the first configuration information.
[0019] In a second aspect, the present application provides a port configuration device deployed in a first host, wherein the first host is deployed with a first database, the first database is configured to store first configuration information related to a second host, the first configuration information comprises a first identifier, the second host is deployed with a second database, the second database is configured to store second configuration information, and the second configuration information comprises a second identifier. The device can comprise: a communication module configured to obtain a first instruction, the first instruction is configured to indicate adding N target ports under a target bridge in the second host, wherein N is a positive integer; a processing module configured to obtain the second identifier from the second host in response to the first instruction; the processing module is further configured to determine that the first configuration information is consistent with the second configuration information when the first identifier is consistent with the second identifier, and store information of the N target ports into the first database; and the processing module is further configured to send a second instruction to the second host based on the port information stored in the first database, the second instruction is configured to instruct the second host to add N ports under the target bridge.
[0020] In some possible implementation manners, the processing module of the device is further configured to determine that the first configuration information is inconsistent with the second configuration information when the first identifier is inconsistent with the second identifier, and the first host is configured to obtain the second configuration information and store the second configuration information into the first database.
[0021] In some possible implementation manners, the first instruction can comprise an identifier of the target bridge and identifiers of the N target ports.
[0022] In some possible implementation manners, before storing the information of the N target ports into the first database, the processing module is further configured to determine that the first database stores a name of the target bridge.
[0023] In some possible implementation manners, the processing module storing the information of the N target ports into the first database can comprise: for any one of the N target ports, determining that the first database does not record information related to the current port, and storing the information of the current port into the first database.
[0024] In some possible implementation manners, the first database can comprise one or more of an openvswitch table, a bridge table or a port table. The openvswitch table stores a database configuration version id of the target machine, the bridge table stores a target machine bridge name, and the port table stores a target machine port name.
[0025] In some possible implementation manners, the first configuration information or the second configuration information can comprise one or more of the following: a switch, a bridge, a port, and an interface.
[0026] In some possible implementation manners, the second instruction comprises all contents in the first configuration information.
[0027] In a third aspect, the present application provides a computer readable storage medium comprising computer readable instructions which, when read and executed by a computer, cause the computer to perform the method of any one of the first aspect.
[0028] In a fourth aspect, the present application provides a computing device which can comprise at least one processor and at least one memory, wherein the memory has stored therein computer program instructions which, when executed by the processor, perform the method of any one of the first aspect.
[0029] It can be understood that the beneficial effects of the above-mentioned second to fourth aspects can be referred to the related description in the first aspect, which will not be repeated here. BRIEF DESCRIPTION OF DRAWINGS
[0030] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiment description. Obviously, the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained without creative labor on the basis of these drawings.
[0031] Figure 1 is a virtual network topology diagram provided by the embodiment of the present application;
[0032] Figure 2 is a software architecture diagram of OVS provided by the embodiment of the present application;
[0033] Figure 3 is a network topology diagram of remotely configuring a virtual switch port provided by the embodiment of the present application;
[0034] Figure 4 is a flow diagram of adding a port provided by the embodiment of the present application;
[0035] Figure 5 is an application scenario diagram provided by the embodiment of the present application;
[0036] Figure 6 is a batch port adding workflow diagram provided by the embodiment of the present application;
[0037] Figure 7 is a schematic diagram of a port configuration device provided by the embodiment of the present application;
[0038] Figure 8 is a computing device structure diagram provided by the embodiment of the present application. DETAILED DESCRIPTION
[0039] In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the following will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some but not all of the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without creative effort should fall into the scope of protection of the present application.
[0040] The term "and / or" used in this document is used to describe an association relationship of associated objects, which means that there can be three relationships, for example, A and / or B can mean that A exists alone, A and B exist simultaneously, and B exists alone. The symbol " / " in this document means an or relationship of associated objects, for example, A / B means A or B.
[0041] The terms "first" and "second" and the like in the description and claims of this document are used to distinguish different objects, and are not used to describe a specific order of the objects. For example, the first response message and the second response message are used to distinguish different response messages, and are not used to describe a specific order of the response messages.
[0042] In the embodiments of the present application, the words "exemplary" or "for example" are used to mean serving as an example, instance, or illustration. Any embodiment or design presented as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or advantageous than other embodiments or design solutions. Rather, the use of "exemplary" or "for example" is intended to present concepts in a concrete manner.
[0043] In the description of the embodiments of the present application, unless otherwise specified, "a plurality of" means two or more, for example, a plurality of processing units means two or more processing units, and the like; a plurality of elements means two or more elements, and the like.
[0044] In order to facilitate the understanding of the embodiments of the present application, the following will be further explained and described with specific embodiments in conjunction with the drawings. The embodiments do not constitute a limitation on the embodiments of the present application.
[0045] Exemplarily, Figure 1 is a topology diagram of a virtual network provided by the embodiments of the present application. As shown in Figure 1 , a virtual switch and one or more virtual machines can be configured in a physical host, and the virtual machines on a single physical host can communicate through the virtual switch. Wherein, the physical host is a hardware type host that exists in reality. In addition, in Figure 1In each physical host, at least one network card is installed, and the virtual switch configured in each physical host can interact with the installed network card. The physical network cards on different physical hosts can interact with each other through a physical switch located outside the physical host. The virtual machines on different physical hosts can interact with each other through the virtual switch configured on the respective physical host, the installed network card, and the physical switch outside the physical host. In some embodiments, Figure 1 The virtual switch software in the foregoing embodiment can employ OVS. OVS is developed based on an open source protocol, can be directly applied to a production environment, and can realize functions such as two-layer and three-layer communication of a virtual network, network security, and network bandwidth management.
[0046] Exemplarily, Figure 2 A software architecture of an OVS is shown, as Figure 2 As shown in the figure, the OVS can include a user state and a kernel state, which are two running levels of an operating system. The code running in the kernel state of the processor core is not subject to any limitation and can freely access any valid address for direct port access. The code running in the user state is subject to many checks of the processor, and can only access the virtual addresses of the pages accessible in the user state specified in the page table item mapping the address space thereof.
[0047] The user state can include ovs-dpctl, ovs-vsctl, ovs-vswitchd, ovsdb-server, and an ovsdb.
[0048] The ovs-dpctl can be used to configure the kernel module openvswitch.ko of the switch, and can create, modify, and delete a data path (datapath). Generally, there are 256 datapaths (0-255) on a single machine. One datapath corresponds to one virtual network device. In addition, the ovs-dpctl can also count the traffic of devices on each datapath, print the information of the flow, and the like.
[0049] The ovs-vsctl can be used to query and update the configuration of ovs-vswitchd, is responsible for configuring the information of a bridge, a port, and a protocol, and a database operation related to the ovsdb-server.
[0050] The ovs-vswitchd is a daemon and is a core component of the OVS, and as a server, can accept the connection of the ovs-dpctl. In addition, the ovs-vswitchd can also be used to be responsible for creating, modifying, and updating a flow table.
[0051] The ovsdb is a JSON file database which can interact with the ovsdb-server to save the configuration information of the switch (for example, which bridges, ports, interfaces, etc. are included) and the ovs-vswitchd can work according to the configuration information in the database.
[0052] The ovsdb-server is a service end process which can interact with the ovsdb, and the ovsdb-server can accept the connection of the ovs-vsctl and the ovs-vswitchd. The ovsdb-server interacts with the ovs-vsctl process through the open virtual switch database (OVSDB) protocol. The OVSDB protocol is a network defined software (SDN) management protocol used to realize the programmable access and configuration management of the virtual switch. The OVSDB management protocol defines a set of remote procedure call (RPC) interfaces, and the communication mode is the request and response mode. The user can manage the OVSDB through the remote call, mainly including the communication protocol (JSON-RPC) method and the supported OVSDB operation. The ovs-vswitchd and the ovsdb-server interact information through the socket, and the ovs-vswitchd can work according to the configuration information in the ovsdb interacting with the ovsdb-server.
[0053] The kernel state can include the openvswitch.ko. The openvswitch.ko is a matching Linux kernel module based on flow to realize the switching.
[0054] In addition, in the Figure 2 , the OVS can also be divided into two aspects, including the management plane and the data plane. The data plane includes the ovs-vswitchd of the user state and the service module ovsdb-server associated therewith.
[0055] The management plane is responsible for various tools provided by the OVS. The provision of these tools is also to facilitate the user to control and manage the underlying various modules and improve the user experience.
[0056] Next, based on the content in Figure 1 and Figure 2 , the process of configuring the port between different virtual machines in Figure 1 is described.
[0057] Exemplarily, Figure 3FIG. 1 shows a network topology diagram for remotely configuring virtual switch ports. Figure 3 As shown in the figure, there are host 1, host 2 and host 3 in the same network. Host 1, host 2 and host 3 can be physical hosts or virtual machines. For example, host 1 can be Figure 1 In the physical host 1 in the virtual machine 1, host 2 can be Figure 1 Virtual machine 2 in physical host 2, host 3 can be Figure 1 For virtual machine 3 in physical host 1, data sent from host 1 to host 2 can be: the data from host 1 is sent to the network card of physical host 1 through the virtual switch on physical host 1, then sent to the network card of physical host 2 through the physical switch, and then reaches host 2 through the virtual switch on physical host 2. Data sent from host 1 to host 3 can be: the data from host 1 is sent to host 3 through the virtual switch.
[0058] ovs-vsctl can run on any host in the network environment, and the host running ovs-vsctl can be used as the management machine.
[0059] The structure for interaction between any two hosts can be regarded as a Browser / Server architecture (B / S architecture). The host running ovs-vsctl can be considered as the browser (Browser side), and the host running ovsdb-server can be considered as the server (Server side). The core business processing is completed on the server side, and the client interacts with the database through the server side.
[0060] by Figure 3 For example, if ovs-vsctl is running on host 3, then host 3 acts as a management machine and can manage host 1 and host 2. The managed host 1 and host 2 act as target machines, and the management includes remote port configuration. It is worth noting that Figure 3 The host 3 as a management machine is only an example in the network and does not constitute a limitation of the method. It is understandable that host 1 and host 2 can also serve as management machines. When host 3 needs to control the addition of a port on host 1, host 3 sends an instruction to add a port to host 1. The ovs-vsctl on host 3 remotely calls the ovsdb-server on host 1 through the ovsdb protocol. The ovsdb-server on host 1 notifies ovs-vswitchd to update and then returns information on whether the port addition is successful to host 3; if the ovsdb-server on host 1 fails to add the port, it returns information about the port addition failure to host 3.
[0061] Next, combine Figure 4 , introduced in Figure 3The process of adding a port on host 1 through host 3 each time is shown. Exemplarily, Figure 4 A flowchart of the process of adding a port is shown. Please refer to Figure 4 The interaction between ovs-vsctl and ovsdb-server is divided into two stages: an initialization stage and an adding port stage.
[0062] In the initialization stage, ovs-vsctl sends a monitoring request to ovsdb-server, telling ovsdb-server that if the relevant content (switch, port, flow table, etc.) changes, it needs to respond to ovs-vsctl. Through this request, ovs-vsctl obtains the current configuration information of the switch, such as: how many bridges, the specific port information of each bridge, etc.
[0063] It is worth noting that the initialization stage also includes that the ovs-vswitchd process on the normally working host 1 sends a monitoring request to ovsdb-server, and ovsdb-server responds to the monitoring request and returns the relevant content (switch, port, flow table, etc.) information to ovs-vswitchd, and ovs-vswitchd works according to the monitoring response.
[0064] In the adding port stage, ovs-vsctl sends an interaction request to ovsdb-server, and sends the port information requested to be added to ovsdb-server through the interaction request, and ovsdb-server responds to the interaction request and performs the operation of adding a port, and after the operation, it notifies ovs-vswitchd to update the corresponding port information, and then returns the response result of the interaction request to ovs-vsctl. Among them, the interaction request includes an add bridge command and an add port command. Exemplarily, the add bridge command is: ovs-vsctl add-br br0, indicating that ovs-vsctl requests to add a bridge named br0. The add port command is: ovs-vsctl add-port br0 eth0, indicating that ovs-vsctl requests to add a port named eth0 under the bridge br0. In the case of determining the bridge br0, the add port command can be: ovs-vsctl add-port eth0. The instruction ovs-vsctl add-port ovs-sriov ens2f0_0 can also be used to implement the port adding function, wherein ovs-sriov indicates that the sriov technology is used. The sriov technology is to solve the problem of insufficient network cards after the network card is transmitted to the virtual machine.
[0065] The communication mode of ovsdb is specified in the OVSDB protocol specification as a request and response manner. Among them, the request (such as a monitoring request or an interaction request in Figure 4 The request end sends a JSON object, and the request JSON object includes a method to be called. For example, the specific format is as follows:
[0066] {"method":"echo","params":["Hello JSON-RPC"],"id":1}
[0067] The request JSON object includes three key elements: method, params, and id. The method indicates the method to be called; the params indicate an array of parameters carried by the request; and the id parameter exists to indicate that the request needs a response, and the server needs to provide a response information with the same id of 1. The id indicates the identification of the request.
[0068] The response indicates that the server receives the request and performs the corresponding operation on the request, and informs the request end of the operation result. The response information is also a JSON object, and the response JSON object includes the operation result of the operation on the request. For example, the specific format is as follows:
[0069] {"result":"Hello JSON-RPC","error":null,"id":1}
[0070] The response JSON object also includes three key elements: result, error, and id. The result indicates the operation result of the request, and is null if an error occurs. The error indicates an error, and is null if the request is successful. The id indicates the identification id of the corresponding request for this response.
[0071] Taking adding a port named ens2f0_0 as an example, in the value element corresponding to the params in the request JSON object, the array of parameters carried by the request includes the element:
[0072] {"uuid-name": "rowcd4a265d_0c14_42ac_bad3_dcfb8c003142", "row": {"name": "ens2f0_0", "interfaces": ["named-uuid", "row63c0331c_6ff8_4c0f_931e_67d32444445c"]}, "op": "insert", "table": "Port"}, which indicates that a record of a port named ens2f0_0 is added in the port table of the OVSDB.
[0073] From the above description, it can be seen that the OVS needs to go through the initialization stage and the port adding stage each time when adding a port, that is, the OVS needs to acquire the current configuration information of the switch each time when adding a port, and when the number of ports of a certain bridge is large (the number of ports of a single host can be greater than 100), the amount of data of interaction is large, which leads to a large overhead when adding a port. Meanwhile, in the port adding stage, the service request packs the information of all ports, and when multiple ports need to be added, the adding port command needs to be executed multiple times. With the increasing number of ports, the information of the ports packed by the service also increases, which leads to an increasing overhead and a slower performance of adding ports.
[0074] Therefore, the embodiment of the present application provides a port configuration method. In the method provided by the present application, a local database is added in the management machine, and the related configuration information in the target machine is stored in the local database. When configuring the ports in the target machine, the related configuration information can be queried in the local database, so as to reduce the interaction between the management machine and the target machine. Meanwhile, the method can realize the batch management of the ports by one-time packing and unpacking when configuring the ports. The method is described in detail below with reference to the accompanying drawings.
[0075] Exemplarily, Figure 5 The application scenario network topology provided by the embodiment of the present application is shown in the figure. The figure is mainly different from Figure 3 in that a database is added in the memory of the host 3 as the management machine, that is, a storage file is added in the memory of the host 3 as the management machine. The added database is used to store the configuration information of the target machine. For Figure 5 other contents in the above Figure 3 , reference can be made to the related description in the foregoing
[0076] As Figure 5As shown, the port configuration of the virtual switch in the network environment is performed by adding a local database on the host (i.e., the host 3) running the ovs-vsctl. The local database can not interact with the ovs-server, i.e., the local database is isolated from the ovs-server on the host. The local database can also interact with the ovs-server.
[0077] In addition, in Figure 5 additionally, the local database can also be added on the host 1 and the host 2 respectively, so that each host can act as a management machine and also as a managed target machine. Exemplarily, when the host 1 acts as a management machine, since the ovsdb interacting with the ovs-server of the host 1 is running on the host 1, there are two databases on the host 1 at this time, the original ovsdb is used to store the configuration information of the host 1, and the newly added local database is used to store the configuration information of the target machine of the desired operation.
[0078] In addition, it should be noted that in the present application, the port configuration is mainly described by taking the addition of the port as an example, and it can be understood that the addition of the port can be replaced by other various possible port configuration services, such as deletion of the port, modification of the port, etc. It can be understood that the local database can be implemented by using a lightweight relational database for management convenience. Of course, any file system, database, etc. technology for realizing the cache purpose can also be used for implementation, which will not be described here.
[0079] Exemplarily, the local database can be SQLite database. SQLite database is a small relational database based on embedded linux, the source code is C, has the characteristics of small size, fast operation, and can be shared on different byte sequence machines, and supports basic SQL statements.
[0080] After the installation of the local database is completed, the database can be operated by using the sqlite3 command to build a table, delete a table, and query data in the table.
[0081] Exemplarily, the sqlite3 command for creating the local database can be: sqlite3 ovsdb.db, which indicates creating the ovsdb database locally.
[0082] In addition, when building a table in the local ovsdb database, since the operation can only be performed when the database is opened, the created ovsdb database can be opened first, and then the related data table can be established in the created ovsdb database. Exemplarily, the data table can include one or more of the following: openvswitch table, bridge table, or port table.
[0083] The table structure of the openvswitch table is shown in Table 1. The fields in Table 1 can include id, version, and config. The id is the primary key of the openvswitch table, and the primary key is increased automatically. The id represents the identifier of the switch, and the data type is int. The field cannot be empty. The version represents the version information of the openvswitch, and the data type is string. The field cannot be empty. The config represents the database configuration version id, and the data type is int. The field cannot be empty.
[0084] Table 1
[0085] id version config 1 V1.0 1
[0086] As a possible implementation, the SQL statement for creating the openvswitch table can be as follows:
[0087] create table openvswitch(
[0088] id int primary key autoincrement not null,
[0089] version text not null,
[0090] config int not null );
[0092] The table structure of the bridge table is shown in Table 2. The fields in Table 2 can include id, name, and switch_id. The id is the primary key of the bridge table, and the primary key is increased automatically. The id represents the identifier of the bridge, and the data type is int. The field cannot be empty. The name represents the name of the bridge, and the data type is string. The field cannot be empty. The switch_id is associated with the openvswitch table, and represents the identifier id of the switch. The data type is int. The field cannot be empty.
[0093] Table 2
[0094] id name switch_id 1 br0 1
[0095] As a possible implementation, the SQL statement for creating the bridge table can be as follows:
[0096] create table bridge(
[0097] id int primary key autoincrement not null,
[0098] name text not null,
[0099] switch_id int not null ) ;
[0101] The table structure of the port table is shown in Table 3. The fields in Table 3 can include id, name, and bridge_id, wherein the id is the primary key of the port table, adopts the primary key self-increment mechanism, the id represents the identification of the port, the data type is int, and the field cannot be empty; the name represents the name of the port, the data type is string, and the field cannot be empty; the bridge_id is associated with the bridge table, and represents the identification id of the network bridge, the data type is int, and the field cannot be empty.
[0102] Table 3
[0103] id name bridge_id 1 ens2f0_0 1
[0104] As a possible implementation manner, the SQL statement for creating the port table can be as follows:
[0105] create table port(
[0106] id int primary key autoincrement not null,
[0107] name text not null,
[0108] bridge_id int not null ) ;
[0110] After the table in the database is established, the operation of adding a port can be performed. The process of adding a port in the bridge table is described below. Figure 4 Figure 5 Please continue to refer to
[0111] Figure 4 After the table in the database is established, local data can be generated on the host (management machine) running the ovs-vsctl command, which is used to save the configuration information of the virtual switch. In the database associated with the ovsdb-server of the target machine, there is an attribute config used to identify the configuration version id of the target machine database. The ovs-vsctl of the management machine sends a monitoring request to the ovsdb-server of the target machine, the ovsdb-server of the target machine responds to the monitoring request, and the ovs-vsctl of the management machine obtains the data including the configuration version id of the target machine database and stores the data into the local database. In this way, when the port adding operation is performed, the management machine only needs to query and determine whether the configuration version id of the local database is the same as the configuration version id of the target machine database. If they are the same, it indicates that the local database information and the remote database information are the same, and the remote database information is not needed to update the local database. If they are not the same, the remote database is needed to update the local database. The updating method is the same as the related description of the initialization phase in Figure 4 , which will not be repeated here.
[0112] If the configuration version id of the management machine database is the same as the configuration version id of the target machine database, the data transmission in the initialization phase when the port is added can be reduced, so as to achieve the effect of accelerating the port configuration speed.
[0113] Next, based on the foregoing related description, a port configuration method provided by an embodiment of the present application is introduced.
[0114] Exemplarily, Figure 6 is a schematic diagram of a batch port adding workflow provided by an embodiment of the present application. Wherein, Figure 6 The method shown in Figure 5 may be but is not limited to being implemented by the host 3 in Figure 6 . In addition, in the present application, the management machine can also be referred to as the first host, and the target machine can also be referred to as the second host. The local database deployed on the management machine can be referred to as the first database, the ovsdb associated with the ovs-sever on the target machine can be referred to as the second database, the configuration information related to the second host stored in the first database can be referred to as the first configuration information, and the configuration information stored in the second database can be referred to as the second configuration information. As shown in
[0115] S61: The management machine obtains a first instruction, the first instruction is used to instruct to add N target ports under a target bridge in the target machine, and the first instruction includes the name of the target bridge and the names of the N target ports. Wherein, N is a positive integer.
[0116] In the embodiment, the user can manage the ports of the target machine on the management machine, for example, input a command of adding ports, and the like. When the user inputs on the management machine, the management machine can obtain the instruction of adding ports in batches input by the user, and the instruction is the first instruction.
[0117] In a possible implementation, the first instruction includes the identification of the target bridge and the identification of the N target ports. The identification of the target bridge can be the name of the target bridge, and the identification of the target port can be the name of the target port.
[0118] For example, it is assumed that a user desires to add two ports ens2f0_0 and ens2f0_1 under a specific bridge of a target machine, and the instruction input by the user is: ovs-vsctl add-ports br0 ens2f0_0,ens2f0_1, which means that the ports ens2f0_0 and ens2f0_1 are added under the bridge named br0 of the target machine.
[0119] S62: The management machine judges whether the first configuration information in the database of the target machine is consistent with the second configuration information in the local database of the management machine in response to the first instruction. When the management machine judges that the first configuration information is consistent with the second configuration information, S64 is executed; when the first configuration information is inconsistent with the second configuration information, S63 is executed.
[0120] In the embodiment, the management machine obtains the configuration information of the target machine and the configuration information of the target machine stored locally in response to the first instruction input by the user, and judges whether the configuration information of the target machine is consistent with the configuration information of the target machine stored locally. The management machine can query the configuration information of the target machine and the configuration information of the target machine stored locally by using a sql query statement. When it is determined that the configuration information of the target machine is consistent with the configuration information of the target machine stored locally, it is indicated that the configuration data of the target machine stored locally is the same as the current configuration information of the target machine, and the next operation can be directly performed. When it is determined that the configuration information of the target machine is inconsistent with the configuration information of the target machine stored locally, it is indicated that the configuration data of the target machine stored locally is different from the current configuration information of the target machine, and the configuration information of the target machine needs to be synchronized to the local machine first. Only when the configuration information of the target machine stored in the local database is consistent with the current configuration information of the target machine, the operation of adding ports can be performed.
[0121] Exemplarily, the management machine obtaining the configuration information in the target machine can include that there are bridge port brO and ports ens2fl_0 and ens2fl_l in the target machine. If the configuration information of the target machine stored in the management machine is bridge port brO and ports ens2fl_0 and ens2fl_l, it indicates that the configuration information of the target machine is consistent with the configuration information of the target machine stored locally, and the next operation can be performed. If the configuration information of the target machine stored in the management machine is bridge port brO and port ens2fl_0, it indicates that the configuration information of the target machine is more than the configuration information of the target machine stored locally, and the configuration information of the target machine needs to be synchronized to the local machine first.
[0122] Exemplarily, the management machine synchronizing the configuration information of the target machine can include that the management machine obtains the current configuration information of the target machine, and stores the current configuration information of the target machine in the local database. The management machine can store the current configuration information of the target machine in the local database in the following ways: replacing the configuration information of the target machine stored in the local database with the current configuration information of the target machine, adding the current configuration information of the target machine in the local database, or only adding the difference data in the local database, for example, only adding the port ens2fl_l which is more than the configuration information of the target machine stored locally.
[0123] As a possible implementation, the local database of the management machine and the database of the target machine store configuration version id, and the management machine judges whether the configuration information of the target machine and the configuration information of the target machine stored locally are consistent by comparing the database configuration version id of the target machine with the target machine configuration version id stored in the local database.
[0124] Exemplarily, the management machine can obtain the database configuration version id of the target machine by sending a query to the target machine. The management machine queries the database configuration version id in the openvswitch table (the aforementioned table 1) in the local database. When it is judged that the two ids obtained are consistent, it indicates that the configuration data of the target machine stored in the local database is the same as the current configuration information of the target machine, and the next operation can be performed. When it is judged that the two ids obtained are not consistent, it indicates that the configuration data of the target machine stored in the local database is not the same as the current configuration information of the target machine, and the management machine needs to synchronize the configuration information and the configuration version id of the target machine.
[0125] For example, the management machine acquires the database configuration version id stored in the target machine as 1, and the target machine database configuration version id stored in the local database as 1, and thus judges that the port-related data stored in the local database and the port-related data stored in the target machine are the same, and can proceed to the next operation. For another example, the management machine acquires the database configuration version id stored in the target machine as 2, and the target machine database configuration version id stored in the local database as 1, and thus judges that the port-related data stored in the local database and the port-related data stored in the target machine are not the same, and needs to synchronize the configuration information and the configuration version id of the target machine first, and then can proceed to the next operation.
[0126] S63: The management machine synchronizes the data in the target machine.
[0127] In this embodiment, the configuration data of the target machine stored in the local database is not the same as the current configuration information of the target machine, and thus the second configuration information needs to be acquired from the target machine first, and the current configuration information of the target machine is synchronized in the local (i.e., the first configuration information is updated based on the second configuration information), so as to make the target machine-related configuration information stored in the local the same as the target machine.
[0128] S64: The management machine judges whether the name of the target bridge is stored in the local database. When the name of the target bridge is stored in the local database, S66 is executed; when the name is not stored, S65 is executed.
[0129] In this embodiment, the management machine can query the bridge name stored in the bridge table (the aforementioned table 2) in the local database, and judge whether the target bridge in the user instruction is stored in the local database. If the name of the target bridge is stored in the local database, it indicates that the target bridge exists in the target machine, and thus the operation of adding a port can be performed, i.e., S66 can be executed. When the management machine judges that the target bridge in the user instruction does not exist in the local database, it indicates that the target bridge does not exist in the target machine, and thus the operation of adding a port cannot be performed, and the user is prompted that the port addition fails, i.e., S65 is executed.
[0130] For example, the management machine acquires the bridge name in the user instruction as br0, and uses an sql to query whether the bridge exists in the bridge table in the local database. The possible select statement is: select * from bridge where name = br0. If a result is returned, it indicates that the bridge exists in the target machine, and the operation of adding a port can be performed; if no result is returned, it indicates that the bridge does not exist in the target machine, and the operation of adding a port cannot be performed, and the user is prompted that the port addition fails.
[0131] S65: The management machine determines that the port addition fails, and returns a prompt information.
[0132] In this embodiment, the management machine cannot find the target bridge in the local database, and cannot perform the port adding operation, so it determines that the port adding fails. At this time, the management machine can return a prompt information to the user that the port adding fails, or can prompt the user that the target bridge does not exist, and the user needs to input the added bridge.
[0133] S66: The management machine stores the information of the N target ports in the local database (i.e., the first configuration information), and sends a second instruction to the target machine, wherein the second instruction includes at least part of the data in the local database. The at least part of the data includes the port included in the first instruction. The second instruction is used to instruct the target machine to add the N target ports under the target bridge.
[0134] In this embodiment, the management machine can find the target bridge in the local database, and can perform the port adding. At this time, the management machine stores the information of the target ports in the local database. After storing the information of the target ports in the database, the management machine generates a second instruction, and sends the second instruction to the target machine, which is used to instruct the target machine to perform the port adding under the target bridge.
[0135] As a possible implementation, the following steps can be included:
[0136] S661: Determine whether a current i-th target port in the N target ports exists, wherein i is initially 1 and i is not greater than N.
[0137] In this embodiment, the management machine parses the instruction of the batch port adding input by the user, and obtains the port list in the instruction. The management machine sequentially reads the ports in the port list, and for each current port read, the management machine determines whether the port name in the current port has existed in the port table (the aforementioned table 3) in the local database according to the current port name. If the port name has existed, it means that the current port has existed in the target machine, and the port cannot be added again, and S662 is performed. If the port name does not exist, it means that the current port does not exist in the target machine, and S663 is performed.
[0138] Exemplarily, the management machine parses the user instruction, acquires two interfaces of the ports ens2f0_0 and ens2f0_1, and can express the interfaces as [ens2f0_0, ens2f0_1]. The first port is ens2f0_0, and the management machine uses a sql statement to query whether the interface exists in the port table in the local database. A possible select statement is: select*from port where name=ens2f0_0. If a result is returned, it indicates that the port exists in the target machine, and the port cannot be newly added. If no result is returned, it indicates that the port does not exist in the target machine, and the port with the name ens2f0_0 can be newly added in the target machine.
[0139] S662: The management machine determines that the current target port already exists, and the target port cannot be newly added. The management machine returns a prompt information that the target port already exists to the user, and executes S664.
[0140] In the embodiment, the management machine queries the information of the current target port existing in the local database through a sql statement, determines that the current port already exists in the target machine, and cannot newly add a port that already exists. Therefore, the management machine returns a prompt information that the current target port already exists to the user, and continues to execute S664.
[0141] Exemplarily, the management machine queries the port table (the foregoing table 3) through a select statement select*from port where name=ens2f0_0, and finds one data. It indicates that the port with the name ens2f0_0 already exists in the target machine, and a port with the name ens2f0_0 cannot be newly added. At this time, the management machine returns a prompt information that the port ens2f0_0 already exists to the user.
[0142] S663: The management machine records the current target port in the port table in the local database.
[0143] In the embodiment, when the management machine determines that the current port does not exist in the port table in the database, the management machine records the current port in the port table in the database through a sql statement. A possible insert statement is: insert into port set name=‘ens2f0_0’, bridge_id=1.
[0144] S664: It is determined whether i is less than N. When i is less than N, i is set as i+1, and S661-S664 are executed. When i is equal to N, S665 is executed.
[0145] In this embodiment, the management machine judges whether the current target port is the last target port to be added. If i of the current i-th port is less than N, it indicates that the current port is not the last target port to be added, and the next target port to be added is obtained (i.e. i is increased by 1), and the step of adding the target port is started again from S661. If i of the current i-th port is equal to N, it indicates that the current port is the last target port to be added. There is no target port to be added in the port list, and S666 is executed.
[0146] S665: A second instruction is generated and sent to the target machine.
[0147] In this embodiment, the management machine records all the ports that can be added in the first instruction in the local database, and can send the port addition instruction to the target machine. At this time, the second instruction is generated, which contains part or all of the data in the local database, and at least includes the port information in the first instruction. At the same time of sending the second instruction to the target machine, the management machine needs to increase the configuration version id value in the local database by 1.
[0148] For example, the management machine packs all the port information in the local database to generate the second instruction, and sends the generated second instruction to the target machine. This process continues to refer to the port addition stage in Figure 4 , which will not be described here again.
[0149] For example, the value element corresponding to the params in the JSON object in the generated interaction request at this time can include the following elements:
[0150] {"uuid-name":"rowcd4a265d_0c14_42ac_bad3_dcfb8c003142","row":{"name":"ens 2f0_0","interfaces":["named-uuid","row63c0331c_6ff8_4c0f_931e_67d32444445c"]},"op":"insert","table":"Port"},
[0151] {"uuid-name":"rowcd4a265d_0c14_42ac_bad3_dcfb8c003143","row":{"name":"ens 2f0_1","interfaces":["named-uuid","row63c0331c_6ff8_4c0f_931e_67d32444445D"]},"op":"insert","table":"Port"}.
[0152] In some embodiments, when the first configuration information is determined to be different from the second configuration information in the foregoing S62, in addition to performing the foregoing operations of S64-S66, a second instruction can be directly sent to the target machine, the second instruction being used to instruct the target machine to add N ports under the target bridge.
[0153] As can be seen from the foregoing various embodiments, by adding the local ovsdb database on the host running the ovs-vsctl, the data can be searched in the local cache, so as to reduce the data of the switch table, the bridge table and the port table obtained from the server, and the operation of adding the ports in batches on the target machine can be completed by one-time packing and unpacking, so that a large amount of communication time can be saved. Taking 100 ports as an example, the current time is about 70s, and after using the method, the time is about 7s, which can achieve 10 times performance benefit.
[0154] It can be understood that the size of the serial number of each step in the foregoing embodiments does not mean the order of execution, and the execution order of each process should be determined according to its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the application. In addition, in some possible implementation manners, each step in the foregoing embodiments can be selectively executed, partially executed or fully executed according to the actual situation, which is not limited here. All or part of any feature of any embodiment of the application can be freely and arbitrarily combined under the premise of no contradiction. The combined technical solution is also within the scope of the application.
[0155] Based on the method in the foregoing embodiments, the embodiments of the application provide a port configuration device. Please refer to Figure 7 , Figure 7 is a structural schematic diagram of a port configuration device provided by the embodiments of the application. The port configuration device 700 is deployed in a first host, the first host is deployed with a first database, the first database is used to store first configuration information related to a second host, the first configuration information includes a first identifier, the second host is deployed with a second database, and the second database is used to store second configuration information, and the second configuration information includes a second identifier.
[0156] Exemplarily, the first host can be but is not limited to the host 3 in Figure 5 , the first database can be but is not limited to the ovsdb on the host 3 in Figure 5 , the second host can be but is not limited to the host 1 and the host 2 in Figure 5 , and the second database can be but is not limited to the ovsdb on the host 1 and / or the host 2 in Figure 5 .
[0157] As Figure 7As shown, the port configuration apparatus 700 comprises a communication module 701 and a processing module 702. The communication module 701 is configured to obtain a first instruction, the first instruction being used to indicate that N target ports are to be added under a target bridge in a second host, where N is a positive integer. The processing module 702 is configured to obtain a second identifier from the second host in response to the first instruction. The processing module 702 is further configured to determine that the first configuration information is consistent with the second configuration information when the first identifier is consistent with the second identifier, and store information of the N target ports into a first database. The processing module 702 is further configured to send a second instruction to the second host based on the port information stored in the first database, the second instruction being used to instruct the second host to add N ports under the target bridge.
[0158] Exemplarily, the communication module 701 can be, but is not limited to, an ovs-vsctl on the host 3 shown in FIG. 1. Figure 5 The processing module 702 can be, but is not limited to, an ovsdb-server on the host 1 shown in FIG. 1. Figure 5
[0159] In some possible implementation manners, the processing module of the apparatus is further configured to determine that the first configuration information is inconsistent with the second configuration information when the first identifier is inconsistent with the second identifier, obtain the second configuration information by the first host, and store the second configuration information into the first database.
[0160] In some possible implementation manners, the first instruction can comprise an identifier of the target bridge and identifiers of the N target ports.
[0161] In some possible implementation manners, before storing the information of the N target ports into the first database, the processing module is further configured to determine that the name of the target bridge is stored in the first database.
[0162] In some possible implementation manners, the processing module storing the information of the N target ports into the first database can comprise: for any one of the N target ports, determining that the information related to the current port is not recorded in the first database, and storing the information of the current port into the first database.
[0163] In some possible implementation manners, the first database can comprise one or more of an openvswitch table, a bridge table or a port table. The openvswitch table stores a database configuration version id of the target machine, the bridge table stores a bridge name of the target machine, and the port table stores a port name of the target machine.
[0164] In some possible implementation manners, the first configuration information or the second configuration information can comprise one or more of the following: a switch, a bridge, a port, and an interface. In some possible implementation manners, the first configuration information or the second configuration information can comprise one or more of the following: a switch, a bridge, a port, and an interface.
[0165] In some possible implementation manners, the second instruction includes all contents in the first configuration information.
[0166] It should be understood that the above apparatus is used to execute the method in the above embodiments, and the corresponding program modules in the apparatus have similar implementation principles and technical effects to those described in the above method, and the working process of the apparatus can refer to the corresponding process in the above method, which will not be described here.
[0167] Figure 8 is a schematic structural diagram of a computing device provided by an embodiment of the present application. As shown in the figure, the computer device can include a processor 810, a memory 820, an input / output interface 830, a communication interface 840 and a bus 850. The processor 810, the memory 820, the input / output interface 830 and the communication interface 840 are connected to each other through the bus 850 for internal communication in the device. The computer device can be used to execute the method shown in the foregoing Figure 8 . Figure 6
[0168] The processor 810 can be implemented in the form of a general central processing unit (CPU), a microprocessor, an application specific integrated circuit (ASIC), or one or more integrated circuits, etc., for executing related programs to implement the technical solutions provided by the embodiments of the present application.
[0169] The memory 820 can be implemented in the form of a read only memory (ROM), a random access memory (RAM), a static storage device, a dynamic storage device, etc. The memory 820 can store an operating system and other application programs, and when the technical solutions provided by the embodiments of the present application are implemented by software or firmware, the related program codes are saved in the memory 820 and called and executed by the processor 810.
[0170] The input / output interface 830 is used to connect the input / output module to realize information input and output. The input / output module can be configured in the device (not shown in the figure) or externally connected to the device to provide corresponding functions. The input device can include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device can include a display, a speaker, a vibrator, an indicator light, etc.
[0171] The communication interface 840 is configured to connect a communication module (not shown in the figure) to realize the communication interaction between the device and other devices. The communication module can realize the communication through a wired manner (for example, a USB, a network cable and the like) or a wireless manner (for example, a mobile network, WIFI, Bluetooth and the like).
[0172] The bus 850 includes a path for transmitting information between various components (for example, the processor 810, the memory 820, the input / output interface 830 and the communication interface 840) of the device.
[0173] It should be noted that, although the device described above only shows the processor 810, the memory 820, the input / output interface 830, the communication interface 840 and the bus 850, in the specific implementation process, the device can also include other components necessary for normal operation. In addition, those skilled in the art can understand that the device described above can also only contain the components necessary for the implementation of the embodiments of the present application, and does not have to contain all the components shown in the figure.
[0174] It can be understood that the processor in the embodiments of the present application can be a central processing unit (CPU), and can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. The general-purpose processor can be a microprocessor or any conventional processor.
[0175] The method steps in the embodiments of the present application can be implemented by hardware, or by a combination of software and hardware executed by a processor. The software instructions can be composed of a corresponding software module, which can be stored in a random access memory (RAM), a flash memory, a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a register, a hard disk, a mobile hard disk, a CD-ROM, or any other form of storage medium well known in the art. An exemplary storage medium is coupled to the processor, so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an ASIC.
[0176] In the above embodiments, all or part of the embodiments can be implemented by software, hardware, firmware, or any combination thereof. When implemented by software, all or part of the embodiments can be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted by the computer-readable storage medium. The computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center through a wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) manner. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. integrated with one or more available media. The available media can be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium (for example, a solid state disk (SSD)), etc.
[0177] It can be understood that the various numerical numbers involved in the embodiments of the present application are only for the convenience of differentiation, and do not limit the scope of the embodiments of the present application.
Claims
1. A port configuration method, characterized by, The application is applied to a first host, wherein the first host stores first configuration information related to a second host, and the first configuration information comprises a first identifier. The method comprises: obtaining a first instruction, wherein the first instruction is used to indicate adding N target ports under a target bridge in the second host, wherein N is a positive integer; obtaining a second identifier from the second host in response to the first instruction, wherein the second identifier indicates the related configuration information of the second host; when the first identifier is consistent with the second identifier, determining that the first configuration information is consistent with the related configuration information of the second host, and sending a second instruction to the second host, wherein the second instruction is used to instruct the second host to add N ports under the target bridge.
2. The method of claim 1, wherein, The method further comprises: when the first identifier is not consistent with the second identifier, determining that the first configuration information is not consistent with the related configuration information of the second host, and obtaining the related configuration information of the second host from the second host by the first host; updating the first configuration information based on the related configuration information of the second host by the first host.
3. The method of claim 1, wherein, The first instruction comprises an identifier of the target bridge and identifiers of the N target ports.
4. The method of claim 1, wherein, After determining that the first configuration information is consistent with the related configuration information of the second host, the method further comprises: storing the information of the N ports into the first configuration information.
5. The method of claim 4, wherein, Before storing the information of the N target ports into the first configuration information, the method further comprises: determining whether the name of the target bridge is stored in the first configuration information; if yes, associating the information of the N ports under the target bridge in the first configuration information.
6. The method of claim 4, wherein, The method further comprises: if no, outputting prompt information, wherein the prompt information is used to indicate that the storage of the information of the N ports fails.
7. The method of claim 4, wherein, The storing of the information of the N ports into the first configuration information specifically comprises: for any one current port in the N target ports, determining that the first configuration information does not record the information related to the current port, and storing the information of the current port into the first configuration information.
8. The method according to any one of claims 1 to 7, characterized in that, The first configuration information comprises one or more of an openvswitch table, a bridge table or a port table, wherein the openvswitch table stores a database configuration version id of the second host, the bridge table stores a bridge name of the second host, and the port table stores a port name of the second host.
9. The method of claim 1, wherein, The second instruction comprises all contents in the first configuration information.
10. A computing device comprising a processor and a memory, wherein, The memory stores computer program instructions, and the computer program instructions are run by the processor to execute the method in any one of claims 1-8. The memory stores computer program instructions, and the computer program instructions are run by the processor to execute the method in any one of claims 1-8.
Citation Information
Patent Citations
Method and device for extending switch port
CN102148749A
Method and equipment for realizing distributed virtual switch system
CN104253770A