Cobbler是一个Linux服务器安装的服务,可以通过网络启动(PXE)的方式来快速安装、重装物理服务器和虚拟机,同时还可以管理DHCP,DNS等。
Cobbler可以使用命令行方式管理,也提供了基于Web的界面管理工具(cobbler-web),还提供了API接口,可以方便二次开发使用。
Cobbler是较早前的kickstart的升级版,优点是比较容易配置,还自带web界面比较易于管理。
Cobbler内置了一个轻量级配置管理系统,但它也支持和其它配置管理系统集成,如Puppet,暂时不支持SaltStack。
一台Centos7的cobbler服务器,一台虚拟机系统安装源选择自动检测用于验证
cobbler软件包在epel源中,所以安装cobbler前需要先安装epel-release
1、安装服务软件包源
此安装包也可以到rpmsearch官网去下载
[root@hostlocal~]#wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
[root@hostlocal~]#rpm -ivh epel-release-latest-7.noarch.rpm
挂载光盘,安装软件包
[root@hostlocal~]#mount /dev/cdrom /mnt
[root@hostlocal~]#yum -y install cobbler
安装cobbler服务相关的服务
[root@localhost ~]# yum install -y cobbler-web dhcp tftp-server pykickstart httpd rsync xinetd
2、进入主配置文件修改指向路径
[root@localhost ~]#vim /etc/cobbler/settings
next_server: 192.168.60.60
server:192.168.60.60
manager_dhcp:1
3、关闭防火防护,开启http、cobbler服务
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
[root@localhost ~]# systemctl start httpd
[root@localhost ~]# systemctl start cobblerd.service
4、修改相关服务的配置文件
[root@localhost ~]# vim /etc/xinetd.d/tftp
disable = no
[root@localhost ~]# systemctl enable rsyncd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/rsyncd.service to /usr/lib/systemd/system/rsyncd.service.
5、查看配置cobbler需要的步骤
[root@localhost ~]# cobbler check
The following are potential configuration items that you may want to fix:
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 : 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.
3 : debmirror package is not installed, it will be required to manage debian deployments and repositories
4 : 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
5 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them
6、生成盐值加密的文件并替换配置文件中的加密信息
[root@localhost ~]# openssl passwd -1 -salt '000000' '000000'
$1$000000$H4wHmgCix3CXPTaPUzb6Q1
[root@localhost ~]# vim /etc/cobbler/settings
default_password_crypted: "$1$000000$H4wHmgCix3CXPTaPUzb6Q1"
[root@localhost ~]# systemctl restart cobblerd.service
[root@localhost ~]# vim /etc/cobbler/dhcp.template
subnet 192.168.60.0 netmask 255.255.255.0 {
option routers 192.168.60.1;
option domain-name-servers 192.168.60.2;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.60.100 192.168.60.254;
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
[root@localhost ~]# cobbler sync'(同步到DHCP的主配置文件)'
[root@localhost ~]# cobbler get-loaders'下载引导程序'
7、启动相关服务,查看cobbler步骤
[root@localhost ~]# systemctl restart dhcpd
[root@localhost ~]# systemctl restart cobblerd.service
[root@localhost ~]# systemctl restart xinetd.service
[root@localhost ~]# cobbler check
The following are potential configuration items that you may want to fix:'(剩余的这三个步骤无所谓)'
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 : debmirror package is not installed, it will be required to manage debian deployments and repositories
3 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them
8、导入镜像文件
[root@localhost ~]# cobbler import --path=/mnt/ --name=CentOS-7-x86_64 --arch=x86_64
[root@localhost ~]# cd /var/www/cobbler/ks_mirror/
CentOS-7-x86_64
[root@localhost ~]#cobbler list'(查看导入文件列表)'
查看压缩内核和引导程序
[root@localhost ks_mirror]# yum install -y tree
[root@localhost ks_mirror]# tree /var/lib/tftpboot/images'(树状查看该目录)'
/var/lib/tftpboot/images
└── CentOS-7-x86_64
├── initrd.img
└── vmlinuz
9、再次重启所有服务,使用裸机装机
[root@localhost ~]# systemctl restart dhcpd
[root@localhost ~]# systemctl restart cobblerd
[root@localhost ~]# systemctl restart xinetd.service
[root@localhost ~]# systemctl restart httpd
10、web管理cobbler
[root@localhost ~]# htdigest -c /etc/cobbler/users.digest Cobbler cbadmin(添加cobbler管理员)
Adding password for cbadmin in realm Cobbler.
New password: (密码000000)
Re-type new password: (再次确认000000)
最后,重启服务,网页测试
[root@localhost ~]# systemctl restart cobblerd.service
[root@localhost ~]# systemctl restart httpd.service
密码就是000000,进入就可以操作里面的文件等
11、pam认证模块管理cobbler
[root@localhost ~]# vim /etc/cobbler/modules.conf
22 [authentication]
23 module = authn_pam
42 [authorization]
43 module = authz_ownership
[root@localhost ~]# useradd zhangyang
[root@localhost ~]# passwd zhangyang
更改用户 zhangyang 的密码 。
新的 密码:
无效的密码: 密码是一个回文
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。
[root@localhost ~]# vim /etc/cobbler/users.conf '(进入配置文件行末shift+g)'
[admins]
admin = ""
cobbler = ""
zhangyang = ""(添加用户)
[root@localhost ~]# systemctl restart cobblerd.service
[root@localhost ~]# systemctl restart httpd.service
使用网页访问
用户登录账号改了,网页还是同一个网页
12、最小化安装成图形化界面
首先安装X(X Window System),命令为
[root@localhost ~]#yum groupinstall "X Window System"
回车(注意有引号)
安装图形界面软件 GNOME
[root@localhost ~]#yum groupinstall "GNOME Desktop"
安装成功后,会显示Complete!
更新系统的默认运行级别
经过上面的操作,系统启动默认还是命令行页面的,需要我们进行切换。如果想要使系统启动即为图形化窗口,需要执行下面的命令
[root@localhost ~]#ln -sf /lib/systemd/system/runlevel5.target /etc/systemd/system/default.target
ln -sf /lib/systemd/system/multi-user.target /etc/systemd/system/default.target 命令行模式
ln -sf /lib/systemd/system/graphical.target /etc/systemd/system/default.target 图形界面模式
重启系统,当系统再次启动的时候,就会默认进入图形界面
[root@localhost ~]#reboot