pxe+ks 无人值守安装
关于自动化的一个程序
dhcp 服务端分配ip
pxe+ks 可以client自己自动安装操作系统
pxe 预启动环境 可以让计算机在网络当中通过其他主机安装操作系统
主要是用于能让client自己通过网络安装操作系统
kickstart ks 无人值守安装的方式 运维人员手动操作的步骤 保存成为一个文件 在client安装的时候可以让其自动执行里面的步骤
dhcp服务 分配的ip
主要用来给client分配ip 这样两台之间就可以进行通讯
tftp服务 tftp协议
负责传输比较小的文件
引导系统-----完整的操作系统
tftp udp传输 用来传输引导文件的 比较小的文件
client没有完整操作系统 所以无法进行tcp链接 指定使用udp传输 tftp服务 69号端口
ftp 服务 用来传输完整的操作系统所需的文件
ftp共享目录下 /var/ftp
(nfs 自定定义的 httpd /var/www/html)
如何实现的无人值守安装
传输流程:
1.client会通过ROM自启动芯片来启动主机,client在启动主机时会进行加电自检,检查自己的硬件设备是否存在问题,如果没有问题则会继续启动主机,主机并没有安装操作系统,所以主机会先去查看自己是否能安装操作系统,如果不能,则去找其他主机安装,其他主机安装需要主机之间能通过ip连通才能传输文件,所以client会先发送一个广播请求,询问能给自己分配ip的主机
2.dhcp服务接受到请求侯,会给client分配一个ip,在分配ip的过程中也会把传输引导文件的tftp服务的ip告诉client,这个还会传输第一个引导文件的名称
3.client发送请求给tftp,请求所需的引导文件
4.tftp将pxe安装时所需的引导文件传输给client,在传输给client的同时会告诉client 传输完整操作系统ftp的ip
5.client发送请求给ftp,请求所需的完整操作系统和kickstart文件
6.tfp传输kickstart文件和完整操作系统,kickstart文件中包含运维人员安装操作系统的步骤
7.client根据kickstart文件来安装整个操作系统
无人值守安装
服务端 192.168.2.10
#安装dhcp服务
[root@localhost ~]# yum -y install dhcp
[root@localhost ~]# cd /etc/dhcp/
[root@localhost dhcp]# vim dhcpd.conf
subnet 192.168.2.0 netmask 255.255.255.0 {
range 192.168.2.50 192.168.2.100; #地址池 可以分配地址的范围
next-server 192.168.2.10; #tftp的ip
filename "pxelinux.0"; #第一个引导文件的名称
}
[root@localhost dhcp]# systemctl restart dhcpd
安装tftp服务
[root@localhost dhcp]# yum -y install tftp-server xinetd
[root@localhost dhcp]# vim /etc/xinetd.d/tftp
14 disable = no #开启tftp服务
tftp传输引导文件
传输目录 用于传输文件的目录
[root@localhost dhcp]# cd /var/lib/tftpboot/
复制引导文件
pxelinux.0 引导程序
[root@localhost tftpboot]# yum -y install syslinux #程序当中包含pxelinux.0的引导程序 通过远程安装的引导程序
[root@localhost tftpboot]# cp /usr/share/syslinux/pxelinux.0 ./
[root@localhost tftpboot]# ls
pxelinux.0
引导文件---光盘
[root@localhost tftpboot]# mount /dev/sr0 /media/
[root@localhost tftpboot]# cp /media/images/pxeboot/vmlinuz ./ 内核文件
[root@localhost tftpboot]# cp /media/images/pxeboot/initrd.img ./ 引导时使用的临时根文件系统
[root@localhost tftpboot]# cp /media/isolinux/splash.png ./ #背景图片
[root@localhost tftpboot]# cp /media/isolinux/boot.* ./ # 提示信息
[root@localhost tftpboot]# cp /media/isolinux/vesamenu.c32 ./ #菜单文件
[root@localhost tftpboot]# ls
boot.cat initrd.img splash.png vmlinuz
boot.msg pxelinux.0 vesamenu.c32
#这里的pxelinux.0是引导程序 但是没有引导程序的配置文件 所以需要复制一个引导程序的配置文件 光盘镜像中自带这使用光盘安装的引导的程序的配置文件isolinux.cfg
引导程序的配置文件都要以.cfg结尾
安装操作系统
[root@localhost tftpboot]# mkdir pxelinux.cfg
[root@localhost tftpboot]# cd pxelinux.cfg/
[root@localhost pxelinux.cfg]# cp /media/isolinux/isolinux.cfg ./default
[root@localhost pxelinux.cfg]# vim default
1 default linux
/var/ftp
centos7 centos6 centos5
centos
/var/ftp/centos kickstart ks.cfg
64 append initrd=initrd.img inst.stage2=ftp://192.1 68.2.10/centos ks=ftp://192.168.2.10/centos/ks.cfg quiet
第三步 安装ftp服务
[root@localhost pxelinux.cfg]# yum -y install vsftpd
[root@localhost ~]# cd /var/ftp/
[root@localhost ftp]# mkdir centos
[root@localhost ftp]# cd centos/
[root@localhost centos]# cp -r /media/* ./ #复制完整操作系统
kickstart
[root@localhost centos]# cat /root/anaconda-ks.cfg #安装主机生成的ks.cfg的文件
[root@localhost centos]# cp /root/anaconda-ks.cfg ./ks.cfg #复制这个样例文件 这样client安装的系统和服务端安装的系统一致
[root@localhost centos]# chmod a+r ks.cfg #加上可读权限
[root@localhost centos]# vim ks.cfg
5 url --url=ftp://192.168.2.10/centos #通过ftp安装
最后一行添加
reboot #重启
eula --agreed #同意协议
[root@localhost centos]# systemctl restart tftp
[root@localhost centos]# systemctl restart xinetd
[root@localhost centos]# systemctl restart vsftpd
[root@localhost centos]# systemctl stop firewalld
[root@localhost centos]# setenforce 0
验证:
server和client 同一种网络适配器 nat vnet6
client 2G内存
不需要指定镜像 只需要硬件
弹窗 关掉
创建新的主机 给硬件---点击开启虚拟机----自动安装