1) 搭建dhcp、tftp、httpd服务实现PXE网络装机服务器
2) 部署应答文件实现无人值守安装RHEL7操作系统
一、搭建配置DHCP服务
1.指定下一个服务器地址及引导文件
[root@svr7 /]# vim /etc/dhcp/dhcpd.conf
subnet 192.168.4.0 netmask 255.255.255.0 {
range 192.168.4.20 192.168.4.100;
option domain-name-servers 192.168.4.7;
option routers 192.168.4.254;
default-lease-time 600;
max-lease-time 7200;
next-server 192.168.4.7; #指定下一个服务器地址
filename "pxelinux.0"; #指定引导文件名称
}
2.重起服务
[root@svr7 /]# systemctl restart dhcpd
pxelinux.0:网卡引导文件,安装说明书,二进制文件
安装一个软件,会自动生成该文件
二、配置TFTP服务
tftp:简单的文件传输协议
默认端口为: 69
默认共享路径:/var/lib/tftpboot
1.安装tftp-server软件
[root@svr7 /]# yum -y install tftp-server
2.重起tftp服务
[root@svr7 /]# systemctl restart tftp
[root@svr7 /]# systemctl enable tftp
3.部署pxelinux.0文件
[root@svr7 /]# yum provides */pxelinux.0 #查询那个软件包产生该文件
[root@svr7 /]# yum -y install syslinux #安装软件
[root@svr7 /]# rpm -ql syslinux | grep pxelinux.0 #查看安装清单
[root@svr7 /]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
[root@svr7 /]# ls /var/lib/tftpboot/
4.部署菜单文件
默认存放路径/var/lib/tftpboot/pxelinux.cfg/
pxelinux.0--》/var/lib/tftpboot/pxelinux.cfg/default
[root@svr7 /]# mkdir /var/lib/tftpboot/pxelinux.cfg
[root@svr7 /]# mount /dev/cdrom /mnt
[root@svr7 /]# ls /mnt/
[root@svr7 /]# cp /mnt/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
[root@svr7 /]# ls -l /var/lib/tftpboot/pxelinux.cfg/default
[root@svr7 /]# chmod u+w /var/lib/tftpboot/pxelinux.cfg/default
[root@svr7 /]# ls -l /var/lib/tftpboot/pxelinux.cfg/default
5.部署图形的模块(vesamenu.c32)与背景图片(splash.png)
[root@svr7 /]# cp /mnt/isolinux/vesamenu.c32 /mnt/isolinux/splash.png /var/lib/tftpboot/
[root@svr7 /]# ls /var/lib/tftpboot/
pxelinux.0 pxelinux.cfg splash.png vesamenu.c32
6.部署 启动内核(vmlinuz) 与 驱动程序(initrd.img)
[root@svr7 /]# cp /mnt/isolinux/vmlinuz /mnt/isolinux/initrd.img /var/lib/tftpboot/
[root@svr7 /]# ls /var/lib/tftpboot/
initrd.img pxelinux.cfg vesamenu.c32
pxelinux.0 splash.png vmlinuz
[root@svr7 /]#
7.修改菜单文件/var/lib/tftpboot/pxelinux.cfg/default
[root@svr7 /]# vim /var/lib/tftpboot/pxelinux.cfg/default
1 default vesamenu.c32 #默认加载图形的模块
2 timeout 60 #读秒时间为6秒
9 menu background splash.png #背景图片
10 menu title NSD1809 PXE Server !!! #标题
60 label linux
61 menu label Install RHEL7 #选项的内容
menu default #读秒结束后默认选择
62 kernel vmlinuz #指定启动内核
63 append initrd=initrd.img #指定启动的驱动程序
################################################
总结:
1.DHCP--->IP地址、next-server、filename
2.tftp--->pxelinux.0
3.pxelinux.0--->default
4.default---》
vesamenu.c32/splash.png/vmlinuz/initrd.img
测试:新建一台虚拟机,采用PXE网络引导安装
注意网络类型选择为:private1
##################################################
三、搭建httpd服务,共享光盘所有内容
1.安装软件包
[root@svr7 /]# yum -y install httpd
2.重起服务
[root@svr7 /]# systemctl restart httpd
3.共享光盘所有内容
[root@svr7 /]# mkdir /var/www/html/rhel7/
[root@svr7 /]# mount /dev/cdrom /var/www/html/rhel7/
mount: /dev/sr0 写保护,将以只读方式挂载
[root@svr7 /]# ls /var/www/html/rhel7/
4.访问测试
[root@svr7 /]# firefox 192.168.4.7/rhel7
###############################################
四、部署无人值守安装,生成应答文件
1.通过图形的system-config-kickstart软件可以生成
[root@svr7 /]# yum -y install system-config-kickstart
2.运行图形的system-config-kickstart进行图形配置
[root@room9pc01 ~]# ssh -X root@192.168.4.7
root@192.168.4.7's password:
[root@svr7 ~]# system-config-kickstart
首先检测 “软件包选择” 是否可以进行选择
需要光盘的源的Yum仓库支持, 要求 仓库标识必须为 [development]
[root@svr7 ~]# vim /etc/yum.repos.d/rhel7.repo
[development]
.......
[root@svr7 ~]# system-config-kickstart
首先检测 “软件包选择” 是否可以进行选择
#################################################
五、应答文件
[root@svr7 ~]# ls /root/ks.cfg
/root/ks.cfg
[root@svr7 ~]# vim /root/ks.cfg
利用httpd服务,将应答文件共享
[root@svr7 ~]# cp /root/ks.cfg /var/www/html/
[root@svr7 ~]# ls /var/www/html/
ks.cfg rhel7
[root@svr7 ~]# firefox 192.168.4.7/ks.cfg
修改菜单文件,指定应答文件位置
[root@svr7 /]# vim /var/lib/tftpboot/pxelinux.cfg/default
label linux
menu label Install RHEL7
menu default
kernel vmlinuz
append initrd=initrd.img ks=http://192.168.4.7/ks.cfg
##################################################
总结:
1.DHCP--->IP地址、next-server、filename
2.tftp--->pxelinux.0
3.pxelinux.0--->default
4.default---》
vesamenu.c32/splash.png/vmlinuz/initrd.img
ks=http://192.168.4.7/ks.cfg
5.ks.cfg----》--url="http://192.168.4.7/rhel7"
################################################