我的博客已迁移到xdoujiang.com请去那边和我交流
一、基础环境
1、关闭selinux服务 
sed -i 's/SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
setenforce 0

2、关闭iptables服务
chkconfig iptables off
iptables -F
/etc/init.d/iptables save
/etc/init.d/iptables stop

3、serverA桥接模式

使用cobbler安装centos6.6(vmware)_第1张图片

4、服务端serverA=192.168.1.120(我这里只使用了eth0网络接口)

使用cobbler安装centos6.6(vmware)_第2张图片

5、之前已经下载好了2张dvd
CentOS-6.6-x86_64-bin-DVD1.iso和CentOS-6.6-x86_64-bin-DVD2.iso

二、安装cobbler(serverA)
1、安装所需要的包
yum -y install cobbler debmirror pykickstart openssl fence-agents dnsmasq syslinux

2、先看下cobbler命令有哪些
cobbler
usage
=====
cobbler  ... 
        [add|edit|copy|getks*|list|remove|rename|report] [options|--help]
cobbler  [options|--help]

3、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)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
4)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.
5)change 'disable' to 'no' in /etc/xinetd.d/rsync
6)comment out 'dists' on /etc/debmirror.conf for proper debian support
7)comment out 'arches' on /etc/debmirror.conf for proper debian support
8)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
Restart cobblerd and then run 'cobbler sync' to apply changes.

4、下载客户端启动文件
cd /var/lib/cobbler/loaders
cat filelist.txt
http://dgoodwin.fedorapeople.org/loaders/README
http://dgoodwin.fedorapeople.org/loaders/COPYING.elilo
http://dgoodwin.fedorapeople.org/loaders/COPYING.yaboot
http://dgoodwin.fedorapeople.org/loaders/COPYING.syslinux 
http://dgoodwin.fedorapeople.org/loaders/elilo-3.8-ia64.efi
http://dgoodwin.fedorapeople.org/loaders/yaboot-1.3.14-12
http://dgoodwin.fedorapeople.org/loaders/pxelinux.0-3.61
http://dgoodwin.fedorapeople.org/loaders/menu.c32-3.61
http://dgoodwin.fedorapeople.org/loaders/grub-0.97-x86.efi
http://dgoodwin.fedorapeople.org/loaders/grub-0.97-x86_64.efi
wget -i filelist.txt

5、修改/etc/cobbler/settings配置文件
1)先备份下配置
cp /etc/cobbler/settings /etc/cobbler/settings.bak
2)生成密码
openssl passwd -1 -salt 'root' 'redhat'
$1$root$M1uN9dLHipbORRwJW/xR3/
3)开始修改
sed -i 's/^server:.*/server: 192.168.1.120/' /etc/cobbler/settings
sed -i 's/^next_server:.*/next_server: 192.168.1.120/' /etc/cobbler/settings
sed -i '/default_password_crypted/c\default_password_crypted:\ "$1$root$M1uN9dLHipbORRwJW/xR3/"' /etc/cobbler/settings
sed -i 's/^manage_dhcp:.*/manage_dhcp: 1/' /etc/cobbler/settings
sed -i 's/^manage_dns:.*/manage_dns: 1/' /etc/cobbler/settings
sed -i 's/^manage_tftpd:.*/manage_tftpd: 1/' /etc/cobbler/settings
sed -i 's/^restart_dhcp:.*/restart_dhcp: 1/' /etc/cobbler/settings
sed -i 's/^restart_dns:.*/restart_dns: 1/' /etc/cobbler/settings
sed -i 's/^pxe_just_once:.*/pxe_just_once: 1/' /etc/cobbler/settings

6、修改/etc/xinetd.d/rsync配置文件
1)先备份下配置
cp /etc/xinetd.d/rsync /etc/xinetd.d/rsync.bak
2)开始修改
sed -i '/disable/s/yes/no/g' /etc/xinetd.d/rsync

7、修改/etc/cobbler/modules.conf配置文件
1)先备份下配置
cp /etc/cobbler/modules.conf /etc/cobbler/modules.conf.bak
2)开始修改
diff /etc/cobbler/modules.conf /etc/cobbler/modules.conf.bak 
56c56
< module = manage_dnsmasq
---
> module = manage_bind
69c69
< module = manage_dnsmasq
---
> module = manage_isc

8、修改/etc/cobbler/dnsmasq.template配置文件
1)先备份下配置
cp /etc/cobbler/dnsmasq.template /etc/cobbler/dnsmasq.template.bak
2)开始修改
diff /etc/cobbler/dnsmasq.template /etc/cobbler/dnsmasq.template.bak 
11c11
< dhcp-range=192.168.1.140,192.168.1.150
---
> dhcp-range=192.168.1.5,192.168.1.200

9、修改kickstart配置文件
1)进入目录
cd /var/lib/cobbler/kickstarts
2)复制模板给centos6.6x86_64.cfg
cp sample_end.ks centos6.6x86_64.cfg
3)修改默认的模板为centos模板
cobbler profile edit --name=CentOS6.6-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos6.6x86_64.cfg
4)具体配置
cat centos6.6x86_64.cfg
auth  --useshadow  --enablemd5
bootloader --location=mbr
clearpart --all --initlabel
text
firewall --disabled
firstboot --disable
keyboard us
lang en_US
url --url=$tree
$yum_repo_stanza
$SNIPPET('network_config')
reboot
rootpw --iscrypted $default_password_crypted
selinux --disabled
skipx
timezone Asia/shanghai
install
zerombr
part /boot --fstype=ext4 --size=200
part swap --fstype=swap --size=2048
part / --fstype=ext4 --size=10000
part /opt --fstype=ext4 --grow --size=1
%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
$SNIPPET('pre_anamon')
%end
%packages --nobase
wget
vim
openssh-server
$SNIPPET('func_install_if_enabled')
%end
%post --nochroot
$SNIPPET('log_ks_post_nochroot')
%end
%post
$SNIPPET('log_ks_post')
$yum_config_stanza
$SNIPPET('post_install_kernel_options')
$SNIPPET('post_install_network_config')
$SNIPPET('func_register_if_enabled')
$SNIPPET('download_config_files')
$SNIPPET('koan_environment')
$SNIPPET('redhat_register')
$SNIPPET('cobbler_register')
$SNIPPET('post_anamon')
$SNIPPET('kickstart_done')
%end

10、挂载并导入dvd iso
1)挂载第1张dvd
mount -o loop /opt/CentOS-6.6-x86_64-bin-DVD1.iso /mnt
cobbler import --arch=x86_64 --path=/mnt --name=centos6.6
umount /mnt
2)挂载第2张dvd
mount -o loop /opt/CentOS-6.6-x86_64-bin-DVD2.iso /mnt
cp -rf /mnt/Packages/ /var/www/cobbler/ks_mirror/centos6.6-x86_64/
umount /mnt

11、创建索引
1)进入目录
cd /var/www/cobbler/ks_mirror/centos6.6-x86_64/
2)createrepo创建索引
createrepo -g repodata/9e2ddcc42b44eb150ebc61dde29c997318d8330b92205b3dbb3a87bcc06d10be-c6-x86_64-comps.xml .
Spawning worker 0 with 6518 pkgs
Workers Finished
Gathering worker results
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete

12、设置开机启动
chkconfig httpd on 
chkconfig cobblerd on
chkconfig dnsmasq on

13、启动服务
/etc/init.d/cobblerd restart
/etc/init.d/dnsmasq restart
service xinetd restart
/etc/init.d/httpd restart

14、同步
cobbler sync

15、查看端口是否都开放了(53 67 69 80 873)
netstat -tupnl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
tcp        0      0 0.0.0.0:53                  0.0.0.0:*                   LISTEN      1002/dnsmasq        
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      1017/sshd           
tcp        0      0 127.0.0.1:25151             0.0.0.0:*                   LISTEN      1077/python2        
tcp        0      0 :::53                       :::*                        LISTEN      1002/dnsmasq        
tcp        0      0 :::22                       :::*                        LISTEN      1017/sshd           
tcp        0      0 :::873                      :::*                        LISTEN      1026/xinetd         
tcp        0      0 :::80                       :::*                        LISTEN      1044/httpd          
udp        0      0 0.0.0.0:53                  0.0.0.0:*                               1002/dnsmasq        
udp        0      0 0.0.0.0:67                  0.0.0.0:*                               1002/dnsmasq        
udp        0      0 0.0.0.0:69                  0.0.0.0:*                               1026/xinetd         
udp        0      0 :::53                       :::*                                    1002/dnsmasq   

16、通过命令cobbler setting report来查看下之前修改的配置内容
cobbler setting report

17、查看
cobbler list
distros:
   centos6.6-x86_64
profiles:
   CentOS6.6-x86_64
systems:
repos:
p_w_picpaths:
mgmtclasses:
packages:
files:

18、查看导入的发行版系统信息cobbler distro report
cobbler distro report
Name                           : centos6.6-x86_64
Architecture                   : x86_64
TFTP Boot Files                : {}
Breed                          : redhat
Comment                        : 
Fetchable Files                : {}
Initrd                         : /var/www/cobbler/ks_mirror/centos6.6-x86_64/p_w_picpaths/pxeboot/initrd.img
Kernel                         : /var/www/cobbler/ks_mirror/centos6.6-x86_64/p_w_picpaths/pxeboot/vmlinuz
Kernel Options                 : {}
Kernel Options (Post Install)  : {}
Kickstart Metadata             : {'tree': 'http://@@http_server@@/cblr/links/centos6.6-x86_64'}
Management Classes             : []
OS Version                     : rhel6
Owners                         : ['admin']
Red Hat Management Key         : inherit
Red Hat Management Server      : inherit
Template Files                 : {}

19、查看配置信息cobbler profile report
cobbler profile report
Name                           : centos6.6-x86_64
TFTP Boot Files                : {}
Comment                        : 
DHCP Tag                       : default
Distribution                   : centos6.6-x86_64
Enable gPXE?                   : 0
Enable PXE Menu?               : 1
Fetchable Files                : {}
Kernel Options                 : {}
Kernel Options (Post Install)  : {}
Kickstart                      : /var/lib/cobbler/kickstarts/centos6.6x86_64.cfg
Kickstart Metadata             : {}
Management Classes             : []
Management Parameters          : inherit
Name Servers                   : []
Name Servers Search Path       : []
Owners                         : ['admin']
Parent Profile                 : 
Proxy                          : 
Red Hat Management Key         : inherit
Red Hat Management Server      : inherit
Repos                          : []
Server Override                : inherit
Template Files                 : {}
Virt Auto Boot                 : 1
Virt Bridge                    : xenbr0
Virt CPUs                      : 1
Virt Disk Driver Type          : raw
Virt File Size(GB)             : 5
Virt Path                      : 
Virt RAM (MB)                  : 512
Virt Type                      : kvm

20、查看状态
查看正在安装
cobbler status
ip             |target              |start            |state            
192.168.1.148  |profile:CentOS6.6-x86_64|Sun Jul  5 20:50:36 2015|installing (6m 4s)      
查看已经安装完成
cobbler status
ip             |target              |start            |state            
192.168.1.148  |profile:CentOS6.6-x86_64|Sun Jul  5 20:50:36 2015|finished   

21、查看安装好后的信息

使用cobbler安装centos6.6(vmware)_第3张图片

使用cobbler安装centos6.6(vmware)_第4张图片

三、客户端也是配置的桥接模式,客户端安装的时候按F12网络引导就OK了,
选择相应需要安装的发行版本,回车后就一路安装了.

使用cobbler安装centos6.6(vmware)_第5张图片

使用cobbler安装centos6.6(vmware)_第6张图片