百度中cobbler的简介:
  从前,我们一直在做装机民工这份很有前途的职业。自打若干年前 Red Hat 推出了 Kickstart,此后我们顿觉身价倍增。不再需要刻了光盘一台一台地安装 Linux,只要搞定 PXE、DHCP、TFTP,还有那满屏眼花缭乱不知所云的 Kickstart 脚本,我们就可以像哈里波特一样,轻点魔棒,瞬间安装上百台服务器。这一堆花里胡哨的东西可不是一般人都能整明白的,没有大专以上学历,通不过英语四级, 根本别想玩转。总而言之,这是一份多么有前途,多么有技术含量的工作啊。很不幸,Red Hat 最新(Cobbler项目最初在2008年左右发布)发布了网络安装服务器套件 Cobbler(补鞋匠),它已将 Linux 网络安装的技术门槛,从大专以上文化水平,成功降低到初中以下,连补鞋匠都能学会。对于我们这些在装机领域浸淫多年,经验丰富,老骥伏枥,志在千里的民工兄弟们来说,不啻为一个晴天霹雳。 
 
对于没有大专以上学历,没有英语四级的,从事着IT民工的我来说,有必要去学一学cobbler,或许对以后能从事Linux相关工作很有帮助。由于没有相应的条件,以下操作步骤只在VM虚拟环境下实现。
 
测试环境:CentOS 5.5 x86_64 关闭iptables、selinux
软件: cobbler.noarch 0:2.0.11-2.el5 
 
一、 安装相关软件:
[root@cobbler ~]# rpm -ivh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
[root@cobbler ~]# yum -y install cobbler dhcp httpd xinetd tftp-server
[root@cobbler ~]# chkconfig xinetd on
[root@cobbler ~]# chkconfig httpd on
[root@cobbler ~]# chkconfig cobblerd on
[root@cobbler ~]# chkconfig dhcpd on
 
二、修改配置文件
DHCP配置
[root@cobbler ~]# vim /etc/cobbler/dhcp.template
  1. subnet 192.168.209.0 netmask 255.255.255.0 { 
  2.      option routers             192.168.209.128; 
  3.      option domain-name-servers 192.168.209.128; 
  4.      option subnet-mask         255.255.255.0; 
  5.      range dynamic-bootp        192.168.209.200 192.168.209.254; 
  6.      filename                   "/pxelinux.0"; 
  7.      default-lease-time         21600; 
  8.      max-lease-time             43200; 
  9.      next-server                $next_server; 
 
修改DHCP分配的信息,这里不需要修改/etc/dhcpd.conf,因为DHCP会由cobbler接管。
 
cobbler配置,修改/etc/cobbler/settings 
找到:
manage_dhcp: 0
next_server: 127.0.0.1
server: 127.0.0.1
修改为:
  1. manage_dhcp: 1 
  2. next_server: 192.168.209.129 
  3. server: 192.168.209.129 
server和next_server修改为本服务器的IP 地址,manage_dhcp 设为 1,接管DHCP
 
tftp配置
[root@cobbler ~]# vim /etc/xinetd.d/tftp 
  1. service tftp 
  2.         socket_type             = dgram 
  3.         protocol                = udp 
  4.         wait                    = yes 
  5.         user                    = root 
  6.         server                  = /usr/sbin/in.tftpd 
  7.         server_args             = -s /tftpboot 
  8.         disable                 = no 
  9.         per_source              = 11 
  10.         cps                     = 100 2 
  11.         flags                   = IPv4 
rsync配置
[root@cobbler ~]# vim /etc/xinetd.d/rsync
  1. service rsync 
  2.         disable = no 
  3.         socket_type     = stream 
  4.         wait            = no 
  5.         user            = root 
  6.         server          = /usr/bin/rsync 
  7.         server_args     = --daemon 
  8.         log_on_failure  += USERID 
将tftp和tftp的配置文件中的disable = yes改成disable = no
 
 
三、启动相关服务,检查错误并解决问题
[root@cobbler ~]# /etc/init.d/xinetd start    
[root@cobbler ~]# /etc/init.d/httpd start      
[root@cobbler ~]# /etc/init.d/cobblerd start
[root@cobbler ~]# cobbler sync 
[root@cobbler ~]# cobbler check
The following are potential configuration items that you may want to fix:
 
1 : 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.
2 : debmirror package is not installed, it will be required to manage debian deployments and repositories
3 : 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
4 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them
 
Restart cobblerd and then run 'cobbler sync' to apply changes.
 
1.提示缺少网络引导操作系统的必须文件
[root@cobbler ~]# cobbler get-loaders
 
2.安装debian仓库,可忽略
[root@cobbler ~]# yum -y install debmirror
注释/etc/debmirror.conf 两行
#@dists="sid";
#@arches="i386";
 
3.默认的cobbler用户密码简单,需要更改密码
[root@cobbler ~]# openssl passwd -1 -salt 'afdafdsafsf' '2edhaT1#abc'     
$1$afdafdsa$JGwxphdqy7Omr3aU0W5Kz0
 
生成密码,命令格式:openssl passwd -1 -salt '任意字母' '你的密码' 
[root@cobbler ~]# vim /etc/cobbler/settings 
default_password_crypted: "$1$afdafdsa$JGwxphdqy7Omr3aU0W5Kz0"
 
用生成的密码修改/etc/cobbler/settings中的默认密码
4.电源管理功能
[root@cobbler ~]# yum  -y install cman
 
修复完成以上问题后,同步信息再检查
[root@cobbler ~]# cobbler sync 
[root@cobbler ~]# /etc/init.d/cobblerd restart  
[root@cobbler ~]# cobbler check              
No configuration problems found.  All systems go.
 
四、导入操作系统的ISO镜像文件(导入后/var/www/cobbler/ks_mirror/)
[root@cobbler ~]# mount -o loop /var/ftp/upload/CentOS.iso /media/
[root@cobbler ~]# cobbler import --path=/media --name=CentOS-5.5-x86_64
 
参数:--path=挂载ios的路径,--name名称(可随意)
 
查看
[root@cobbler ~]# cobbler distro list
   CentOS-5.5-x86_64
   CentOS-5.5-xen-x86_64
 
五、 Kickstart 配置模板,可通过安装图形界面的kickstart生成
[root@cobbler ~]# cd /var/lib/cobbler/kickstarts/
[root@cobbler kickstarts]# mv sample.ks sample.ks.bak
[root@cobbler kickstarts]# vim sample.ks
  1. #platform=x86, AMD64, or Intel EM64T 
  2. # System authorization information 
  3. auth  --useshadow  --enablemd5  
  4. # System bootloader configuration 
  5. bootloader --location=mbr 
  6. # Clear the Master Boot Record 
  7. zerombr 
  8. # Partition clearing information 
  9. clearpart --all --initlabel  
  10. # Use text mode install 
  11. text 
  12. # Firewall configuration 
  13. firewall --disabled 
  14. # Run the Setup Agent on first boot 
  15. firstboot --disable 
  16. # System keyboard 
  17. keyboard us 
  18. # System language 
  19. lang en_US 
  20. # Installation logging level 
  21. logging --level=info 
  22. # Use network installation 
  23. url --url=http://192.168.209.129/cobbler/ks_mirror/CentOS-5.5-x86_64 
  24. # Network information 
  25. network --bootproto=dhcp --device=eth0 --onboot=on 
  26. # Reboot after installation 
  27. reboot 
  28. #Root password 
  29. rootpw --iscrypted $1$36bsCbH1$UDJ6eCqPi2Nm1KsgajvHs1 
  30.  
  31. # SELinux configuration 
  32. selinux --disabled 
  33. # Do not configure the X Window System 
  34. skipx 
  35. # System timezone 
  36. timezone --isUtc Asia/Shanghai 
  37. # Install OS instead of upgrade 
  38. install 
  39. # Disk partitioning information 
  40. part / --bytes-per-inode=4096 --fstype="ext3" --size=10000 
  41. part swap --bytes-per-inode=4096 --size=2048 
  42. part /data --bytes-per-inode=4096 --fstype="ext3" --grow --size=1 
  43. part /boot --bytes-per-inode=4096 --fstype="ext3" --size=100 
  44.  
  45. %packages 
  46. @base 
  47. @development-libs 
  48. @development-tools 
  49. @core 
  50. @text-internet 
  51. @editors 
  52. keyutils 
  53. trousers 
  54. fipscheck 
  55. device-mapper-multipath 
  56. imake 
  57. ntp 
可以通过使用浏览器查看ks的配置信息:http://192.168.209.129/cblr/svc/op/ks/profile/CentOS-5.5-x86_64
默认情况下cobbler安装操作系统时使用的kickstart文件是var/lib/cobbler/kickstarts/sample.ks
可以使用以下命令修改指定使用指定的kickstart文本
cobbler profile edit --name=centos5.5 --distro=CentOS-5.5-test-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos.ks
 
六、测试

 

如果需要修改引导时的启动菜单,可修改以下文件

[root@cobbler ~]# vim /tftpboot/pxelinux.cfg/default 

 

 

七、Cobbler web界面访问

[root@localhost ~]# yum -y install cobbler-web

为已存在的用户重置密码:

htdigest /etc/cobbler/users.digest "Cobbler" cobbler 

添加新用户:

htdigest /etc/cobbler/users.digest "Cobbler" test

设置/etc/cobbler/modules如下:

[authentication]  

module = authn_configfile  

[authorization]  

module = authz_allowall   

重启Cobbler服务:

/etc/init.d/cobblerd restart

 

参考:

http://kerry.blog.51cto.com/172631/648430

http://www.cnblogs.com/txwsqk/archive/2011/08/09/2132803.html