目录
1.kickstart作用
在企业中安装多台操作系统时面临的问题
当安装Linux操作系统时,安装过程会需要回答许多关于设定的问题
这些问题必须手动安装,否则无法安装
当只安装1台Linux系统,手动选择设定工作量比较轻松
当安装多台Linux,这些设定需要重复多次,这些重复动作是效率低下的操作
如何解决以上问题?
用文件来记录所有安装过程中问题的答案,并让所有需要安装的主机自动读取以上解决方案中记录系统安装过程中所有问题答案的文件叫kickstart脚本
2.实验环境
1.主机名称 : westos_node1
2.ip :172.25.254.21
3.火墙,selinux关闭
4.httpd服务开启
5.配置软件仓库能正常工作systemctl disable --now firewalld
setenforce 0
3.kickstart自动安装脚本的制作
安装httpd,安装dhcp-server
dnf install httpd -y
systemctl enable --now httpd
配置软件仓库
vim /etc/rc.d/rc.local
mount /iso/rhel-8.2-x86_64-dvd.iso /var/www/html/westoschmod +x /etc/rc.d/rc.local
测试资源共享:
firefox浏览器里查看 http://172.25.254.21/westos共享资源的意义
在安装操作系统时,每个被安装的操作系统都要有安装资源
如果使用镜像安装,每个安装的系统都需要加载一个镜像
这样会浪费存储,通过网络来共享镜像中的资源,让安装系统的主机能通过
网络访问被共享的资源这样就可以解决多台主机需要多个镜像安装的问题
搭建dhcpd服务器
让被安装的主机可以获得ip来访问网络资源及kickstart文件关闭防火墙,配置dhcpd配置文件
vim /etc/dhcp/dhcpd.conf
# dhcpd.conf
#
# Sample configuration file for ISC dhcpd
## option definitions common to all supported networks...
option domain-name "westos.org";
option domain-name-servers 172.25.254.21;default-lease-time 600;
max-lease-time 7200;# Use this to enble / disable dynamic dns updates globally.
#ddns-update-style none;# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
#authoritative;# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;# 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 172.25.254.0 netmask 255.255.255.0 {
range 172.25.254.60 172.25.254.99;
option routers 172.25.254.21;
}
在已经装好的rhel8中,/root/anaconda-ks.cfg 就是安装当前系统时回答的所有问题的答案
生成的kickstart,此文件为kickstart模板cp /root/anaconda-ks.cfg /var/www/html/westos.cfg
vim /var/www/html/westos.cfgkickstart脚本文件
#version=RHEL8
#ignoredisk --only-use=sda #只是用我们系统中的第一快硬盘
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel #把sda硬盘的所有内容删掉
# Reboot after installation
reboot
# Use graphical install
#graphical #安装过程开启图形
text #安装过程不开图形
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us' #键盘布局为美式键盘
# System language
lang en_US.UTF-8 --addsupport=zh_CN.UTF-8 #系统支持的语言# Network information
network --bootproto=dhcp --onboot=on #网卡设定
repo --name="AppStream" --baseurl=http://172.25.254.21/westos/AppStream #软件安装资源
# Use network installation
url --url="http://172.25.254.21/westos" #系统安装资源
# Root password
rootpw --iscrypted $6$KrTyNmbTsh8fas0X$pmUtPf/A3HyXGWKxAaABpaJRMEPej/WNE5SyoV7mE9tMO8qjrzhki7t9g7C2bvnEWU2VCryV8hFvF5tpfnedU/
# X Window System configuration information #系统默认开启的加密认证方式
xconfig --startxonboot #安装完成后开机启动图形
firstboot --disable #首次启动初始化禁止
# System services
#services --enabled="chronyd" #在开机时开启或关闭的服务
# System timezone
timezone Asia/Shanghai #系统时区,启用utc计时方式,不其同ntp时间同步
# Disk partitioning information
part / --fstype="xfs" --size=1 --grow #让/分区使用全部空闲磁盘空间
part swap --fstype="swap" --size=500 #swap分区大小为500M
part /boot --fstype="xfs" --size=500 #/boot分区大小为500M%packages
#安装软件包
@^graphical-server-environment #图形
ibus-libpinyin.x86_64 #输入法%end
在虚拟机安装界面里
tab 输入 ks=http://172.25.254.21/westos.ks