Batch automatic deployment method and device for operating system based on fixed address
Through dynamic modification of SSH and DHCP configurations and combined with PXE boot, the automatic deployment of operating systems in large-scale test clusters and highly automated running environments is achieved, solving the problems of high manpower consumption and difficulty in reconfiguring IP addresses in traditional methods. It is suitable for servers without BMC configuration.
Patent Information
- Application Number
- CN202411589592.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-07
- Publication Date
- 2025-02-28
AI Technical Summary
Traditional operating system batch automation deployment methods have problems such as high labor costs, difficulty in reconfiguring IP addresses, and inability to deploy BMC servers without configuration in large-scale test clusters and highly automated running environments.
The MAC address corresponding to the control IP address of the host to be installed is obtained through the SSH service, dynamically modify the DHCP configuration to assign a fixed IP address, restart the host and boot the operating system through PXE, and finally judge the operating system installation result through the SSH service.
It realizes that in large-scale test clusters and highly automated running environments, no need to manually reconfigure fixed control IP addresses, and automatically completes batch deployment of operating systems, reducing labor costs and maintenance, and is suitable for servers without BMC configuration.
Smart Images

Figure CN119536757A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the technical field of software installation, and in particular, relates to a method and device for batch automatic deployment of operating systems based on fixed addresses. Background Art
[0002] With the development of computer technology, some operating systems are widely used in large organizations, such as large-scale servers or desktop computers. In actual use scenarios, these organizations often need to install the same operating system on a large number of clients.
[0003] Traditional operating system installation requires manual on-site installation for different operating systems. However, when faced with large-scale test clusters and large-scale host system installation in a highly automated test deployment environment, traditional methods will have the following problems, such as:
[0004] In the traditional automated deployment and installation method, the PXE (Preboot eXecution Environment) system installation requires manual operation, which is very labor-intensive when installing in large quantities.
[0005] The traditional automated deployment and installation method uses the DHCP (Dynamic Host Configuration Protocol) service to allocate random IP addresses. For large-scale test clusters and highly automated test deployments, the IP addresses allocated to machines are fixed, which means that after the new system is installed on the machine, manual intervention is required to reconfigure the machine back to the previous IP address, which is very labor-intensive for large-scale installations.
[0006] Traditional automated deployment and installation methods are usually implemented through the Intelligent Platform Management Interface (IPMI) service, which makes it impossible to automatically deploy servers that are not equipped with a baseboard management controller (BMC). Summary of the invention
[0007] The purpose of this application is to provide a method and device for batch automated deployment of operating systems based on fixed addresses, aiming at large-scale test clusters and test deployment environments with highly automated running tests, through automated deployment of operating systems with fixed IP addresses.
[0008] According to a first aspect of the present application, a method for batch automatic deployment of operating systems based on fixed addresses is provided, comprising:
[0009] Obtain the MAC address (Media Access Control Address, also known as LAN address) corresponding to the control IP address of the host to be installed through the SSH (Secure Shell) service, and assign a fixed IP address to the MAC address by dynamically modifying the DHCP configuration;
[0010] Restarting the host to be installed based on the fixed IP address, and instructing the host to be installed to perform operating system installation using a preset operating system image to be installed;
[0011] After detecting that the host to be installed has been installed and has entered the operating system, the operating system of the host to be installed is accessed through the SSH service, and the installation result is determined by obtaining the kernel version of the operating system.
[0012] In an optional implementation manner, obtaining the MAC address corresponding to the control IP address of the host to be installed through the SSH service further includes:
[0013] Read the preset configuration file, obtain the control IP address and password information of the host to be installed, connect to the specified client through the SSH service, obtain the MAC address corresponding to the control IP address, and return the configuration file corresponding to the control IP address and the MAC address.
[0014] In an optional implementation manner, the assigning a fixed IP address to the MAC address by dynamically modifying the DHCP configuration further includes:
[0015] Read the DHCP static address configuration file and find the allocation record of the static IP address and MAC address binding;
[0016] If the control IP address obtained from the configuration file exists in the DHCP static address configuration file, compare whether the MAC address of the IP address in the allocation record is consistent with the MAC address obtained in the configuration file, and if they are inconsistent, modify the MAC address corresponding to the IP address to the MAC address obtained in the configuration file;
[0017] If the control IP address obtained from the configuration file does not exist in the DHCP static address configuration file, modify the DHCP static address configuration file to add a static address allocation relationship between the obtained IP address and the corresponding MAC address;
[0018] Restart the DHCP service.
[0019] In an optional implementation manner, the restarting the host to be installed based on the fixed IP address further includes:
[0020] Modify the PXE boot file according to the preset operating system image to be installed, and restart PXE related services;
[0021] Use the SSH service to remotely change the boot type of the host to be installed to PXE boot, and restart it after the change is complete.
[0022] In an optional implementation manner, determining the installation result by obtaining the kernel version of the operating system further includes:
[0023] Read the configuration file to obtain the control IP address and password of the host to be installed; try to connect to the host to be installed through the SSH service, and set the connection timeout. If the connection to the host to be installed is not made within the timeout, return the print information that the port status has not been activated normally and loop the connection operation; if the connection to the host is successful, determine that the port status is normally activated, enter the installed operating system through the SSH service, check the system kernel version information of the operating system, compare the obtained system kernel version information with the kernel version information in the actually installed operating system image, and if the kernel versions are consistent, return the check result that the operating system is installed successfully; if the kernel versions are inconsistent, return the check result that the operating system installation fails.
[0024] According to a second aspect of the present application, a device for batch automatic deployment of operating systems based on fixed addresses is provided, comprising:
[0025] A configuration unit, used to obtain a MAC address corresponding to a control IP address of a host to be installed through an SSH service, and allocate a fixed IP address to the MAC address by dynamically modifying a DHCP configuration;
[0026] An installation unit, configured to restart the host to be installed based on the fixed IP address, and instruct the host to be installed to perform operating system installation using a preset operating system image to be installed;
[0027] The checking unit is used to access the operating system of the host to be installed through the SSH service after detecting that the host to be installed has been installed and entered the operating system, and determine the installation result by obtaining the kernel version of the operating system.
[0028] In an optional implementation manner, the configuration unit is further used to:
[0029] Read the preset configuration file, obtain the control IP address and password information of the host to be installed, connect to the specified client through the SSH service, obtain the MAC address corresponding to the control IP address, and return the configuration file corresponding to the control IP address and the MAC address.
[0030] In an optional implementation manner, the configuration unit is further used to:
[0031] Read the DHCP static address configuration file and find the allocation record of the static IP address and MAC address binding;
[0032] If the control IP address obtained from the configuration file exists in the DHCP static address configuration file, compare whether the MAC address of the IP address in the allocation record is consistent with the MAC address obtained in the configuration file, and if they are inconsistent, modify the MAC address corresponding to the IP address to the MAC address obtained in the configuration file;
[0033] If the control IP address obtained from the configuration file does not exist in the DHCP static address configuration file, modify the DHCP static address configuration file to add a static address allocation relationship between the obtained IP address and the corresponding MAC address;
[0034] Restart the DHCP service.
[0035] In an optional embodiment, the installation unit is further used to:
[0036] Modify the PXE boot file according to the preset operating system image to be installed, and restart PXE related services;
[0037] Use the SSH service to remotely change the boot type of the host to be installed to PXE boot, and restart it after the change is complete.
[0038] In an optional embodiment, the inspection unit is further used to:
[0039] Read the configuration file to obtain the control IP address and password of the host to be installed; try to connect to the host to be installed through the SSH service, and set the connection timeout. If the connection to the host to be installed is not made within the timeout, return the print information that the port status has not been activated normally and loop the connection operation; if the connection to the host is successful, determine that the port status is normally activated, enter the installed operating system through the SSH service, check the system kernel version information of the operating system, compare the obtained system kernel version information with the kernel version information in the actually installed operating system image, and if the kernel versions are consistent, return the check result that the operating system is installed successfully; if the kernel versions are inconsistent, return the check result that the operating system installation fails.
[0040] Compared with the related art, the technical solution of this application has the following advantages:
[0041] Through the automated script, batch installation can be performed with one click. By dynamically modifying the DHCP configuration file and binding the client network card MAC with the actual allocated IP, the control IP before and after the PXE reinstallation of the system remains unchanged. For large-scale test clusters and highly automated test deployment environments, there is no need to manually reconfigure the fixed control IP, which makes it convenient for users to directly use the new system. Based on the SSH service, the status of the Client port can be checked and the kernel version of the system after reinstallation can be checked to determine the installation result of the Client system, which is also applicable to servers without BMC configuration.
[0042] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or be understood by practicing the present application. The purpose and other advantages of the present application can be realized and obtained through the structures and processes indicated in the description and the drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. It is obvious that the drawings described below are certain embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0044] Figure 1 It is a schematic diagram of the overall process of a method for batch automated deployment of operating systems based on fixed addresses according to an exemplary embodiment of the present application.
[0045] Figure 2 is a flow chart of batch operating system deployment according to an exemplary embodiment of the present application.
[0046] Figure 3 It is a flow chart of dynamically modifying DHCP configuration according to an exemplary embodiment of the present application.
[0047] Figure 4 is a flow chart of port checking and result checking according to an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0048] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0049] In order to improve the efficiency of batch installation of operating systems in large-scale test clusters and highly automated test deployment environments, so that the installed systems can be put into use again without manual configuration of the environment, a remote, automated, fast and reliable method for batch installation of operating systems is needed.
[0050] Based on the above analysis, the present application provides a method and device for batch automated deployment of operating systems based on fixed addresses, which realizes an overall solution for automated installation based on Python. Specifically, the MAC address of the network port corresponding to the control IP of the host to be installed is obtained through the SSH network protocol service, and the DHCP configuration of the PXE server (Server) is dynamically modified according to the corresponding relationship between the obtained MAC address and the control IP, and the system image to be installed is set according to the parameter information obtained by the software; the host with the specified IP is set to PXE startup and restart the host through the SSH service; the SSH port check module is used to check whether the host enters the operating system after restarting, and the SSH service is used to check whether the operating system kernel is consistent with the specified installation system kernel to determine whether the installation is successful and return the result, so as to solve the problems of high labor cost and large maintenance.
[0051] See also Figure 1 , illustratively, the method for batch automated deployment of operating systems based on fixed addresses provided by the present application includes:
[0052] Step 101: Obtain the MAC address corresponding to the control IP address of the host to be installed through the SSH service, and allocate a fixed IP address to the MAC address by dynamically modifying the DHCP configuration.
[0053] like Figure 2 As shown, the host to be installed takes the client as an example, and illustratively, Figure 2 As shown, in process 1, a preset configuration file containing the initial IP and password of the client that needs to be installed by PXE is read, the client control IP address and password information are obtained, and the SSH service is used to connect to the specified client server, and the network port MAC address corresponding to the control IP is obtained and a configuration file corresponding to the IP address and MAC address is returned to the PXE Server.
[0054] In an exemplary embodiment, the configuration file may be a json file (JavaScript Object Notation, a data format). In an optional embodiment, the configuration file may also be a regular file such as a YAML file (YAML Ain't Markup Language, a format focused on data serialization, used for configuration files and data exchange), a TOML file (Tom's Obvious, Minimal Language), an XML file (Extensible Markup Language), or an INI file (initialization file, a simple text file format, usually composed of sections, keys, and values, used to store configuration data).
[0055] In process 2, the configuration file corresponding to the obtained IP address and MAC address is used to dynamically modify the DHCP configuration, obtain the specified system image source path and other parameter information, specify the corresponding MAC address to allocate a static IP, and ensure that the control IP remains unchanged before and after the system is reinstalled.
[0056] For example, Figure 3 As shown, the process of dynamically modifying the DHCP configuration further includes:
[0057] The PXE Server reads the configuration file and obtains the IP address of the specified host and the MAC address of the corresponding network port;
[0058] The PXE Server reads the DHCP static address configuration file and searches for the allocation record of the existing static IP address and MAC address binding;
[0059] If the control IP address obtained from the configuration file exists in the DHCP static address configuration file, the MAC address of the IP address in the allocation record is compared to see if it is consistent with the obtained MAC address. If they are inconsistent, the MAC address corresponding to the IP address is modified to the MAC address obtained in the configuration file; if they are consistent, no change is made.
[0060] If the control IP address obtained from the configuration file does not exist in the DHCP static address configuration file, the DHCP static address configuration file is modified to add a static address allocation relationship between the obtained IP address and the corresponding MAC address.
[0061] After modifying the DHCP static address configuration file on the PXE Server, save the changes and restart the DHCP service.
[0062] Step 102: Restart the host to be installed based on the fixed IP address, and instruct the host to be installed to perform operating system installation using a preset operating system image to be installed.
[0063] For example, Figure 2 As shown, in process 3, the PXE boot file is modified according to the preset operating system image to be installed, and the PXE related services are restarted.
[0064] In process 4, remotely modify the client's boot type to PXE boot through the SSH service, and restart the client after the modification is completed.
[0065] In process 5, after the client is restarted, it directly performs PXE boot and reinstalls the specified PXE operating system.
[0066] Step 103: After detecting that the host to be installed has been installed and has entered the operating system, access the operating system of the host to be installed through the SSH service, and determine the installation result by obtaining the kernel version of the operating system.
[0067] For example, Figure 2 As shown, in process 6, after the restart command is sent to the client through SSH, the port check module on the PXE server periodically checks whether the SSH port on the client is up again, and then determines whether the client has completed the restart and entered the operating system. UP means that the port status is normally activated, that is, the link is established normally and data transmission is carried out.
[0068] In process 7, after detecting that the SSH port is UP, connect to the client operating system through the SSH service and check whether the client system kernel version is consistent with the expected version, so as to determine whether the PXE installation is successful, and finally return the installation result.
[0069] For example, Figure 4 As shown, the SSH port status check and installation result check process further includes:
[0070] The PXE Server reads the configuration file and obtains the control IP address and password of the specified host;
[0071] The PXE Server attempts to connect to the host with the specified IP through the SSH service and sets the connection timeout. If the timeout is reached and the host is not connected, the print information that the port status is not UP is returned and the connection operation is repeated in a loop; if the host is successfully connected, the print information that the port status is UP is returned.
[0072] When the PXE server detects that the port status is UP, it enters the installed operating system through the SSH service, checks the system kernel version information of the operating system and returns it to the PXE server. The PXE server compares the obtained system kernel version information with the kernel version information in the actually installed operating system image. If the kernel versions are consistent, the check result returned is that the operating system is successfully installed; if the kernel versions are inconsistent, the check result returned is that the operating system installation fails.
[0073] The above example shows a single-machine installation. Based on the above single-machine installation process, in the batch deployment stage, it is only necessary to write the relevant information of multiple hosts to be installed in the configuration file that initially contains the control IP address and password information of the host to be installed. In order to ensure that multiple clients can install the PXE system at the same time, in an exemplary embodiment, Python's multi-threading method is used to implement it, and all clients are instructed to start synchronously and independently perform the above installation steps through multi-threading, ensuring the efficiency and reliability of batch deployment.
[0074] It can be seen that the method for batch automated deployment of operating systems based on fixed addresses provided by this application has the following advantages over related technologies:
[0075] Through the automated script, batch installation can be performed with one click. By dynamically modifying the DHCP configuration file and binding the client network card MAC with the actual allocated IP, the control IP before and after the PXE reinstallation of the system remains unchanged. For large-scale test clusters and highly automated test deployment environments, there is no need to manually reconfigure the fixed control IP, which makes it convenient for users to directly use the new system. Based on the SSH service, the status of the Client port can be checked and the kernel version of the system after reinstallation can be checked to determine the installation result of the Client system, which is also applicable to servers without BMC configuration.
[0076] Accordingly, the present application provides, in a second aspect, a device for batch automatic deployment of operating systems based on fixed addresses, comprising:
[0077] A configuration unit, used to obtain a MAC address corresponding to a control IP address of a host to be installed through an SSH service, and allocate a fixed IP address to the MAC address by dynamically modifying a DHCP configuration;
[0078] An installation unit, configured to restart the host to be installed based on the fixed IP address, and instruct the host to be installed to perform operating system installation using a preset operating system image to be installed;
[0079] The checking unit is used to access the operating system of the host to be installed through the SSH service after detecting that the host to be installed has been installed and entered the operating system, and determine the installation result by obtaining the kernel version of the operating system.
[0080] The above-mentioned device can be implemented through the fixed address-based batch automatic deployment method of operating systems provided by the embodiment of the first aspect above. The specific implementation method can be found in the description of the embodiment of the first aspect, and will not be repeated here.
[0081] It is understood that the circuit structures, names and parameters described in the above embodiments are only examples. Those skilled in the art can also easily combine and adjust the structural features of the above embodiments according to the use requirements, and should not limit the concept of the present application to the specific details of the above examples.
[0082] Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that he or she may still modify the technical solutions described in the aforementioned embodiments, or make equivalent substitutions for some of the technical features therein; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for batch automatic deployment of operating systems based on fixed addresses, characterized in that: include: Obtain the MAC address corresponding to the control IP address of the host to be installed through the SSH service, and assign a fixed IP address to the MAC address by dynamically modifying the DHCP configuration; Restarting the host to be installed based on the fixed IP address, and instructing the host to be installed to perform operating system installation using a preset operating system image to be installed; After detecting that the host to be installed has been installed and has entered the operating system, the operating system of the host to be installed is accessed through the SSH service, and the installation result is determined by obtaining the kernel version of the operating system.
2. The method for batch automatic deployment of operating systems based on fixed addresses according to claim 1, characterized in that: The step of obtaining the MAC address corresponding to the control IP address of the host to be installed through the SSH service further includes: Read the preset configuration file, obtain the control IP address and password information of the host to be installed, connect to the specified client through the SSH service, obtain the MAC address corresponding to the control IP address, and return the configuration file corresponding to the control IP address and the MAC address.
3. The method for batch automatic deployment of operating systems based on fixed addresses according to claim 1, characterized in that: The method of allocating a fixed IP address to the MAC address by dynamically modifying the DHCP configuration further includes: Read the DHCP static address configuration file and find the allocation record of the static IP address and MAC address binding; If the control IP address obtained from the configuration file exists in the DHCP static address configuration file, compare whether the MAC address of the IP address in the allocation record is consistent with the MAC address obtained in the configuration file, and if they are inconsistent, modify the MAC address corresponding to the IP address to the MAC address obtained in the configuration file; If the control IP address obtained from the configuration file does not exist in the DHCP static address configuration file, modify the DHCP static address configuration file to add a static address allocation relationship between the obtained IP address and the corresponding MAC address; Restart the DHCP service.
4. The method for batch automatic deployment of operating systems based on fixed addresses according to claim 1, characterized in that: The restarting the host to be installed based on the fixed IP address further includes: Modify the PXE boot file according to the preset operating system image to be installed, and restart PXE related services; Use the SSH service to remotely change the boot type of the host to be installed to PXE boot, and restart it after the change is complete.
5. The method for batch automatic deployment of operating systems based on fixed addresses according to claim 1, characterized in that: The step of determining the installation result by obtaining the kernel version of the operating system further includes: Read the configuration file to obtain the control IP address and password of the host to be installed; try to connect to the host to be installed through the SSH service, and set the connection timeout. If the connection to the host to be installed is not made within the timeout, return the print information that the port status has not been activated normally and loop the connection operation; if the connection to the host is successful, determine that the port status is normally activated, enter the installed operating system through the SSH service, check the system kernel version information of the operating system, compare the obtained system kernel version information with the kernel version information in the actually installed operating system image, and if the kernel versions are consistent, return the check result that the operating system is installed successfully; if the kernel versions are inconsistent, return the check result that the operating system installation fails.
6. A device for batch automatic deployment of operating systems based on fixed addresses, characterized in that: include: A configuration unit, used to obtain a MAC address corresponding to a control IP address of a host to be installed through an SSH service, and allocate a fixed IP address to the MAC address by dynamically modifying a DHCP configuration; An installation unit, configured to restart the host to be installed based on the fixed IP address, and instruct the host to be installed to perform operating system installation using a preset operating system image; The checking unit is used to access the operating system of the host to be installed through the SSH service after detecting that the host to be installed has been installed and entered the operating system, and determine the installation result by obtaining the kernel version of the operating system.
7. The device for batch automatic deployment of operating systems based on fixed addresses according to claim 6, characterized in that: The configuration unit is further used to: Read the preset configuration file, obtain the control IP address and password information of the host to be installed, connect to the specified client through the SSH service, obtain the MAC address corresponding to the control IP address, and return the configuration file corresponding to the control IP address and the MAC address.
8. The device for batch automatic deployment of operating systems based on fixed addresses according to claim 6, characterized in that: The configuration unit is further used to: Read the DHCP static address configuration file and find the allocation record of the static IP address and MAC address binding; If the control IP address obtained from the configuration file exists in the DHCP static address configuration file, compare whether the MAC address of the IP address in the allocation record is consistent with the MAC address obtained in the configuration file, and if they are inconsistent, modify the MAC address corresponding to the IP address to the MAC address obtained in the configuration file; If the control IP address obtained from the configuration file does not exist in the DHCP static address configuration file, modify the DHCP static address configuration file to add a static address allocation relationship between the obtained IP address and the corresponding MAC address; Restart the DHCP service.
9. The device for batch automatic deployment of operating systems based on fixed addresses according to claim 6, characterized in that: The installation unit is further used for: Modify the PXE boot file according to the preset operating system image to be installed, and restart PXE related services; Use the SSH service to remotely change the boot type of the host to be installed to PXE boot, and restart it after the change is complete.
10. The device for batch automatic deployment of operating systems based on fixed addresses according to claim 6, characterized in that: The inspection unit is further used for: Read the configuration file to obtain the IP address and password of the host to be installed; try to connect to the host to be installed through the SSH service, and set the connection timeout. If the connection to the host to be installed is not made after the timeout, return a print message indicating that the port status has not been activated normally and perform the connection operation in a loop; If the connection to the host is successful, the port status is determined to be activated normally. Use the SSH service to enter the installed operating system, check the system kernel version information of the operating system, and compare the obtained system kernel version information with the kernel version information in the actually installed operating system image. If the kernel versions are consistent, the inspection result is returned that the operating system is successfully installed. If the kernel versions are inconsistent, the check result returned is that the operating system installation failed.
Citation Information
Patent Citations
Bare metal server deployment method and device
CN104767649A
Automatic deployment method and system based on YAML, electronic equipment and storage medium
CN115811475A
Method for automatically deploying bare computer server operating system
CN116048641A
Cited By
System and method for batch modification of BMC and MAC addresses
CN121037204A