#####################################################
##若有轉載,請務必保留本文連接及版權信息
##歡迎廣大運維同仁一塊兒交流linux/unix網站運維技術!
##QQ:335623998
##E-mail:335623998@qq.com
##博客: http://dreamway.blog.51cto.com/
##weibo:http://weibo.com/zhaixiangpan
#####################################################
node
《Cobbler部署指南》系列python
1、《Cobbler部署指南之安裝篇》http://dreamway.blog.51cto.com/blog/1281816/1166589linux
2、《Cobbler部署指南之配置管理篇[上文]》http://dreamway.blog.51cto.com/blog/1281816/1166921git
3、《Cobbler部署指南之配置管理篇[下文]》http://dreamway.blog.51cto.com/blog/1281816/1166932
github
4、《Cobbler部署指南之yum倉庫配置管理篇》http://dreamway.blog.51cto.com/blog/1281816/1166936
web
5、《Cobbler部署指南之Cobbler安裝操做系統篇》http://dreamway.blog.51cto.com/blog/1281816/1166947
sql
6、《Cobbler部署指南之安裝虛擬化Xen系統篇》http://dreamway.blog.51cto.com/blog/1281816/1166950
shell
7、《Cobbler部署指南之電源管理篇》http://dreamway.blog.51cto.com/blog/1281816/1166957
apache
8、《Cobbler部署指南之FAQ處理篇》http://dreamway.blog.51cto.com/blog/1281816/1167078json
九、Cobbler報錯處理
經過cobbler check檢查出現的報錯
紅色標註爲報錯關鍵信息
# cobbler check
httpd does not appear to be running and proxying cobbler, or SELinux isin the way. Original traceback:
Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/cobbler/cli.py", line 184, in check_setup
s.ping()
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 1129, in request
self.send_content(h, request_body)
File "/usr/lib64/python2.4/xmlrpclib.py", line 1243, in send_content
connection.endheaders()
File "/usr/lib64/python2.4/httplib.py", line 804, in endheaders
self._send_output()
File "/usr/lib64/python2.4/httplib.py", line 685, in _send_output
self.send(msg)
File "/usr/lib64/python2.4/httplib.py", line 652, in send
self.connect()
File "/usr/lib64/python2.4/httplib.py", line 636, inconnect
raise socket.error, msg
error: (111, 'Connection refused')
解決啓動httpd服務
service httpd start
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
[FAILED]#啓動httpd時的報錯,解決方法以下
解決
vim /etc/httpd/conf.d/wsgi.conf
去掉註釋
LoadModule wsgi_module modules/mod_wsgi.so
再啓動httpd服務
service httpd start
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using x.x.x.x for ServerName
[ OK ]
再進行一些針對apache ServerName參數配置的處理
egrep "ServerName|Listen" /etc/httpd/conf/httpd.conf |grep -v '#'
Listen 172.17.10.14:80
ServerName 80
官方相關資料https://github.com/cobbler/cobbler/wiki/Cobbler%20web%20interface
此步共修復七個須要處理的提示,一個一個解決
# cobbler check
The following are potential configuration items that you may want to fix:
1 : service dhcpd isnot running
解決:DHCP先不處理
2 : 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.
解決:執行 cobbler get-loaders,系統將自動下載loader程序,完成提示2的修復工做。
# cobbler get-loaders
task started: 2013-03-10_103017_get_loaders
task started (id=Download Bootloader Content, time=Sun Mar 10 10:30:17 2013)
downloading http://dgoodwin.fedorapeople.org/loaders/README to /var/lib/cobbler/loaders/README
downloading http://dgoodwin.fedorapeople.org/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilo
downloading http://dgoodwin.fedorapeople.org/loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yaboot
downloading http://dgoodwin.fedorapeople.org/loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.syslinux
downloading http://dgoodwin.fedorapeople.org/loaders/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64.efi
downloading http://dgoodwin.fedorapeople.org/loaders/yaboot-1.3.14-12 to /var/lib/cobbler/loaders/yaboot
downloading http://dgoodwin.fedorapeople.org/loaders/pxelinux.0-3.61 to /var/lib/cobbler/loaders/pxelinux.0
downloading http://dgoodwin.fedorapeople.org/loaders/menu.c32-3.61 to /var/lib/cobbler/loaders/menu.c32
downloading http://dgoodwin.fedorapeople.org/loaders/grub-0.97-x86.efi to /var/lib/cobbler/loaders/grub-x86.efi
downloading http://dgoodwin.fedorapeople.org/loaders/grub-0.97-x86_64.efi to /var/lib/cobbler/loaders/grub-x86_64.efi
*** TASK COMPLETE ***
3 : debmirror package isnot installed, it will be required to manage debian deployments and repositories
解決:提示說debmirror沒安裝。若是不是安裝 debian之類的系統,此提示能夠忽略,若是須要安裝,
安裝 debmirror
yum -y install debmirror
編輯註釋
修改 /etc/debmirror.conf 配置文件,註釋掉 @dists 和 @arches 兩行
sed -i 's|@dists=.*|#@dists=|' /etc/debmirror.conf
sed -i 's|@arches=.*|#@arches=|' /etc/debmirror.conf
4 : ksvalidator was not found, install pykickstart
解決:安裝ksvalidator
yum install pykickstart -y
5 : The defaultpassword used by the sample templates for newly installed machines (default_password_crypted in /etc/cobbler/settings) is still setto'cobbler'and should be changed, try: "openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'"to generate new one
解決:修改cobbler用戶的默認密碼,可使用以下命令生成密碼,並使用生成後的密碼替換/etc/cobbler/settings中 default_password_crypted 的密碼。
生成密碼命令:
#openssl passwd -1 -salt 'random-phrase-here''[任意密碼]'
openssl passwd -1 -salt 'random-phrase-here''hexun'
$1$random-p$Q1IN9LaNg7yhRKJuY50fV1
6 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them
解決:安裝cman工具用於電源管理
yum -y install cman
Restart cobblerd andthen run 'cobbler sync'to apply changes.
修復完畢重啓cobbler服務,而後運行cobbler sync
7:修復完成以上問題後,同步信息再檢查
/etc/init.d/cobblerd restart
Stopping cobbler daemon: [ OK ]
Starting cobbler daemon: [ OK ]
再次檢查,又報錯
cobbler check
The following are potential configuration items that you may want to fix:
1 : The defaultpassword used by the sample templates for newly installed machines (default_password_crypted in /etc/cobbler/settings) is still setto'cobbler'and should be changed, try: "openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'"to generate new one
Restart cobblerd andthen run 'cobbler sync'to apply changes.
報錯緣由是上面的第五個問題沒徹底解決,僅僅生成了密鑰,沒有放入cobbler主配置文件
vim /etc/cobbler/settings
default_password_crypted: "$1$random-p$Q1IN9LaNg7yhRKJuY50fV1"
再重啓服務
/etc/init.d/cobblerd restart
Stopping cobbler daemon: [ OK ]
Starting cobbler daemon: [ OK ]
cobbler check
No configuration problems found. All systems go.
執行cobbler sync
cobbler sync
task started: 2013-03-10_105055_sync
task started (id=Sync, time=Sun Mar 10 10:50:55 2013)
running pre-sync triggers
cleaning trees
removing: /tftpboot/pxelinux.cfg/default
略
received on stdout: Shutting down dhcpd: [ OK ]
Starting dhcpd: [ OK ]
received on stderr:
running shell triggers from /var/lib/cobbler/triggers/sync/post/*
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.scm_track
running shell triggers from /var/lib/cobbler/triggers/change/*
*** TASK COMPLETE ***
執行cobbler sync會重啓相關服務,DHCP服務也會啓動了,第一個提示也就解決了,下面也有說明
[root@cobbler-1014 x86_64]# /etc/init.d/cobblerd restart
Stopping cobbler daemon: [FAILED]
Starting cobbler daemon: [ OK ]
[root@cobbler-1014 x86_64]# cobbler check
The following are potential configuration items that you may want to fix:
1 : service dhcpd isnot running
Restart cobblerd andthen run 'cobbler sync'to apply changes.
執行cobbler sync便可啓動dhcp服務
cobbler sync
使用koan重裝系統時報錯
koan --server=172.17.10.14 --list=profiles
Traceback (most recent call last):
File "/usr/bin/koan", line 18, in ?
import koan.app as app
File "/usr/lib/python2.4/site-packages/koan/app.py", line 64, in ?
import configurator
File "/usr/lib/python2.4/site-packages/koan/configurator.py", line 36, in ?
import simplejson as json
ImportError: No module named simplejson
解決:須要安裝simplejson軟件包,
最新版下載地址:http://pypi.python.org/pypi/simplejson/
最新版的simplejson要求python 2.6+以上的,CntOS5.8是Python 2.4.3,因此下載的simplejson-2.0.9.tar.gz版本
https://pypi.python.org/packages/source/s/simplejson/simplejson-2.0.9.tar.gz
安裝步驟:
訪問外網下載文件setuptools-0.6c7-py2.4.egg
如沒有外網能夠經過其餘機器下載https://pypi.python.org/packages/2.4/s/setuptools/setuptools-0.6c7-py2.4.egg
而後上傳至客戶機再繼續安裝
tar zxf simplejson-2.0.9.tar.gz
cd simplejson-2.0.9
python setup.py install
建議CentOS5.8 安裝此版本的koan使用能夠避免此問題
ftp://rpmfind.net/linux/epel/5/i386/koan-1.6.6-1.el5.noarch.rpm
koan --server=172.17.10.14 --virt-name=testvm --virt --profile=centos5.8-xen-x86_64
- looking for Cobbler at http://172.17.10.14:80/cobbler_api
- reading URL: http://172.17.10.14/cblr/svc/op/ks/profile/centos5.8-xen-x86_64
install_tree: http://172.17.10.14/cblr/links/centos5.8-xen-x86_64
xen package needs to be installed
Xen 宿主機安裝虛擬機時提示沒有安裝xen軟件包
解決:
yum install xen -y
執行此命令會安裝一共9個軟件包,以下
Running Transaction
Installing : bridge-utils 1/9
Installing : cyrus-sasl-md5 2/9
Installing : ebtables 3/9
Installing : e4fsprogs-libs 4/9
Installing : xen-libs 5/9
Installing : libvirt 6/9
Installing : libvirt-python 7/9
Installing : python-virtinst 8/9
Installing : xen 9/9
koan --server=172.17.10.14 --virt-name=testvm --virt --profile=centos5.8-xen-x86_64
- looking for Cobbler at http://172.17.10.14:80/cobbler_api
- reading URL: http://172.17.10.14/cblr/svc/op/ks/profile/centos5.8-xen-x86_64
install_tree: http://172.17.10.14/cblr/links/centos5.8-xen-x86_64
xend needs to be started
解決:
報錯緣由是xend服務沒有啓動,執行如下命令處理
chkconfig xend on
/etc/init.d/xend start
#注意此過程會自動橋接網卡,可能出現短暫斷網
koan --server=172.17.10.14 --virt-name=testvm --virt --profile=centos5.8-xen-x86_64
- looking for Cobbler at http://172.17.10.14:80/cobbler_api
- reading URL: http://172.17.10.14/cblr/svc/op/ks/profile/centos5.8-xen-x86_64
install_tree: http://172.17.10.14/cblr/links/centos5.8-xen-x86_64
libvirtd is stopped
libvirtd needs to be running
解決:
chkconfig libvirtd on
/etc/init.d/libvirtd start
koan --server=172.17.10.14 --virt-name=testvm --virt --profile=centos5.8-xen-x86_64
- looking for Cobbler at http://172.17.10.14:80/cobbler_api
- reading URL: http://172.17.10.14/cblr/svc/op/ks/profile/centos5.8-xen-x86_64
install_tree: http://172.17.10.14/cblr/links/centos5.8-xen-x86_64
libvirtd (pid 3772) is running...
downloading initrd initrd.img to /var/lib/xen/initrd.img_koan
url=http://172.17.10.14/cobbler/p_w_picpaths/centos5.8-xen-x86_64/initrd.img
- reading URL: http://172.17.10.14/cobbler/p_w_picpaths/centos5.8-xen-x86_64/initrd.img
downloading kernel vmlinuz to /var/lib/xen/vmlinuz_koan
url=http://172.17.10.14/cobbler/p_w_picpaths/centos5.8-xen-x86_64/vmlinuz
- reading URL: http://172.17.10.14/cobbler/p_w_picpaths/centos5.8-xen-x86_64/vmlinuz
- warning: old python-virtinst detected, a lot of features will be disabled
- adding disk: /var/lib/xen/p_w_picpaths//testvm-disk0 ofsize 5 (driver type=raw)
- ['virt-install', '--connect', 'xen:///', '--name', 'testvm', '--ram', '512', '--vcpus', '1', '--uuid', '42559fd2-385f-2435-80f1-9f5005a02a81', '--autostart', '--vnc', '--paravirt', '--boot', 'kernel=/var/lib/xen/vmlinuz_koan,initrd=/var/lib/xen/initrd.img_koan,kernel_args=ks=http://172.17.10.14/cblr/svc/op/ks/profile/centos5.8-xen-x86_64 ksdevice=link kssendmac lang= text ', '--os-variant', 'rhel5', '--disk', 'path=/var/lib/xen/p_w_picpaths//testvm-disk0,size=5', '--network', 'bridge=xenbr0', '--wait', '0', '--noautoconsole']
usage: virt-install --name NAME --ram RAM STORAGE INSTALL [options]
virt-install: error: no such option: --autostart
解決
我安裝的
系統版本:CentOS5.8 64bit
koan版本:koan-2.2.3-2.el5
xen版本:xen-3.0.3-142.el5_9.2
經過EPEL安裝的koan版本爲koan-2.2.3-2.el5,使用中報錯較多,後更換爲koan-1.6.6-1.el5此版本比較穩定,下載連接:ftp://rpmfind.net/linux/epel/5/i386/koan-1.6.6-1.el5.noarch.rpm
cobbler check
The following are potential configuration items that you may want to fix:
1 : comment 'dists'on /etc/debmirror.conf for proper debian support
2 : comment 'arches'on /etc/debmirror.conf for proper debian support
Restart cobblerd andthen run 'cobbler sync'to apply changes.
解決
關於debmirror編輯註釋
修改 /etc/debmirror.conf 配置文件,註釋掉 @dists 和 @arches 兩行
sed -i 's|@dists=.*|#@dists=|' /etc/debmirror.conf
sed -i 's|@arches=.*|#@arches=|' /etc/debmirror.conf
/usr/bin/ipmitool power status
Could notopen device at /dev/ipmi0 or /dev/ipmi/0 or /dev/ipmidev/0: No such file or directory
Unable to get Chassis Power Status
解決
/etc/init.d/ipmi start
Starting ipmi drivers: [ OK ]
/etc/rc.d/init.d/ipmievd start
Starting ipmievd:
ipmievd: using pidfile /var/run/ipmievd.pid0
chkconfig ipmi on
chkconfig ipmievd on
再執行查看電源狀態
/usr/bin/ipmitool power status
Chassis Power ison
obbler system edit --name=host-188116 --power-address=172.17.11.20 --power-type='ipmitool' --power-user=root --power-pass=djxxxx
usage: cobbler [options]
cobbler: error: option--power-type: invalid choice: 'ipmitool' (choose from 'ack_manual', 'apc', 'apc_snmp', 'bladecenter', 'brocade', 'bullpap', 'cisco_mds', 'cisco_ucs', 'drac', 'drac5', 'egenera', 'ifmib', 'ilo', 'ilo_mp', 'ipdu', 'ipmilan', 'lpar', 'manual', 'mcdata', 'node', 'rhevm', 'rps10', 'rsa', 'rsb', 'sanbox2', 'scsi', 'scsi_test', 'tool', 'virsh', 'vixel', 'vmware', 'vmware_helper', 'vmware_soap', 'wti', 'xvm', 'xvmd')
解決
選擇合適的power類型,報錯後面已經列出可選參數,我這裏使用的DELL PE1950應該選擇ipmilan
cobbler system edit --name=host-188116 --power-address=172.17.11.20 --power-type='ipmilan' --power-user=root --power-pass=djxxxx
電源管理相關的報錯
cobbler system edit --name host-xxx --power-address=172.17.11.20 --power-type="ipmitool" --power-user=root --power-pass=passwd
power management type must be one of:
cobbler system powerstatus --name=host-xx
task started: 2013-03-28_115206_power
task started (id=Power management (status), time=Thu Mar 28 11:52:06 2013)
Exception occured: cobbler.cexceptions.CX
Exception value: 'no power type set for system'
Exception Info:
File "/usr/lib/python2.4/site-packages/cobbler/utils.py", line 126, in die
raise CX(msg)
Exception occured: cobbler.cexceptions.CX
Exception value: 'no power type set for system'
Exception Info:
File "/usr/lib/python2.4/site-packages/cobbler/remote.py", line 89, in run
rc = self._run(self)
File "/usr/lib/python2.4/site-packages/cobbler/remote.py", line 259, in runner
self.remote.power_system(object_id,self.options.get("power",""),token,logger=self.logger)
File "/usr/lib/python2.4/site-packages/cobbler/remote.py", line 1919, in power_system
rc=self.api.power_status(obj, user=None, password=None, logger=logger)
File "/usr/lib/python2.4/site-packages/cobbler/api.py", line 1041, in power_status
return action_power.PowerTool(self._config, system, self, user, password, logger = logger).power("status")
File "/usr/lib/python2.4/site-packages/cobbler/action_power.py", line 74, in power
utils.die(self.logger,"no power type set for system")
File "/usr/lib/python2.4/site-packages/cobbler/utils.py", line 134, in die
raise CX(msg)
!!! TASK FAILED !!!
cobbler system powerstatus --name=host-188116
task started: 2013-03-28_124153_power
task started (id=Power management (status), time=Thu Mar 28 12:41:53 2013)
cobbler power configuration is:
type : ipmilan
address: 172.17.11.20
user : root
id :
running: /usr/sbin/fence_ipmilan
received on stdout: Getting status of IPMI:172.17.11.20...Chassis power = On
Done
received on stderr:
Exception occured: cobbler.cexceptions.CX
Exception value: "command succeeded (rc=0), but output ('Getting status of IPMI:172.17.11.20...Chassis power = On\nDone\n') was not understood"
Exception Info:
File "/usr/lib/python2.4/site-packages/cobbler/utils.py", line 126, in die
raise CX(msg)
Exception occured: cobbler.cexceptions.CX
Exception value: "command succeeded (rc=0), but output ('Getting status of IPMI:172.17.11.20...Chassis power = On\nDone\n') was not understood"
Exception Info:
File "/usr/lib/python2.4/site-packages/cobbler/remote.py", line 89, in run
rc = self._run(self)
File "/usr/lib/python2.4/site-packages/cobbler/remote.py", line 259, in runner
self.remote.power_system(object_id,self.options.get("power",""),token,logger=self.logger)
File "/usr/lib/python2.4/site-packages/cobbler/remote.py", line 1919, in power_system
rc=self.api.power_status(obj, user=None, password=None, logger=logger)
File "/usr/lib/python2.4/site-packages/cobbler/api.py", line 1041, in power_status
return action_power.PowerTool(self._config, system, self, user, password, logger = logger).power("status")
File "/usr/lib/python2.4/site-packages/cobbler/action_power.py", line 116, in power
utils.die(self.logger,"command succeeded (rc=%s), but output ('%s') was not understood" % (rc, output))
File "/usr/lib/python2.4/site-packages/cobbler/utils.py", line 134, in die
raise CX(msg)
!!! TASK FAILED !!!
解決方法詳見步驟8.2、8.3,詳細以下:
yum install cman -y
Cobbler代碼維護者jimi告知:某些系統版本將執行程序安裝在/sbin/目錄下,經過rpm -ql cman查看,CentOS5.8下如此解決便可
ln -s /sbin/fence_* /usr/sbin/
備份
cp/usr/lib/python2.4/site-packages/cobbler/action_power.py /usr/lib/python2.4/site-packages/cobbler/action_power.py.$(date +%F)
編輯
vim /usr/lib/python2.4/site-packages/cobbler/action_power.py
刪除或註釋此文件以下代碼
utils.die(self.logger,"command succeeded (rc=%s), but output ('%s') was not understood" % (rc, output))
刪除文件action_power.pyo 、 action_power.pyc
這兩個文件在目錄/usr/lib/python2.4/site-packages/cobbler/下
重啓cobbler,注意必定是重啓cobbler
cobbler reboot
步驟8.2、8.3是我在使用電源管理中發現的問題,後經過github與Cobbler代碼維護者jimi溝通解決的,很是感謝他的幫助,詳見
https://github.com/cobbler/cobbler/issues/426
10. DHCP非Cobbler本機
由於有的同窗生產環境已有DHCP服務,Cobbler本機能夠不用再安裝配置DHCP,步驟以下:
配置無論理DHCP
vim /etc/cobbler/settings
manage_dhcp: 0
重啓cobbler
/etc/init.d/cobblerd restart
檢查配置
cobbler check
同步配置
cobbler sync
DHCP服務配置next-server 指向cobbler服務器IP便可,例如
subnet 192.168.10.0 netmask255.255.255.0 {
range 192.168.10. 192.168.10.240;
option subnet-mask 255.255.255.0;
option routers 192.168.10.254;
next-server 192.168.4.194;
filename"pxelinux.0";
}
《Cobbler部署指南》參考資料:
https://github.com/cobbler/cobbler/wiki
cobbler、koan man手冊及help命令幫助
《Cobbler部署指南》系列至此告一段落,更多內容請一塊兒交流或參考Cobbler github。
《Cobbler部署指南》系列文檔下載:http://down.51cto.com/data/745895