1、安裝和修改cobbler配置
1. Cobbler不在CentOS的基本源中,須要導入EPEL源升級軟件包, 確保epel-release包的版本爲最新,當前最新版本爲6-8:
# rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm html
2. yum安裝cobbler包
# yum -y install cobbler python
3. 【可選】新版的Fedora安裝系統存放在「testing」存儲庫中一段時間來檢查有沒有bug,若是你想經過EPEL安裝最新版的cobbler(未經過生產環境驗證有沒有bug),可在安裝或升級時啓動-testing模式。
# sudo yum -y install --enablerepo=epel-testing cobbler
or
# sudo yum -y update --enablerepo=epel-testing cobbler linux
4. 安裝dhcp服務
# yum -y install dhcp
ubuntu
5. 其餘服務的安裝
額外須要的服務還有httpd rsync tftp-server xinetd,若是系統沒有裝上的話,能夠執行如下執行安裝。
# yum -y install httpd rsync tftp-server xinetd centos
6. 開啓cobbler服務,重啓Apache服務,設置各個服務開機自啓動
# service httpd start
# service cobblerd start
# service xinetd start
# /sbin/chkconfig httpd on
# /sbin/chkconfig dhcpd on
# /sbin/chkconfig xinetd on
# /sbin/chkconfig tftp on
# /sbin/chkconfig cobblerd on
服務器
7. 關閉SELinux和防火牆
# vi /etc/sysconfig/selinux
SELINUX=enforcing更改成SELINUX=disabled
設置SELinux 成爲permissive模式
# setenforce 0
關閉防火牆功能
# /etc/init.d/iptables stop
# chkconfig --del iptables
重啓cobbler服務
# service cobbler restart
網絡
8. 修改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功能) app
9. 加載部分缺失的網絡boot-loaders
# cobbler get-loaders dom
10. 啓動tftp和rsync服務
# vi /etc/xinetd.d/tftp
修改爲:disable=no
# vi /etc/xinetd.d/rsync
修改爲:disable=no ide
11. 修改DHCP模板,確保DHCP分配的地址和Cobbler在同一網段
# vi /etc/cobbler/dhcp.template
ddns-update-style interim; allow booting; allow bootp; ignore client-updates; set vendorclass = option vendor-class-identifier; #須要修改192.168.0.0爲本身網段 subnet 192.168.0.0 netmask 255.255.255.0 { #修改本身的路由 option routers 192.168.0.1; #域名服務器地址 option domain-name-servers 202.106.0.20; #子網掩碼 option subnet-mask 255.255.255.0; #分配IP地址段 range dynamic-bootp 192.168.0.100 192.168.0.254; filename "/pxelinux.0"; default-lease-time 21600; max-lease-time 43200; next-server $next_server; } |
12. 若是要部署Debian/ubuntu系統則須要debmirror軟件包
# yum install wget
# yum install ed patch perl perl-Compress-Zlib perl-Cwd perl-Digest-MD5 \
perl-Digest-SHA1 perl-LockFile-Simple perl-libwww-perl
# wget ftp://fr2.rpmfind.net/linux/epel/5/ppc/debmirror-20090807-1.el5.noarch.rpm
# rpm -ivh debmirror-20090807-1.el5.noarch.rpm
修改/etc/debmirror.conf配置文件,註釋掉@dists和@arches兩行
# vi /etc/debmirror.conf
... #@dists="sid"; @sections="main,main/debian-installer,contrib,non-free"; #@arches="i386"; ... |
default_password_crypted: "$1$random-p$RkqDMTpuNlZZhJ7moLn3Q."
注意:這裏保存的密碼,將會用於批量部署機器中,root帳戶的登陸密碼。
14. 安裝cman啓動電源管理功能
# yum install cman
15. 檢查cobbler安裝環境
# cobbler check
No configuration problems found. All systems go.
注意,必定要修復徹底部的configuration problems,不然tftp會出現鏈接超時,cobbler沒法經過PXE進行系統批量安裝的操做。
# cobbler sync
1. 上傳ISO鏡像至服務器
2. 建立文件夾
# mkdir -p /system/ubuntu12.04
# mount -o loop ~/Downloads/ubuntu-12.04-server-amd64.iso /system/ubuntu12.04/
4. 從iso中導入客戶端的OS。這將自動設置了「x86_64」,並將其命名爲ubuntu12.04。
# cobbler import --path=/system/ubuntu12.04/ --name=ubuntu12.04 --arch=x86_64
這須要一點時間,不要急。可查看/var/www/cobbler/ks_mirror/ubuntu12.04-x86_64/目錄文件生成狀況。
# cobbler sync
# cobbler list
distros: |
3、部署測試
建立一臺虛擬機測試一下,把虛擬機設置成網絡 PXE 啓動(和 cobbler 在同一個網絡),啓動後就能夠看到 Cobbler 引導界面,看到界面後選擇 ubuntu12.04-x86_64 條目就能夠順利開始無人工干預安裝系統,Cobbler 引導界面以下:
完成自動化安裝後,使用root用戶帳號登陸,密碼爲以前在配置文件中寫入的值(本文爲1234567890)
4、配置文件
cobbler有許多的配置文件,可是隻有少部分基本功能須要修改。
5、常見問題
一、cobblerd校驗錯誤:
cobblerd does not appear to be running/accessible
解決方法:
service cobblerd start
service httpd start
二、重啓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。
三、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,重啓使之生效。
四、較驗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
參考文獻:
http://bbs.chinaunix.net/thread-3731875-1-1.html
http://cwtea.blog.51cto.com/4500217/1047410/
http://www.vpsee.com/2012/03/install-cobbler-on-centos-6-2/ http://www.chenshake.com/installation-and-configuration-centos-6-3-cobbler-1/