https://blog.csdn.net/Happy_Sunshine_Boy/article/details/88635839
https://www.cnblogs.com/liuxgcn/p/11076469.html
安装环境
虚拟化 VMware® Workstation 14 Pro
PXE服务器系统 CentOS7 3.10.0-862.3.2.el7.1.2
虚机网络配置:桥接模式
服务器ip :172.18.0.65/24
准备工作
关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
关闭selinux
sestatus / getenforce 查看selinux状态
setenforce 0 设置为permission状态
修改/etc/sysconfig/selinux
SELINUX=disabled
防火墙,selinux关闭完成。
软件安装
yum install -y httpd dhcp tftp-server xinetd syslinux system-config-kickstart
rpm -q httpd dhcp tftp-server xinetd syslinux system-config-kickstart
[root@NODE ~] rpm -q httpd dhcp tftp-server xinetd syslinux system-config-kickstart
httpd-2.4.6-90.el7.centos.x86_64
dhcp-4.2.5-77.el7.centos.x86_64
tftp-server-5.2-22.el7.x86_64
xinetd-2.3.15-13.el7.x86_64
syslinux-4.05-12.el7.x86_64
system-config-kickstart-2.9.7-1.el7.noarch
配置DHCP服务
修改或创建DHCP配置文件
vi /etc/dhcp/dhcpd.conf
#
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.example
# see dhcpd.conf(5) man page
#
subnet 172.18.0.0 netmask 255.255.255.0 {
option routers 172.18.0.1; #为客户端设定默认网关
option subnet-mask 255.255.255.0; #为客户端设定子网掩码
range 172.18.0.185 172.18.0.189; #设置动态分配ip的地址范围
default-lease-time 3600;
max-lease-time 7200;
next-server 172.0.18.65; #tftp服务器地址,也就是本机地址
filename "/pxelinux.0"; #文件名就是这个
}
启动DHCP服务,并查看启动状态
systemctl start dhcpd
systemctl enable dhcpd
systemctl status dhcpd
查看端口状态
ss -nulp | grep dhcpd
HTTP服务配置
创建镜像挂载目录
mkdir -pv /var/www/html/CentOS7
挂载镜像
mount /dev/sr0 /var/www/html/CentOS7
如果镜像是iso文件上传到系统中了,使用-o loop挂载。
mount -o loop *.iso /var/www/html/CentOS7
[root@NODE ~]# mount /dev/sr0 /var/www/html/CentOS7
mount: /dev/sr0 is write-protected, mounting read-only
启动http服务
systemctl start httpd
systemctl enable httpd
systemctl status httpd
浏览器验证
TFTP服务配置
修改或创建 /etc/xinetd.d/tftp
disable = no
启动tftp.socket服务
systemctl start tftp.socket
systemctl enable tftp.socket
systemctl status tftp.socket
启动tftp.service服务
systemctl start tftp.service
systemctl enable tftp.service
systemctl status tftp.service
查看端口
ss -unlp | grep 69
启动xinetd服务
systemctl start xinetd
systemctl enable xinetd
systemctl status xinetd
配置文件
需要导入TFTP服务器的主要文件有:
引导文件:pxelinux.0
内核文件:vmlinuz initrd.img
引导菜单:isolinux.cfg – 开机后选择启动项的菜单文
引导文件pxelinux.0
由selinux生成
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
导入内核及菜单文件
images/pxeboot/vmlinuz initrd.img
isolinux/vesamenu.c32 boot.msg
cp /var/www/html/CentOS7/images/pxeboot/vmlinuz initrd.img /var/lib/tftpboot/
cp /var/www/html/CentOS7/isolinux/vesamenu.c32 boot.msg /var/lib/tftpboot/
chmod 755 -R /var/lib/tftpboot/
编辑pxelinux.cfg菜单文件
该菜单文件的配置模板在镜像文件中:/var/www/html/cdrom/isolinux/isolinux.cfg 中
创建目录,复制isolinux.cfg到创建的目录中并命名为default
mkdir -pv /var/lib/tftpboot/pxelinux.cfg
cp /var/www/html/CentOS7/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
chmod 755 /var/lib/tftpboot/pxelinux.cfg/default
修改default文件
vi /var/lib/tftpboot/pxelinux.cfg/default
添加:
#---------可用最简配置-------------------
default cdrom
prompt 0 #1出现提示,0不出现提示
label cdrom
kernel vmlinuz
append initrd=initrd.img ks=http://172.18.0.65/ksdir/ks.cfg devfs=nomount #指定ks.cfg文件读取的位置
配置ks.cfg文件
ks.cfg模板文件在/root下的anaconda-ks.cfg文件
mkdir /var/www/html/ksdir
cp /root/anaconda-ks.cfg /var/www/html/ksdir/ks.cfg
chmod 755 /var/www/html/ksdir/ks.cfg
验证
编辑ks.cfg文件,添加url
vim /var/www/html/ks.cfg
图片中ksdir目录写错,安装源应该从镜像中找。所以应该是挂载iso的目录CentOS7。
install ,url写在auth后面,cdrom前边装机会报错,放在这个位置没事。【笑脸】
#version=DEVEL
# System authorization information
auth --enableshadow --passalgo=sha512
# Use CDROM installation media
cdrom
# Use graphical install
graphical
# Run the Setup Agent on first boot
install
url --url='http://172.18.0.106/CentOS7'
firstboot --enable
ignoredisk --only-use=sda
firewall --disabled #关闭防护墙
selinux --disabled #关闭selinux
# Keyboard layouts
keyboard --vckeymap=cn --xlayouts='cn'
# System language
lang zh_CN.UTF-8
# Network information
network --bootproto=dhcp --device=ens33 --ipv6=auto --activate
network --hostname=localhost.localdomain
# Root password
rootpw --iscrypted $6$OGyUYKe54svNh32h$UCTh6m6pQLCaFox2xAd08BGEepaqkJUSKoGVBQzL39GQ6TcSNjCojy1zjeSrjQmfmB9tV.Kkjucm5mHVIDGNK.
# System services
services --enabled="chronyd"
# System timezone
timezone Asia/Shanghai --isUtc
user --groups=wheel --name=zettakit --password=$6$qOizIBGVivrxpSbX$GEro1scNeZSuHDMTnnbZ3Jm9aQYY2c4FnEH8IWzktvQCuwiz4NwNaPn8oFGJZ/AlwWDxRSPeu0v/zBItW9tiA0 --iscrypted --gecos="zettakit"
# System bootloader configuration
bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
autopart --type=lvm
# Partition clearing information
clearpart --none --initlabel
%packages
@^minimal
@core
chrony
kexec-tools
19/11/25再次实验
重新搭建,再次尝试,报错如上。
检查到
[root@pxe_server ksdir]# ll /var/www/html/ksdir/ks.cfg
-rw------- 1 root root 1340 11月 25 11:42 /var/www/html/ksdir/ks.cfg
[root@pxe_server ksdir]#
于是修改权限644,再次尝试,发现运行到此处不报错。
CentOS7.5安装成功
问题记录
报错
发现镜像未挂载。挂载镜像即可。
报错
原因:未添加 install 及url
自动部署
最小化安装7.4之后,将PXE目录传到装好的系统中,进入PXE目录,运行 sh set_up_pxe.sh即可。
然后新建虚机,网络同样使用桥接模式,便可自行安装。
链接:https://pan.baidu.com/s/1VzkTm6RzxvdlOIRjK7KEkw
提取码:z49r
复制这段内容后打开百度网盘手机App,操作更方便哦