PXE(Preboot eXecute Environment,預啟動執行環境)是由 Intel 公司開發的技術,可以讓計算機透過網際網路來啟動作業系統(前提是計算機上安裝的網路卡支援 PXE 技術),主要用於在無人值守安裝系統中引導客戶端 WordPress 主機安裝 Linux 作業系統。 Kickstart 是一種無人值守的安裝方式,其工作原理是預先把原本需要運維人員手工填寫的引數儲存成一個 ks.cfg 檔案,當安裝過程中需要填寫引數時則自動匹配 Kickstart 生成的檔案。
為了讓站群伺服器與客戶端 WordPress 主機進行檔案傳輸,並分配 IP 可用的地址 我們先來配置 DHCP 服務
[root@localhost ~] yum install dhcp -y
Loaded plugins: fastestmirror
Determining fastest mirrors
* c6-media:
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package dhcp.x86_64 12:4.1.1-38.P1.el6.centos will be installed
–> Processing Dependency: portreserve for package: 12:dhcp-4.1.1-38.P1.el6.centos.x86_64
–> Running transaction check
—> Package portreserve.x86_64 0:0.0.4-9.el6 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

==============================================================
Package Arch Version Repository Size
==============================================================
Installing:
dhcp x86_64 12:4.1.1-38.P1.el6.centos c6-media 817 k
Installing for dependencies:
portreserve x86_64 0.0.4-9.el6 c6-media 23 k

Transaction Summary
=============================================================
Install 2 Package(s)

Total download size: 840 k
Installed size: 1.9 M
Downloading Packages:
————————————————————————————————————-
Total 12 MB/s | 840 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : portreserve-0.0.4-9.el6.x86_64
1/2
Installing : 12:dhcp-4.1.1-38.P1.el6.centos.x86_64 2/2
Verifying : 12:dhcp-4.1.1-38.P1.el6.centos.x86_64 1/2
Verifying : portreserve-0.0.4-9.el6.x86_64 2/2

Installed:
dhcp.x86_64 12:4.1.1-38.P1.el6.centos

Dependency Installed:
portreserve.x86_64 0:0.0.4-9.el6

Complete!
複製這個檔案為 dhcp 的配置檔案
[root@localhost ~] cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf
cp: overwrite `/etc/dhcp/dhcpd.conf’? y
修改 dhcp 配置檔案
[root@localhost ~] vim /etc/dhcp/dhcpd.conf
指定引導站群伺服器和引導驅動檔案 “pxelinux.0”
# A slightly different configuration for an internal subnet.
subnet 192.168.100.0 netmask 255.255.255.0 {
range 192.168.100.10 192.168.100.50;
default-lease-time 600;
max-lease-time 7200;
next-server 192.168.100.1;
filename “pxelinux.0″;
}
儲存退出
安裝 tftp 服務提供引導及驅動檔案
[root@localhost ~] yum install tftp-server -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* c6-media:
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package tftp-server.x86_64 0:0.49-7.el6 will be installed
–> Processing Dependency: xinetd for package: tftp-server-0.49-7.el6.x86_64
–> Running transaction check
—> Package xinetd.x86_64 2:2.3.14-39.el6_4 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================================================
Package Arch Version Repository Size
===============================================================================================================================================================
Installing:
tftp-server x86_64 0.49-7.el6 c6-media 39 k
Installing for dependencies:
xinetd x86_64 2:2.3.14-39.el6_4 c6-media 121 k

Transaction Summary
===============================================================================================================================================================
Install 2 Package(s)

Total download size: 161 k
Installed size: 317 k
Downloading Packages:
—————————————————————————————————————————————————————
Total 3.0 MB/s | 161 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : 2:xinetd-2.3.14-39.el6_4.x86_64 1/2
Installing : tftp-server-0.49-7.el6.x86_64 2/2
Verifying : tftp-server-0.49-7.el6.x86_64 1/2
Verifying : 2:xinetd-2.3.14-39.el6_4.x86_64 2/2

Installed:
tftp-server.x86_64 0:0.49-7.el6

Dependency Installed:
xinetd.x86_64 2:2.3.14-39.el6_4

Complete!
配置 tftp 服務
[root@localhost ~] vim /etc/xinetd.d/tftp

# 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 /tftpboot
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}
建立 tftp 儲存目錄
[root@localhost ~] mkdir /tftpboot
安裝 syslinux 站群軟體(提供引導檔案)
[root@localhost ~] yum install syslinux -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* c6-media:
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package syslinux.x86_64 0:4.02-8.el6 will be installed
–> Processing Dependency: mtools for package: syslinux-4.02-8.el6.x86_64
–> Running transaction check
—> Package mtools.x86_64 0:4.0.12-1.el6 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================================================
Package Arch Version Repository Size
===============================================================================================================================================================
Installing:
syslinux x86_64 4.02-8.el6 c6-media 859 k
Installing for dependencies:
mtools x86_64 4.0.12-1.el6 c6-media 194 k

Transaction Summary
===============================================================================================================================================================
Install 2 Package(s)

Total download size: 1.0 M
Installed size: 2.3 M
Downloading Packages:
—————————————————————————————————————————————————————
Total 21 MB/s | 1.0 MB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : mtools-4.0.12-1.el6.x86_64 1/2
Installing : syslinux-4.02-8.el6.x86_64 2/2
Verifying : syslinux-4.02-8.el6.x86_64 1/2
Verifying : mtools-4.0.12-1.el6.x86_64 2/2

Installed:
syslinux.x86_64 0:4.02-8.el6

Dependency Installed:
mtools.x86_64 0:4.0.12-1.el6

Complete!
複製引導檔案到 tftp 目錄下
[root@localhost ~] cp /usr/share/syslinux/pxelinux.0 /tftpboot/
安裝映象站群還有引導檔案 需要複製到 tftpboot 下面
[root@localhost ~] cp /mnt/isolinux/* /tftpboot/
tftpboot 目錄下創立 pxelinux.cfg 目錄 並複製 isolinux.cfg 改名為 default
#default 檔案是開機時的選項選單
[root@localhost tftpboot] mkdir pxelinux.cfg
[root@localhost tftpboot]
[root@localhost tftpboot]
[root@localhost tftpboot] cp isolinux.cfg pxelinux.cfg/default
[root@localhost tftpboot] vim pxelinux.cfg/default
default vesamenu.c32
#prompt 1
timeout 1

display boot.msg

menu background splash.jpg
menu title Welcome to CentOS 6.5!
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://192.168.100.1/pub/ks.cfg
label vesa
menu label Install system with ^basic video driver
kernel vmlinuz
append initrd=initrd.img xdriver=vesa nomodeset
label rescue
ks.cfg 為我們指定的應答檔案
安裝 vsftpd 傳輸光碟映象站群給客戶機
[root@localhost tftpboot] yum install vsftpd -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* c6-media:
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package vsftpd.x86_64 0:2.2.2-11.el6_4.1 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================================================
Package Arch Version Repository Size
===============================================================================================================================================================
Installing:
vsftpd x86_64 2.2.2-11.el6_4.1 c6-media 151 k

Transaction Summary
===============================================================================================================================================================
Install 1 Package(s)

Total download size: 151 k
Installed size: 331 k
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : vsftpd-2.2.2-11.el6_4.1.x86_64 1/1
Verifying : vsftpd-2.2.2-11.el6_4.1.x86_64 1/1

Installed:
vsftpd.x86_64 0:2.2.2-11.el6_4.1

Complete!
將完整光碟映象站群複製到 vsftp 的匿名目錄下

[root@localhost tftpboot] cp -rp /mnt/* /var/ftp/pub/
[root@localhost tftpboot] cd /var/ftp/pub
[root@localhost pub] cp /root/anaconda-ks.cfg /var/ftp/pub/ks.cfg
[root@localhost pub] vim /var/ftp/pub/ks.cfg
# Kickstart file automatically generated by anaconda.

#version=DEVEL
install
cdrom
url –url=ftp://192.168.100.1/pub
lang en_US.UTF-8
keyboard us
network –onboot no –device eth0 –bootproto dhcp –noipv6
rootpw –iscrypted $6$1B9c8VVXZm4BJZ6n$BemGfzmvSZ2BmpUeikQhpffk0/58gKCdw9mE1o5Wv9aEjQcj60iUogaNO7KXBuT.dO08JXrde/O6vbihVtzKG.
firewall –service=ssh
authconfig –enableshadow –passalgo=sha512
selinux –enforcing
省略…..

repo –name=”CentOS” –baseurl=ftp://192.168.100.1/pub
[root@localhost pub] chmod 777 ks.cfg #給 ks.cfg 檔案許可權 否則會沒有許可權執行
重啟 dhcp xinetd vsftpd 關閉防火牆 關閉 selinux
[root@localhost pub] service dhcpd restart
Shutting down dhcpd: [ OK ]
Starting dhcpd: [ OK ]
[root@localhost pub] service xinetd restart
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]
[root@localhost pub] service vsftpd restart
Shutting down vsftpd: [ OK ]
Starting vsftpd for vsftpd: [ OK ]
[root@localhost pub] service iptables stop
[root@localhost pub] setenforce 0
開一臺虛擬機器選擇橋接模式 開啟電源
會獲取到映象站群
開始安裝