使用RHEL6.3+PXE+DHCP+Apache+NFS+KickStart
本文遵循“署名非商业性使用相同方式共享 2.5 中国大陆”协议
[root@rhel6u3-1 ~]# uname -r
2.6.32-279.el6.i686
[root@rhel6u3-1 ~]# lsb_release -a
LSB Version: :core-4.0-ia32:core-4.0-noarch:graphics-4.0-ia32:graphics-4.0-noah
Distributor ID: RedHatEnterpriseServer
Description: Red Hat Enterprise Linux Server release 6.3 (Santiago)
Release: 6.3
Codename: Santiago
[root@rhel6u3-1 ~]# mount /dev/cdrom /media/cdrom/ //挂载光盘镜像文件
mount: block device /dev/sr0 is write-protected, mounting read-only
包括: dhcp,xinetd,tftp,nfs,http,system-config-kickstart syslinux
[root@rhel6u3-1 Packages]# yum -y install dhcp xinetd tftp-server nfs* httpd syslinux system-config-kickstart //安装所有需要的包
//查看安装的包是否安装成功
[root@rhel6u3-1 Packages]# rpm -qa dhcp //为pxe网卡提供网络参数并指向tftp服务器文件
dhcp-4.1.1-31.P1.el6.i686
[root@rhel6u3-1 Packages]# rpm -qa xinetd //tftp服务依赖服务
xinetd-2.3.14-34.el6.i686
[root@rhel6u3-1 Packages]# rpm -qa tftp-server //提供启动安装需要的内核文件
tftp-server-0.49-7.el6.i686
[root@rhel6u3-1 Packages]# rpm -qa nfs-utils //提供安装需要的系统文件
nfs-utils-1.2.3-26.el6.i686
[root@rhel6u3-1 Packages]# rpm -qa httpd //提供安装需要的无人值守kickstat脚本
httpd-2.2.15-15.el6_2.1.i686
[root@rhel6u3-1 Packages]# rpm -qa syslinux //提供pexlinux.0文件
syslinux-4.02-7.el6.i686
[root@rhel6u3-1 Packages]# rpm -qa system-config-kickstart //生成ks.cfg文件
system-config-kickstart-2.8.6.4-1.el6.noarch
[root@rhel6u3-1 ~]# cp -p /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf //复制dhcpd.conf配置模版
添加tftp服务器地址及pexlinux.0文件
[root@rhel6u3-1 ~]# vim /etc/dhcp/dhcpd.conf //配置DHCP服务器
# dhcpd.conf
option domain-name "rsyslog.org";
option domain-name-servers 192.168.100.102, 192.168.100.103;
default-lease-time 86400;
max-lease-time 604800;
ddns-update-style none;
log-facility local7;
next-server 192.168.100.101; //指向tftp服务器
filename="pxelinux.0"; //tftp根目录的相对路径
subnet 192.168.100.0 netmask 255.255.255.0 {
range 192.168.100.30 192.168.100.80;
option routers 192.168.100.1;
}
[root@rhel6u3-1 ~]# cd /var/lib/tftpboot/ //tftp的目录跟RHEL5位置不同
[root@rhel6u3-1 isolinux]# pwd
/media/cdrom/isolinux
[root@rhel6u3-1 isolinux]# cp vmlinuz initrd.img boot.msg splash.jpg /var/lib/tftpboot/ //复制所需要的文件到tftp服务器根目录
[root@rhel6u3-1 /]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
[root@rhel6u3-1 /]# mkdir /var/lib/tftpboot/pxelinux.cfg //创建pxelinux.cfg目录
[root@rhel6u3-1 /]# cp -p /media/cdrom/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default //创建default文件
[root@rhel6u3-1 /]# cat /var/lib/tftpboot/pxelinux.cfg/default
default local
#prompt 1
timeout 600
display boot.msg
menu background splash.jpg
menu title Welcome to Red Hat Enterprise Linux 6.3!
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 #0000000
label local
localboot
label RHEL6U3
kernel vmlinuz
append initrdinitrd=initrd.img ramdisk_size=8192ks=http://192.168.100.101/ks.cfg
[root@rhel6u3-1 data]# vim /etc/exports
/media/cdrom 192.168.100.0/255.255.255.0(ro,sync)
第七步:启动httpd nfs xinetd tftp服务.
[root@rhel6u3-1 data]# /etc/rc.d/init.d/dhcpd start
Starting dhcpd: [ OK ]
[root@rhel6u3-1 data]# /etc/rc.d/init.d/nfs start
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS mountd: [ OK ]
Starting NFS daemon: [ OK ]
[root@rhel6u3-1 data]# /etc/rc.d/init.d/xinetd start
Starting xinetd: [ OK ]
[root@rhel6u3-1 data]# chkconfig tftp on
[root@rhel6u3-1 data]# yum –y groupinstall “X Windows System” “GNOME Desktop Enviroment"
[root@rhel6u3-1 data]# system-config-kickstart
[root@rhel6u3-1 data]# cd /var/www/html/
[root@rhel6u3-1 html]# ls
ks.cfg
[root@rhel6u3-1 html]# cat ks.cfg
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --enabled --ssh
# Install OS instead of upgrade
install
# Use NFS installation media
nfs --server=192.168.100.101 --dir=/media/cdrom
# Root password
rootpw --iscrypted $1$kC9vxUwe$l.U7ZGNt9Yjcvt2YHy3J50
# System authorization information
auth --useshadow --passalgo=sha512
# Use text mode install
text
# System keyboard
keyboard us
# System language
lang en_US
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# Installation logging level
logging --level=info
# Reboot after installation
reboot
# System timezone
timezone --isUtc Asia/Shanghai
# Network information
network --bootproto=dhcp--device=eth0--onboot=on
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --asprimary --fstype="ext4"--size=128
part swap --asprimary --fstype="swap"--size=2048
part / --asprimary --fstype="ext4"--size=8000
part /data --asprimary --fstype="ext4"--size=1
%packages
@base
@chinese-support
%end
[root@rhel6u3-1 ~]# /etc/rc.d/init.d/httpd start
Starting httpd: [ OK ]
[root@rhel6u3-1 ~]# /etc/rc.d/init.d/iptables stop
iptables: Flushing firewall rules: [ OK ]
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Unloading modules: [ OK ]
[root@rhel6u3-1 ~]# setenforce 0