前言:
cobble的自动部署可以在,软件和硬件上使用dhcp广播的方式,自动部署系统,不用一台一台手动的安装操作系统,还可以使用web页面,定制专属的操作系统。
使用Rocky源
本机的ip地址是192.168.121.30,使用网卡NAT模式。更改主机名,关掉防火墙和selinux,做好时间同步。
# setenforce 0
# systemctl stop firewalld.service
# systemctl disable firewalld.service
# yum -y install httpd dhcp* tftp tftp-server pykickstart rsync rsync-daemon -----安装软件包,加粗的最后安装
# yum -y install cobbler-web --allowerasing
# systemctl restart httpd
[root@server ~]# systemctl enable httpd ---重启,下次自启动httpd服务
rsyncd, tftp,cobblerd这三个也设置下次启动生效,并重启
# vim /etc/cobbler/settings.yaml -----更改四个地方
---更改主机IP地址和密码,登录用户的,一开始随机
/server:192.168.121.30 更改服务主机IP地址
/next_server: 192.168.121.30
/default_pass 更改随机密码
/maage_chcp true 开启dhcp
# openssl passwd -1 -salt "ZZ" '123' ---生成MD5加密的密码123,复制到default_pass里面
#systemctl restart cobb 重启服务
# cobbler check ----解决五个问题
# yum -y install syslinux*
# cd /usr/share/syslinux/
[root@cobbler syslinux]# cp pxelinux.0 /var/lib/cobbler/loaders/
[root@cobbler syslinux]# cp menu.c32 /var/lib/cobbler/loaders/
# yum -y install yum-utils 解决问题
# vim /etc/cobbler/dhcp.template 配置地址池
subnet 192.168.121.0 netmask 255.255.255.0 {
option routers 192.168.121.2; #本机网卡的网关
option domain-name-servers 8.8.8.8;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.121.100 192.168.121.200;
default-lease-time 21600;
max-lease-time 43200;
#systemctl restart httpd
#systemctl restart cobblerd.service
#cobbler sync 同步
#systemctl restart dhcpd
将镜像断开,换成图形化的镜像
#mount /dev/cd /mnt
# cobbler import --path=/mnt/ --name=Rocky-9 carch=x86_64 生成镜像
# cobbler distro report --name Rocky-9-x86_64 查看镜像
# cobbler profile get-autoinstall --name Rocky-9-x86_64 > /var/lib/cobbler/templates/rocky9.ks 生成版本文件信息
#vim /var/lib/cobbler/templates/rocky9.ks
# Firewall configuration
firewall --disabled
# Run the Setup Agent on first boot
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# Use network installation
url --url=http://192.168.121.30/cblr/links/Rocky-9-x86_64
# If any cobbler repo definitions were referenced in the kickstart profile, include them here.
repo-name=source-1 --baseurl="http://192.168.121.30/cobbler/distro_mirror/AppStream"
repo-name=source-2 --baseurl="http://192.168.121.30/cobbler/distro_mirror/BaseOS"
repo --name=source-1 --baseurl="http://192.168.121.30/cobbler/distro_mirror/AppStream"
repo --name=source-2 --baseurl="http://192.168.121.30/cobbler/distro_mirror/BaseOS"
@^minimal-environment@^minimal-environment
# cd /usr/share/cobbler/bin/
# bash mkgrub.sh -----运行python脚本
[root@cobbler ~]# systemctl restart cobblerd.service
[root@cobbler ~]# systemctl restart dhcpd
[root@cobbler ~]# systemctl restart httpd
[root@cobbler ~]# systemctl restart tftp
[root@cobbler ~]# systemctl enable tftp
[root@cobbler ~]# cobbler sync
重开一台虚拟机,连接到NAT网卡,出现自动部署