从机服务器从网卡开始启动,向主机服务器的DHCP发送请求,主服务器回应ip地址和文件地址,从机再通过得到的文件地址去主服务器访问配置文件,配置文件中有URL安装源,再访问URL安装源去安装部署
1.两台rhel7虚拟机
2.将VMware的虚拟网络编辑器的NAT模式更改为如下:
2.开启主机图形界面
下载图形界面:yum group install "Server with GUI"
打开图形界面:init 5
3.配置主服务器的网络可用,可以使用脚本一键配置
vim /init_ip.sh
#!/bin/bash read -p "网卡名称:" eh read -p "ip地址:" ip cat >/etc/sysconfig/network-scripts/ifcfg-$eh<
ip a 查看网卡名称
运行脚本:bash /init_ip.sh
网卡名称填写自己的,一般是ens33/ens160/eth0
ip地址:172.25.254.40
4.一定要关闭VMware dhcp功能
5.挂载镜像 mount /dev/sr0 /mnt
6.配置仓库方便下载
vim /etc/yum.repos.d/npm.repo
yum install system-config-kickstart
system-config-kickstart
vim ks.cfg
检查ks.cfg是否有语法错误
ksvalidator ks.cfg
yum install httpd -y
vim /etc/httpd/conf.d/vhost.conf
allowoverride none require all granted servername 172.25.254.40 documentroot /var/www/html
返回到家目录
cd
复制ks.cfg
cp ks.cfg /var/www/html
创建镜像挂载目录的软链接到/var/www/html下
ln -s /mnt /var/www/html/mnt
systemctl restart httpd
systemctl stop firewall
setenforce 0
yum install dhcp -y
编写时可以借助模版/usr/share/doc/dhcp*/dhcpd.conf.example
直接拷贝一份模版文件
\cp -f /usr/share/doc/dhcp*/dhcpd.conf.example /etc/dhcp/dhcpd.conf
vim /etc/dhcp/dhcpd.conf
# dhcpd.conf # # Sample configuration file for ISC dhcpd # # option definitions common to all supported networks... #公司域名,自己取的 option domain-name "caikeyou.org"; #对外分发的dns地址 option domain-name-servers 114.114.114.114; default-lease-time 600; max-lease-time 7200; # Use this to enble / disable dynamic dns updates globally. #ddns-update-style none; # If this DHCP server is the official DHCP server for the local # network, the authoritative directive should be uncommented. #authoritative; # Use this to send dhcp log messages to a different log file (you also # have to hack syslog.conf to complete the redirection). log-facility local7; # No service will be given on this subnet, but declaring it helps the # DHCP server to understand the network topology. #subnet 10.152.187.0 netmask 255.255.255.0 { #} # This is a very basic subnet declaration. #IP网段和子网掩码 subnet 172.25.254.0 netmask 255.255.255.0 { #dhcp地址池,分发地址的范围 range 172.25.254.80 172.25.254.90; #网关 option routers 172.25.254.2; #正常配置dhcp服务不用写,但是我们希望将下面的目录一起发送给请求主机,实现服务器的自动化部署 next-server 172.25.254.40; filename "pxelinux.0"; }
重启dhcp服务
systemctl enable --now dhcpd
yum install syslinux.x86_64
共享pxelinux.0数据文件的网络服务
查看下载安装包
rpm -ql tftp-server
设置开机自启动
systemctl enable --now tftp
复制挂载镜像目录/mnt下的isolinux
cp /mnt/isolinux/* /var/lib/tftpboot/
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
cd /var/lib/tftpboot/
mkdir pxelinux.cfg
cp ioslinux.cfg pxelinux.cfg/default
vim pxelinux.cfg/default
按上下键选择项,然后按+-实现上下挪动,使顺序与下面一样