cobbler

cobbler介绍

Cobbler是一个Linux服务器安装的服务,可以通过网络启动(PXE)的方式来快速安装、重装物理服务器和虚拟机,同时还可以管理DHCP,DNS等。

Cobbler可以使用命令行方式管理,也提供了基于Web的界面管理工具(cobbler-web),还提供了API接口,可以方便二次开发使用。

Cobbler是较早前的kickstart的升级版,优点是比较容易配置,还自带web界面比较易于管理。

Cobbler内置了一个轻量级配置管理系统,但它也支持和其它配置管理系统集成,如Puppet,暂时不支持SaltStack。
puppet是一种Linux、Unix、windows平台的集中配置管理系统,使用自有的puppet描述语言,可管理配置文件、用户、cron任务、软件包、系统服务等。puppet把这些系统实体称之为资源,puppet的设计目标是简化对这些资源的管理以及妥善处理资源间的依赖关系。

puppet采用C/S星状的结构,所有的客户端和一个或几个服务器交互。每个客户端周期的(默认半个小时)向服务器发送请求,获得其最新的配置信息,保证和该配置信息同步。每个puppet客户端每半小时(可以设置)连接一次服务器端, 下载最新的配置文件,并且严格按照配置文件来配置客户端. 配置完成以后,puppet客户端可以反馈给服务器端一个消息. 如果出错,也会给服务器端反馈一个消息

cobbler集成的服务

PXE服务支持
DHCP服务管理
DNS服务管理(可选bind,dnsmasq)
电源管理
Kickstart服务支持
YUM仓库管理
TFTP(PXE启动时需要)
Apache(提供kickstart的安装源,并提供定制化的kickstart配置)

cobbler配置文件详解


cobbler配置文件目录在/etc/cobbler
/etc/cobbler/settings.yaml	cobbler 主配置文件----->使用比较多
/etc/cobbler/iso/	iso模板配置文件
/etc/cobbler/pxe	pxe模板配置文件
/etc/cobbler/power	电源配置文件
/etc/cobbler/user.conf	 web服务授权配置文件
/etc/cobbler/users.digest	web访问的用户名密码配置文件
/etc/cobbler/dhcp.template	dhcp服务器的的配置模板----->使用比较多
/etc/cobbler/dnsmasq.template	dns服务器的配置模板
/etc/cobbler/tftpd.template	tftp服务的配置模板
/etc/cobbler/modules.conf	模块的配置文件

cobbler数据目录:
/var/lib/cobbler/config/	用于存放distros,system,profiles等信息配置文件
/var/lib/cobbler/triggers/	用于存放用户定义的cobbler命令
/var/lib/cobbler/kickstart/	默认存放kickstart文件
/var/lib/cobbler/loaders/	存放各种引导程序以及镜像目录
/var/www/cobbler/ks_mirror/	导入的发行版系统的所有数据
/var/www/cobbler/images/	导入发行版的kernel和initrd镜像用于远程网络启动
/var/www/cobbler/repo_mirror/	yum仓库存储目录


cobbler日志文件:
/var/log/cobbler/installing	客户端安装日志
/var/log/cobbler/cobbler.log	cobbler日志

cobbler命令详解:
cobbler check       //核对当前设置是否有问题
cobbler list        //列出所有的cobbler元素
cobbler report      //列出元素的详细信息
cobbler sync        //同步配置到数据目录,更改配置最好都要执行下
cobbler reposync    //同步yum仓库
cobbler distro      //查看导入的发行版系统信息
cobbler system      //查看添加的系统信息
cobbler profile     //查看配置信息

cobbler服务端部署

// 修改主机名并时钟同步
[root@node1 ~]# hostnamectl hostname server.example.com
[root@server ~]# yum -y install chrony
[root@server ~]# systemctl restart chronyd
[root@server ~]# systemctl enable chronyd
[root@server ~]# hwclock -w
[root@server ~]# timedatectl     //查看是否时钟同步


//安装软件包
[root@server ~]# yum -y install httpd dhcp* tftp tftp-server pykickstart rsync rsync-daemon
[root@server ~]# yum -y install cobbler cobbler-web
[root@server ~]# yum -y install cobbler-web --allowerasing

//启动服务并开机自启
[root@server ~]# systemctl restart httpd
[root@server ~]# systemctl enable httpd

[root@server ~]# systemctl restart rsyncd
[root@server ~]# systemctl enable rsyncd

[root@server ~]# systemctl restart  tftp
[root@server ~]# systemctl enable  tftp

[root@server ~]# systemctl restart  cobblerd
[root@server ~]# systemctl enable  cobblerd

//修改主配置文件
[root@server ~]# vim /etc/cobbler/settings.yaml 
server: 192.168.100.10   //本地cobblerd的IP地址
next_server: 192.168.100.10   //DHCP服务器调用
default_password_crypted: "$1$22200$UkZGcRHHwzAGRmP8YN9oX0"  //设置的密码
manage_dhcp: true  //打开DHCP
[root@server ~]# systemctl restart cobblerd.service   //重启服务

//设置密码
[root@server ~]# openssl passwd -1 -salt "$RANDOM"  'redhat'
$1$22200$UkZGcRHHwzAGRmP8YN9oX0
密码:$密码格式 $随机值$自定义密码
-salt  设置随机值

//检查
[root@server ~]# cobbler check
The following are potential configuration items that you may want to fix:

1: 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 package installed and can ignore this message entirely. Files in this directory, should you want to support all architectures, should include pxelinux.0, menu.c32, and yaboot.
2: reposync is not installed, install yum-utils or dnf-plugins-core
3: yumdownloader is not installed, install yum-utils or dnf-plugins-core
4: debmirror package is not installed, it will be required to manage debian deployments and repositories
5: fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them

Restart cobblerd and then run 'cobbler sync' to apply changes.

// 解决报错
解决问题1[root@server ~]# yum -y install syslinux*
[root@server ~]# cd /usr/share/syslinux/
[root@server syslinux]# cp pxelinux.0  /var/lib/cobbler/loaders
[root@server syslinux]# cp menu.c32  /var/lib/cobbler/loaders

解决问题2和解决问题3[root@server syslinux]# yum -y install yum-utils
问题4和问题5可以忽略
因为是debian系统才需要解决,显示使用的是centos8
Debian系统解决办法安装fence-agents

//修改DHCP的值
[root@server syslinux]# vim /etc/cobbler/dhcp.template 
subnet 192.168.100.0 netmask 255.255.255.0 {		//DHCP网段  与  网络掩码
     option routers             192.168.100.254;   //网关
     option domain-name-servers 114.114.114.114;	//DNS
     option subnet-mask         255.255.255.0;		//子网掩码
     range dynamic-bootp        192.168.100.200 192.168.100.210;  //自动分配的地址词
     default-lease-time         21600;		//租约时间
     max-lease-time             43200;		//最大租约时间
     next-server                $next_server;  //调用的值

//重启服务
[root@server syslinux]# systemctl restart httpd
[root@server syslinux]# systemctl restart cobblerd.service 

//同步
[root@server syslinux]#  cobbler sync

//使用图形化的镜像
[root@server ~]# mount /dev/cdrom /mnt/
[root@server mnt]# ls
AppStream  BaseOS  EFI  images  isolinux  LICENSE  media.repo

//导入镜像
[root@server ~]# cobbler import --path=/mnt/ --name=Rocky-9 arch=x86_64
--name  //名字
arch	//架构

//查看cobbler镜像列表和查看详细信息
[root@server ~]# cobbler list 
[root@server ~]# cobbler distro report --name  Rocky-9-x86_64  //详细信息

//创建自动安装脚本
[root@server ~]# cobbler profile get-autoinstall --name  Rocky-9-x86_64 > /var/lib/cobbler/templates/rocky9.ks

//修改添加/var/lib/cobbler/templates/rocky9.ks
firewall --enabled  //关闭防火墙
//设置yum仓库
repo --name=source-1 --baseurl="http://192.168.100.10/cobbler/distro_mirror/AppStream"
repo --name=source-2 --baseurl="http://192.168.100.10/cobbler/distro_mirror/BaseOS"
timezone  Aisa/Shanghai  //修改时区

# Enable installation monitoring
%end
%packages
@^minimal-environment  //最小化安装
%end

//执行脚本
[root@server ~]# cd /usr/share/cobbler/bin/
[root@server bin]# ls
migrate-data-v2-to-v3.py  migrate-settings.sh  mkgrub.sh  settings-migration-v1-to-v2.sh
[root@server bin]# bash mkgrub.sh 

//启动服务
[root@server bin]# cobbler sync   //同步
[root@server bin]# systemctl restart httpd
[root@server bin]# systemctl restart cobblerd.service 
[root@server bin]# systemctl restart dhcpd
[root@server bin]# systemctl enable dhcpd
[root@server bin]# systemctl restart tftp
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值