PXE(preboot execute environment,預啓動執行環境)是由Intel公司開發的技術,工作於Client/Server的網絡模式,支持工作站通過網絡從遠端服務器下載映像,並由此支持通過網絡啓動操作系統即所謂的無盤工作站。
PXE工作條件:
客戶端
硬件支持:網卡或主板集成了PXEClient纔可以和PXEServer進行通信
服務端
DHCP服務:既然要實現網絡通信IP地址自然是必不可少的
TFTP(Trivial FTP)或MFTP(Multicast TFTP)服務,簡單FTP服務提供PXE啓動需要的pxelinux.0、vmlinux和initrd等文件
DNS服務,有時會用到,可選
FTP/HTTP/NFS 輸出系統安裝樹,軟件倉庫
操作演示
# step 1: 安裝dhcp [root@node1 ~]# yum install -y dhcp # 爲省事可以直接拷個配置文件的樣例過去再做修改 [root@node1 ~]# cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf cp: overwrite `/etc/dhcp/dhcpd.conf'? y [root@node1 ~]# vim /etc/dhcp/dhcpd.conf option domain-name "bob.org"; # 域名後綴 option domain-name-servers 172.16.100.2; # dns 服務器 default-lease-time 43200; # IP地址租約 max-lease-time 86400; # 最大租約時間 log-facility local7; # 日誌文件 # 一個subnet定義一個IP地址池 subnet 172.16.100.0 netmask 255.255.0.0 { range 172.16.100.100 172.16.100.200; option routers 172.16.100.2; next-server 172.16.100.11; # 指定tftp服務器地址 filename="pxelinux.0"; # 指定pxlinux.0文件地址,必須用雙引號,地址是相對tftp服務根目錄的 } # 安裝tftp和syslinux, 安裝syslinux會自動安裝上syslinux-nonlinux和mtools #(pxelinux.0由syslinux-nonlinux提供的) [root@node1 ~]# yum install tftp-server syslinux -y [root@node1 ~]# rpm -ql tftp-server /etc/xinetd.d/tftp # tftp服務腳本,是Xinet管理的服務 /usr/sbin/in.tftpd /usr/share/doc/tftp-server-0.49 /usr/share/doc/tftp-server-0.49/CHANGES /usr/share/doc/tftp-server-0.49/README /usr/share/doc/tftp-server-0.49/README.security /usr/share/doc/tftp-server-0.49/README.security.tftpboot /usr/share/man/man8/in.tftpd.8.gz /usr/share/man/man8/tftpd.8.gz /var/lib/tftpboot # tftp服務的根目錄 # 可以看到pxlinux.0是由syslinux-nonlinux這個軟件包提供的 [root@node1 ~]# rpm -ql syslinux-nonlinux | grep pxelinux.0 /usr/share/syslinux/gpxelinux.0 /usr/share/syslinux/pxelinux.0 # 把pxelinux.0複製到tftp服務的要目錄下,因爲dhcp配置裏指定的是根目錄 [root@node1 ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/ # 爲方便直接把光盤掛到ftp目錄下面 [root@node1 ~]# mount -r /dev/cdrom /var/ftp/pub/centos/ # 爲tftp下面提供vmlinuz和initrd.img [root@node1 ~]# cp /var/ftp/pub/centos/p_w_picpaths/pxeboot/{vmlinuz,initrd.img} /var/lib/tftpboot/ [root@node1 ~]# cd /var/lib/tftpboot/ [root@node1 tftpboot]# ls initrd.img pxelinux.0 vmlinuz # tftp默認的菜單配置文件是放在pxelinux.cfg/default下的 # 這個相當於光盤下isolinux/isolinux.cfg,可以把這個文件複製過來修改一下就好 [root@node1 tftpboot]# mkdir pxelinux.cfg # 爲tftp目錄下準備菜單程序和boot.msg,背景圖片splash.jpg # vesamenu.c32爲菜單程序,可從光盤裏複製過來,syslinx-nonlinux包也提供了,在/usr/share/syslinux/下 [root@node1 tftpboot]# cp /var/ftp/pub/centos/isolinux/{boot.msg,splash.jpg,vesamenu.c32} ./ [root@node1 tftpboot]# ls boot.msg initrd.img isolinux.cfg pxelinux.0 splash.jpg vesamenu.c32 vmlinuz [root@node1 tftpboot]# cp /var/ftp/pub/centos/isolinux/isolinux.cfg pxelinux.cfg/default # 根據需要修改下default文件 [root@node1 tftpboot]# vim pxelinux.cfg/default default vesamenu.c32 #prompt 1 timeout 600 display boot.msg menu background splash.jpg menu title Welcome to CentOS 6.4 via PXE! menu color border 0 #ffffffff #00000000 menu color sel 7 #ffffffff #ff000000 menu color title 0 #ffffffff #00000000 menu color tabmsg 0 #ffffffff #00000000 menu color unsel 0 #ffffffff #00000000 menu color hotsel 0 #ff000000 #ffffffff menu color hotkey 7 #ffffffff #ff000000 menu color scrollbar 0 #ffffffff #00000000 label linux menu label ^Install or upgrade an existing system menu default kernel vmlinuz append initrd=initrd.img ks=ftp://172.16.100.11/pub/ks.cfg label rescue menu lalbe ^Rescue kernel vmlinuz append initrd=initrd.img rescue # tftp是xinet管理的服務工作在端口69/udp, 啓動tftp和dhcp服務 [root@node1 ~]# chkconfig tftp on [root@node1 ~]# service xinetd restart Stopping xinetd: [ OK ] Starting xinetd: [ OK ] [root@node1 ~]# service dhcpd start Starting dhcpd: [ OK ] [root@node1 ~]# netstat -unlp | grep 67 udp 0 0 0.0.0.0:67 0.0.0.0:* 15641/dhcpd [root@node1 ~]# netstat -unlp | grep 69 udp 0 0 0.0.0.0:69 0.0.0.0:* 16097/xinetd
# 連上去查看tftp是否工作正常,tftp沒有ls命令 [root@node1 ~]# tftp 172.16.100.11 tftp> help tftp-hpa 0.49 Commands may be abbreviated. Commands are: connect connect to remote tftp mode set file transfer mode put send file get receive file quit exit tftp verbose toggle verbose mode trace toggle packet tracing literal toggle literal mode, ignore ':' in file name status show current status binary set mode to octet ascii set mode to netascii rexmt set per-packet transmission timeout timeout set total retransmission timeout ? print help information help print help information # verbose打開冗餘模式,可以顯示更多詳細信息 tftp> verbose Verbose mode on. # get文件成功代表tftp正常工作 tftp> get pxelinux.0 getting from 172.16.100.11:pxelinux.0 to pxelinux.0 [netascii] Received 26981 bytes in 0.0 seconds [72143767 bit/s]
安裝過程截圖:
這個界面一閃就過去了,想看到的話得把tftp停一下就可以看到了
安裝成功