Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Detailed introduction of efficient batch Network installation of PXE in CentOS7

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "the detailed introduction of PXE efficient batch network installation in CentOS7". In the daily operation, I believe that many people have doubts about the detailed introduction of PXE efficient batch network installation in CentOS7. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "detailed introduction of PXE efficient batch network installation in CentOS7". Next, please follow the editor to study!

Batch deployment of PXE efficient batch Network installed servers

Scale: assemble multiple servers at the same time

Automation: install the system and configure various services

Remote implementation: no installation media such as CD, U disk and so on

About PXE Network PXE

Pre-start the execution environment, running before the operating system

Can be used for remote installation to build diskless workstations

Server side

Run the DHCP service to assign addresses and locate bootstrappers

DHCP automatically assigns IP addresses to locate boot files

Run the TFTP server to provide bootstrap downloads

TFTP simple File transfer Protocol

Use the UDP protocol

Port number 69

Advantages: high efficiency

Disadvantages: small capacity

Used to store: bootstrap pxelinux.0 (syslinux package), compressed kernel vmlinuz, system initialization file initrd.img, boot menu default

Run the FTP service to download image files

FTP (vsftpd) File transfer Protocol

Advantages: safety, large capacity

Disadvantages: slow transmission speed

Use the TCP protocol

Port number 20 is used for data transmission, port number 21 is used for connection

For storage: system image

Installation package: dhcp,tftp-server,vsftpd,syslinux

Client

The network card supports PXE protocol.

The motherboard supports network startup

Basic deployment process

Prepare the CentOS 7 installation source (YUM repository)

Enable TFTP services and provide kernel and bootstrap programs

Enable the DHCP service to assign addresses and indicate the location of the bootstrap

Configure the startup menu

TFTP services and bootstrap files

Install the tftp-server package and enable the tftp service

Prepare the kernel file vmlinuz and initialize the mirror initrd.img

Prepare the bootstrap file pxelinux.0

PXE settings for the DHCP service

Next-server / / points to the TFTP path

Filename / / Bootstrapper File location

Default startup menu file

Create / var/lib/tftpboot/pxelinux.cfg/default

Directory name pxelinux.cfg cannot be changed

Verify PXE network installation

Adjust BIOS settings to boot from the network

Automatically obtain the IP address and specify the CentOS 7 installation source

The rest of the process is the same as the local installation

Demo

1. First, configure a virtual machine in the VMware 15 virtual machine without installing the system, and the network card is set in host-only mode, which is used to verify the PXE network installation, open the CentOS 7 virtual machine, and configure the dual network card mode. The original network card is used for network connection, so it is convenient for us to install the service software, and the added network card is set to host-only mode to bind it with the configured virtual machine in the same device. At the same time, the static IP address is configured in the added network card, which can provide the IP address to the configured virtual machine.

[root@localhost ~] # ifconfig / / View network card information in CentOS 7 system ens33: flags=4163 mtu 1500 / / original network card information inet 192.168.144.133 netmask 255.255.255.0 broadcast 192.168.144.255 inet6 fe80::a85a:c203:e2e:3f3c prefixlen 64 scopeid 0x20 ether 00:0c:29:5b:d3:a0 txqueuelen 1000 (Ethernet) RX packets 26199 bytes 36984367 (35.2MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 8391 bytes 524793 (512.4 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0ens36: flags=4163 mtu 1500 / / added network card information inet6 fe80::deb1:3cec:3e26:5ec2 prefixlen 64 scopeid 0x20 ether 00:0c:29:5b:d3:aa txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0B) RX errors 0 Dropped 0 overruns 0 frame 0 TX packets 10 bytes 1308 (1.2 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@localhost ~] # cd / etc/sysconfig/network-scripts/ enter the Nic configuration file directory [root@localhost network-scripts] # ls / / View Information ifcfg-ens33 ifdown-ippp ifdown-sit ifup-bnep ifup-plip ifup -Team network-functions-ipv6ifcfg-lo ifdown-ipv6 ifdown-Team ifup-eth ifup-plusb ifup-TeamPortifdown ifdown-isdn ifdown-TeamPort ifup-ib ifup-post ifup-tunnelifdown-bnep ifdown-post ifdown-tunnel ifup-ippp ifup-ppp ifup-wirelessifdown-eth ifdown-ppp ifup ifup-ipv6 ifup-routes init.ipv6-globalifdown-ib ifdown-routes ifup-aliases ifup-isdn ifup-sit Network-functions [root@localhost network-scripts] # cp-p ifcfg-ens33 ifcfg-ens36 / / copy ens33 configuration file to ens36 [root@localhost network-scripts] # vim ifcfg-ens36 / / Edit Nic information TYPE=EthernetPROXY_METHOD=noneBROWSER_ONLY=noBOOTPROTO=static / / change dhcp to staticDEFROUTE=yesIPV4_FAILURE_FATAL=noIPV6INIT=yesIPV6_AUTOCONF=yesIPV6_DEFROUTE=yesIPV6_FAILURE_FATAL=noIPV6_ADDR_GEN_MODE=stable-privacyNAME=ens36 / / change 33 change 33 for 36DEVICE=ens36 / / configure IP address NETMASK=255.255.255.0 / / configure subnet mask GATEWAY=192.168.100.1 / / configure gateway ~ / Note: delete the UUID entry ~ ~ ~ ~: wq [root@localhost network-scripts] # service network restart / / restart the network card service Restarting network (via systemctl): [OK] [root@localhost network-scripts] # ifconfig / / View the network card information ens33: flags=4163 mtu 1500 inet 192.168.144.133 netmask 255.255.255.0 broadcast 192.168.144.255 inet6 fe80::a85a:c203:e2e:3f3c prefixlen 64 scopeid 0x20 ether 00:0c:29:5b:d3:a0 txqueuelen 1000 (Ethernet) RX packets 124487 bytes 178695031 (170.4 MiB) RX errors 0 dropped 0 frame 0 TX packets 35758 Bytes 2193524 (2.0 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0ens36: flags=4163 mtu 1500 / / obtain the static IP address inet 192.168.100.100 netmask 255.255.255.0 broadcast 192.168.100.255 inet6 fe80::f6eb:23e3:3afb:fef4 prefixlen 64 scopeid 0x20 ether 00:0c:29:5b:d3:aa txqueuelen 1000 (Ethernet) RX packets 2 bytes 486 (486.0) B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 186 bytes 32776 (32 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

2. Install the DHCP service and edit the DHCP service configuration file

[root@localhost network-scripts] # yum install dhcp-y loaded plug-in: fastestmirror, langpacksLoading mirror speeds from cached hostfile * base: mirrors.163.com * extras: mirrors.huaweicloud.com * updates: mirrors.huaweicloud.com is resolving dependencies-> checking transactions-- > package dhcp.x86_64.12.4.2.5-68.el7.centos.1 will be installed. / / omit some of the contents. Installed: dhcp.x86_64 12 dhclient.x86_64 4.2.5-68.el7.centos.1 is upgraded as a dependency: dhclient.x86_64 12 dhclient.x86_64 4.2.5-68.el7.centos.1 dhcp-common.x86_64 12 68.el7.centos.1 dhcp-common.x86_64 4.2.5-68.el7.centos.1 dhcp-libs.x86_64 12 dhclient.x86_64 4.2.5-68.el7.centos.1 over! [root@localhost network-scripts] # cp/ usr/share/doc/dhcp-4.2.5/dhcpd.conf.example / etc/dhcp/dhcpd.conf cp: overwrite "/ etc/dhcp/dhcpd.conf"? Yes / / copy the DHCP configuration file template into the configuration file, enter yes to confirm that [root@localhost network-scripts] # vim / etc/dhcp/dhcpd.conf / / Edit the configuration DHCP configuration file. / / omit some of the contents. Ubnet 192.168.100.0 netmask 255.255.255.0 {/ / set the network segment address range 192.168.100.20 192.168.100.30 / / set the IP address allocation range option routers 192.168.100.100; / / set the gateway to point to yourself to facilitate the server to assign the address option domain-name-servers 8.8.8.8; / / set the allocation DNS address next-server 192.168.100.100 / / set to point to the TFTP server address, that is, native filename "pxelinux.0"; / / set to point to the location of the boot file. Note: the file name cannot be typed incorrectly. / / omit part of the content.: wq / / Save exit

3. Install the bootstrapper file

[root@localhost network-scripts] # yum install syslinux-y / / the installation bootstrapper has loaded plug-ins: fastestmirror, langpacksLoading mirror speeds from cached hostfile * base: mirrors.163.com * extras: mirrors.huaweicloud.com * updates: mirrors.huaweicloud.com is resolving dependencies-- > checking transactions-- > package syslinux.x86_64.0.4.05-15.el7 will be installed. / / omit some of the contents. Installed: syslinux.x86_64 0vl 4.05-15.el7 over! [root@localhost network-scripts] # rpm-ql syslinux | grep pxelinux.0/ / check whether the boot file / usr/share/syslinux/gpxelinux.0/usr/share/syslinux/pxelinux.0 / / program boot file is installed successfully in the installed software

4. Install TFTP service software

[root@localhost network-scripts] # yum install tftp-server-y / / install tftp service loaded plug-ins: fastestmirror, langpacksLoading mirror speeds from cached hostfile * base: mirrors.163.com * extras: mirrors.huaweicloud.com * updates: mirrors.huaweicloud.com is resolving dependencies-- > checking transactions-- > package tftp-server.x86_64.0.5.2-22.el7 will be installed. / / omit some of the contents. Installed: tftp-server.x86_64 0VRV 5.2-22.el7 over! [root@localhost network-scripts] # rpm-ql tftp-server / / View tftp service list / etc/xinetd.d/tftp / / tftp configuration file directory / usr/lib/systemd/system/tftp.service/usr/lib/systemd/system/tftp.socket/usr/sbin/in.tftpd/usr/share/doc/tftp-server-5.2/usr/share/doc/tftp-server- 5.2/CHANGES/usr/share/doc/tftp-server-5.2/README/usr/share/doc/tftp-server-5.2/README.security/usr/share/man/man8/in.tftpd.8.gz/usr/share/man/man8/tftpd.8.gz/var/lib/tftpboot / / tftp site directory

5. Put the bootstrap file into the tftp service site, and turn on the tftp service function

[root@localhost network-scripts] # cp / usr/share/syslinux/pxelinux.0 / var/lib/tftpboot/ copy files into tftp site [root@localhost network-scripts] # cd / var/lib/tftpboot/ enter tftp site [root@localhost tftpboot] # ls / / View directory information pxelinux.0 / / add bootstrap files to the site [root@localhost tftpboot] # vim / etc/xinetd.d/tftp / / enter and edit the tftp main configuration file # default: off# description: The tftp server serves files using the trivial file transfer\ # protocol. The tftp protocol is often used to boot diskless\ # workstations, download configuration files to network-aware printers \ # and to start the installation process for some operating systems.service tftp {socket_type = dgram protocol = udp wait = yes user = root server = / usr/sbin/in.tftpd server_args =-s / var/lib/tftpboot Disable = no / / change yes to no enable service function per_source = 11 cps = 100 2 flags = IPv4} ~ : wq / / Save exit

6. Install the ftp service function, mount the image file CentOS 7 in the ftp site, find the system initial file and the compressed kernel file, and add it to the tftp site.

[root@localhost tftpboot] # yum install vsftpd-y loaded plug-in: fastestmirror, langpacksLoading mirror speeds from cached hostfile * base: mirrors.163.com * extras: mirrors.huaweicloud.com * updates: mirrors.huaweicloud.com is resolving dependencies-> checking transactions-- > package vsftpd.x86_64.0.3.0.2-25.el7 will be installed. / / omit some of the contents. Installed: vsftpd.x86_64 0 3.0.2-25.el7 over! [root@localhost tftpboot] # rpm-ql vsftpd / / View the list of ftp service files. / / omit some contents. / usr/share/man/man5/vsftpd.conf.5.gz/usr/share/man/man8/vsftpd.8.gz/var/ftp / / ftp site location / var/ftp/pub [root@localhost ~] # cd / var/ftp/ enter Ftp service site [root@localhost ftp] # ls / / View directory pub [root@localhost ftp] # mkdir centos7/ / create directory centos7 directory user mount image file [root@localhost ftp] # ls / / View centos7 pub / / successfully created [root@localhost ftp] # mount / dev/sr0 / var/ftp/centos7/ / / Mount the image file to the centos7 directory in the ftp site mount: / dev/sr0 write protection [root@localhost ftp] # df-hT / / View disk information file system type capacity available available mount point / dev/sda2 xfs 20g 3.7g 17g 19% / devtmpfs devtmpfs 898M 0898m 0% / devtmpfs tmpfs 912m 0912m 0% / dev/shmtmpfs tmpfs 912M 9.0M 903M 1% / runtmpfs tmpfs 912M 0912M 0% / sys/fs/cgroup/dev/sda5 xfs 10G 37M 10G 1% / home/dev/sda1 xfs 6.0G 174M 5.9G 3% / boottmpfs tmpfs 183M 28K 183M 1% / run/user/0/dev/sr0 iso9660 4.3G 4.3G 0% / var/ftp/centos7 / / successfully mounted [root@localhost ftp] # cd centos7/ enter the centos7 directory [root@localhost centos7] # ls / / to view the mounted image information CentOS_BuildTag EULA images LiveOS repodata RPM-GPG-KEY-CentOS-Testing-7EFI GPL isolinux Packages RPM-GPG-KEY-CentOS -7 TRANS.TBL [root@localhost centos7] # cd images/ enter images directory [root@localhost images] # ls / / View directory information efiboot.img pxeboot TRANS.TBL [root@localhost images] # cd pxeboot/ enter pxeboot directory [root@localhost pxeboot] # ls / / View directory information initrd.img TRANS.TBL vmlinuz / / compress kernel and system beginning Initialization file [root@localhost pxeboot] # cp initrd.img vmlinuz / var/lib/tftpboot/ add compressed kernel and system initialization files to tdtp site [root@localhost pxeboot] # ls / var/lib/tftpboot/ View tftp site information initrd.img pxelinux.0 vmlinuz / / successfully add compressed kernel and system initialization files

7. Add the startup menu to the tftp site. When finished, turn on the dhcp, tftp, ftp services, and turn off the firewall and enhanced security functions.

[root@localhost pxeboot] # cd / var/lib/tftpboot/ enter the tftp site [root@localhost tftpboot] # ls / / View site information initrd.img pxelinux.0 vmlinuz [root@localhost tftpboot] # mkdir pxelinux.cfg / / add a startup menu directory to the site Note: the directory name cannot be typed wrong [root@localhost tftpboot] # ls / / View directory initrd.img pxelinux.0 pxelinux.cfg vmlinuz / / successfully create the startup menu directory [root@localhost tftpboot] # cd pxelinux.cfg/ enter the created startup menu directory [root@localhost pxelinux.cfg] # vim default / / Edit the startup menu file default auto / / default mode prompt 1 / / wait time 1 second / / write configuration file template label auto kernel vmlinuz / / kernel Information append initrd=initrd.img method= ftp://192.168.100.100/centos7 / / load system initialization file Mode is ftp The directory is centos7label linux text kernel vmlinuz append text initrd=initrd.img method= ftp://192.168.100.100/centos7label linux rescue / / enter the first aid mode kernel vmlinuz append rescue initrd=initrd.img method= ftp://192.168.100.100/centos7~ ~: wq / / after writing, save and exit [root@localhost pxelinux.cfg] # systemctl start dhcpd / / start the dhcp service [root@localhost pxelinux.cfg] # Systemctl start tftp / / start tftp service [root@localhost pxelinux.cfg] # systemctl start vsftpd / / start ftp service [root@localhost pxelinux.cfg] # systemctl stop firewalld.service / / turn off firewall function [root@localhost pxelinux.cfg] # setenforce 0 / / turn off enhanced security features

8. Verify the installation of PXE network deployment, open the configured virtual machine, press the ESC key in the boot interface, enter boot mode, and select to boot from the network.

About kickstartkickstart unattended Technology

Create an answer file and predefine various installation settings

Eliminates the interactive setup process, thus realizing fully automated installation

Complete various configuration operations after installation by adding% post script

Demo

1. Install the kickstart service software in CentOS 7

[root@localhost pxelinux.cfg] # yum install system-config-kickstart-y / / install kickstart software loaded plug-ins: fastestmirror, langpacksLoading mirror speeds from cached hostfile * base: mirrors.163.com * extras: mirrors.huaweicloud.com * updates: mirrors.huaweicloud.com is resolving dependencies-- > checking transactions-- > package system-config-kickstart.noarch.0.2.9.7-1.el7 will be installed. / / omit some of the contents. Installed: system-config-kickstart.noarch 0VOR 2.9.7-1.el7 installed as a dependency: gnome-python2.x86_64 0VOR 2.28.1-14.el7 gnome-python2-canvas.x86_64 0VR 2.28.1-14.el7 libart_lgpl .x86 _ 64 0v 2.3.21-10.el7 libgnomecanvas.x86_64 0v 2.30.3-8.el7 rarian.x86_64 0v 0.8.1-11.el7 rarian-compat.x86_64 0v 0.8.1-11.el7 system-config-date.noarch 0v 1.10.6 -3.el7.centos system-config-date-docs.noarch 0VR 1.0.11-4.el7 system-config-keyboard.noarch 0V 1.4.0-5.el7 system-config-keyboard-base.noarch 0V 1.4.0-5.el7 system-config-language.noarch 0V 1.4.0-9.el7 usermode-gtk.x86_64 0v 1.111-5.el7 over!

2. Open the kickstart service software in the graphic interface after the installation is completed.

3. Set the basic configuration first after opening the software

4. Set the installation method and bootloader options

5. Set partition information

6. Set the network card configuration

7. Configure post-installation script information

8. Save the configured file information to the FTP site after completion

9. Close the software after saving, open the terminal, go to the ftp site to view the saved file, enter to view the file, and add the required component installation package to the template.

[root@localhost ~] # cd / var/ftp / / enter the ftp site [root@localhost ftp] # ls / / View directory information centos7 ks.cfg pub [root@localhost ftp] # vim ks.cfg / / enter edit mode to view saved template information platform=x86, AMD64 Or Intel EM64T#version=DEVEL# Install OS instead of upgradeinstall# Keyboard layoutskeyboard 'us'# Root passwordrootpw-iscrypted $1$ QnfXQpTo$2SWg34gaOZQoLWy.bGlmd/ root user key template # Use network installationurl-url= "ftp://192.168.100.100/centos7" / / installation path template # System languagelang zh_CN / / set keyboard mode # Firewall configurationfirewall-disabled# System authorization Informationauth-- useshadow-- passalgo=sha512# Use graphical installgraphicalfirstboot-- disable# SELinux configurationselinux-- enforcing# Network informationnetwork-- bootproto=dhcp-- device=ens33 / / the Nic information set # Reboot after installationreboot# System timezonetimezone Asia/Shanghai# System bootloader configurationbootloader-- location=none# Partition clearing informationclearpart-- all-- initlabel# Disk partitioning informationpart / boot-- fstype= "xfs"-- size=500 / / disk partition setting template part / home-- fstype= "xfs"-- size=4096part swap -- fstype= "swap"-- size=4096part /-- fstype= "xfs"-- grow-- size=1: Q / / exit template [root@localhost ftp] # cd / root / / enter root user's home directory [root@localhost ~] # ls / / View home directory information anaconda-ks.cfg public video Document Music / / find anaconda-ks.cfg template initial-setup-ks.cfg template Picture download Desktop [root@localhost ~] # vim anaconda-ks.cfg / / enter Edit anaconda-ks.cfg template. / / omit part of the content.% packages@ ^ gnome-desktop-environment@base@core@desktop-debugging@dial-up@directory-client@fonts@gnome-desktop@guest-agents / / find this part of the information and copy @ guest-desktop-agents@input-methods@internet-browser@java-platform@multimedia@network-file-system-client@networkmanager-submodules@print-client@x11chronykexec-tools%end...// omitted part of the content.: Q / / exit [root@localhost ~] # vim / var/ftp/ks.cfg / / enter the ftp site Edit the ks.cfg file part / boot-- fstype= "xfs"-- size=500part / home-- fstype= "xfs"-- size=4096part swap-- fstype= "swap"-- size=4096part /-fstype= "xfs"-- grow-- size=1%packages@ ^ gnome-desktop-environment@base@core@desktop-debugging@dial-up@directory-client@fonts / / paste this section on the following line @ gnome- Desktop@guest-agents@guest-desktop-agents@input-methods@internet-browser@java-platform@multimedia@network-file-system-client@networkmanager-submodules@print-client@x11chronykexec-tools%end~: wq / / Save exit

10. Add the ks.cfg file boot entry to the tftp site startup menu file.

[root@localhost ~] # cd / var/lib/tftpboot/ enter the tftp site [root@localhost tftpboot] # ls / / View site information initrd.img pxelinux.0 pxelinux.cfg vmlinuz [root@localhost tftpboot] # cd pxelinux.cfg/ enter the directory [root@localhost pxelinux.cfg] # lsdefault [root@localhost pxelinux.cfg] # vim default / / Enter the edit startup menu file default autoprompt 1label auto kernel vmlinuz / / add the ks= ftp://192.168.100.100/ks.cfg entry so that the system can read the ks.cfg template content append initrd=initrd.img method= ftp://192.168.100.100/centos7 ks= ftp://192.168.100.100/ks.cfglabel linux text kernel vmlinuz append text initrd=initrd.img method= ftp://192 during installation. .168.100.100 / centos7label linux rescue kernel vmlinuz append rescue initrd=initrd.img method= ftp://192.168.100.100/centos7:wq / / Save exit

Configure a new virtual machine, set the network card to host-only mode, and then verify PXE deployment installation + kickstart unattended installation.

At this point, the study of "detailed introduction of efficient batch network installation of PXE in CentOS7" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report