利用Cobbler批量快速网络安装CentOS

Cobbler是什么?

Cobbler(补鞋匠)集成了PXE、DHCP、DNS、Kickstart服务管理和yum仓库管理工具,相对之前的 Kickstart 更加快捷、方便的批量布署Red Hat、CentOS类系统

测试环境:

VMware® Workstation : 9.0.0 build-812388

操作系统 : CentOS 5.6 32位

利用Cobbler批量快速网络安装CentOS

 

一.安装epel源
 
  1. [root@server1 ~]# wget http://dl.Fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
  2. [root@server1 ~]# rpm -ivh epel-release-5-4.noarch.rpm
  3. warning: epel-release-5-4.noarch.rpm: Header V3 DSA signature: NOKEY, key ID 217521f6
  4. Preparing... ########################################### [100%]
  5. 1:epel-release ########################################### [100%]
  6. [root@server1 ~]#
安装epel源的好处
就是epel这个项目是由fedora维护的,在维护的这个源中包含许多软件,包括ntop,nagios之类的,也就是说,你安装了epel源就可以直接用yum install ntop来安装了,不过这个应该针对红帽企业版Linux(RHEL)及其衍生发行版(比如CentOS、Scientific Linux)系统,Ubuntu这类的应该不行。
 
二.安装与配置cobbler
 
1.安装cobbler和一些必须的包,并设置开机自动启动
 
  1. [root@server1 ~]# yum -y install cobbler httpd rsync tftp-server xinetd dhcp Python-ctypes pykickstart cman
  2. ...
  3. cobbler-2.2.2-1.el5.rf.noarch from rpmforge has depsolving problems
  4. --> Missing Dependency: python-netaddr is needed by package cobbler-2.2.2-1.el5.rf.noarch (rpmforge)
  5. cobbler-2.2.2-1.el5.rf.noarch from rpmforge has depsolving problems
  6. --> Missing Dependency: mod_wsgi is needed by package cobbler-2.2.2-1.el5.rf.noarch (rpmforge)
  7. Error: Missing Dependency: python-netaddr is needed by package cobbler-2.2.2-1.el5.rf.noarch (rpmforge)
  8. Error: Missing Dependency: mod_wsgi is needed by package cobbler-2.2.2-1.el5.rf.noarch (rpmforge)
  9. You could try using --skip-broken to work around the problem
  10. You could try running: package-cleanup --problems
  11. package-cleanup --dupes
  12. rpm -Va --nofiles --nodigest
我的系统需要安装这2个包。
 
  1. [root@server1 ~]# wget ftp://rpmfind.net/linux/epel/5/i386/python-netaddr-0.5.2-1.el5.noarch.rpm
  2. [root@server1 ~]# rpm -ivh python-netaddr-0.5.2-1.el5.noarch.rpm
  3. warning: python-netaddr-0.5.2-1.el5.noarch.rpm: Header V3 DSA signature: NOKEY, key ID 217521f6
  4. Preparing... ########################################### [100%]
  5. 1:python-netaddr ########################################### [100%]
  6. [root@server1 ~]# wget ftp://rpmfind.net/linux/epel/5/i386/mod_wsgi-3.2-2.el5.i386.rpm
  7. [root@server1 ~]# rpm -ivh mod_wsgi-3.2-2.el5.i386.rpm
  8. warning: mod_wsgi-3.2-2.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 217521f6
  9. Preparing... ########################################### [100%]
  10. 1:mod_wsgi ########################################### [100%]
安装完成2个上面的包之后再次安装
 
  1. [root@server1 ~]# yum -y install cobbler httpd rsync tftp-server xinetd dhcp python-ctypes pykickstart cman
  2. ...中间省略
  3. [root@server1 ~]# chkconfig httpd on
  4. [root@server1 ~]# chkconfig cobblerd on
  5. [root@server1 ~]# chkconfig dhcpd on
  6. [root@server1 ~]# chkconfig xinetd on
  7. [root@server1 ~]#/etc/init.d/iptables stop
  8. [root@server1 ~]#chkconfig --level 35 iptables off
服务控制脚本
 
  1. [root@server1 ~]#chmod +x /etc/init.d/cobbler_all
  2. 用法:/etc/init.d/cobbler_all start|stop|startus|sync
脚本内容:
 
  1. #!/bin/bash
  2. case $1 in
  3. start)
  4. /etc/init.d/httpd start
  5. /etc/init.d/xinetd start
  6. /etc/init.d/dhcpd start
  7. /etc/init.d/cobblerd start
  8. ;;
  9. stop)
  10. /etc/init.d/httpd stop
  11. /etc/init.d/xinetd stop
  12. /etc/init.d/dhcpd stop
  13. /etc/init.d/cobblerd stop
  14. ;;
  15. status)
  16. /etc/init.d/httpd status
  17. /etc/init.d/xinetd status
  18. /etc/init.d/dhcpd status
  19. /etc/init.d/cobblerd status
  20. ;;
  21. sync)
  22. cobbler sync
  23. ;;
  24. *)
  25. echo "Input error,please in put 'start|stop|status|sync'!";
  26. exit 2>&1 >/dev/null &
  27. ;;
  28. esac
 
相关配置文件及目录:
cobbler相关配置文件: /etc/cobbler
cobbler数据存储目录: /var/www/cobbler
dhcp配置文件: /etc/dhcpd.conf
dhcp租期缓存文件: /var/lib/dhcpd/dhcpd.leases
pxe配置文件: /tftpboot/pxelinux.cfg/default
ks模板文件: /var/lib/cobbler/kickstarts_*.ks

相关推荐