服务器(192.168.100.250)给192.168.100.0网段的客户机安装RHEL6.4操作系统,并给每台客户端192.168.100.x分配主机名clientx.linuxidc.com,实现无人值守安装
-----------------------------分割线-----------------------------
推荐相关阅读:
Linux PXE无人值守安装出现 PXE-E32:TFTP OPen timeout的解决办法
RHCE认证之无人值守安装Linux系统(FTP+TFTP+DHCP+Kickstart+PXE)
-----------------------------分割线-----------------------------
一.配置YUM
[root@PXE-server ~]# cat /etc/yum.repos.d/rhel-server.repo
[rhel-server]
name=Red Hat Enterprise Linux
baseurl=file:///media
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-RedHat-release
[root@PXE-server ~]# mount /dev/cdrom1 /media //放入安装光盘并挂载
二..配置DHCP
[root@PXE-server ~]# yum -y install dhcp
[root@PXE-server ~]# vim /etc/dhcp/dhcpd.conf
subnet 192.168.100.0 netmask 255.255.255.0 {
range 192.168.100.100 192.168.100.200; //分配给客户机的地址段
option domain-name-servers 192.168.100.250; //DNS也是本机
option domain-name "linuxidc.com";
option routers 192.168.100.254;
default-lease-time 600;
max-lease-time 7200;
next-server 192.168.100.250; //TFTP服务器的IP地址
filename "pxelinux.0"; //网卡引导文件名
}
[root@PXE-server ~]# service dhcpd start
[root@PXE-server ~]# chkconfig dhcpd on
三.配置TFTP
1.安装软件包
[root@PXE-server ~]# yum -y install tftp-server
[root@PXE-server ~]# vim /etc/xinetd.d/tftp
……
server_args = -s /var/lib/tftpboot //tftp根目录
disable = no //开启tftp服务
……
[root@PXE-server ~]# service xinetd restart
[root@PXE-server ~]# chkconfig xinetd on
[root@PXE-server ~]# cd /media/images/pxeboot/
[root@PXE-server pxeboot]# cp initrd.img vmlinuz /var/lib/tftpboot/ //将光盘中linux内核与镜像文件拷贝到tftp根目录下
[root@PXE-server pxeboot]# yum -y install syslinux
[root@PXE-server pxeboot]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/ //将网卡引导文件也拷贝至tftp根目录
2.创建PXE启动配置
[root@PXE-server pxeboot]# mkdir /var/lib/tftpboot/pxelinux.cfg //创建文件夹
[root@PXE-server pxeboot]# cd ../../isolinux/
[root@PXE-server isolinux]# cp isolinux.
[root@PXE-server isolinux]# cp isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default //拷贝光盘中样例文件到tftp根目录下并改名为default
四.配置NFS共享
[root@PXE-server isolinux]# yum -y install nfs-utils rpcbind
[root@PXE-server isolinux]# mkdir -p /data/nfs //创建nfs共享目录
[root@PXE-server isolinux]# vim /etc/exports
/data/nfs *(ro)
[root@PXE-server isolinux]# cp -rf /media /data/nfs/ //将光盘下软件包拷贝到nfs共享目录
[root@PXE-server isolinux]# service rpcbind start
[root@PXE-server isolinux]# service nfs start
[root@PXE-server isolinux]# chkconfig rpcbind on
[root@PXE-server isolinux]# chkconfig nfs on
五.配置DNS
[root@PXE-server isolinux]# yum -y install bind bind-chroot
[root@PXE-server isolinux]# vim /etc/named.conf
……
listen-on port 53 { 192.168.100.250; };
……
allow-query { any; };
……
zone "linuxidc.com.zone" IN { //正向解析
type master;
file "linuxidc.com.zone";
};
zone "100.168.192.in-addr.arpa" IN { //反向解析
type master;
file "192.168.100.arpa";
};
……
[root@PXE-server isolinux]# cd /var/named/
[root@PXE-server named]# vim linuxidc.com.zone
$TTL 3H
@IN SOAlinuxidc.com. root.linuxidc.com. (
2014041901 ; serial
1D; refresh
1H; retry
1W; expire
3H ); minimum
NSdns.linuxidc.com.
dnsIN A192.168.100.250
$GENERATE 100-200 client$ IN A 192.168.100.$ //使用函数解析
[root@PXE-server named]# vim 192.168.100.arpa
$TTL 3H
@IN SOAlinuxidc.com. root.linuxidc.com. (
2014041901 ; serial
1D; refresh
1H; retry
1W; expire
3H ); minimum
NSdns.linuxidc.com.
250IN PTRdns.linuxidc.com.
$GENERATE 100-200 $ IN PTR client$.linuxidc.com.
[root@PXE-server named]# service named start
[root@PXE-server named]# chkconfig named on
[root@PXE-server named]# nslookup 192.168.100.100 192.168.100.250 //测试反向解析
[root@PXE-server named]# nslookup client181.linuxidc.com //测试正向解析
六.创建kickstart应答文件
[root@PXE-server named]# yum -y install system-config-kickstart
[root@PXE-server named]# system-config-kickstart //通过图形化工具配置客户端启动选项生成应答文件
[root@PXE-server ~]# cp ks.cfg /data/nfs/ //部署到NFS共享目录
[root@PXE-server ~]# cat ks.cfg //根据需要设置客户端配置应答文件
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install
# Use NFS installation media
nfs --server=192.168.100.250 --dir=/data/nfs/media //通过NFS共享
# Root password
rootpw --iscrypted $1$sW2gH1K6$B333cigoFqn3IaAUK2RIj1
# System authorization information
auth --useshadow --passalgo=sha512
# Use text mode install