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
开一台虚拟机器选择桥接模式 开启电源
会获取到镜像站群
开始安装