pxe装机
一.pxe自动装机
1.pex的优点
1.规模化:同时装配多台服务器(20-30)
2.自动化:系统安装和服务配置不需要人工干预
3.远程实现:不需要光盘,不需要u盘
2.前提条件
1.网卡都支持pxe协议
2.dhcp,动态的给客户机分配ip地址
3.需要ftp文件传输协议
4.我们需要准备好光盘镜像
3.配置安装pxe
1.下载安装tftp-server xinetd
[root@localhost yum.repos.d]# yum -y install tftp-server xinetd
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 tftp-server.x86_64.0.5.2-22.el7 将被 安装
---> 软件包 xinetd.x86_64.2.2.3.15-14.el7 将被 安装
--> 解决依赖关系完成
2.配置
[root@localhost yum.repos.d]# vim /etc/xinetd.d/tftp
service tftp
{
socket_type = dgram
protocol = udp
wait = no
user = root
server = /usr/sbin/in.tftpd
server_args = -s /var/lib/tftpboot
disable = no
per_source = 11
cps = 100 2
flags = IPv4
3.重启服务
[root@localhost yum.repos.d]# systemctl restart xinetd.service
4.安装dhcp
[root@localhost yum.repos.d]# yum -y install dhcp
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
5.复制配置文件,进行配置
[root@localhost yum.repos.d]# cd /usr/share/doc/dhcp-4.2.5/
[root@localhost dhcp-4.2.5]# ls
dhcpd6.conf.example dhcpd.conf.example ldap
[root@localhost dhcp-4.2.5]# cp dhcpd.conf.example /etc/dhcp
[root@localhost dhcp-4.2.5]# cd /etc/dhcp
[root@localhost dhcp]# ls
dhclient.d dhclient-exit-hooks.d dhcpd6.conf dhcpd.conf dhcpd.conf.example scripts
[root@localhost dhcp]# rm -rf dhcpd.conf
[root@localhost dhcp]# ls
dhclient.d dhclient-exit-hooks.d dhcpd6.conf dhcpd.conf.example scripts
[root@localhost dhcp]# mv dhcpd.conf.example dhcpd.conf
[root@localhost dhcp]# ls
dhclient.d dhclient-exit-hooks.d dhcpd6.conf dhcpd.conf scripts
将 /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example 复制到/etc/dhcp/dhcpd.conf 并将空文件删除改名
[root@localhost dhcp]# vim dhcpd.conf
next-server 192.168.233.10; #指定 TFTP 服务器的地址
filename "pxelinux.0"; #指定要下载的 PXE 引导程序的文件
subnet 192.168.233.0 netmask 255.255.255.0 { #声明要分配的网段地址
range 192.168.233.100 192.168.233.200;#设置地址池
option routers 192.168.233.10;#默认网关地址指向TFTP服务器的IP地址
}
root@localhost dhcp]# systemctl restart dhcpd.service
重启服务
6.挂载
[root@localhost /]# mount /dev/cdrom /mnt
mount: /dev/sr0 写保护,将以只读方式挂载
[root@localhost /]# df -Th
文件系统 类型 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root xfs 50G 4.1G 46G 9% /
devtmpfs devtmpfs 897M 0 897M 0% /dev
tmpfs tmpfs 912M 0 912M 0% /dev/shm
tmpfs tmpfs 912M 9.1M 903M 1% /run
tmpfs tmpfs 912M 0 912M 0% /sys/fs/cgroup
/dev/sda1 xfs 5.0G 179M 4.9G 4% /boot
tmpfs tmpfs 183M 12K 183M 1% /run/user/42
tmpfs tmpfs 183M 0 183M 0% /run/user/0
/dev/sr0 iso9660 4.3G 4.3G 0 100% /mnt
7.将文件复制到指定文件目录
[root@localhost /]# cd /mnt/images/pxeboot/
[root@localhost pxeboot]# ls
initrd.img TRANS.TBL vmlinuz
[root@localhost pxeboot]# cp initrd.img /var/lib/tftpboot/
[root@localhost pxeboot]# cp vmlinuz /var/lib/tftpboot/
[root@localhost pxeboot]# cd /var/lib/tftpboot/
[root@localhost tftpboot]# ls
initrd.img vmlinuz
8.安装pxe引导软件
[root@localhost tftpboot]# yum -y install syslinux
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 syslinux.x86_64.0.4.05-15.el7 将被 安装
--> 解决依赖关系完成
将文件复制到指定文件夹
[root@localhost tftpboot]# cd /usr/share/syslinux/
[root@localhost syslinux]# ls
altmbr.bin cpuidtest.c32 gptmbr.bin ifcpu64.c32 isohdppx_c.bin mboot.c32 pcitest.c32 sanboot.c32 vesamenu.c32
altmbr_c.bin diag gptmbr_c.bin ifcpu.c32 isohdppx_f.bin mbr.bin pmload.c32 sdi.c32 vpdtest.c32
altmbr_f.bin disk.c32 gptmbr_f.bin ifplop.c32 isolinux.bin mbr_c.bin poweroff.com sysdump.c32 whichsys.c32
cat.c32 dmitest.c32 gpxecmd.c32 int18.com isolinux-debug.bin mbr_f.bin pwd.c32 syslinux64.exe zzjson.c32
chain.c32 dosutil gpxelinux.0 isohdpfx.bin kbdmap.c32 memdisk pxechain.com syslinux.com
cmd.c32 elf.c32 gpxelinuxk.0 isohdpfx_c.bin linux.c32 memdump.com pxelinux.0 syslinux.exe
config.c32 ethersel.c32 hdt.c32 isohdpfx_f.bin ls.c32 meminfo.c32 reboot.c32 ver.com
cpuid.c32 gfxboot.c32 host.c32 isohdppx.bin lua.c32 menu.c32 rosh.c32 vesainfo.c32
[root@localhost syslinux]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
[root@localhost syslinux]# cd /var/lib/tftpboot/
[root@localhost tftpboot]# ls
initrd.img pxelinux.0 vmlinuz
9.安装vsftpd,进行系统文件的传输
[root@localhost tftpboot]# yum -y install vsftpd
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 vsftpd.x86_64.0.3.0.2-29.el7_9 将被 安装
--> 解决依赖关系完成
[root@localhost tftpboot]# mkdir /var/ftp/centos7
[root@localhost tftpboot]# cp -rf /mnt/* /var/ftp/centos7/
[root@localhost tftpboot]# systemctl sta
start status
[root@localhost tftpboot]# systemctl start f
fcoe.service flatpak-system-helper.service fstrim.service
firstboot-graphical.service fprintd.service fstrim.timer
[root@localhost tftpboot]# systemctl start v
virt-guest-shutdown.target vsftpd@ vsftpd.service vsftpd.target
[root@localhost tftpboot]# systemctl start vsftpd
10.设置菜单
[root@localhost tftpboot]# cd /var/lib/tftpboot/
[root@localhost tftpboot]# ls
initrd.img pxelinux.0 vmlinuz
[root@localhost tftpboot]# mkdir pxelinux.cfg
[root@localhost tftpboot]# ls
initrd.img pxelinux.0 pxelinux.cfg vmlinuz
[root@localhost tftpboot]# vim /var/lib/tftpboot/pxelinux.cfg/default
default auto
prompt 0
label auto
kernel vmlinuz
append initrd=initrd.img method=ftp://192.168.230.110/centos7 ks=ftp://192.168.230.110/ks.cfg
label linux text
kernel vmlinuz
append text initrd=initrd.img method=ftp://192.168.230.110/centos7
lable linux rescue
kernel vmlinuz
append rescue initrd=initrd.img method=ftp://192.168.230.110/centos7
11.关闭防火墙
[root@localhost tftpboot]# systemctl stop firewalld.service
[root@localhost tftpboot]# setenforce 0
二.无人值守
1.安装system-config-kickstart
root@localhost tftpboot]# yum -y install system-config-kickstart
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
正在解决依赖关系
2.配置kickstart选项
3. 配置需要安装的软件包
[root@localhost tftpboot]# cd /root
[root@localhost ~]# ls
anaconda-ks.cfg initial-setup-ks.cfg ks.cfg 公共 模板 视频 图片 文档 下载 音乐 桌面
[root@localhost ~]# cp /root/ks.cfg /var/ftp/ks.cfg
[root@localhost ~]# cd /var/ftp/
[root@localhost ftp]# ls
centos7 ks.cfg pub
[root@localhost ftp]# vim ks.cfg
%packages
@base
@core
@desktop-debugging
@dial-up
@directory-client
@fonts
@gnome-desktop
@guest-desktop-agents
@input-methods
@internet-browser
@java-platform
@multimedia
@network-file-system-client
@print-client
@x11
binutils
chrony
ftp
gcc
kernel-devel
kexec-tools
make
open-vm-tools
patch
python
%end
4. 编辑引导菜单文件 default
[root@localhost ftp]# vim /var/lib/tftpboot/pxelinux.cfg/default
label auto
kernel vmlinuz#kernel 和 append用来定义引导参数
append initrd=initrd.img method=ftp://192.168.233.21/centos7 ks=ftp://192.168.233.10/ks.cfg
#添加 ks 引导参数以指定 ks.cfg 应答文件的 URL 路径
原文地址:https://blog.csdn.net/Wthzdq/article/details/143800865
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!