部署PXE服务,集群装机
虚拟主机A操作
- 步骤一:安装dhcp服务
[[email protected] ~]# yum -y install dhcp
已加载插件:langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
软件包 12:dhcp-4.2.5-42.el7.x86_64 已安装并且是最新版本
无须任何处理
- 步骤二:配置dhcp文件
[[email protected] ~]# vim /etc/dhcp/dhcpd.conf
subnet 192.168.4.0 netmask 255.255.255.0 { #自动分配IP网段
range 192.168.4.100 192.168.4.202; #地址池
option domain-name-servers 8.8.8.8; #DNS
option routers 192.168.4.254; #网关
default-lease-time 600; #签约时间
max-lease-time 7200;
next-server 192.168.4.100; #下一跳的IP
filename "pxelinux.0"; #路径名称文件
}
[[email protected] ~]# systemctl restart dhcpd #启动服务
[[email protected] ~]# systemctl enable dhcpd #开机自启
- 步骤三:安装tfpt服务
- tfpt:简单系统文件传输
- 默认路径 /var/lib/tftpboot/
[[email protected] ~]# yum -y install tftp-server #安装tfpt服务
已加载插件:langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
[[email protected] ~]# systemctl restart tftp #启动服务
[[email protected] ~]# systemctl enable tftp #开机自启
- 步骤四:部署pxelinux.0文件
[[email protected] ~]# yum provides */pxelinux.0 #查找pxelinux.0 安装源包名称
源 :dvd
匹配来源:
文件名 :/usr/share/syslinux/pxelinux.0
syslinux-4.05-12.el7.x86_64 : Simple kernel loader which boots from a FAT
: filesystem
源 :@dvd
匹配来源:
文件名 :/usr/share/syslinux/pxelinux.0
- 安装 syslinux源包获得pxelinux.0文件
[[email protected] ~]# yum -y install syslinux
已加载插件:langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
软件包 syslinux-4.05-12.el7.x86_64 已安装并且是最新版本
无须任何处
- 查找pxelinux.0安装位置
[[email protected] ~]# rpm -ql syslinux | grep pxelinux.0
/usr/share/syslinux/gpxelinux.0
/usr/share/syslinux/pxelinux.0
- 拷贝文件到tftp默认文件目录
[[email protected] ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
[[email protected] ~]# ls /var/lib/tftpboot/
pxelinux.0
- 部署default默认的菜单文件
[[email protected] ~]# mkdir /var/lib/tftpboot/pxelinux.cfg #新建菜单文件路径
[[email protected] ~]# cp /mnt/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default #拷贝菜单文件到系统默认目录
[[email protected] ~]# chmod 644 /var/lib/tftpboot/pxelinux.cfg/default #文件增加权限644
[[email protected] ~]# cp /mnt/isolinux/vesamenu.c32 /var/lib/tftpboot/ #拷贝开机图形模块文件到默认目录
-
修改菜单文件
[[email protected] ~]# vim /var/lib/tftpboot/pxelinux.cfg/default
- 安装ftp服务
[[email protected] isolinux]# yum -y install vsftpd #安装发ftp服务
已加载插件:langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
[[email protected] isolinux]# systemctl restart vsftpd #启动
[[email protected] isolinux]# systemctl enable vsftpd #开机自启
- 挂着镜像文件到ftp默认路径
[[email protected] isolinux]# mkdir /var/ftp/rhel7 #新建文件目录
[[email protected] isolinux]# mount /root/rhel-server-7.2-x86_64-dvd.iso /var/ftp/rhel7/ #挂着镜像文件到ftp默认路径
mount: /dev/loop1 写保护,将以只读方式挂载
- 安装system-config-kickstart服务,配置开机程序
[[email protected] isolinux]# yum -y install system-config-kickstart #安装配置开机启动程序
已加载插件:langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
正在解决依赖关系
--> 正在检查事务
---> 软件包 system-config-kickstart.noarch.0.2.9.2-4.el7 将被 安装
- yum源仓库命名为system-config-kickstart服务的默认命令
[[email protected] yum.repos.d]# vim dvd.repo
[development] #仓库命令必需是development
name=pan
baseurl=file:///mnt
enabled=1
gpgcheck=0
[[email protected] yum.repos.d]# system-config-kickstart 运行 system-config-kickstart
- 拷贝配置好文件到ftp默认路径
[[email protected] yum.repos.d]# cp /root/ks.cfg /var/ftp/
- 修改配置文件default ,65行后删除
[[email protected] yum.repos.d]# vim /var/lib/tftpboot/pxelinux.cfg/default
64 append initrd=initrd.img ks=ftp://192.168.4.100/ks.cfg #最后一行增加 ks=ftp://192.168.4.100/ks.cfg
- 验证