一:cobbler是什么?

  Cobbler是一个快速网络安装linux的服务,而且在经过调整也可以支持网络安装windows。该工具使用python开发,小巧轻便(才15k行代码),使用简单的命令即可完成PXE网络安装环境的配置,同时还可以管理DHCP,DNS,以及yum包镜像。Cobbler支持命令行管理,web界面管理,还提供了API接口,可以方便二次开发使用,和PXE不同的是,使用cobbler不会因为在局域网中启动了dhcp而导致有些机器因为默认从pxe启动在重启服务器后加载tftp内容导致启动终止。

二:cobbler常用架构

  

wKiom1RDKxWzLkuzAADTcatEYQI310.jpg

三:cobbler的安装

  1)安装cobbler需要epel源.利用yum进行安装

 yum install cobbler

   查看下生成的文件

[root@node3 ~]# tree /var/www/cobbler/
/var/www/cobbler/
├── aux
│   ├── anamon
│   └── anamon.init
├── p_w_picpaths
├── ks_mirror   
│   └── config
├── links
├── localmirror
├── pub
├── rendered
├── repo_mirror
└── svc
    ├── services.py
    ├── services.pyc
    └── services.pyo
10 directories, 5 files

 2)启动前的准备

 启动httpd服务.检测cobbler  check 

[root@node3 ~]# service httpd start
[root@node3 ~]# service cobblerd start
Starting cobbler daemon:                                   [  OK  ]

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

1 : The 'server' field in /etc/cobbler/settings must be set to something other than localhost, or kickstarting features will not work.  This should be a resolvable hostname or IP for the boot server as reachable by all machines that will use it.
2 : For PXE to be functional, the 'next_server' field in /etc/cobbler/settings must be set to something other than 127.0.0.1, and should match the IP of the boot server on the PXE network.
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 : change 'disable' to 'no' in /etc/xinetd.d/rsync
5 : debmirror package is not installed, it will be required to manage debian deployments and repositories
6 : ksvalidator was not found, install pykickstart
7 : 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
8 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them

启动cobbler后检测了一下发现了许多错误,根据这些错误提示进行排错.

 

解决第一个问题,编辑vim /etc/cobbler/settings

server: 172.16.16.5

解决DHCP服务器问题

next_server: 172.16.16.5

确保syslinux已经安装

[root@node3 ~]# yum install syslinux
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
Setting up Install Process
Package syslinux-4.02-8.el6.x86_64 already installed and latest version #提示已经安装
Nothing to do

确保rsync开机启动

[root@node3 ~]# chkconfig rsync on

 安装pykickstart

[root@node3 ~]# yum install pykickstart

生成cobbler随机密码并进行替换

[root@node3 ~]# openssl passwd -apr1 -salt 'openssl rand -hex 4'
Password: #输入密码
$apr1$openssl $aA7bNBhsYJPhUH8z6mKS3/

vim /etc/cobbler/setting
default_password_crypted: "$1$mF86/UHC$WvcIcX2t6crBz2onWxyac."

cd /usr/share/syslinux 下复制当前目录的所有文件到 /var/lib/cobbler/loaders/

修改/etc/cobbler/setting配置文件选择是否有cobbler自己提供DHCP和LFTP服务

为1是自己提供为0是单独的服务器提供

修复完成后重启cobblerd和sync


3)提供cobbler依赖的服务

  安装配置DHCP服务

yum install dhcp

  提供DHCP的配置文件

cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample   /etc/dhcp
mv dhcpd.conf.sample  dhcpd.conf
vim dhcpd.conf

spacer.gif

wKioL1RDMqTDTQn6AACM5jyygGY814.jpg

提供tftp服务器(在安装cobbler时默认已经安装了)

chkconfig tftp on
service xinetd start

4)提供 distro文件

 通过挂载光盘映像文件来提供

wKiom1RDMyiyWdzBAAGFCZ3F8DI583.jpg

mount /dev/cdrom /mnt -r   挂载cdrom下的光盘镜像到/mnt 下

 把挂载的光盘镜像内的文件导入cobbler

wKioL1RDM9bioumCAAHLwQq7NZA113.jpg

导入过程要多等一会....................................

完成后查看cobbler distro list 是否有导入的文件


5)提供profile文件

 创建profile文件依赖于kickstart. 所以要先提供kickstart文件

 创建kickstart请参考pxe安装

 正式创建profile

cobbler profile add --name=centos-6.5-x86_64-basic --distro=centos-6.5-x86_64 --kickstart=/root/centos6.x86_64.cfg

 查看创建有哪些profile第一个为创建distro时自动创建的做基本的profile.第二个为自己新增加创建的profile

wKiom1RDNE2yzWV9AABuj7CIHDw204.jpg

导入完成以后执行cobbler sync 下 sync后会在/var/lib/tftpboot/pxelinux.cfg 自动创建一个default文件

查看下此文件

wKioL1RDNPaxn3MXAAJLIoPwhF8426.jpg

6)新创建虚拟机进行安装

  安装系统选择

wKiom1RDNTTA-7tBAADEBAyM9vs141.jpg

成功进入安装界面

wKiom1RDNYyBKZMFAAD1NVajreg375.jpg

注:重新修改安装配置的话要重新加载一下cobbler

例:cobbler profile edit --name=centos-6.5-x86_64-basic --distro=centos-6.5-x86_64 --kickstart=/root/centos6.x86_64.cfg

修改profit文件后需要从新加载一下 cobbler sync



7)安装cobbler的WEB管理

 

 yum -y cobbler-web
   vim /etc/cobbler/modules.conf

wKioL1RDNtKRF1HnAAAtOoEqALM937.jpg

添加cobbler用户添加cobbler密码

wKioL1RDNx7AXI_bAAEARwtXtgg655.jpg

 编辑/etc/cobbler/users.conf配置文件

wKioL1RDN2GzZg3VAAAyNdAXrME156.jpg

重启cobblerd

service cobblerd restart

重启一下httpd

service  httpd restart

wKiom1RDN4PT4oAoAADhApYjj4c488.jpg


OK cobbler配置已经完成