cobbler-2.8.5
一、关闭防火墙、SELINUX
systemctl disable firewalld //禁止防火墙服务启动
systemctl stop firewalld //关闭防火墙服务
vi /etc/sysconfig/selinux //更改为“SELINUX=disabled”
# getenforce 0//临时关闭SELINUX
# setenforce 0//临时关闭SELINUX
二、更新源
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
yum clean all && yum makecache
四、安装ntp客户端、同步阿里云时间
yum install -y ntp
ntpdate ntp1.aliyun.com
hwclock -w
hwclock
五、安装Cobbler所需相关软件
yum install fence-agents -y
yum install cobbler cobbler-web dhcp tftp-server pykickstart httpd xinetd debmirror -y
六、修改相关的配置文件
1、编辑/etc/httpd/conf/httpd.conf的文件,然后启动httpd服务。
vi /etc/httpd/conf/httpd.conf
systemctl start httpd
systemctl enable httpd

2、编辑/etc/xinetd.d/tftp的文件,然后启动xinetd服务。
vi /etc/xinetd.d/tftp
systemctl start xinetd && systemctl enable xinetd

3、编辑/etc/cobbler/settings文件。
vi /etc/cobbler/settings
在一般模式下直接输入所在行的数字,然后按两下g键跳到指定行。照下面提示修改。
需注意的是:next_server和server的冒号后面有一个空格,不加否则后面会出错
Line:242 manage_dhcp: 1 ##开启DHCP可管理状态
Line:258 manage_tftpd: 1 ##开启tftp管理
Line:261 manage_rsync: 1 ##开启rsync管理
Line:272 next_server: 192.168.1.37 ##你自己的ip
Line:292 pxe_just_once: 1 ##PXE安装 只允许一次,防止误操作
Line:358 restart_dns: 1
Line:359 restart_dhcp: 1
Line:384 server: 192.168.1.37
4、编辑/etc/debmirror.conf文件
vi /etc/debmirror.conf //注释两条内容

5、设置密码,并将/etc/cobbler/settings里默认密码替换掉。
openssl passwd -1 -salt '' 'root' //生成密码,这里设置密码为“root”
vi /etc/cobbler/settings

6、编辑/etc/cobbler/dhcp.template文件。
vi /etc/cobbler/dhcp.template

七、启动cobbler服务
systemctl start cobblerd && systemctl enable cobblerd && systemctl start rsyncd && systemctl enable rsyncd
八、下载bootloader所需文件
cobbler get-loaders # 2.8.5 版本,该命令已移除,x86_64架构安装 yum install syslinux
九、检查服务 查看缺失
cobbler check
防火墙关闭了,/etc/sysconfig/selinux配置文件也修改了,那么这个问题可以忽略掉不管。
十、创建文件夹存放镜像
上传镜像并挂载
mount -o loop /media/iso/CentOS-7-x86_64-DVD-1908.iso /media/cdrom/
cobbler import --name=centos7 --arch=x86_64 --path=/media/cdrom
# 导入镜像此命令耗时会很长,需要静静等待……
# --path 镜像路径
# --name 为安装源定义一个名字
# --arch 指定安装源是32位、64位、ia64, 目前支持的选项有: x86│x86_64│ia64
编辑ks文件
cobbler profile edit --name=centos7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos7.ks --kopts='net.ifnames=0 biosdevname=0'
十一、执行同步、启动dhcp服务
systemctl restart rsyncd && systemctl restart xinetd && systemctl restart cobblerd && systemctl enable httpd && systemctl restart dhcpd //重启所有服务
cobbler sync //执行同步
systemctl start dhcpd //启动dhcp
十二、界面化展示
1、新建一台全新的虚拟机,选择好自己的虚拟网卡且不要选择镜像,然后开启虚拟机。
在这里插入图片描述
2、在出现的界面中选择镜像,静静等待加载即可。
十二、定制启动界面
cat /var/lib/tftpboot/pxelinux.cfg/default
修改PXE默认启动选项
默认情况下PXE启动的是Local(启动后会出现local和自定义CentOS7.5-x86_64两个选项,需手动,要无人工干涉,就需要修改)
修改前

修改后

默认时间可修改
不用cobbler sync,否则会恢复原来的配置,编辑ks文件也会覆盖.
十三、参考命令
cobbler profile edit --name=CentOS7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS7.ks
cobbler profile edit --name=CentOS7-x86_64 --kopts='net.ifnames=0 biosdevname=0'
cobbler sync
systemctl enable rsyncd && systemctl enable xinetd && systemctl enable cobblerd && systemctl enable httpd && systemctl enable dhcpd
systemctl restart rsyncd && systemctl restart xinetd && systemctl restart cobblerd && systemctl enable httpd && systemctl restart dhcpd
##########
十四、KS文件参考
# Install OS instead of upgrade
install
# Use CDROM installation media
url --url=$tree
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'
#Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# System timezone
timezone Asia/Shanghai --isUtc --nontp
# System language
lang en_US.UTF-8
# System authorization information
auth --enableshadow --passalgo=sha512
# Root password
rootpw --iscrypted $default_password_crypted
# Use text mode install
text
# System bootloader configuration
bootloader --location=mbr --boot-drive=sda
# Run the Setup Agent on first boot
firstboot --disabled
ignoredisk --only-use=sda
# Network information
network --hostname=localhost.localdomain
# System services
services --disabled="chronyd"
# Disk partitioning information
part biosboot --fstype="biosboot" --ondisk=sda --size=2
part /boot --fstype="xfs" --ondisk=sda --size=1024
part pv.01 --fstype="lvmpv" --ondisk=sda --size=1 --grow
volgroup centos --pesize=4096 pv.01
logvol swap --fstype="swap" --size=2048 --name=swap --vgname=centos
logvol / --fstype="xfs" --size=1 --grow --name=root --vgname=centos
# SELinux configuration
selinux --disabled
#Firewall configuration
firewall --disabled
# Do not configure the X Window System
skipx
# Reboot after installation
reboot
%packages
@^minimal
@core
@base
@compat-libraries
@debugging
@development
%end
%addon com_redhat_kdump --disable --reserve-mb='auto'
%end
%post
systemctl disable postfix
rm -rf /etc/yum.repos.d/*.repo
cat > /etc/yum.repos.d/CentOS-Media.repo <<EOF
[c7-media]
name=name=CentOS-$releasever - Media
baseurl=http://192.168.77.128/centos7/
gpgcheck=0
enabled=1
EOF
yum install chrony device-mapper device-mapper-multipath wget vim curl lrzsz lsof -y
cat > /etc/chrony.conf <<EOF
server 192.168.77.128 iburst
EOF
systemctl start chronyd
systemctl disable chronyd
chronyc -a makestep
wget http://192.168.77.128/scripts/local_hw_sysinit_centos7-straight.sh
chmod +x *.sh
bash local_hw_sysinit_centos7-straight.sh
wget -O /etc/yum.repos.d/epel.repo http://192.168.77.128/repo/epel-7.repo
wget -O /etc/yum.repos.d/CentOS-Base.repo http://192.168.77.128/repo/Centos-7.repo
sed -i 's/enabled=1/enabled=0/' /etc/yum.repos.d/CentOS-Media.repo
%end
参考
https://hellogitlab.com/OS/Cobbler/
浙公网安备 33010602011771号