新聞中心
一、概念與原理

什么是PXE
嚴(yán)格來說,PXE 并不是一種安裝方式,而是一種引導(dǎo)的方式。進(jìn)行 PXE 安裝的必要條件是要安裝的計(jì)算機(jī)中包含一個(gè) PXE 支持的網(wǎng)卡(NIC),即網(wǎng)卡中必須要有 PXE Client。PXE (Pre-boot Execution Environment,直譯為啟動(dòng)前的執(zhí)行環(huán)境)協(xié)議使計(jì)算機(jī)可以通過網(wǎng)絡(luò)啟動(dòng)。協(xié)議分為 client 和 server 端,PXE client 在網(wǎng)卡的 ROM 中,當(dāng)計(jì)算機(jī)引導(dǎo)時(shí),BIOS 把 PXE client 調(diào)入內(nèi)存執(zhí)行,由 PXE client 將放置在遠(yuǎn)端的文件通過網(wǎng)絡(luò)下載到本地運(yùn)行。運(yùn)行 PXE 協(xié)議需要設(shè)置 DHCP 服務(wù)器和 TFTP 服務(wù)器。DHCP 服務(wù)器用來給 PXE client(將要安裝系統(tǒng)的主機(jī))分配一個(gè) IP 地址,由于是給 PXE client 分配 IP 地址,所以在配置 DHCP 服務(wù)器時(shí)需要增加相應(yīng)的 PXE 設(shè)置。此外,在 PXE client 的 ROM 中,已經(jīng)存在了 TFTP Client。PXE Client 通過 TFTP 協(xié)議到 TFTP Server 上下載所需的文件。
什么是KickStart
KickStart是一種無人職守安裝方式。KickStart的工作原理是通過記錄典型的安裝過程中所需人工干預(yù)填寫的各種參數(shù),并生成一個(gè)名為ks.cfg的文件;在其后的安裝過程中(不只局限于生成KickStart安裝文件的機(jī)器)當(dāng)出現(xiàn)要求填寫參數(shù)的情況時(shí),安裝程序會(huì)首先去查找KickStart生成的文件,當(dāng)找到合適的參數(shù)時(shí),就采用找到的參數(shù),當(dāng)沒有找到合適的參數(shù)時(shí),才需要安裝者手工干預(yù)。這樣,如果KickStart文件涵蓋了安裝過程中出現(xiàn)的所有需要填寫的參數(shù)時(shí),安裝者完全可以只告訴安裝程序從何處取ks.cfg文件,然后去忙自己的事情。等安裝完畢,安裝程序會(huì)根據(jù)ks.cfg中設(shè)置的重啟選項(xiàng)來重啟系統(tǒng),并結(jié)束安裝。
二、環(huán)境說明
執(zhí)行pxe+kickstart來批量安裝系統(tǒng),需要的環(huán)境為
1.DHCP服務(wù)器
2.TFTP服務(wù)器
3.httpd服務(wù)器或者ftp服務(wù)器或nfs服務(wù)器等能提供文件訪問的服務(wù)器
4.ks.cfg文件
5.syslinux服務(wù)提供的pxelinux.0文件
6.一臺(tái)帶有支持pxe協(xié)議的網(wǎng)卡的主機(jī)
7.為確保實(shí)驗(yàn)可用性,請(qǐng)將防火墻和selinux關(guān)閉
三、安裝步驟
1)、系統(tǒng)版本
[root@localhost ~]# uname -r
3.10.0-327.el7.x86_64
123
[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
2)、配置網(wǎng)絡(luò)環(huán)境以及yum源
本處使用的yum源為系統(tǒng)默認(rèn)源,
本級(jí)網(wǎng)絡(luò)為
[root@localhost dhcp]# ip a
1: lo:
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eno16777736:
link/ether 00:0c:29:cc:38:86 brd ff:ff:ff:ff:ff:ff
inet 172.16.219.136/24 brd 172.16.219.255 scope global dynamic eno16777736
valid_lft 1353sec preferred_lft 1353sec
inet6 fe80::20c:29ff:fecc:3886/64 scope link
valid_lft forever preferred_lft forever
3)、安裝DHCP服務(wù)
[root@localhost ~]# yum install -y dhcp
配置dhcp服務(wù)器,使其能夠提供172.16.219.50-172.16.219.53的ip地址,子網(wǎng)掩碼為255.255.255.0。配置如下
[root@localhost ~]# vi /etc/dhcp/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
authoritative;
allow booting;
allow bootp;
allow unknown-clients;
# A slightly different configuration for an internal subnet.
subnet 172.16.219.0 netmask 255.255.255.0 {
range 172.16.219.50 172.16.219.53;
default-lease-time 600;
max-lease-time 7200;
next-server 172.16.219.136; # DHCP server ip
filename "pxelinux.0";
}
4)、安裝httpd服務(wù)(本文通過http的方式提供服務(wù))
[root@localhost ~]# yum install -y httpd
配置如下
[root@localhost ~]# vi /etc/httpd/conf.d/pxeboot.conf
Alias /CentOS7_x64 /var/lib/tftpboot/centos7_x64/
Options Indexes FollowSymLinks
Require ip 127.0.0.1 172.16.219.0/24
~
5)、安裝tftp-server服務(wù)端
[root@localhost ~]# yum install tftp-server xinetd -y
修改xinetd文件
# 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
per_source = 11
cps = 100 2
flags = IPv4
}
把siabled的yes改為no
6)、準(zhǔn)備所需要的rpm包
mount -o loop /root/CentOS-XX.iso /mnt/
mkdir /var/lib/tftpboot/centos7_x64
cp -fr /mnt/* /var/lib/tftpboot/centos7_x64/
chmod -R 755 /var/lib/tftpboot/centos7_x64/
7)、準(zhǔn)備tftpboot下的文件
安裝syslinux,此服務(wù)為pxe提供pxelinux.0文件
[root@localhost ~]# yum install -y syslinux
準(zhǔn)備文件
cd /usr/share/syslinux/
cp pxelinux.0 menu.c32 memdisk mboot.c32 chain.c32 /var/lib/tftpboot/
自定義pxe文件
mkdir /var/lib/tftpboot/pxelinux.cfg
default menu.c32
prompt 0
timeout 300
ONTIMEOUT local
menu title ########## PXE Boot Menu ##########
label 1
menu label ^1) Install CentOS 7
kernel centos7_x64/images/pxeboot/vmlinuz
append initrd=centos7_x64/images/pxeboot/initrd.img method=http://172.16.219.136/centos7_x64 devfs=nomount
label 2
menu label ^2) Boot from local drive localboot
9)、重啟各個(gè)服務(wù)
systemctl restart xinetd
systemctl restart httpd
systemctl restart dhcpd
將各個(gè)服務(wù)設(shè)置成開機(jī)自啟動(dòng)
systemctl enable xinetd
systemctl enable httpd
systemctl enable dhcpd
一切準(zhǔn)備就緒,可以開始測(cè)試了
10)、測(cè)試安裝
名稱欄目:CentOS7基于PXE安裝系統(tǒng)
路徑分享:http://fisionsoft.com.cn/article/dhpeijp.html


咨詢
建站咨詢
