这期内容当中小编将会给大家带来有关如何进行pxe自动化安装系统,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。
10年积累的网站建设、网站设计经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先制作网站后付款的网站建设流程,更有思礼免费网站建设让你可以放心的选择与我们合作。
pxe自动化安装,所需要的服务有:dhcp服务器,tftp服务器,http服务器
pxe自动化安装,所需要的包组及相关安装文件有:syslinux以及自动化安装系统所需的应答文件selinux
本次实验以一台CentOS7作为dhcp服务器,tftp服务器,以及http服务器向本网段内的主机提供自动化安装
主机 | 系统 | IP |
---|---|---|
CentOS7 | CentOS7 | 192.168.73.120 |
[root@centos7 ~]# yum install dhcp tftp-server httpd syslinux -y
1.使用system-config-kickstart生成ks6.cfg
[root@centos7 ~]# system-config-kickstart [root@centos7 ~]# vim ks6.cfg #platform=x86, AMD64, or Intel EM64T #version=DEVEL # Firewall configuration firewall --disabled # Install OS instead of upgrade install # Use network installation url --url="http://192.168.73.120/centos/6/os/x86_64" # Root password rootpw --iscrypted $1$6oVXZR1R$QOASc6inirmHCZmQ.W9Hg0 # System authorization information auth --useshadow --passalgo=sha512 # Use text mode install text # System keyboard keyboard us # System language lang en_US # SELinux configuration selinux --disabled # Do not configure the X Window System skipx # Installation logging level logging --level=info # Reboot after installation reboot # System timezone timezone Asia/Shanghai # Network information network --bootproto=dhcp --device=eth0 --onboot=on # System bootloader configuration bootloader --location=mbr # Clear the Master Boot Record zerombr # Partition clearing information clearpart --all --initlabel # Disk partitioning information part /boot --fstype="ext4" --size=200 part / --fstype="ext4" --size=20000 part swap --fstype="swap" --size=1024 %packages @core %end
2.复制ks6.cfg为ks7.cfg,并修改部分参数
[root@centos7 ~]# cp ks6.cfg ks7.cfg [root@centos7 ~]# vim ks7.cfg #platform=x86, AMD64, or Intel EM64T #version=DEVEL # Firewall configuration firewall --disabled # Install OS instead of upgrade install # Use network installation url --url="http://192.168.73.120/centos/7/os/x86_64" #将url改为7的url # Root password rootpw --iscrypted $1$6oVXZR1R$QOASc6inirmHCZmQ.W9Hg0 # System authorization information auth --useshadow --passalgo=sha512 # Use text mode install text # System keyboard keyboard us # System language lang en_US # SELinux configuration selinux --disabled # Do not configure the X Window System skipx # Installation logging level logging --level=info # Reboot after installation reboot # System timezone timezone Asia/Shanghai # Network information network --bootproto=dhcp --device=ens33 --onboot=on #将网卡名修改为ens33 # System bootloader configuration bootloader --location=mbr # Clear the Master Boot Record zerombr # Partition clearing information clearpart --all --initlabel # Disk partitioning information part /boot --fstype="ext4" --size=200 part / --fstype="ext4" --size=20000 part swap --fstype="swap" --size=1024 %packages @core %end
1.创建http目录
[root@centos7 ~]# mkdir -pv /var/www/html/{centos/{6,7}/os/x86_64,ksdir} mkdir: created directory ‘/var/www/html/centos’ mkdir: created directory ‘/var/www/html/centos/6’ mkdir: created directory ‘/var/www/html/centos/6/os’ mkdir: created directory ‘/var/www/html/centos/6/os/x86_64’ mkdir: created directory ‘/var/www/html/centos/7’ mkdir: created directory ‘/var/www/html/centos/7/os’ mkdir: created directory ‘/var/www/html/centos/7/os/x86_64’ mkdir: created directory ‘/var/www/html/ksdir’
2.将CentOS6及7的光盘文件挂在至相关的目录下(工作中可以直接将光盘镜像复制至目录下)
[root@centos7 ~]# lsblk | grep sr sr0 11:0 1 10G 0 rom /mnt sr1 11:1 1 3.7G 0 rom [root@centos7 ~]# mount /dev/sr0 /var/www/html/centos/7/os/x86_64/ mount: /dev/sr0 is write-protected, mounting read-only [root@centos7 ~]# mount /dev/sr1 /var/www/html/centos/6/os/x86_64/ mount: /dev/sr1 is write-protected, mounting read-only [root@centos7 ~]# lsblk | grep sr sr0 11:0 1 10G 0 rom /var/www/html/centos/7/os/x86_64 sr1 11:1 1 3.7G 0 rom /var/www/html/centos/6/os/x86_64
3.将准备好的应答文件复制至目录下
[root@centos7 ~]# cp ks6.cfg /var/www/html/ksdir [root@centos7 ~]# cp ks7.cfg /var/www/html/ksdir
4.启动httpd服务,并设置为开机自动启动
[root@centos7 ~]# systemctl start httpd [root@centos7 ~]# systemctl enable httpd
1.在tftp工作目录下创建出相关的文件目录
[root@centos7 ~]# mkdir -pv /var/lib/tftpboot/{kernel{6,7},pxelinux.cfg} mkdir: created directory ‘/var/lib/tftpboot/kernel6’ mkdir: created directory ‘/var/lib/tftpboot/kernel7’ mkdir: created directory ‘/var/lib/tftpboot/pxelinux.cfg’
2.将centos6和centos7的内核及虚拟文件系统复制至tftp工作目录下的相对应kernel目录中
[root@centos7 tftpboot]# cd /var/lib/tftpboot/kernel6 [root@centos7 kernel6]# cp /var/www/html/centos/6/os/x86_64/isolinux/vmlinuz . [root@centos7 kernel6]# cp /var/www/html/centos/6/os/x86_64/isolinux/initrd.img . [root@centos7 kernel6]# cd /var/lib/tftpboot/kernel7 [root@centos7 kernel7]# cp /var/www/html/centos/7/os/x86_64/isolinux/vmlinuz . [root@centos7 kernel7]# cp /var/www/html/centos/7/os/x86_64/isolinux/initrd.img .
3.复制启动相关的文件至tftp工作目录
[root@centos7 kernel7]# cd /var/lib/tftpboot/ [root@centos7 tftpboot]# cp /usr/share/syslinux/menu.c32 . [root@centos7 tftpboot]# cp /usr/share/syslinux/pxelinux.0 .
4.复制光盘上的菜单文件至/var/lib/tftpboot/pxelinux.cfg目录下改名为default,修改此文件
[root@centos7 tftpboot]# cp /var/www/html/centos/7/os/x86_64/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default [root@centos7 tftpboot]# vim /var/lib/tftpboot/pxelinux.cfg/default default menu.c32 #将此行改为menu.c32 timeout 600 menu title CentOS install label linux 6 menu label Install CentOS ^6 kernel kernel6/vmlinuz #此处为centos6内核所在的路径 append initrd=kernel6/initrd.img ks=http://192.168.73.120/ksdir/ks6.cfg #指定KS文件在网络中的位置 label linux 7 menu label Install CentOS ^7 kernel kernel7/vmlinuz #此处为centos7内核所在的路径 append initrd=kernel7/initrd.img ks=http://192.168.73.120/ksdir/ks7.cfg #指定KS文件在网路中的位置 label local menu label Boot from ^local drive localboot 0xffff
5.查看下目录结构
[root@centos7 tftpboot]#tree . ├── centos6 │ ├── initrd.img │ └── vmlinuz ├── centos7 │ ├── initrd.img │ └── vmlinuz ├── menu.c32 ├── pxelinux.0 └── pxelinux.cfg └── default
6.启动tftp服务,并设置为开机启动
[root@centos7 ~]# systemctl start tftp [root@centos7 ~]# systemctl enable tftp
1.由于dhcpd默认的配置文件为空,此处将dhcpd的样板配置文件复制后加以修改
[root@centos7 ~]# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf cp: overwrite ‘/etc/dhcp/dhcpd.conf’? y
2.配置dhcp服务
[root@centos7 ~]# vim /etc/dhcp/dhcpd.conf # option definitions common to all supported networks... option domain-name "mylinuxops.com"; #指定预添加域名 option domain-name-servers 114.114.114.114; #指定DNS服务器 default-lease-time 6000; max-lease-time 72000; ...中间省略... # 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. subnet 192.168.73.0 netmask 255.255.255.224 { range 192.168.73.1 192.168.73.100; #指定dhcp地址池 option routers 192.168.73.254; #指定网关 filename "pxelinux.0"; #指定启动文件 next-server 192.168.73.120; #指定tftp服务器路径 }
3.启动dhcp服务器,并设置为开机自动启动
[root@centos7 ~]# systemctl start dhcpd [root@centos7 ~]# systemctl enable dhcpd Created symlink from /etc/systemd/system/multi-user.target.wants/dhcpd.service to /usr/lib/systemd/system/dhcpd.service.
1.所有服务部署完毕,进行测试之前,确保网络中没有其他的DHCP服务,避免产生干扰。
2.centos7在自动化安装时需要1G以上的内存空间。
3.安装时注意物理磁盘的大小以及ks文件中的磁盘大小 ,确保有足够的空间进行安装。
上述就是小编为大家分享的如何进行pxe自动化安装系统了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注创新互联行业资讯频道。