Cobbler自动化装机
Cobbler服务构建
Cobbler与PXE的不同点
Cobbler是红帽公司研发的基于PXE技术的装机服务,可以选择性安装多个不同的操作系统;
Cobbler优点
搭建更为简单,管理更为便捷;
能选择系统版本进行安装;
Cobbler与PXE如何选择
PXE:适合环境中只需要安装同一操作系统即可,并且开机后不需介入;
Cobbler:适合环境中有多种操作系统的需求,开机后需人员选择安装的操作系统版本;
Cobbler安装记录
`
配置epel yum源
yum install -y epel-release
安装cobbler所需依赖软件
yum install -y cobbler cobbler-web pykickstart debmirror
开启apache服务,即是管理页面也是镜像分享服务
systemctl restart httpd && systemctl enable httpd
开启Cobbler服务
systemctl start cobblerd && systemctl enable cobblerd
netstat -an |grep 25151
修改Cobbler主配置文件,10.10.10.11为本机IP
sed -i 's/^server./server: 10.10.10.11/' /etc/cobbler/settings
sed -i 's/^next_server./next_server: 10.10.10.11/' /etc/cobbler/settings
关闭防火墙和selinux
systemctl stop firewalld.service && systemctl disablefirewalld.service
sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config && setenforce 0
向代码主站发起获取必备数据
cobbler get-loaders
开启rsync,Cobbler借助rsync进行目录之间的内容同步
systemctl restart rsyncd && systemctl enable rsyncd
关闭非常规系统以及32位系统的安装
vim /etc/debmirror.conf
注释下边这两行
@dists="sid";
@arches="i386";
创建与系统加密方案一致的密码,用于系统初始化密码
openssl passwd -1 -salt $(openssl rand -hex 4)
$1$92172ed7$yaxqV0iSrpKRmPsQStZnZ1
设置默认密码
vim /etc/cobbler/settings
default_password_crypted: "$1$92172ed7$yaxqV0iSrpKRmPsQStZnZ1"
安装cobbler隔离机制,防止重复安装,centos7中没有cman报错正常
yum install cman fence-agents -y
开启tftp服务器,centos7中需要安装xinetd软件包
yum install xinetd -y
vim /etc/xinetd.d/tftp
disable = no
systemctl restart xinetd && systemctl enable xinetd
systemctl restart tftp && systemctl enable tftp
systemctl restart cobblerd
进行自动同步文件
cobbler sync
进行cobbler自检
cobbler check
配置并开启dhcp服务
yum install -y dhcp
vim /etc/dhcp/dhcpd.conf
option domain-name "chinasoft.com";
option domain-name-servers 114.114.114.114,8.8.8.8;
default-lease-time 43200;
max-lease-time 86400;
log-facility local7;
subnet 10.10.10.0 netmask 255.255.255.0 {
range 10.10.10.100 10.10.10.200;
option routers 10.10.10.11;
}
next-server 10.10.10.11;
filename="pxelinux.0";
systemctl restart dhcpd && systemctl enable dhcpd
systemctl restart cobblerd
导入镜像文件至Cobbler服务中
导入centos7.6镜像
mkdir /mnt/cdrom
mount -t iso9660 /dev/cdrom /mnt/cdrom/
cobbler import --name="centos7.6" --path=/mnt/cdrom/
导入centos6.8镜像
umount /mnt/cdrom/
mount /dev/cdrom /mnt/cdrom/
cobbler import --name="centos6.8" --path=/mnt/cdrom/
可以通过访问http://IP/cobbler 看到文件列表
http://10.10.10.11/cobbler/ks_mirror/centos7.6/
查看已导入镜像
cobbler distro list
查看默认自带的ks文件,默认自带的ks文件不能做网络装机
cobbler profile list
删除对应的默认ks文件
cobbler profile remove --name=centos7.6-x86_64
cobbler profile remove --name=centos6.8-x86_64
删除导入的镜像
cobbler distro remove --name=centos7.6-x86_64
Centos7生成ks文件
yum install -y system-config-kickstart
system-config-kickstart
修改ks文件
vim centos76-x86_64.cfg
rootpw --iscrypted $default_password_crypted
url --url="http://10.10.10.11/cobbler/ks_mirror/centos7.6/"
vim centos68-x86_64.cfg
rootpw --iscrypted $default_password_crypted
url --url="http://10.10.10.11/cobbler/ks_mirror/centos6.8/"
拷贝ks文件至默认ks存放目录
mv centos76-x86_64.cfg /var/lib/cobbler/kickstarts/
mv centos68-x86_64.cfg /var/lib/cobbler/kickstarts/
将已导入镜像文件与ks文件进行匹配
cobbler profile add --name=centos6.8-basic --distro=centos6.8-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos68-x86_64.cfg
cobbler profile add --name=centos7.6-basic --distro=centos7.6-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos76-x86_64.cfg
装机验证,需要选择安装的操作系统
`