Centos7 in pxe kickstart automatically deployed and installed unattended installation (one step !!!)

Experiment (a): the deployment of Remote Installation Services PXE

Batch deploy server

Scale: at the same time with multiple servers

Automation: system installation, configuration services

Remote achieved: no CD-ROM, U-installed media

Screenshot micro-channel _20190910120648.png

The basic elements of experimental steps:

1, DHCP (automatically assigned an IP address file positioning guide)

next-server // path directed TFTP

filename // bootstrap file location

2, TFTP (Trivial File Transfer Protocol UDP: 69 small capacity high efficiency) (bootstrap pxelinux.0 (syslinux package), the compressed kernel vmlinuz, the initrd.img file system initialization, the boot menu default)

3, FTP (vsftpd system image file transfer protocol (centos7) security, capacity TCP: 20 data transfer, 21: connection)

Required installation package: dhcp, tftp-server, vsftpd, syslinux

lab environment:

A Linux server as the PXE installed

A bare-metal system is not installed

(A) In order not to affect the use of NAT mode, we installed a new card to the Linux server, and set to host-only mode, and a new network card configured as a fixed IP address assigned address dhcp

1, add the Linux server setup a new network card, and set to host-only mode

Screenshot micro-channel _20190910120648.png

2, configure a new network card information ens36

[root @ localhost ~] # cd / etc / sysconfig / network-scripts / copy card information as a new network card configuration file 
[root @ localhost Network-scripts] # cp -p the ifcfg-ens33 the ifcfg-ens36 
[root @ localhost network-scripts] # vim ifcfg- ens36 ens36 configure a new network card 
[root @ localhost network-scripts] # systemctl restart network network service restart

Screenshot micro-channel _20190910120648.png

(二)安装DHCP服务,编辑配置文件/etc/dhcp/dhcpd.conf

[root@localhost network-scripts]# yum install dhcp -y  安装dhcp服务
[root@localhost network-scripts]# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf 复制为dhcp的配置文件
cp:是否覆盖"/etc/dhcp/dhcpd.conf"? y
[root@localhost network-scripts]# vim /etc/dhcp/dhcpd.conf  编辑dhcp配置文件
subnet 192.168.100.0 netmask 255.255.255.0 {
        range 192.168.100.20 192.168.100.30;
        option routers 192.168.100.100;
        option domain-name-servers 114.114.114.114;
        next-server 192.168.100.100;
        filename "pxelinux.0";
}

Screenshot micro-channel _20190910120648.png

(三)安装syslinux,tftp服务

1,安装syslinux并查看引导文件pxelinux.0位置

[root@localhost network-scripts]# yum install syslinux -y  安装syslinux
[root@localhost network-scripts]# rpm -ql syslinux | grep pxelinux  查看引导文件位置

Screenshot micro-channel _20190910120648.png

2,安装tftp服务

[root@localhost network-scripts]# yum install tftp-server -y 安装tftp服务
[root@localhost network-scripts]# rpm -ql tftp-server  查看文件位置
[root@localhost network-scripts]# vim /etc/xinetd.d/tftp 开启tftp服务

Screenshot micro-channel _20190910120648.png

Screenshot micro-channel _20190910120648.png

3,复制引导文件pxelinux.0到/var/lib/tftpboot(TFTP站点中)

[root@localhost network-scripts]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot 复制引导文件到站点中
[root@localhost network-scripts]# cd /var/lib/tftpboot/  切换到站点中查看
[root@localhost tftpboot]# ls 
pxelinux.0

Screenshot micro-channel _20190910120648.png

(四)安装vsftp服务(安装之前先将centos7镜像文件连接到光盘),将压缩内核和初始化文件复制到TFTP站点中

[root@localhost tftpboot]# yum install vsftpd -y  安装vsftp服务
[root@localhost tftpboot]# cd /var/ftp
[root@localhost ftp]# mkdir centos7
[root@localhost ftp]# mount /dev/cdrom centos7/
[root@localhost ftp]# cd centos7/images/pxeboot/
[root@localhost pxeboot]# cp initrd.img vmlinuz /var/lib/tftpboot/
[root@localhost pxeboot]# ls /var/lib/tftpboot/

Screenshot micro-channel _20190910164435.png

Screenshot micro-channel _20190910164633.png

(五)编辑启动菜单default配置文件,关闭防火墙并开启三个服务

[root@localhost pxeboot]# cd /var/lib/tftpboot/   切换到tftp站点
[root@localhost tftpboot]# mkdir pxelinux.cfg   创建配置文件目录
[root@localhost tftpboot]# ls
initrd.img  pxelinux.0  pxelinux.cfg  vmlinuz
[root@localhost tftpboot]# cd pxelinux.cfg/
[root@localhost pxelinux.cfg]# vim default  编辑default配置文件
[root@localhost pxelinux.cfg]# systemctl stop firewalld.service  关闭防火墙
[root@localhost pxelinux.cfg]# setenforce 0
[root@localhost pxelinux.cfg]# systemctl start dhcpd   启动三个服务
[root@localhost pxelinux.cfg]# systemctl start tftp
[root@localhost pxelinux.cfg]# systemctl start vsftpd
default auto
prompt 1

label auto
        kernel vmlinuz
        append initrd=initrd.img method=ftp://192.168.100.100/centos7

label linux text
        kernel vmlinuz
        append text initrd=initrd.img method=ftp://192.168.100.100/centos7

label linux rescue
        kernel vmlinuz
        append rescue initrd=initrd.img method=ftp://192.168.100.100/centos7

Screenshot micro-channel _20190910164633.png

(六)创建并开启未安装系统的裸机,选择网络装机,安装系统

1,创建的未安装系统的裸机需要选择仅主机模式

Screenshot micro-channel _20190910164633.png

2,打开未安装系统的裸机,选择网络装机

Screenshot micro-channel _20190910164435.png

Screenshot micro-channel _20190910164633.png

成功部署pxe批量装机服务!!!


实验(二):kickstart无人值守技术

创建应答文件(ks.cfg),预先定义号各种安装设置

免去交互设置过程,从而实现全自动化安装

通过添加%post脚本,完成安装后的各种配置操作

(一)安装kickstart软件包,并打开设置(除了我列出的图片要修改的之外,其余的不需要修改)

[root@localhost ~]# yum install system-config-kickstart -y  安装kickstart软件

1,安装好之后打开kickstart进行设置

Screenshot micro-channel _20190910173644.png

2,设置安装的内容信息

基本配置选择中文语言,时区,root密码,安装后重启

Screenshot micro-channel _20190910173644.png

安装方法选择FTP服务器,并指明服务器的地址

Screenshot micro-channel _20190910174056.png

设置分区信息,启动目录/boot:500M 家目录/home:4096M 交换空间swap:4096M 根目录/:为分配的所有空间

Screenshot micro-channel _20190910174331.png

Screenshot micro-channel _20190910174414.png

微信截图_20190910174509.png

微信截图_20190910174552.png

设置网路设备信息为ens33

微信截图_20190910174631.png

防火墙设置为禁用

微信截图_20190910174705.png

填写安装后脚本的解释器为/bin/bash

微信截图_20190910174751.png

保存ks.conf到/var/ftp目录中

微信截图_20190910174857.png

微信截图_20190910175026.png

(二)将安装软件包的模板复制到ks.cfg中,并在/var/lib/tftproot中引导加载模板,让其生效

1,查看ks.conf,复制本地anaconda-ks.cfg中的packages软件包模板到ks.cfg中

[root@localhost pxelinux.cfg]# ls /var/ftp  切换到/var/ftp查看保存的ks.cfg设置配置文件
centos7  ks.cfg  pub
[root@localhost pxelinux.cfg]# cd /root  切换到本地/root下
[root@localhost ~]# ls
anaconda-ks.cfg  initial-setup-ks.cfg  公共  模板  视频  图片  文档  下载  音乐  桌面
[root@localhost ~]# vim anaconda-ks.cfg 将anaconda-ks.cfg中的安装软件包模块复制到/var/ftp/下的ks.cfg中
[root@localhost ~]# vim /var/ftp/ks.cfg

微信截图_20190910180837.png

微信截图_20190910181238.png

(三)引导加载ks.cfg模板到/var/lib/tftproot/pxelinux.cfg/下的default配置文件中

[root @ localhost ~] # cd /var/lib/tftpboot/pxelinux.cfg/ /var/lib/tftpboot/pxelinux.cfg/ switch to the directory 
[the root @ localhost the pxelinux.cfg] LS # 
default 
[PXELINUX the root @ localhost .cfg] # vim default editor

微信截图_20190910182359.png

(Iv) open for the bare-metal install the system, look at the effect of the installation

微信截图_20190910182759.png

Skip interface, direct mounting system, the unattended installation


thanks for reading! ! !

Guess you like

Origin blog.51cto.com/14080162/2437227