本次虚拟化环境为VMware Workstation Pro,cobbler服务端为CentOS7.9,需要自动安装的版本为CentOS7.9和CentOS8.1
目录
- 一、安装cobbler服务端
- 1、修改YUM源
- 2、关闭防火墙
- 3、安装软件包
- 4、cobbler环境配置
- 5、解决语法问题
- 6、启动服务
- 7、导入镜像
- 8、自定义ks文件
- 9、修改启动菜单
- 10、自动安装操作系统
- 二、配置多版本自动安装系统
- 1、导入镜像
- 2、自定义ks文件
- 3、修改启动菜单
- 4、自动安装操作系统
一、安装cobbler服务端
1、修改YUM源
如果是内网服务器,有本地YUM源
cd /etc/yum.repos.d/
mkdir ./repobak
mv ./*.repo ./repobak/
上传repo文件
yum clean all
yum makecache
yum repolist
如果有外网环境直接下载公网源
cd /etc/yum.repos.d/
mkdir ./repobak
mv ./*.repo ./repobak/
curl -O https://mirrors.aliyun.com/repo/Centos-7.repo
curl -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
2、关闭防火墙
关闭防火墙,selinux
systemctl stop firewalld.service
systemctl disable firewalld.service
vim /etc/selinux/config
3、安装软件包
yum install -y httpd dhcp xinetd tftp-server cobbler cobbler-web
cobbler语法检查前先启动http与cobbler
systemctl start httpd.service
systemctl start cobblerd.service
4、cobbler环境配置
cobbler check
The following are potential configuration items that you may want to fix:
1 : The 'server' field in /etc/cobbler/settings must be set to something other than localhost, or kickstarting features will not work. This should be a resolvable hostname or IP for the boot server as re achable by all machines that will use it.
2 : For PXE to be functional, the 'next_server' field in /etc/cobbler/settings must be set to something other than 127.0.0.1, and should match the IP of the boot server on the PXE network.
3 : change 'disable' to 'no' in /etc/xinetd.d/tftp
4 : Some network boot-loaders are missing from /var/lib/cobbler/loaders. If you only want to handle x86/x86_64 netbooting, you may ensure that you have installed a *recent* version of the syslinux packag e installed and can ignore this message entirely. Files in this directory, should you want to support all architectures, should include pxelinux.0, menu.c32, elilo.efi, and yaboot.
5 : enable and start rsyncd.service with systemctl
6 : debmirror package is not installed, it will be required to manage debian deployments and repositories
7 : The default password used by the sample templates for newly installed machines (default_password_crypted in /etc/cobbler/settings) is still set to 'cobbler' and should be changed, try: "openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'" to generate new one
Restart cobblerd and then run 'cobbler sync' to apply changes.
5、解决语法问题
第1、2条
vim /etc/cobbler/settings
manage_dhcp: 1
next_server: 192.168.241.128
server: 192.168.241.128
manage_rsync: 1
pxe_just_once: 1
第3条
vim /etc/xinetd.d/tftp
wait = no
disable = no
第4条
/var/lib/cobbler/loaders 中缺少一些网络引导加载器。如果只想处理 x86/x86_64 网络引导,则可以确保已安装 syslinux 包的最新版本,并且可以完全忽略此消息。如果想要支持所有体系结构,此目录中的文件应包括 pxelinux.0、menu.c32、elilo.efi 和 yaboot。
yum -y install syslinux
安装syslinux,不需要支持所有架构,便不用理会该警告
第5条
systemctl start rsyncd
systemctl enable rsyncd
第6条
yum install -y pykickstart debmirror
vi /etc/debmirror.conf #注释掉 @dists 和 @arches 两行
#@dists="sid";
#@arches="i386";
第7条
openssl passwd -1 -salt 'cobbler' '123456'
得到
1
1
1cobbler$sqDDOBeLKJVmxTCZr52/11
vim /etc/cobbler/settings
default_password_crypted: "$1$cobbler$sqDDOBeLKJVmxTCZr52/11"
cp /etc/cobbler/dhcp.template /etc/cobbler/dhcp.template.bak
vim /etc/cobbler/dhcp.template
systemctl restart cobblerd.service
cobbler sync
cobbler check
6、启动服务
systemctl status httpd dhcpd rsyncd tftp cobblerd
systemctl start httpd dhcpd rsyncd tftp cobblerd
systemctl enable httpd dhcpd rsyncd tftp cobblerd
7、导入镜像
导入镜像到cobbler服务端中
上传镜像,挂载镜像
mkdir /mnt/centos7.9
mount CentOS-7.9-x86_64-Everything-2207-02.iso /mnt/centos7.9
cobbler import --path=/mnt/centos7.9 --name=CentOS-7.9-x86_64-Everything-2207-02 --arch=x86_64
8、自定义ks文件
cd /var/lib/cobbler/kickstarts/
ll
vim centos7u9.ks
以服务器版为例
#Kickstart Configurator for cobbler by KE HUIWEN
#platform=x86, AMD64, or Intel EM64T
#System language
lang en_US
#System keyboard
keyboard us
#Sytem timezone
timezone Asia/Shanghai
#Root password
rootpw --iscrypted $default_password_crypted
#Use text mode install
text
#Install OS instead of upgrade
install
#Use NFS installation Media
url --url=$tree
#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 1024 --ondisk sda
part swap --fstype="swap" --size 4096 --ondisk sda
part / --fstype xfs --size 1 --grow --ondisk sda
#System authorization infomation
auth --useshadow --enablemd5
#Network information
$SNIPPET('network_config')
# network --bootproto=dhcp --device=eth0 --onboot=on
# Reboot after installation
reboot
#Firewall configuration
firewall --disabled
#SELinux configuration
selinux --disabled
#Do not configure XWindows
skipx
#Package install information
%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%end
%packages
@^infrastructure-server-environment
@base
@compat-libraries
@core
@debugging
@development
@directory-client
@guest-agents
@ha
@hardware-monitoring
@infiniband
@java-platform
@large-systems
@load-balancer
@network-file-system-client
@performance
@remote-system-management
@resilient-storage
@security-tools
@smart-card
@system-admin-tools
@virtualization-hypervisor
kexec-tools
%end
%post
systemctl disable postfix.service
%end
#指定启动文件,要手写,不要复制
cobbler profile edit --name "CentOS-7.9-Everything-2207-02-x86_64" --kickstart=/var/lib/cobbler/kickstarts/centos7u9.ks
#修改centos配置文件中的kickstart值
cobbler profile edit --name=CentOS-7.9-Everything-2207-02-x86_64 --kopts='net.ifnames=0 biosdevname=0'
cobbler sync #执行rsync同步,同步成功
查看kickstart 关联是否成功,注意是否修改成功
cobbler profile report
9、修改启动菜单
cobbler system add --name=default --profile=CentOS-7.9-Everything-2207-02-x86_64
cobbler system list
cobbler sync
cat /var/lib/tftpboot/pxelinux.cfg/default
DEFAULT menu
PROMPT 0
MENU TITLE Cobbler | http://cobbler.github.io/
TIMEOUT 200
TOTALTIMEOUT 6000
ONTIMEOUT CentOS-7.9-Everything-2207-02-x86_64
LABEL local
MENU LABEL (local)
MENU DEFAULT
LOCALBOOT -1
LABEL CentOS-7.9-Everything-2207-02-x86_64
kernel /images/CentOS-7.9-Everything-2207-02-x86_64/vmlinuz
MENU LABEL CentOS-7.9-Everything-2207-02-x86_64
append initrd=/images/CentOS-7.9-Everything-2207-02-x86_64/initrd.img ksdevice=bootif lang= text net.ifnames=0 biosdevname=0 kssendmac ks=http://10.49.33.206/cblr/svc/op/ks/profile/CentOS-7.9-Everything-2207-02-x86_64
ipappend 2
MENU end
10、自动安装操作系统
新建虚拟机,安装客户机操作系统界面时选择稍后安装操作系统
开启虚拟机,选择镜像安装
等待安装完成
二、配置多版本自动安装系统
1、导入镜像
上传镜像,挂载镜像
mkdir /mnt/centos8.1
mount CentOS-8.1.1911-x86_64-dvd1.iso /mnt/centos8.1
cobbler import --path=/mnt/centos8.1 --name=CentOS-8.1.1911-x86_64-dvd1 --arch=x86_64
2、自定义ks文件
cd /var/lib/cobbler/kickstarts/
ll
vim centos8u1.ks
#安装服务器版centos
注意安装包会有所不同
#Kickstart Configurator for cobbler by KE HUIWEN
#platform=x86, AMD64, or Intel EM64T
#System language
lang en_US
#System keyboard
keyboard us
#Sytem timezone
timezone Asia/Shanghai
#Root password
rootpw --iscrypted $default_password_crypted
#Use text mode install
text
#Install OS instead of upgrade
install
#Use NFS installation Media
url --url=$tree
#System bootloader configuration
bootloader --location=mbr --boot-drive=sda
#Clear the Master Boot Record
zerombr
#Partition clearing information
clearpart --all --initlabel
#Disk partitioning information
part /boot --fstype xfs --size 1024 --ondisk sda
part swap --fstype="swap" --size 4096 --ondisk sda
part / --fstype xfs --size 1 --grow --ondisk sda
#System authorization infomation
auth --useshadow --enablemd5
#Network information
$SNIPPET('network_config')
# network --bootproto=dhcp --device=eth0 --onboot=on
# Reboot after installation
reboot
#Firewall configuration
firewall --disabled
#SELinux configuration
selinux --disabled
#Do not configure XWindows
skipx
#Package install information
%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%end
%packages
@base
@core
@desktop-debugging
@dial-up
@fonts
@gnome-desktop
@guest-desktop-agents
@input-methods
@internet-browser
@java-platform
@multimedia
@network-file-system-client
@print-client
binutils
ftp
gcc
kernel-devel
kexec-tools
make
mesa-libxatracker
open-vm-tools
patch
xorg-x11-drv-vmware
%end
%post
systemctl disable postfix.service
%end
#指定启动文件,要手写,不要复制
cobbler profile edit --name "CentOS-8.1.1911-dvd1-x86_64" --kickstart=/var/lib/cobbler/kickstarts/centos8u1.ks
#修改centos配置文件中的kickstart值
cobbler profile edit --name=CentOS-8.1.1911-dvd1-x86_64 --kopts='net.ifnames=0 biosdevname=0'
cobbler sync #执行rsync同步,同步成功
查看kickstart 关联是否成功,注意是否修改成功
cobbler profile report
3、修改启动菜单
cobbler system add --name=centos8u1 --profile=CentOS-8.1.1911-dvd1-x86_64
cobbler system list
cobbler sync
cat /var/lib/tftpboot/pxelinux.cfg/default
DEFAULT menu
PROMPT 0
MENU TITLE Cobbler | http://cobbler.github.io/
TIMEOUT 200
TOTALTIMEOUT 6000
ONTIMEOUT CentOS-7.9-Everything-2207-02-x86_64
LABEL local
MENU LABEL (local)
MENU DEFAULT
LOCALBOOT -1
LABEL CentOS-7.9-Everything-2207-02-x86_64
kernel /images/CentOS-7.9-Everything-2207-02-x86_64/vmlinuz
MENU LABEL CentOS-7.9-Everything-2207-02-x86_64
append initrd=/images/CentOS-7.9-Everything-2207-02-x86_64/initrd.img ksdevice=bootif lang= text net.ifnames=0 biosdevname=0 kssendmac ks=http://192.168.241.128/cblr/svc/op/ks/profile/CentOS-7.9-Everything-2207-02-x86_64
ipappend 2
LABEL CentOS-8.1.1911-dvd1-x86_64
kernel /images/CentOS-8.1.1911-dvd1-x86_64/vmlinuz
MENU LABEL CentOS-8.1.1911-dvd1-x86_64
append initrd=/images/CentOS-8.1.1911-dvd1-x86_64/initrd.img ksdevice=bootif lang= text net.ifnames=0 biosdevname=0 kssendmac ks=http://192.168.241.128/cblr/svc/op/ks/profile/CentOS-8.1.1911-dvd1-x86_64
ipappend 2
MENU end
4、自动安装操作系统
新建虚拟机,操作如上1.10,选择CentOS-8.1
等待自动安装
安装完成