1、安装yum源
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm
2、安装必要服务
yum install -y dhcp tftp rsync xinetd httpd pykickstart debmirror

# vim /etc/xinetd.d/tftp
disable  = no
# vim /etc/xinetd.d/rsync
disable  = no
3、关闭selinux
sed -i 's/SELINUX\=enforcing/SELINUX\=disabled/' /etc/sysconfig/selinux
重启服务器
4、cobbler安装配置
1、cobbler安装
yum -y install cobbler cobbler-web

2、cobbler配置
启动cobbler
/etc/init.d/cobblerd start
启动httpd服务
/etc/init.d/httpd start
启动xinetd服务
/etc/init.d/xinetd
3、修改cobbler配置
# vi /etc/cobbler/setting
'next_server: 127.0.0.1' 替换本机IP地址 (DHCP服务地址)
'server: 127.0.0.1' 替换本机IP地址(cobbler服务地址)
'manage_dhcp: 0' 替换为 1(cobbler管理dhcp,后面用于同步更新配置信息[cobbler sync])
'manage_rsync: 0' 替换为 1 (cobbler管理rsync功能)
4、修改 debmirror.conf
vim /etc/debmirror.conf
#注释掉@dists="sid"与@arches="i386即可
#@dists="sid";
#@arches="i386";
4、加载部分缺失的网络boot-loaders
# cobbler get-loaders

5、设置用户名密码:
为已存在的用户重置密码:
htdigest /etc/cobbler/users.digest "cobbler" cobbler
添加新用户:
htdigest /etc/cobbler/users.digest "Cobbler"  usernam
设置/etc/cobbler/modules 如下:
[authentication] 
module = authn_configfile 
[authorization] 
module = authz_allowall  
重启Cobbler 服务:
service cobblerd restart

5、检查配置,执行
cobbler check
cobbler sync
6、修改DHCP模板
vim /etc/cobbler/dhcp.template
subnet 192.168.5.0 netmask 255.255.255.0 {
     option routers             192.168.5.1;
     option domain-name-servers 114.114.114.114;
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        192.168.5.100 192.168.5.200;
     default-lease-time         21600;
     max-lease-time             43200;
     next-server                $next_server;
     class "pxeclients" {
7、修改cobbler默认密码
用 openssl 生成一串密码后加入到 cobbler 的配置文件(/etc/cobbler/settings)里,替换 default_password_crypted 字段:
openssl passwd -1 -salt 'random-phrase-here' 'king111'
$1$random-p$FYe9b6Tsw63eelz0AXgFv/
 #   vi /etc/cobbler/settings
 
default_password_crypted: "$1$random-p$FYe9b6Tsw63eelz0AXgFv/"
注意:这里保存的密码,将会用于批量部署机器中,root账户的登录密码。
8、安装cman启动电源管理功能
# yum install cman

9.、检查cobbler安装环境
# cobbler check
 No configuration problems found.  All systems go.
注意,一定要修复完全部的configuration problems,否则tftp会出现连接超时,cobbler无法通过PXE进行系统批量安装的操作。
# cobbler sync
cobbler使用
10、导入安装文件
创建挂载文件夹
mkdir /centos65
挂载光盘镜像
mount /dev/cdrom /centos65
4. 从iso中导入客户端的OS。这将自动设置了“x86_64”,并将其命名为CentOS6.5。
# cobbler import --path=/centos65/ --name=CentOS6.5 --arch=x86_64
这需要一点时间,不要急。可查看/var/www/cobbler/ks_mirror/CentOS6.5-x86_64/目录文件生成情况。
# cobbler sync
# cobbler list
三、部署测试
创建一台虚拟机测试一下,把虚拟机设置成网络 PXE 启动(和 cobbler 在同一个网络),启动后就可以看到 Cobbler 引导界面,看到界面后选择 CentOS6.5-x86_64条目就可以顺利开始无人工干预安装系统。

四、配置文件
cobbler有许多的配置文件,但是只有少部分基本功能需要修改。 
 Settings File
 Modules Configuration
Cobbler最主要的setting file就是/etc/cobbler/settings。Cobbler2.4.0开始引入动态修改模式(Dynamic Settings),我们只需启动这一模式,便不用再手动修改这个文件了。该文件是YAML格式的,如果直接修改setting文件,则必须重启cobbler服务才会生效,但如果是通过CLI命令或者是Web GUI进行修改的话,改动会立即生效,无需重启服务。

五、常见问题
1、cobblerd校验错误:
cobblerd does not appear to be running/accessible
解决方法:
service cobblerd start
service httpd start

2、重启httpd错误:
Starting httpd: Syntax error on line 10 of /etc/httpd/conf.d/cobbler.conf:
 Invalid command 'WSGIScriptAliasMatch', perhaps misspelled or defined by a module not included in the server configuration
解决方法:
 vi /etc/httpd/conf.d/wsgi.conf
  #LoadModule wsgi_module modules/mod_wsgi.so 去掉#号,使之成为:LoadModule wsgi_module modules/mod_wsgi.so。

3、httpd、SELinux未运行:
httpd does not appear to be running and proxying cobbler, or SELinux is in the way. Original traceback:
 Traceback (most recent call last):
解决方法:
service httpd start
vi /etc/sysconfig/selinux
 SELINUX=enforcing更改为SELINUX=disabled,重启使之生效。

4、较验cobbler check出错
 Traceback (most recent call last):
   File "/usr/bin/cobbler", line 35, in ?
     sys.exit(app.main())
   File "/usr/lib/python2.4/site-packages/cobbler/cli.py", line 558, in main
     rc = cli.run(sys.argv)
   File "/usr/lib/python2.4/site-packages/cobbler/cli.py", line 202, in run
     self.token         = self.remote.login("", self.shared_secret)
   File "/usr/lib64/python2.4/xmlrpclib.py", line 1096, in __call__
     return self.__send(self.__name, args)
   File "/usr/lib64/python2.4/xmlrpclib.py", line 1383, in __request
     verbose=self.__verbose
   File "/usr/lib64/python2.4/xmlrpclib.py", line 1147, in request
     return self._parse_response(h.getfile(), sock)
   File "/usr/lib64/python2.4/xmlrpclib.py", line 1286, in _parse_response
     return u.close()
   File "/usr/lib64/python2.4/xmlrpclib.py", line 744, in close
     raise Fault(**self._stack[0])
 xmlrpclib.Fault: <Fault 1: "cobbler.cexceptions.CX:'login failed'">
解决方法:此为BUG,按下方操作执行即可。
service cobblerd restart
cobbler get-loaders