当前位置:首页 > 系统 > CentOS7 使用PXE+kickstar批量安装

CentOS7 使用PXE+kickstar批量安装

系统3年前 (2020-02-13)

CentOS7 使用PXE+kickstar批量安装

kickstar可实现批量无人值守的方式安装系统,批量部署前可以生成一个设置好各种参数的脚本ks.cfg文件,然后自动化安装

流程为

CentOS7 使用PXE+kickstar批量安装

服务端192.168.10.11  DHCP范围192.168.10.100-192.168.10.110


安装组件

yum -y install dnsmasq tftp-server xinetd syslinux httpd pykickstart system-config-kickstart


配置dhcp

mv /etc/dnsmasq.conf /etc/dnsmasq.conf.backup
vim /etc/dnsmasq.conf
改为
interface=ens34
dhcp-range=192.168.10.100,192.168.10.110,255.255.255.0,1h
dhcp-boot=pxelinux.0
enable-tftp
tftp-root=/var/lib/tftpboot

#执行
systemctl enable dnsmasq
systemctl start dnsmasq
systemctl status dnsmasq

CentOS7 使用PXE+kickstar批量安装


配置tftp

sed -i '/disable\>/s/\<yes\>/no/' /etc/xinetd.d/tftp

#执行
systemctl enable tftp
systemctl restart tftp.service
systemctl status tftp.service

CentOS7 使用PXE+kickstar批量安装


配置httpd

rm -rf /etc/httpd/conf.d/welcome.conf 
sed -i 's#\#ServerName www.example.com:80#ServerName 127.0.0.1:80#g' /etc/httpd/conf/httpd.conf
mkdir -p /var/www/html/centos7 
mount -o loop /dev/cdrom /var/www/html/centos7

#执行
systemctl enable httpd
systemctl start httpd
systemctl status httpd

CentOS7 使用PXE+kickstar批量安装


配置pxe

cp -r /usr/share/syslinux/* /var/lib/tftpboot
cp -a /var/www/html/centos7/isolinux/* /var/lib/tftpboot/
mkdir /var/lib/tftpboot/pxelinux.cfg
vim /var/lib/tftpboot/pxelinux.cfg/default
改为
default ks
prompt 0

label ks
  kernel vmlinuz
  append initrd=initrd.img ks=http://192.168.10.11/ks.cfg

CentOS7 使用PXE+kickstar批量安装


生成ks

#避免Package selection is disabled due to problems downloading package informatio错误两种方式
#方法1
vim /etc/yum.repos.d/development.repo
改为
[development]
name=development
baseurl=file:///var/www/html/centos7
gpgcheck=0

#方法2
#或者vim /usr/share/system-config-kickstart/packages.py
#164行后添加"base"

CentOS7 使用PXE+kickstar批量安装

#执行
system-config-kickstart

CentOS7 使用PXE+kickstar批量安装

左上角File--Open File


CentOS7 使用PXE+kickstar批量安装

选择本机安装过系统自动生成的anaconda-ks.cfg


CentOS7 使用PXE+kickstar批量安装

设置语言、键盘布局、时区、密码


CentOS7 使用PXE+kickstar批量安装

安装方式选择http,填写http服务器地址以及yum仓库路径


CentOS7 使用PXE+kickstar批量安装

安装新boot loader,改为MBR


CentOS7 使用PXE+kickstar批量安装

清除主分区记录,移除所有存在的分区,初始化分区,根据需求自定义分区


CentOS7 使用PXE+kickstar批量安装

配置网卡


CentOS7 使用PXE+kickstar批量安装

验证默认


CentOS7 使用PXE+kickstar批量安装

关闭SELinux和防火墙


CentOS7 使用PXE+kickstar批量安装

反勾选安装图形界面环境


CentOS7 使用PXE+kickstar批量安装

选择需要安装的包


CentOS7 使用PXE+kickstar批量安装

安装前脚本,根据需求在右边白框内编写脚本,这里默认


CentOS7 使用PXE+kickstar批量安装

安装后脚本,根据需求在右边白框内编写脚本


CentOS7 使用PXE+kickstar批量安装

点击左上角File,保存


CentOS7 使用PXE+kickstar批量安装

选择保存到/root目录下


#验证
cp /root/ks.cfg /var/www/html/
ksvalidator /var/www/html/ks.cfg


CentOS7 使用PXE+kickstar批量安装

新建一个和服务器同一个网段的虚拟机,测试启动后一切自动安装


附上ks.cfg

#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --iscrypted $1$mgFXptMu$u3fP3Gbq5b49HqIPYMvS71
# System language
lang en_US
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use graphical install
graphical
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx

# Firewall configuration
firewall --disabled
# Network information
network  --bootproto=static --device=ens33 --gateway=192.168.10.2 --ip=192.168.10.15 --nameserver=8.8.8.8 --netmask=255.255.255.0
# Reboot after installation
reboot
# System timezone
timezone Asia/Hong_Kong
# Use network installation
url --url="http://192.168.10.11/centos7"
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --fstype="xfs" --size=512
part / --fstype="xfs" --grow --size=1
part swap --fstype="swap" --size=4096

%post
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.bak
mv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.bak
adduser vos
echo "vos":"voscn" | chpasswd
%end

%packages
@^minimal
@compat-libraries
@core
@debugging
@development
@system-admin-tools
tree
nmap
sysstat
lrzsz
dos2unix
telnet

%end


本站所有文章均可随意转载,转载时请保留原文链接及作者。

本文链接:https://www.vos.cn/os/401.html

相关文章

fedora23删除旧内核

fedora23删除旧内核

安装完系统,把默认的gnome换成了kde后,使用dnf升级了系统,重启系统发现多出新内核,准备删除老内核打开命令行查看系统内现存的内核 rpm -qa | g...

Oracle主备容灾方案

Oracle主备容灾方案

【实验需求】生产中心有一台Oracle服务器安装于Redhat Linux上,灾备中心有一台对应的容灾Oracle服务器,两台服务器的数据库空间来自各自所连接的T系列阵列LUN,阵列同Oracle服务...

修复升级EVE-NG后无法正常打开问题

修复升级EVE-NG后无法正常打开问题

升级流程Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.9.40-eve-ng-ukms+ x86_64) * Documentation:  ...

利用LVM特性对EVE-NG硬盘分区扩容

利用LVM特性对EVE-NG硬盘分区扩容

下载的EVE-NG镜像中,存放模拟器镜像的分区太小了,上传几个cisco和juniper的模拟器就快满了,所以需要使用lvm特性对ubuntu server的硬盘分区进行扩容,首先先将eve-ng虚拟...

CentOS7 搭建LNMP

CentOS7 搭建LNMP

使用CentOS 1708,其实就是RHEL 7.4,使用YUM搭建LNMP环境(Linux、Nginx、MariaDB、PHP),全部使用新版组件,比如Nginx 1.12.2、MariaDB 10...

CentOS7 软RAID配置

CentOS7 软RAID配置

虚拟机添加4块新硬盘,形成5盘环境,做Linux软RAID磁盘阵列准备环境搭建添加硬件选择硬盘默认选择SCSI创建新虚拟磁盘容量默认20G,存储为单个文件加默认安装系统的,一共5个fdisk -l查看...