文章目录
1. cobbler介绍
Cobbler是一个Linux服务器安装的服务,可以通过网络启动(PXE)的方式来快速安装、重装物理服务器和虚拟机,同时还可以管理DHCP,DNS等。
Cobbler可以使用命令行方式管理,也提供了基于Web的界面管理工具(cobbler-web),还提供了API接口,可以方便二次开发使用。
Cobbler是较早前的kickstart的升级版,优点是比较容易配置,还自带web界面比较易于管理。
Cobbler内置了一个轻量级配置管理系统,但它也支持和其它配置管理系统集成,如Puppet,暂时不支持SaltStack。
cobbler集成的服务
- PXE服务支持
- DHCP服务管理
- DNS服务管理(可选bind,dnsmasq)
- 电源管理
- Kickstart服务支持
- YUM仓库管理
- TFTP(PXE启动时需要)
- Apache(提供kickstart的安装源,并提供定制化的kickstart配置)
cobbler配置文件详解
cobbler配置文件目录在/etc/cobbler
配置文件 | 作用 |
---|---|
/etc/cobbler/settings | 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 //查看配置信息
2. CentOS7 cobbler服务端部署与装机流程
2.1 CentOS7服务端部署
环境说明:
centos7系统,20G硬盘,4G内存
#关闭防火墙
[root@cobbler ~]# systemctl disable --now firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@cobbler ~]# setenforce 0
[root@cobbler ~]# sed -ri 's/^(SELINUX=).*/\1disabled/g' /etc/selinux/config
#系统重启
[root@cobbler ~]# reboot
#安装基础软件,epel源
[root@cobbler ~]# yum -y install dnf vim tree epel-release
#安装cobbler以及相关的软件
[root@cobbler ~]# yum -y install httpd dhcp tftp xinetd pykickstart cobbler cobbler-web python-ctypes
[root@cobbler ~]# yum list all|grep cobbler
cobbler.x86_64 2.8.5-6.el7 @epel
cobbler-web.noarch 2.8.5-6.el7 @epel
#启动服务并设置开机自启
[root@cobbler ~]# systemctl enable --now httpd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@cobbler ~]# systemctl enable --now cobblerd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/cobblerd.service to /usr/lib/systemd/system/cobblerd.service.
[root@cobbler ~]# systemctl enable --now rsyncd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/rsyncd.service to /usr/lib/systemd/system/rsyncd.service.
#修改cobbler的配置文件,设置ip,密码加密(需提前生成),开启管理dhcp
[root@cobbler ~]# openssl passwd -1 -salt "$RANDOM" '123456'
$1$13003$X2YFLae3fUQ0Tw0Y3MKHf0 //此密码会添加到下面的配置文件
[root@cobbler ~]# vim /etc/cobbler/settings
next_server: 192.168.177.141 //此处需改成cobbler服务器的IP,即本机IP
# of the manpage for how that works.
server: 192.168.177.141 //此处需改成cobbler服务器的IP,即本机IP
# set to 1 to enable Cobbler's DHCP management features.
# the choice of DHCP management engine is in /etc/cobbler/modules.conf
manage_dhcp: 1 //此处改成1 让cobbler管理dhcp服务
# set to 1 to enable Cobbler's TFTP management features.
# the choice of TFTP mangement engine is in /etc/cobbler/modules.conf
manage_tftpd: 1 //此处改成1 让cobbler管理tftp服务
# set to 1 to enable Cobbler's RSYNC management features.
manage_rsync: 1 //此处改成1 让cobbler管理rsync服务
# and put the output between the "" below.
default_password_crypted: "$1$13003$X2YFLae3fUQ0Tw0Y3MKHf0" //此处改成加密的密码
#重启服务后,cobbler check 检查,保证完全配置cobbler
[root@cobbler ~]# systemctl restart httpd.service
[root@cobbler ~]# systemctl restart cobblerd.service
[root@cobbler ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 5 127.0.0.1:25151 *:*
LISTEN 0 5 *:873 *:*
LISTEN 0 128 [::]:80 [::]:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 100 [::1]:25 [::]:*
LISTEN 0 128 [::]:443 [::]:*
LISTEN 0 5 [::]:873 [::]:*
[root@cobbler ~]# cobbler check
The following are potential configuration items that you may want to fix:
1 : change 'disable' to 'no' in /etc/xinetd.d/tftp
//在 /etc/xinetd.d/tftp 中将“disable”更改为“n0”
2 : 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, elilo.efi, and yaboot.
//cobbler服务需要一些文件,要么你安装syslinux然后忽略这些文件,要么执行命令cobbler get-loaders,这个是最简单的方法了。包括的文件为:pxelinux.0, menu.c32, elilo.efi, and yaboot
3 : debmirror package is not installed, it will be required to manage debian deployments and repositories
//deb包管理器没安装,可能某些软件安装的时候需要它,因为是centos系统,该项可以忽略
4 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them
//需要fencing tools,以管理optional;安装cman或者fence-agents 并使用它们。
Restart cobblerd and then run 'cobbler sync' to apply changes.
#将上述1,2,4问题解决 并重启cobbler服务
[root@cobbler ~]# vim /etc/xinetd.d/tftp
disable = no
[root@cobbler ~]# yum -y install fence-agents
[root@cobbler ~]# cobbler get-loaders
No such command: get-loaders
//配置出现报错 我去网上查了很多,有人给出的建议是因为需要相关引导文件 pxelinux.0(引导文件)和menu.c32(菜单文件),这两个文件是从sysliunx里面来的,所以复制之前,先要保证安装好好syslinux,再进行复制,于是继续尝试
[root@cobbler ~]# yum -y install syslinux
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Package syslinux-4.05-15.el7.x86_64 already installed and latest version
Nothing to do
[root@cobbler ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/cobbler/loaders/
[root@cobbler ~]# cp /usr/share/syslinux/menu.c32 /var/lib/cobbler/loaders/
[root@cobbler ~]# systemctl restart cobblerd.service
[root@cobbler ~]# cobbler get-loaders
No such command: get-loaders
//依旧没解决,这个问题困扰了我很长时间,经过多方查阅资料和实验,我终于明白了整个问题所在:在我安装的cobbler版本中,压根就不支持使用该命令下载引导启动文件!尽管cobbler check命令依然报错,但是我们可以不用理会该报错,直接进行cobbler的下一步配置即可!
[root@cobbler ~]# 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