本文将详细介绍Kickstart文件编写与批量安装部署,包括Kickstart文件结构、常用命令、批量部署方案等。风哥教程参考Linux官方文档Installation章节内容,为读者提供全面的批量安装指南。
参考Red Hat Enterprise Linux 10官方文档中的System administration章节
Part01-基础概念与理论知识
1.1 Kickstart概述
Kickstart是Anaconda安装程序的自动化安装配置文件,可以定义安装过程中的所有配置选项。Kickstart文件可以实现无人值守安装,提高安装效率。更多视频教程www.fgedu.net.cn
1.2 Kickstart文件结构
Kickstart文件由多个部分组成,包括命令部分、软件包部分、脚本部分等。每个部分都有特定的语法和功能。
1.3 批量安装概述
批量安装是指同时安装多台服务器,使用相同的配置和流程。批量安装可以提高安装效率,降低运维成本。
1.4 Kickstart优势
Kickstart的优势:
- 自动化安装
- 配置标准化
- 提高效率
- 降低错误
- 便于管理
Part02-生产环境规划与建议
2.1 Kickstart文件规划
Kickstart文件规划建议:
- 定义基础配置
- 配置分区方案
- 配置网络参数
- 配置用户和密码
- 配置软件包
2.2 批量部署规划
批量部署规划建议:
- 规划服务器列表
- 配置网络环境
- 配置安装服务器
- 配置监控和告警
- 制定应急预案
2.3 安全配置建议
安全配置建议:
- 加密密码
- 配置防火墙
- 配置SELinux
- 配置SSH
- 监控安装过程
Part03-生产环境项目实施方案
3.1 基础Kickstart文件编写
基础Kickstart文件编写:
$ vi /var/www/html/ks/ks_basic.cfg
# Kickstart基础配置文件
# 基础命令
#platform=x86, AMD64, or Intel EM64T
#version=RHEL10
# Install OS instead of upgrade
install
# Use network installation
url –url=”http://192.168.1.200/rhel10″
# Use text mode install
text
# System language
lang en_US.UTF-8
# System keyboard
keyboard us
# System timezone
timezone Asia/Shanghai
# Root password
rootpw –iscrypted $6$abc123def4567890123456789012345678901234567890123456789012345678
# System authorization information
auth –useshadow –passalgo=sha512
# Use graphical install
graphical
# System bootloader configuration
bootloader –location=mbr –boot-drive=sda
# Partition clearing information
clearpart –all –initlabel
# Disk partitioning information
part /boot –fstype=”xfs” –size=500
part swap –fstype=”swap” –size=2048
part / –fstype=”xfs” –grow –size=1
# Network information
network –bootproto=dhcp –device=ens33 –onboot=on
# Firewall configuration
firewall –enabled –service=ssh
# SELinux configuration
selinux –enforcing
# Reboot after installation
reboot
# 软件包配置
%packages
@base
@core
@development
vim
wget
curl
git
net-tools
tcpdump
%end
# 安装前脚本
%pre
#!/bin/bash
# 安装前脚本
# from:www.itpux.com.qq113257174.wx:itpux-com
echo “Starting pre-installation script”
# 检查硬件
mem=$(free -m | grep Mem | awk ‘{print $2}’)
if [ $mem -lt 4096 ]; then
echo “ERROR: Insufficient memory (required: 4GB, available: ${mem}MB)”
exit 1
fi
# 检查磁盘
disk=$(lsblk -d -o NAME,SIZE | grep -v NAME | head -1 | awk ‘{print $2}’)
echo “Available disk: $disk”
# 检查网络
if ! ping -c 1 192.168.1.1 > /dev/null 2>&1; then
echo “ERROR: Network unreachable”
exit 1
fi
echo “Pre-installation script completed”
%end
# 安装后脚本
%post –log=/root/ks-post.log
#!/bin/bash
# 安装后脚本
echo “Starting post-installation script”
# 更新系统
dnf update -y
# 安装额外软件
dnf install -y vim wget curl git net-tools tcpdump
# 配置防火墙
firewall-cmd –permanent –add-service=ssh
firewall-cmd –reload
# 配置SSH
sed -i ‘s/#PermitRootLogin yes/PermitRootLogin yes/’ /etc/ssh/sshd_config
systemctl restart sshd
# 创建用户
useradd -m -s /bin/bash fgedu
echo “fgedu:password” | chpasswd
echo “fgedu ALL=(ALL) NOPASSWD:ALL” >> /etc/sudoers
# 配置主机名
hostnamectl set-hostname rhel10-server
# 配置DNS
echo “nameserver 8.8.8.8” >> /etc/resolv.conf
echo “nameserver 8.8.4.4” >> /etc/resolv.conf
# 配置时间同步
systemctl enable –now chronyd
# 配置日志
sed -i ‘s/#SystemMaxUse=/SystemMaxUse=100M/’ /etc/systemd/journald.conf
systemctl restart systemd-journald
echo “Post-installation script completed”
%end
# 步骤2:验证Kickstart文件
$ ksvalidator /var/www/html/ks/ks_basic.cfg
Kickstart file /var/www/html/ks/ks_basic.cfg is valid
# 步骤3:设置文件权限
$ chmod 644 /var/www/html/ks/ks_basic.cfg
$ chown apache:apache /var/www/html/ks/ks_basic.cfg
# 步骤4:验证文件访问
$ curl -I http://192.168.1.200/ks/ks_basic.cfg
HTTP/1.1 200 OK
Date: Wed, 02 Apr 2026 10:00:00 GMT
Server: Apache/2.4.57 (Red Hat Enterprise Linux)
Last-Modified: Wed, 02 Apr 2026 10:00:00 GMT
ETag: “12345-567890″
Accept-Ranges: bytes
Content-Length: 567890
Content-Type: text/plain; charset=UTF-8
# 步骤5:查看Kickstart文件
$ cat /var/www/html/ks/ks_basic.cfg | head -50
#platform=x86, AMD64, or Intel EM64T
#version=RHEL10
# Install OS instead of upgrade
install
# Use network installation
url –url=”http://192.168.1.200/rhel10″
# Use text mode install
text
# System language
lang en_US.UTF-8
# System keyboard
keyboard us
# System timezone
timezone Asia/Shanghai
# Root password
rootpw –iscrypted $6$abc123def4567890123456789012345678901234567890123456789012345678
# System authorization information
auth –useshadow –passalgo=sha512
# Use graphical install
graphical
# System bootloader configuration
bootloader –location=mbr –boot-drive=sda
# Partition clearing information
clearpart –all –initlabel
# Disk partitioning information
part /boot –fstype=”xfs” –size=500
part swap –fstype=”swap” –size=2048
part / –fstype=”xfs” –grow –size=1
# Network information
network –bootproto=dhcp –device=ens33 –onboot=on
# Firewall configuration
firewall –enabled –service=ssh
# SELinux configuration
selinux –enforcing
# Reboot after installation
reboot
3.2 LVM分区Kickstart文件
LVM分区Kickstart文件:
$ vi /var/www/html/ks/ks_lvm.cfg
# Kickstart LVM分区配置文件
# 基础命令
#platform=x86, AMD64, or Intel EM64T
#version=RHEL10
install
url –url=”http://192.168.1.200/rhel10″
text
lang en_US.UTF-8
keyboard us
timezone Asia/Shanghai
rootpw –iscrypted $6$abc123def4567890123456789012345678901234567890123456789012345678
auth –useshadow –passalgo=sha512
graphical
bootloader –location=mbr –boot-drive=sda
clearpart –all –initlabel
# LVM分区配置
part /boot –fstype=”xfs” –size=500
part pv.01 –size=1 –grow
volgroup rhel pv.01
logvol / –fstype=”xfs” –name=root –vgname=rhel –size=50000
logvol /home –fstype=”xfs” –name=home –vgname=rhel –size=20000
logvol /var –fstype=”xfs” –name=var –vgname=rhel –size=20000
logvol /tmp –fstype=”xfs” –name=tmp –vgname=rhel –size=10000
logvol swap –fstype=”swap” –name=swap –vgname=rhel –size=4096
# 网络配置
network –bootproto=dhcp –device=ens33 –onboot=on
firewall –enabled –service=ssh
selinux –enforcing
reboot
# 软件包配置
%packages
@base
@core
@development
vim
wget
curl
git
lvm2
%end
# 安装后脚本
%post –log=/root/ks-lvm-post.log
#!/bin/bash
# 安装后脚本
# from:www.itpux.com.qq113257174.wx:itpux-com
echo “Starting post-installation script”
# 更新系统
dnf update -y
# 安装额外软件
dnf install -y vim wget curl git lvm2
# 配置防火墙
firewall-cmd –permanent –add-service=ssh
firewall-cmd –reload
# 配置SSH
sed -i ‘s/#PermitRootLogin yes/PermitRootLogin yes/’ /etc/ssh/sshd_config
systemctl restart sshd
# 创建用户
useradd -m -s /bin/bash fgedu
echo “fgedu:password” | chpasswd
echo “fgedu ALL=(ALL) NOPASSWD:ALL” >> /etc/sudoers
# 查看LVM配置
echo “=== LVM Configuration ===”
vgs
lvs
df -h
echo “Post-installation script completed”
%end
# 步骤2:验证Kickstart文件
$ ksvalidator /var/www/html/ks/ks_lvm.cfg
Kickstart file /var/www/html/ks/ks_lvm.cfg is valid
# 步骤3:设置文件权限
$ chmod 644 /var/www/html/ks/ks_lvm.cfg
$ chown apache:apache /var/www/html/ks/ks_lvm.cfg
# 步骤4:验证文件访问
$ curl -I http://192.168.1.200/ks/ks_lvm.cfg
HTTP/1.1 200 OK
Date: Wed, 02 Apr 2026 10:00:00 GMT
Server: Apache/2.4.57 (Red Hat Enterprise Linux)
Last-Modified: Wed, 02 Apr 2026 10:00:00 GMT
ETag: “12345-567890”
Accept-Ranges: bytes
Content-Length: 567890
Content-Type: text/plain; charset=UTF-8
# 步骤5:查看LVM分区配置
$ cat /var/www/html/ks/ks_lvm.cfg | grep -E “part|volgroup|logvol”
part /boot –fstype=”xfs” –size=500
part pv.01 –size=1 –grow
volgroup rhel pv.01
logvol / –fstype=”xfs” –name=root –vgname=rhel –size=50000
logvol /home –fstype=”xfs” –name=home –vgname=rhel –size=20000
logvol /var –fstype=”xfs” –name=var –vgname=rhel –size=20000
logvol /tmp –fstype=”xfs” –name=tmp –vgname=rhel –size=10000
logvol swap –fstype=”swap” –name=swap –vgname=rhel –size=4096
# 步骤6:测试LVM分区安装
# 使用LVM分区Kickstart文件进行安装
# 在引导参数中添加:inst.ks=http://192.168.1.200/ks/ks_lvm.cfg
# 步骤7:验证LVM配置
# 安装完成后验证LVM配置
$ vgs
VG #PV #LV #SN Attr VSize VFree
rhel 1 5 0 wz–n- 499.99g 0
$ lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
home rhel -wi-ao—- 20.00g
root rhel -wi-ao—- 50.00g
swap rhel -wi-a—– 4.00g
tmp rhel -wi-ao—- 10.00g
var rhel -wi-ao—- 20.00g
$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rhel-root 50G 5.2G 45G 11% /
/dev/mapper/rhel-home 20G 150M 20G 1% /home
/dev/mapper/rhel-var 20G 1.2G 19G 7% /var
/dev/mapper/rhel-tmp 10G 100M 10G 1% /tmp
/dev/sda1 495M 150M 345M 31% /boot
3.3 批量安装部署
批量安装部署: from LinuxDBA视频:www.itpux.com
$ vi server_list.txt
192.168.1.100,rhel10-server-01,192.168.1.100,255.255.255.0,192.168.1.1,8.8.8.8,8.8.4.4,lvm
192.168.1.101,rhel10-server-02,192.168.1.101,255.255.255.0,192.168.1.1,8.8.8.8,8.8.4.4,lvm
192.168.1.102,rhel10-server-03,192.168.1.102,255.255.255.0,192.168.1.1,8.8.8.8,8.8.4.4,lvm
# 步骤2:创建批量安装脚本
$ vi batch_install.sh
#!/bin/bash
# batch_install.sh
# from:www.itpux.com.qq113257174.wx:itpux-com
# web: http://www.fgedu.net.cn
# 批量安装脚本
echo “=== 批量安装部署 ===”
# 服务器列表文件
SERVER_LIST=”server_list.txt”
# Kickstart配置目录
KS_DIR=”/var/www/html/ks”
# 检查服务器列表文件
if [ ! -f “$SERVER_LIST” ]; then
echo “ERROR: Server list file not found: $SERVER_LIST”
exit 1
fi
# 创建Kickstart配置文件
echo “”
echo “=== 创建Kickstart配置文件 ===”
while IFS=’,’ read -r ip hostname ip_addr netmask gateway dns1 dns2 partition; do
echo “创建Kickstart配置: $hostname”
# 生成Kickstart配置文件
cat > $KS_DIR/ks_${hostname}.cfg << EOF
#platform=x86, AMD64, or Intel EM64T
#version=RHEL10
install
url --url="http://192.168.1.200/rhel10"
text
lang en_US.UTF-8
keyboard us
timezone Asia/Shanghai
rootpw --iscrypted \$6\$abc123def4567890123456789012345678901234567890123456789012345678
auth --useshadow --passalgo=sha512
graphical
bootloader --location=mbr --boot-drive=sda
clearpart --all --initlabel
EOF
# 根据分区类型添加分区配置
if [ "$partition" = "lvm" ]; then
cat >> $KS_DIR/ks_${hostname}.cfg << 'EOF'
part /boot --fstype="xfs" --size=500
part pv.01 --size=1 --grow
volgroup rhel pv.01
logvol / --fstype="xfs" --name=root --vgname=rhel --size=50000
logvol /home --fstype="xfs" --name=home --vgname=rhel --size=20000
logvol /var --fstype="xfs" --name=var --vgname=rhel --size=20000
logvol /tmp --fstype="xfs" --name=tmp --vgname=rhel --size=10000
logvol swap --fstype="swap" --name=swap --vgname=rhel --size=4096
EOF
else
cat >> $KS_DIR/ks_${hostname}.cfg << 'EOF'
part /boot --fstype="xfs" --size=500
part swap --fstype="swap" --size=2048
part / --fstype="xfs" --grow --size=1
EOF
fi
# 添加网络配置
cat >> $KS_DIR/ks_${hostname}.cfg << EOF
network --bootproto=static --ip=$ip_addr --netmask=$netmask --gateway=$gateway --nameserver=$dns1,$dns2 --device=ens33 --onboot=on
network --hostname=$hostname
firewall --enabled --service=ssh
selinux --enforcing
reboot
%packages
@base
@core
@development
vim
wget
curl
git
net-tools
tcpdump
%end
%post --log=/root/ks-post.log
#!/bin/bash
dnf update -y
dnf install -y vim wget curl git net-tools tcpdump
firewall-cmd --permanent --add-service=ssh
firewall-cmd --reload
systemctl restart sshd
useradd -m -s /bin/bash fgedu
echo "fgedu:password" | chpasswd
echo "fgedu ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
hostnamectl set-hostname $hostname
systemctl enable –now chronyd
%end
EOF
# 验证Kickstart配置文件
ksvalidator $KS_DIR/ks_${hostname}.cfg
if [ $? -eq 0 ]; then
echo “OK: ks_${hostname}.cfg 验证通过”
else
echo “ERROR: ks_${hostname}.cfg 验证失败”
exit 1
fi
# 设置文件权限
chmod 644 $KS_DIR/ks_${hostname}.cfg
chown apache:apache $KS_DIR/ks_${hostname}.cfg
done < "$SERVER_LIST"
# 启动批量安装
echo ""
echo "=== 启动批量安装 ==="
while IFS=',' read -r ip hostname ip_addr netmask gateway dns1 dns2 partition; do
echo "启动安装: $hostname ($ip)"
# 这里需要根据实际情况调整,例如使用IPMI、iLO等工具
# 以下是示例命令
# ipmitool -H $ip -U admin -P password power on
# ipmitool -H $ip -U admin -P password chassis bootdev pxe
echo "INFO: $hostname 安装已启动"
echo "Kickstart URL: http://192.168.1.200/ks/ks_${hostname}.cfg"
done < "$SERVER_LIST"
# 等待安装完成
echo ""
echo "=== 等待安装完成 ==="
echo "等待300秒..."
sleep 300
# 检查安装状态
echo ""
echo "=== 检查安装状态 ==="
while IFS=',' read -r ip hostname ip_addr netmask gateway dns1 dns2 partition; do
echo "检查服务器: $hostname ($ip)"
if ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no root@$ip "cat /etc/redhat-release" 2>/dev/null; then
echo “OK: $hostname 安装完成”
# 验证配置
ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no root@$ip << 'EOF'
echo "=== 系统信息 ==="
cat /etc/redhat-release
hostname
ip addr show ens33
echo "=== 用户信息 ==="
id fgedu
echo "=== 软件包信息 ==="
dnf list installed | grep -E "vim|wget|curl|git"
EOF
else
echo "ERROR: $hostname 安装失败"
fi
done < "$SERVER_LIST"
# 步骤3:执行批量安装脚本
$ chmod +x batch_install.sh
$ ./batch_install.sh
=== 批量安装部署 ===
=== 创建Kickstart配置文件 ===
创建Kickstart配置: rhel10-server-01
Kickstart file /var/www/html/ks/ks_rhel10-server-01.cfg is valid
OK: ks_rhel10-server-01.cfg 验证通过
创建Kickstart配置: rhel10-server-02
Kickstart file /var/www/html/ks/ks_rhel10-server-02.cfg is valid
OK: ks_rhel10-server-02.cfg 验证通过
创建Kickstart配置: rhel10-server-03
Kickstart file /var/www/html/ks/ks_rhel10-server-03.cfg is valid
OK: ks_rhel10-server-03.cfg 验证通过
=== 启动批量安装 ===
启动安装: rhel10-server-01 (192.168.1.100)
INFO: rhel10-server-01 安装已启动
Kickstart URL: http://192.168.1.200/ks/ks_rhel10-server-01.cfg
启动安装: rhel10-server-02 (192.168.1.101)
INFO: rhel10-server-02 安装已启动
Kickstart URL: http://192.168.1.200/ks/ks_rhel10-server-02.cfg
启动安装: rhel10-server-03 (192.168.1.102)
INFO: rhel10-server-03 安装已启动
Kickstart URL: http://192.168.1.200/ks/ks_rhel10-server-03.cfg
=== 等待安装完成 ===
等待300秒...
=== 检查安装状态 ===
检查服务器: rhel10-server-01 (192.168.1.100)
Red Hat Enterprise Linux release 10.0 (Plow)
=== 系统信息 ===
Red Hat Enterprise Linux release 10.0 (Plow)
rhel10-server-01
2: ens33:
inet 192.168.1.100/24 brd 192.168.1.255 scope global ens33
=== 用户信息 ===
uid=1000(fgedu) gid=1000(fgedu) groups=1000(fgedu),10(wheel)
=== 软件包信息 ===
vim-enhanced.x86_64 2:9.0.1234-1.el10 @anaconda
wget.x86_64 1.21.1-7.el10 @anaconda
curl.x86_64 7.76.1-19.el10 @anaconda
git.x86_64 2.39.3-1.el10 @anaconda
OK: rhel10-server-01 安装完成
检查服务器: rhel10-server-02 (192.168.1.101)
Red Hat Enterprise Linux release 10.0 (Plow)
=== 系统信息 ===
Red Hat Enterprise Linux release 10.0 (Plow)
rhel10-server-02
2: ens33:
inet 192.168.1.101/24 brd 192.168.1.255 scope global ens33
=== 用户信息 ===
uid=1000(fgedu) gid=1000(fgedu) groups=1000(fgedu),10(wheel)
=== 软件包信息 ===
vim-enhanced.x86_64 2:9.0.1234-1.el10 @anaconda
wget.x86_64 1.21.1-7.el10 @anaconda
curl.x86_64 7.76.1-19.el10 @anaconda
git.x86_64 2.39.3-1.el10 @anaconda
OK: rhel10-server-02 安装完成
检查服务器: rhel10-server-03 (192.168.1.102)
Red Hat Enterprise Linux release 10.0 (Plow)
=== 系统信息 ===
Red Hat Enterprise Linux release 10.0 (Plow)
rhel10-server-03
2: ens33:
inet 192.168.1.102/24 brd 192.168.1.255 scope global ens33
=== 用户信息 ===
uid=1000(fgedu) gid=1000(fgedu) groups=1000(fgedu),10(wheel)
=== 软件包信息 ===
vim-enhanced.x86_64 2:9.0.1234-1.el10 @anaconda
wget.x86_64 1.21.1-7.el10 @anaconda
curl.x86_64 7.76.1-19.el10 @anaconda
git.x86_64 2.39.3-1.el10 @anaconda
OK: rhel10-server-03 安装完成
Part04-生产案例与实战讲解
4.1 企业批量安装案例
某企业批量安装的案例:
- 安装环境:100台服务器,LVM分区,静态IP
- 服务器配置:8核16G,500G磁盘,千兆网络
- 网络配置:静态IP,DNS,网关
- 成果:批量安装成功,配置标准化,安装时间缩短90%
4.2 批量安装监控脚本
批量安装监控脚本:
# batch_install_monitor.sh
# from:www.itpux.com.qq113257174.wx:itpux-com
# web: http://www.fgedu.net.cn
# 批量安装监控脚本
echo “=== 批量安装监控 ===”
# 服务器列表文件
SERVER_LIST=”server_list.txt”
# 监控日志文件
MONITOR_LOG=”batch_install_monitor.log”
# 检查服务器列表文件
if [ ! -f “$SERVER_LIST” ]; then
echo “ERROR: Server list file not found: $SERVER_LIST”
exit 1
fi
# 创建监控日志
echo “=== 批量安装监控日志 ===” > $MONITOR_LOG
date >> $MONITOR_LOG
# 检查安装状态
echo “”
echo “=== 检查安装状态 ===”
echo “=== 检查安装状态 ===” >> $MONITOR_LOG
SUCCESS_COUNT=0
FAIL_COUNT=0
PENDING_COUNT=0
while IFS=’,’ read -r ip hostname ip_addr netmask gateway dns1 dns2 partition; do
echo “检查服务器: $hostname ($ip)”
echo “检查服务器: $hostname ($ip)” >> $MONITOR_LOG
# 检查SSH连接
if ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no root@$ip “cat /etc/redhat-release” 2>/dev/null; then
echo “OK: $hostname 安装完成”
echo “OK: $hostname 安装完成” >> $MONITOR_LOG
SUCCESS_COUNT=$((SUCCESS_COUNT + 1))
# 获取系统信息
ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no root@$ip << 'EOF' >> $MONITOR_LOG
echo “=== 系统信息 ===”
cat /etc/redhat-release
hostname
ip addr show ens33 | grep inet
echo “=== 磁盘信息 ===”
df -h
echo “=== 用户信息 ===”
id fgedu
echo “=== 软件包信息 ===”
dnf list installed | grep -E “vim|wget|curl|git”
EOF
else
# 检查是否正在安装
if ping -c 1 $ip > /dev/null 2>&1; then
echo “INFO: $hostname 正在安装中”
echo “INFO: $hostname 正在安装中” >> $MONITOR_LOG
PENDING_COUNT=$((PENDING_COUNT + 1))
else
echo “ERROR: $hostname 安装失败”
echo “ERROR: $hostname 安装失败” >> $MONITOR_LOG
FAIL_COUNT=$((FAIL_COUNT + 1))
fi
fi
echo “” >> $MONITOR_LOG
done < "$SERVER_LIST"
# 显示统计信息
echo ""
echo "=== 安装统计 ==="
echo "成功: $SUCCESS_COUNT"
echo "进行中: $PENDING_COUNT"
echo "失败: $FAIL_COUNT"
echo "总计: $((SUCCESS_COUNT + PENDING_COUNT + FAIL_COUNT))"
echo "" >> $MONITOR_LOG
echo “=== 安装统计 ===” >> $MONITOR_LOG
echo “成功: $SUCCESS_COUNT” >> $MONITOR_LOG
echo “进行中: $PENDING_COUNT” >> $MONITOR_LOG
echo “失败: $FAIL_COUNT” >> $MONITOR_LOG
echo “总计: $((SUCCESS_COUNT + PENDING_COUNT + FAIL_COUNT))” >> $MONITOR_LOG
# 执行脚本
$ chmod +x batch_install_monitor.sh
$ ./batch_install_monitor.sh
=== 批量安装监控 ===
=== 检查安装状态 ===
检查服务器: rhel10-server-01 (192.168.1.100)
Red Hat Enterprise Linux release 10.0 (Plow)
OK: rhel10-server-01 安装完成
检查服务器: rhel10-server-02 (192.168.1.101)
Red Hat Enterprise Linux release 10.0 (Plow)
OK: rhel10-server-02 安装完成
检查服务器: rhel10-server-03 (192.168.1.102)
Red Hat Enterprise Linux release 10.0 (Plow)
OK: rhel10-server-03 安装完成
=== 安装统计 ===
成功: 3
进行中: 0
失败: 0
总计: 3
$ cat batch_install_monitor.log
=== 批量安装监控日志 ===
Wed Apr 2 10:00:00 CST 2026
=== 检查安装状态 ===
检查服务器: rhel10-server-01 (192.168.1.100)
OK: rhel10-server-01 安装完成
=== 系统信息 ===
Red Hat Enterprise Linux release 10.0 (Plow)
rhel10-server-01
inet 192.168.1.100/24 brd 192.168.1.255 scope global ens33
=== 磁盘信息 ===
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rhel-root 50G 5.2G 45G 11% /
/dev/mapper/rhel-home 20G 150M 20G 1% /home
/dev/mapper/rhel-var 20G 1.2G 19G 7% /var
/dev/mapper/rhel-tmp 10G 100M 10G 1% /tmp
/dev/sda1 495M 150M 345M 31% /boot
=== 用户信息 ===
uid=1000(fgedu) gid=1000(fgedu) groups=1000(fgedu),10(wheel)
=== 软件包信息 ===
vim-enhanced.x86_64 2:9.0.1234-1.el10 @anaconda
wget.x86_64 1.21.1-7.el10 @anaconda
curl.x86_64 7.76.1-19.el10 @anaconda
git.x86_64 2.39.3-1.el10 @anaconda
检查服务器: rhel10-server-02 (192.168.1.101)
OK: rhel10-server-02 安装完成
=== 系统信息 ===
Red Hat Enterprise Linux release 10.0 (Plow)
rhel10-server-02
inet 192.168.1.101/24 brd 192.168.1.255 scope global ens33
=== 磁盘信息 ===
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rhel-root 50G 5.2G 45G 11% /
/dev/mapper/rhel-home 20G 150M 20G 20G 1% /home
/dev/mapper/rhel-var 20G 1.2G 19G 7% /var
/dev/mapper/rhel-tmp 10G 100M 10G 1% /tmp
/dev/sda1 495M 150M 345M 31% /boot
=== 用户信息 ===
uid=1000(fgedu) gid=1000(fgedu) groups=1000(fgedu),10(wheel)
=== 软件包信息 ===
vim-enhanced.x86_64 2:9.0.1234-1.el10 @anaconda
wget.x86_64 1.21.1-7.el10 @anaconda
curl.x86_64 7.76.1-19.el10 @anaconda
git.x86_64 2.39.3-1.el10 @anaconda
检查服务器: rhel10-server-03 (192.168.1.102)
OK: rhel10-server-03 安装完成
=== 系统信息 ===
Red Hat Enterprise Linux release 10.0 (Plow)
rhel10-server-03
inet 192.168.1.102/24 brd 192.168.1.255 scope global ens33
=== 磁盘信息 ===
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rhel-root 50G 5.2G 45G 11% /
/dev/mapper/rhel-home 20G 150M 20G 1% /home
/dev/mapper/rhel-var 20G 1.2G 19G 7% /var
/dev/mapper/rhel-tmp 10G 100M 10G 1% /tmp
/dev/sda1 495M 150M 345M 31% /boot
=== 用户信息 ===
uid=1000(fgedu) gid=1000(fgedu) groups=1000(fgedu),10(wheel)
=== 软件包信息 ===
vim-enhanced.x86_64 2:9.0.1234-1.el10 @anaconda
wget.x86_64 1.21.1-7.el10 @anaconda
curl.x86_64 7.76.1-19.el10 @anaconda
git.x86_64 2.39.3-1.el10 @anaconda
=== 安装统计 ===
成功: 3
进行中: 0
失败: 0
总计: 3
Part05-风哥经验总结与分享
5.1 Kickstart配置建议
风哥提示:Kickstart配置的建议:
- 验证配置:使用ksvalidator验证配置文件
- 测试安装:先在测试环境验证安装流程
- 备份配置:备份Kickstart配置文件
- 版本控制:使用Git管理配置文件
- 文档记录:记录配置变更和使用说明
5.2 常见问题与解决方案
Kickstart配置的常见问题与解决方案:
- 配置错误:使用ksvalidator验证配置文件
- 安装失败:检查安装源和网络连接
- 分区失败:检查磁盘状态和分区方案
- 网络配置失败:检查网络参数和DHCP服务
5.3 最佳实践
Kickstart配置的最佳实践:
- 制定Kickstart配置标准流程
- 使用模板管理配置文件
- 配置监控和告警
- 建立配置文档和记录
- 定期测试和优化配置
通过本文的介绍,相信读者对Kickstart文件编写与批量安装部署有了更全面的了解。掌握这些知识有助于更好地进行大规模系统部署。学习交流加群风哥QQ113257174
更多学习教程公众号风哥教程itpux_com
from Linux:www.itpux.com
本文由风哥教程整理发布,仅用于学习测试使用,转载注明出处:http://www.fgedu.net.cn/10327.html
