环境介绍:
192.168.3.152 物理服务器一台 简称W
关闭firewalld和selinux
安装必要软件:
在W上安装
yum -y install dhcp xinetd tftp-server httpd syslinux
yum -y install system-config-kickstart (用于全自动安装,执行system-config-kickstart可进入生产ks.cfg的界面)
配置
- http配置
安装好httpd服务后,到/var/www/html/
# cd /var/www/html
# mount -t iso9660 /zl/iso/CentOS-7-x86_64-Minimal-1804.iso /var/www/html/centos7-install/ -o loop,ro
or
# mount -t iso9660 /zl/iso/CentOS-7-x86_64-Minimal-1804.iso /mnt/centos7-install/ -o loop,ro 然后
# cp -pr /mnt/centos7-install/* /var/www/html/centos7-install
- dhcp配置
# cat /etc/dhcp/dhcpd.conf
option domain-name "node1.trinet.com"; # 本物理机hostname
option domain-name-servers 192.168.3.152; # 域名解析IP,还是本物理机IP
default-lease-time 600;
max-lease-time 7200;
log-facility local7;
subnet 192.168.0.0 netmask 255.255.0.0 {
range 192.168.3.160 192.168.3.200; # IP地址范围
option routers 192.168.2.1;
next-server 192.168.3.152; # 下一跳,tftp服务器IP
filename "pxelinux.0"; # 相对于/var/lib/tftpboot而言,见下边的tftp配置这一目录
}
- tftp配置
# cat /etc/xinetd.d/tftp 注意disable,一定是no
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /var/lib/tftpboot
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}
systemctl restart tftp
tftp的服务端口是UDP
- tftpboot目录
# cd /var/lib/tftpboot
# cp /usr/share/syslinux/pxelinux.0 ./
# mkdir pxelinux.cfg
再将http共享目录/var/www/html 下的centos7-install中的isolinux目录下的所有内容复制到当前目录下
scp or cp 由于 我们只有一台机器,所以直接cp
# cp /var/www/html/centos7-install/isolinux/* ./
然后,将该目录下的isolinux.cfg文件复制到pxelinux.cfg,并改名为default
# cp ./isolinux.cfg pxelinux.cfg/default
- 配置安装路径
# cat pxelinux.cfg/default
menu background bg.jpg # 修改背景图,添加到最上边,不需要管initrd.img
kickstart
直接使用配置
这里的rootpw是daemon
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --iscrypted $1$2tWrqPLh$mLw3WsscT8nOfTWpXKDJd.
# Use network installation
url --url="http://192.168.3.152/centos7-install"
# System language
lang en_US
# System authorization information
auth --useshadow --passalgo=sha512
# Use graphical install
graphical
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# Firewall configuration
firewall --disabled
# Network information
network --bootproto=dhcp --device=zl0
network --bootproto=static --device=zl1 --gateway=192.168.2.1 --ip=192.168.3.253 --nameserver=114.114.114.114 --netmask=255.255.0.0
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai
# System services
services --enabled="chronyd"
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --fstype="xfs" --size=200
part / --asprimary --fstype="xfs" --grow --size=1
%packages
@^minimal
@core
chrony
kexec-tools
%end
设置完成之后将ks.cfg文件保存到httpd的发布目录/var/www/html下,保存为ks.cfg文件
然后编辑 vim /var/lib/tftpboot/pxelinux.cfg/default
开始安装
先服务重启,dhcpd httpd and tftp
journalctl -u dhcpd -f 观察IP获取
若同一个局域网中已存在dhcp服务器,那么有可能获取ip会失败
重启服务器,从PXE启动,然后
OK,杀割!