前言
redhat配置PXE+kickstart,自动为同网段服务器安装系统。
PXE+kickstart配置
IP地址:192.168.0.106
网卡配置:仅主机模式
- 配置DHCP服务
- 安装dhcp
1
yum install dhcp
- 编辑配置文件/etc/dhcp/dhcpd.conf
1
2
3
4
5
6
7
8
9
10
11
12
13allow booting;
allow bootp;
ddns-update-style none;
ignore client-updates;
subnet 192.168.0.0 netmask 255.255.255.0 {
option subnet-mask 255.255.255.0;
option domain-name-servers 8.8.8.8;
range dynamic-bootp 192.168.0.50 192.168.0.250; #为客户端自动分配IP地址,地址范围192.168.0.50~192.168.0.250
default-lease-time 21600;
max-lease-time 43200;
next-server 192.168.0.106; #网关设置为本机IP
filename "pxelinux.0";
} - 重启dhcpd服务并加入开机启动项
1
2systemctl restart dhcpd
systemctl enable dhcpd
- 配置tftp服务
- 安装tfp-server
1
yum install tftp-server
- 修改配置文件/etc/xinetd.d/tftp
- 重启xinetd服务并加入开机启动项
1
2systemctl restart xinetd
systemctl enable xinetd
- 配置syslinux
- 安装syslinux
1
yum install syslinux
- 将syslinux的配置文件拷贝到tftp服务的目录
1
2
3
4
5
6cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
cp /media/cdrom/isolinux/{vesamenu.c32,boot.msg} /var/lib/tftpboot/
cp /media/cdrom/images/pxeboot/{vmlinuz,initrd.img} /var/lib/tftpboot/
cd /var/lib/tftpboot
mkdir pxelinux.cfg
cp /media/cdrom/isolinux/isolinux.cfg pxelinux.cfg/default - 修改配置文件/var/lib/tftpboot/pxelinux.cfg/default
- 配置http服务
- 安装httpd
1
yum install httpd
- 拷贝镜像文件到http根目录
1
cp -rf /media/cdrom/* /var/www/html/
- 重启httpd服务并加入开机启动项
1
2systemctl restart httpd
systemctl enable httpd
- 配置kickstart
- 编辑配置文件ks.cfg配置文件修改以下内容:
1
2
3
4
5mkdir /var/www/html/pub
cp /root/anaconda-ks.cfg /var/www/html/pub
cd /var/www/html/pub
mv anaconda-ks.cfg ks.cfg
chmod 755 ks.cfg - 重启httpd服务
1
systemctl restart httpd