Cobbler简介


Cobbler这个英文翻译过来的意思是补鞋匠,为什么会是补鞋匠的意思,很简单,因为它简单得连补鞋匠都能学会安装系统。

Cobbler通过将部署系统所涉及的所有服务集中在一起,来提供一个全自动批量快速建立Linux系统的网络安装环境。

在学习Cobbler之前可以看看PXE无人值守安装系统。


Cobbler特点:

·Cobbler支持多种Linux操作系统得快速部署,对PXE、DHCP、HTTP、TFTP、Kiskstart、YUM仓库、电源等进行统一管理

·Cobbler提供实现不同用户需求得可定制系统部署方案

·Cobbler分别提供命令管理和Web界面管理、方便Cobbler管理员使用。


部署准备:

·VMware虚拟机

·Cobbler服务器(我这里是Ctenos7)

·在虚拟机中网络连接改为NAT模式、IP地址为:192.168.106.131

·Cobbler源码包epel-release-latest-7.noarch.rpm 密码:9sxj


部署开始:

·安装epel-release-latest-7.noarch软件包(Cobbler是由这个软件包提供服务得,源码包在准备前提供了连接。可以用共享或者其他工具存放到 Linux中

[root@localhost ~]# rpm -ivh epel-release-latest-7.noarch.rpm 


·挂载自己的镜像文件到 /mnt 目录下

[root@localhost ~]# mount /dev/sr0 /mnt


·因为后面需要用YUM安装服务,这里需要重新加载YUM仓库

[root@localhost ~]# yum list


·安装cobbler cobbler-web dhcp tftp-sever pykickstart httpd rsync xinetd服务,这些包都需要安装哦!

[root@localhost ~]# yum install cobbler cobbler-web dhcp tftp-sever pykickstart httpd rsync xinetd -y


·修改cobbler主配置文件

[root@localhost ~]# vim /etc/cobbler/settings


next_server: 192.168.106.131     #指定cobbler服务器地址

server:192.168.106.131            #指定TFTP服务器地址(因为tftp在cobbler中,所以指向的地址都一样)

manage_dhcp: 1     #把对dhcp管理服务开启(1:开启 0:关闭)


·启动httpd服务、启动Cobblerd服务、关闭防火墙

[root@localhost ~]# systemctl start httpd.service

[root@localhost ~]# systemctl start cobblerd.service

[root@localhost ~]# systemctl disable firewalld.service

[root@localhost ~]# setenforce 0


·对cobbler做检查设置

[root@localhost ~]# cobbler check


1 : SELinux is enabled. Please review the following wiki page for details on ensuring cobbler works correctly in your SELinux environment:

    https://github.com/cobbler/cobbler/wiki/Selinux

2 : change 'disable' to 'no' in /etc/xinetd.d/tftp

3 : Some network boot-loaders are missing from /var/lib/cobbler/loaders, you may run 'cobbler get-loaders' to download them, or, 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. The 'cobbler get-loaders' command is the easiest way to resolve these requirements.

4 : enable and start rsyncd.service with systemctl

5 : debmirror package is not installed, it will be required to manage debian deployments and repositories

6 : 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

7 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them


·接下来我们需要对上述检查结果进行修改。修改tftp配置文件

[root@localhost ~]# vim /etc/xinetd.d/tftp

disable                 = no#开启tftp服务


·启动远程同步服务、重启cobbler服务

[root@localhost ~]# systemctl enable rsyncd.service

[root@localhost ~]# systemctl restart cobblerd.service


·设置盐值加密(就是给客户机root的密码),会出现一串加密字符,把字符添加到cobbler主配置文件相应的位置

[root@localhost ~]# openssl passwd -1 -salt 'abc123' 'abc123'

$1$abc123$9v8z2./E/PZihXrVcy3II0


·把生成的密码复制到以下配置文件中

[root@localhost ~]# vim /etc/cobbler/settings


default_password_crypted: "$1$abc123$9v8z2./E/PZihXrVcy3II0"


·重启xinetd服务

[root@localhost ~]# systemctl restart xinetd.service


·修改被cobbler所管理的dhcp模板


subnet 192.168.106.0 netmask 255.255.255.0 {    #指定自己的网段

     option routers             192.168.106.1;#修改网关

     option domain-name-servers 192.168.106.2;#修改DNS

     option subnet-mask         255.255.255.0;

     range dynamic-bootp        192.168.106.100 192.168.106.200;#修改地址池


·同步生成DHCP配置文件

[root@localhost ~]# cobbler sync


·下载引导操作系统文件


[root@localhost ~]# cobbler get-loaders


·在过程中,我们不一定知道那些服务启动、或者修改了忘记重启,就干脆全部重启一次。

[root@localhost ~]# systemctl start dhcpd.service    //启动dhcp

[root@localhost ~]# systemctl start cobblerd.service    //启动cobbler

[root@localhost ~]# systemctl start xinetd.service     //启动tftp


·在开始之前我们就把镜像文件挂载到了/mnt 目录下,现在需要把镜像文件导入cobbler默认存在的位子

[root@localhost ~]# cobbler import --path=/mnt/ --name=CentOS-7-x86_64 --arch=x86_64    //文件较大,需要等待


/var/www/cobbler/ks_mirror/CentOS-7-x86_64    //导入的镜像文件存放的位子


·使用cobbler list 查看发行版本,和模板

[root@localhost ~]# cobbler list

distros:

   CentOS-7-x86_64


profiles:

   CentOS-7-x86_64



·可以安装一个软件tree,来查看压缩内核与引导文件

[root@localhost ~]# yum install tree -y

[root@localhost ~]# tree /var/lib/tftpboot/images

Cobbler 全自动化安装、简介、Web界面管理【附送源码包】_第1张图片


·添加配置让cobbler受web管理,这样方便。添加一个管理者(cbamin)到指定的路径下

[root@localhost ~]# htdigest -c /etc/cobbler/users.digest cobbler cbadmin

Cobbler 全自动化安装、简介、Web界面管理【附送源码包】_第2张图片

验证自动化安装:

重启所有服务、在VMware新建一台Linux。如下图:

Cobbler 全自动化安装、简介、Web界面管理【附送源码包】_第3张图片

Cobbler 全自动化安装、简介、Web界面管理【附送源码包】_第4张图片

Cobbler 全自动化安装、简介、Web界面管理【附送源码包】_第5张图片

Cobbler 全自动化安装、简介、Web界面管理【附送源码包】_第6张图片

Cobbler 全自动化安装、简介、Web界面管理【附送源码包】_第7张图片

到此几乎不出意外就没问题了。

验证web管理:

Cobbler 全自动化安装、简介、Web界面管理【附送源码包】_第8张图片

实验成功!