#### 一.kickstart自动安装脚本的作用 #####
#在企业中安装多台操作系统时面临的问题#
当安装Linux操作系统时,安装过程会需要回答很多关于设定的问题,这些问题必须手动选择,否则无法进行安装。
当只安装1台Linux系统,手动选择设定工作量比较轻松,当安装多台Linux,这些设定需要重复多次,这些重复动作是效率底下的操作。
#如何解决以上问题?#
用文件来记录所有安装过程中问题的答案,并让所有需要安装的主机自动读取
#kickstart作用#
以上解决方案中记录系统安装过程中所有问题答案的文件叫kickstart脚本
#### 二.实验环境 ####
1.主机名称 :nodea ip :172.25.254.34
2.DHCP配置完成
3.火墙,selinux关闭
4.httpd服务开启
5.配置软件仓库能正常工作
#### 三.kickstart自动安装脚本的制作 ####
在rhel7系统中提供图形的kickstart制作方式
在rhel8中已经把图形的工具取消,并添加到rhn网络中
在rhel8中如果无法通过rhn网络制作kickstart,可以使用模板生成
#通过模板生成kickstart文件#
在已经装好的rhel8中,/root/anaconda-ks.cfg 就是安装当前系统时回答的所有问题的答案
生成的kickstart,此文件为kickstart模板
操作步骤:
1.共享资源:
dnf install httpd -y
systemctl enable --now httpd
systemctl disable --now firewalld
setenforce 0 ##selinux调整为警告模式
mount /iso/rhel /var/www/html/source
#共享资源的意义#
在安装操作系统时,每个被安装的操作系统都要有安装资源
如果使用镜像安装,每个安装的系统都需要加载一个镜像
这样会浪费存储,通过网络来共享镜像中的资源,让安装系统的主机能通过
网络访问被共享的资源这样就可以解决多台主机需要多个镜像安装的问题
#用模板自作kickstart#
在已经装好的rhel8中,/root/anaconda-ks.cfg 就是安装当前系统时回答的所有问题的答案
生成的kickstart,此文件为kickstart模板
cp /root/anaconda-ks.cfg /var/www/html/anaconda-ks.cfg
vim /var/www/html/anaconda-ks.cfg
#version=RHEL8
ignoredisk --only-use=sda | ##只是用我们系统中的第一快硬盘 |
# Partition clearing information | |
# Partition clearing information clearpart --all --initlabel | ##把sda硬盘的所有内容删掉 |
# Use graphical install #graphical text | ##安装过程开启图形 |
repo --name="AppStream" --baseurl=http://172.25.254.20/westos_8/AppStream | ##软件安装资源 |
# Use netsource installation media url --url="http://172.25.254.20/westos_8" | ##系统安装资源 |
# Keyboard layouts keyboard --vckeymap=us --xlayouts='us' | ##键盘布局为美式键盘 |
# System language lang en_US.UTF-8 --addsupport=zh_CN.UTF-8 | ##系统支持的语言 |
# Network information network --bootproto=dhcp --device=ens160 --onboot=on --ipv6=auto --no-activate network --hostname=localhost.localdomain | ##网卡设定 ##主机名设定 |
# Root password rootpw --plaintext westos | |
# Root password authselect --enableshadow --passalgo=sha512 | ##系统默认开启的加密认证方式 |
# X Window System configuration information | |
#xconfig --startxonboot skipx | ##安装完成后开机启动图形 ##安装完成后开机不启动图形 |
# Run the Setup Agent on first boot firstboot --disable | ##首次启动初始化禁止 |
# System services services --disabled="chronyd,firewalld" --enabled="sshd" | ##在开机时开启或关闭的服务 |
# System timezone timezone Asia/Shanghai --isUtc --nontp | ##系统时区,启用utc计时方式,不其同ntp时间同步 |
#user --name=westos --
password=$6$W8HmY8FoDLmjcv65$Xo.SIxQ4rAWK19QBUvXP1et1us191K5w6GlIZvyEMaKx1FBK6EFTiwHC0X5DiktBfJzRsCyxDlmVemkSWfHl
--iscrypted --gecos="westos"
# Disk partitioning information part / --fstype="xfs" --grow --size=1 | ##让/分区使用全部空闲磁盘空间 |
reboot %packages @base httpd %end | ##安装软件组base |
#%pre | ##系统安装前自动执行的脚本 ##系统安装后自动执行的脚本 |
选择http安装: