kickstart自动安装
[root@localhost ~]# mkdir /rhel7
[root@localhost /]# mount /dev/sr0 /rhel7/
[root@localhost /]# df
[root@localhost /]# vim /etc/rc.d/rc.local
[root@localhost /]# chmod +x /etc/rc.d/rc.local
[root@localhost /]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# vim rhel7.repo
[rhel7]
name=rhel7
baseurl=file:///rhel7
gpgcheck=0
[root@localhost yum.repos.d]# mv redhat.repo redhat.repo.bak
[root@localhost yum.repos.d]# yum makecache
[root@localhost yum.repos.d]# ln -s /rhel7/ /var/www/html/
[root@localhost yum.repos.d]# cd /var/www/html/
[root@localhost html]# ls
rhel7
[root@localhost dyj]# yum install system-config-kickstart
#安装图形化生成kickstart自动安装脚本的工具
[root@localhost dyj]# system-config-kickstart
#启动图形制作工具进行本机设置
[root@localhost ~]# vim ks.cfg
part /boot --fstype="xfs" --size=1024
part swap --fstype="swap" --size=512
part / --fstype="xfs" --grow --size=1
%packages
@base
httpd
%end
[root@localhost ~]# ksvalidator ks.cfg #检测文件是否规范
root@localhost yum.repos.d]# yum install httpd -y #下载httpd服务
[root@localhost html]# systemctl enable --now httpd #开机自启
[root@localhost html]# vim /etc/httpd/conf/httpd.conf
<Directory /var/www/html>
#AllowOverride none
Require all denied
</Directory>
[root@localhost html]# systemctl restart httpd 重启服务
测试:
搭建dhcp服务测试kickstart
先关闭虚拟机的DHCP服务
[root@localhost html]# yum install dhcp -y #下载dhcp服务为其他服务器提供分配ip的功能
[root@localhost ~]# rpm -qc dhcp #查看文件
[root@localhost ~]# \cp -f /usr/share/doc/dhcp*/dhcpd.conf.example /etc/dhcp/dhcpd.conf
#生成配置文件
[root@localhost ~]# vim /etc/dhcp/dhcpd.conf
#编辑主配置文件
[root@localhost ~]# systemctl enable --now dhcpd
新建一台虚拟机测试kickstart
pxe部署
[root@localhost ~]# yum install syslinux.x86_64 -y #安装syslinux
[root@localhost ~]# yum install tftp-server.x86_64 -y #共享pxelinux.0数据文件的网络服务
[root@localhost ~]# rpm -ql tftp-server
[root@localhost ~]# systemctl enable --now tftp #启动tftp
[root@localhost ~]# cp /rhel7/isolinux/* /var/lib/tftpboot/
[root@localhost ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
[root@localhost ~]# cd /var/lib/tftpboot/
[root@localhost tftpboot]# ls
boot.cat grub.conf isolinux.bin memtest pxelinux.cfg TRANS.TBL vesamenu.c32
boot.msg initrd.img isolinux.cfg pxelinux.0 splash.png upgrade.img vmlinuz
[root@localhost tftpboot]# vim /etc/dhcp/dhcpd.conf
[root@localhost tftpboot]# vim /var/lib/tftpboot/pxelinux.cfg/default
测试:新建一台虚拟机进行以下操作