In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
PXE+kickstart unattended installation centos71.1 PXE instructions
The so-called PXE is the abbreviation of Preboot Execution Environment, which literally means the execution environment before booting.
To achieve PXE, there must be two links:
(1) one is that the network card of the client must support the PXE client function, and choose to boot from the network card when booting, so that the system will enter the program of the PXE client with the network card.
(2) one is that the PXE server must provide services with at least DHCP and TFTP!
And where:
The DHCP service must be able to provide the network parameters of the client and tell the client where the TFTP is located.
TFTP provides the client's boot loader and kernel file download paths.
In addition, NFS/FTP/HTTP (choose the same) and other installation files (the unzipped file of the installation image) can be regarded as a relatively complete PXE server. Generally, TFTP and DHCP services are provided by the same server, and most of the time they also provide NFS/FTP/HTTP services, so PXE servers generally provide three-in-one services.
1.2 PXE proc
Such as the following picture: the picture comes from the network, although it is not easy to understand, but the details are well described.
(1). Client sends an IP address request message to DHCP on PXE Server, and DHCP detects whether Client is legal (mainly to detect the MAC address of the network card of Client), returns the IP address of Client if it is legal, and transmits the location information of the Boot loader file pxelinux.0 in the pxe environment to Client.
(2). Client requests pxelinux.0,TFTP on PXE Server to send pxelinux.0 size information to Client after receiving the message to test whether Client is satisfied. When TFTP receives the agreed size information sent back by Client, it formally sends pxelinux.0 to Client.
(3) .client executes the received pxelinux.0 file.
(4). Client requests the pxelinux.cfg file from TFTP (in fact, it is a directory, in which is the startup menu, that is, the configuration file of grub). TFTP sends the configuration file back to Client, and then Client performs subsequent operations according to the configuration file.
(5). Client sends Linux kernel request information to TFTP, and TFTP receives the message and sends the kernel file to Client.
(6). Client sends root file request information to TFTP, and TFTP receives the message and returns to the Linux root file system.
(7) .client loads the Linux kernel (the startup parameters have been set in the configuration file in 4).
(8) .client downloads the system installation file through nfs/ftp/http for installation. If the configuration file in 4 specifies the kickstart path, the installation system is automatically answered based on this file.
1.3 deployment environment description
As shown in the figure below, 192.168.38.137 is a PXE server that provides dhcp+tftp+http services. The other hosts in this network segment are the host groups of the system to be installed.
1.4 deployment of DHCP services
First install the dhcp server program.
Yum-y install dhcp
DHCP mainly provides the client network parameters and the location of TFTP, as well as the file name of boot loader. At the same time, we only tell the relevant location of the TFTP for the private network, so you can edit / etc/dhcp/dhcpd.conf to add two parameters to the subnet block. The name of the boot loader file downloaded specifically for the PXE client on PXE is pxelinux.0.
[root@server] # cat / etc/dhcp/dhcpd.confddns-update-style none;default-lease-time 259200; option routers 518400; option routers 192.168.38.2 option subnet-mask option domain-name-servers 192.168.38.2 X subnet 192.168.38.0 netmask 255.255.255.0 {range 192.168.38.200 192.168.38.200 192.168.38.220; option subnet-mask 255.255.0; next-server 192.168.38.137 # is the location of TFTP filename "pxelinux.0"; # tells you the name of the boot loader file to be downloaded from the TFTP root directory}
Restart dhcp
Systemctl restart dhcpd1.5 deployment TFTP
As you can see from the flow chart, the boot loader file pxelinux.0 and kernel-related configuration files (under the directory pxelinux.cfg) are mainly provided by TFTP!
The installation of TFTP is simple, just use yum directly. However, tell the client where the root directory of TFTP is, so that the client can find the relevant files. Also note that TFTP is managed by xinetd, the super daemon, so after setting up TFTP, what you want to start is xinetd.
Yum install tftp-server
The root directory of the default TFTP service is / var/lib/tftpboot/,. By default, this is it, and then disable can be changed to no.
Sed-ri'/ disable/s/yes/no/' / etc/xinetd.d/tftpcat / etc/xinetd.d/tftpservice tftp {socket_type = dgram protocol = udp wait = yes user = root server = / usr/sbin/in.tftpd server_args =-s / var/lib/tftpboot disable = no Per_source = 11 cps = 100 2 flags = IPv4}
Start TFTP and observe:
Systemctl start tftpss-ltnup | grep tftpudp UNCONN 00: 69: * users: ("in.tftpd", pid=8425,fd=0), ("systemd", pid=1,fd=28))
The next files must be placed in the / var/lib/tftpboot/ directory.
1.6 provide bootloader and related configuration files for pxe
If you want to use the boot boot of PXE, you need to use the syslinux package provided by CentOS, from which you can copy two files to the root directory of tftp / var/lib/tftpboot/. The whole process is as follows:
Yum-y install syslinuxcp-a / usr/share/syslinux/ {menu.c32,vesamenu.c32,pxelinux.0} / var/lib/tftpboot/mkdir / var/lib/tftpboot/pxelinux.cfgls-l / var/lib/tftpboot/-rw-r--r--. 1 root root 55140 Oct 31 2018 menu.c32 # provides graphical menu function-rw-r--r--. 1 root root 26759 Oct 31 2018 pxelinux.0 # bootloader file drwxr-xr-x. 2 root root 6 Sep 8 14:02 pxelinux.cfg # boot menu is set here-rw-r--r--. 1 root root 153104 Oct 31 2018 vesamenu.c32 # also provides graphical menu function, but the interface is different from menu.c32
Pxelinux.cfg is a directory that can place default boot options or provide different boot options for different client hosts. In general, you can create a file called default in the pxelinux.cfg directory to provide the default options.
If there is no menu.c32 or vesamenu.c32, the menu is displayed one line at a time in plain text mode. If you use menu.c32 or vesamenu.c32, there will be a similar contrast effect, at this time, you can use the up and down keys to select options, rather than looking at the screen to enter the numeric key to select the boot option. After testing, using vesamenu.c32 looks better than menu.c32.
After this part is set, it is the kernel-related settings.
1.7 get Linux kernel files from the installation image
To install the Linux system, you must provide the Linux kernel file and the initrd file. Here, take the 64-bit version of CentOS 7.2 as an example.
Here you plan to put the kernel-related files in the / tftpboot/CentOS7.2/ directory. Since you want to get kernel-related files from the installation image, you must first mount the image.
Mount / dev/cdrom / mntmkdir / var/lib/tftpboot/CentOS7.6cp / mnt/isolinux/ {initrd.img,vmlinuz} / var/lib/tftpboot/CentOS7.6/cp / mnt/isolinux/isolinux.cfg / var/lib/tftpboot/pxelinux.cfg/default
In fact, only two files, vmlinuz and initrd.img, are needed, but isolinux.cfg is also copied here. Boot options are provided in this file, which can be used as a template for modifying boot options and menus, which is easier and more convenient to modify!
1.8 set up the boot menu and provide system installation files
The following is the default content provided in the isolinux.cfg provided in the syslinux package in CentOS 7.6.
[root@server ~] # cat / mnt/isolinux/isolinux.cfg default vesamenu.c32 # this is required, or use menu.c32timeout 600 # timeout wait time No action within 60 seconds will automatically select the default menu to load display boot.msg # this is the file that provides some instructions for the options # Clear the screen when exiting the menu, instead of leaving the menu displayed.# For vesamenu This means the graphical background is still displayed without# the menu itself for as long as the screen remains in graphics mode.menu clearmenu background splash.png # background Picture menu title CentOS 7 # title menu vshift 8menu rows 18menu margin 8#menu hiddenmenu helpmsgrow 15menu tabmsgrow 1 background Border Areamenu color border * # 00000000 # 00000000 none# Selected itemmenu color sel 0 # ffffffff # 00000000 none# Title barmenu color title 0 # ff7ba3d0 # 00000000 none# Press [Tab] messagemenu color tabmsg 0 # ff3a6496 # 00000000 none# Unselected menu itemmenu color unsel 0 # 84b8ffff # 00000000 none# Selected hotkeymenu color hotsel 0 # 84b8ffff # 00000000 none# Unselected hotkeymenu color hotkey 0 # ffffffff # 00000000 none# Help textmenu color help 0 # ffffffff # 00000000 none# A scrollbar of some type? Not sure.menu color scrollbar 0 # ffffffff # ff355594 none# Timeout msgmenu color timeout 0 # ffffffff # 00000000 nonemenu color timeout_msg 0 # ffffffff # 00000000 none# Command prompt textmenu color cmdmark 0 # 84b8ffff # 00000000 nonemenu color cmdline 0 # ffffffff # 00000000 none# Do not display the actual menu unless the user presses a key. All that is displayed is a timeout message.menu tabmsg Press Tab for full configuration options on menu items.menu separator # insert an empty linemenu separator # insert an empty linelabel linux menu label ^ Install CentOS 7 # menu text kernel vmlinuz # kernel file path, note that the relative path starts with the root path / tftpboot of tftp So change to ". / CentOS7.2/vmlinuz" append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\ x207\ x20x86_64 quiet # kernel startup option, including the path of initrd, and also change to the search path of ". / CentOS7.6/initrd.img" # stage2 file, which is usually ".treeinfo" If you cannot find the file, look for label check menu label Test this ^ media & install CentOS 7 menu default # menu default to indicate that the boot time mark stays on this label by default at the beginning. The setting method of kernel vmlinuz append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\ x207\ x20x86_64 rd.live.check quietmenu separator # insert an empty line# utilities submenu # submenu item menu begin ^ Troubleshooting menu title Troubleshootinglabel vesa menu indent count 5 menu label Install CentOS 7 in ^ basic graphics mode text help Try this option out If you're having trouble installing CentOS 7. Endtext kernel vmlinuz append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\ x207\ x20x86_64 xdriver=vesa nomodeset quietlabel rescue menu indent count 5 menu label ^ Rescue a CentOS system text help If the system will not boot This lets you access files and edit config files to try to get it booting again. Endtext kernel vmlinuz append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\ x207\ x20x86_64 rescue quietlabel memtest menu label Run a ^ memory test text help If your system is having issues, a problem with your system's memory may be the cause. Use this utility to see if the memory is working correctly. Endtext kernel memtestmenu separator # insert an empty linelabel local menu label Boot from ^ local drive localboot 0xffffmenu separator # insert an empty linemenu separator # insert an empty linelabel returntomain menu label Return to ^ main menu menu exitmenu end
So, modify it slightly to make it suitable for pxe's menu configuration file.
[root@server ~] # cat / var/lib/tftpboot/pxelinux.cfg/defaultdefault vesamenu.c32timeout 600display boot.msgmenu clearmenu background splash.pngmenu title CentOS 7menu vshift 8menu rows 18menu margin 8#menu hiddenmenu helpmsgrow 15menu tabmsgrow 13menu color border * # 00000000 # 00000000 nonemenu color sel 0 # ffffffff # 00000000 nonemenu color title 0 # ff7ba3d0 # 00000000 nonemenu color tabmsg 0 # ff3a6496 # 00000000 nonemenu color unsel 0 # 84b8ffff # 00000000 nonemenu color hotsel 0 # 84b8ffff # 00000000 nonemenu color hotkey 0 # ffffffff # 00000000 nonemenu color help 0 # ffffffff # 00000000 nonemenu color scrollbar 0 # ffffffff # ff355594 Nonemenu color timeout "ffffffff # 00000000 nonemenu color timeout_msg" ffffffff # 00000000 nonemenu color cmdmark "84b8ffff # 00000000 nonemenu color cmdline" ffffffff # 00000000 nonelabel linux menu label ^ Install CentOS7 through pxe menu default kernel. / CentOS7.6/vmlinuz append initrd=./CentOS7.6/initrd.img inst.stage2= https://mirrors.huaweicloud.com/centos/7.6.1810/os/x86_64/ quiet net.ifnames=0 biosdevname=0
The two kernel startup parameters "net.ifnames=0 biosdevname=0" are designed to make the network card name ethN, rather than a random name such as the default eno16777728.
Note that the path of stage2 in the example uses a network source. It is best to build http locally. I have been lazy, and of course ftp can also.
If you use http, mount the image to the corresponding directory directly.
Yum install httpd-ysystemctl start httpdmkdir / var/www/html/CentOS7.6mount / dev/cdrom / var/www/html/CentOS7.6/1.9 boot test
Open a new virtual machine, enter the bios interface settings and boot from the network card. You will first search the DHCP server, search for the bootloader file after finding DHCP, start the menu settings file, etc., and then enter the startup menu and wait for the item to be started. As follows:
Because only one startup item is set, there is only one item in the menu. Start it and a series of files will be loaded until the installation interface appears.
Then you can directly operate the installation system. However, after all, this is a manual operation, and batch system installation cannot be realized, so it is necessary to provide an automatic answer file, and each manual operation step is answered by the items given in the automatic answer file, so that the operating system can be installed automatically and batch system installation can be realized.
1.10 unattended batch installation of operating system through pxe+kickstart
The so-called unattended is the automatic answer, when the installation process requires human-computer interaction to provide some options of the answer (such as how to partition), the automatic answer file can automatically provide the answer according to the corresponding item. However, unattended is not completely unattended, at least setting bios to boot from the network card must be artificially set, and setting not booting from the network card after the installation of the system also needs to be artificially set. In addition, others can basically achieve unattended installation.
To configure an unattended system installation environment, you need to provide a variety of answers needed during the installation process. These answers are set in the configuration file of kickstart. Generally, after normal installation, the Linux system has an anaconda-ks.cfg in the root user's home directory.
Reference: https://blog.csdn.net/yanghua1012/article/details/80426659
Reference: http://ju.outofmemory.cn/entry/194801
You can also use the graphical tool: system-config-kickstart
The following is the contents of the modified file, which will be used as the kickstart reply file. And set the file to be provided by the ftp service, so save the kickstart file to the pub directory of ftp.
Mkdir / var/www/html/ks_filecp ~ / anaconda-ks.cfg / var/www/html/ks_file/ks7_mini.cfgchmod + r / var/www/html/ks_file/-R # must ensure that ks.cfg is globally readable [root@server ~] # cat / var/www/html/ks_file/ks7_mini.cfg installkeyboard 'us'rootpw-- iscrypted $6 $TwMc7kHxAYSdICBU$yUVPcTo.SWi6FpWrZsx3.X.yjbrvqvgMxu0Jvqims55ZU6hQKPaR5DeQISwhcMBkmyVK/UJ1SFnpmu9E3S/Wu0url-- url= "https:// Mirrors.huaweicloud.com/centos/7.6.1810/os/x86_64/ "# url-- url=" http://192.168.38.137/CentOS7.6/"lang en_USauth-- useshadow-- passalgo=sha512textfirstboot-- disableselinux-- disabledfirewall-- disablednetwork-- bootproto=dhcp-- device=eth0reboottimezone Asia/Shanghaiuser-- name=qqq-- password=$6 $Vfzluz2el5OucNGd$oXvo557fWOVXnJVbaUBRUG25UDudEK9y0FaTHoVhyoWJju4EeiSsirf74dxQqphl10Yuc12MoiGsfqC0vJzVl/-- iscrypted-- gecos= "qqq" bootloader-- append= "net.ifnames=0"-location=mbrzerombrclearpart-- all-- initlabelpart /-- fstype= "xfs" -- size=10000part / boot-- fstype= "xfs"-- size=1000part swap-- fstype= "swap"-- size=1024%postsed'/ ^ server/d' / etc/chrony.conf-ised'1a server ntp.aliyun.com iburst' / etc/chrony.conf-ised'1a server 0.cn.pool.ntp.org iburst' / etc/chrony.conf-ised'1a server ntp1.aliyun.com iburst' / etc/chrony.conf-isystemctl enable chronydecho'* / 30 * / usr / sbin/ntpdate ntp.aliyun.com & > / dev/null' > > / var/spool/cron/rootsed'/ ^ GSSAPIAuthentication/d' / etc/ssh/sshd_config-ised'/ ^ UseDNS/d' / etc/ssh/sshd_config-iecho "GSSAPIAuthentication no" > > / etc/ssh/sshd_configecho "UseDNS no" > > / etc/ssh/sshd_configln-sf / usr/share/zoneinfo/Asia/Shanghai / etc/localtimemkdir / root/.sshcd / root/.sshcat > authorized_keys / etc/yum.repos.d/my.repo
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.