運維自動化部署Cobbler之服務安裝篇

 

 
一、概述
服務最好安裝在 Centos下,它需要Python支持
Cobbler服務是一個容器,它整合了以下幾個開源軟件:
1 Dhcp
2 Dns (可選bind,dnsmasq)
3 Kickstart/PXE
4 Apache(提供kickstart 的安裝源,並提供定製化的kickstart配置)
5 Tftp (PXE啓動時需要)
 
同時,它和apache做了深度整合
 
通過 cobbler,可以實現對RedHat/Centos/Fedora系統的快速部署,同時也支持Suse 和Debian(Ubuntu)系統
 
綜上所述,一個理想的安裝環境是:
1 系統 Centos 5/6
2 Python
Python2.4以上 
(更低的版本沒有測試過)
3 Apache
Apache1/2 都可以,須打開模塊:mod_wsgi
以支持Cobbler的相關python代碼
4 Dhcp 必選項(很多定製化選項,都需要修改Dhcp配置)
5 Bind 可選
6 Tftp  
 
相關配置參數:
1 服務器IP 192.168.100.1/24 , 192.168.3.1/24
2 Cobbler服務 監聽IP 192.168.100.1
3 DHCP 可配置IP段
192.168.100.100/24 --- 192.168.100.180/24
192.168.3.2/24 --- 192.168.3.128/24
注意 : 我的配置中有2段IP,其中第二段 是爲cobbler準備的

官方文檔 : https://github.com/cobbler/cobbler/wiki/
 
二、 安裝
1)  定義 Yum源
可根據自己所在地選擇離自己近的鏡像源,比如mirrors.163.com或mirrors.sohu.com
相關配置文件: /etc/yum.repos.d/CentOS-Base.repo
 
2)  安裝 epel源
 Centos5 32位: rpm -Uvh http://mirrors.ustc.edu.cn/fedora/epel/5/i386/epel-release-5-4.noarch.rpm
 Centos5 64位: rpm -Uvh http://mirrors.ustc.edu.cn/fedora/epel/5/x86_64/epel-release-5-4.noarch.rpm
 
 Centos6 32位: rpm -Uvh 'http://mirrors.ustc.edu.cn/fedora/epel/6/i386/epel-release-6-7.noarch.rpm'
 Centos6 64位: rpm -Uvh 'http://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/epel-release-6-7.noarch.rpm'
 
 
 確定是否正確安裝 :
 yum list|grep -E "^epel"
 epel-release.noarch                        5-4                         installed
 
也可以用這個命令: rpm -qa |grep -i epel
 
3) 安裝cobbler服務 
 A) yum -y install cobbler
 確認是否正確安裝 :
 rpm -qa |grep -i cobbler
 
 B) 安裝其它需要的服務
 yum -y install cman tftp-server dhcp cobbler cobbler-web bind pykickstart rsync
 根據需要來,比如 我的測試環境不需要bind,就沒有安裝
 
 需要確認 mod_wsgi已經正確安裝,否則需要手動安裝
 yum -y install mod_wsgi
 確認apache配置已經 加載wsgi_module:  /etc/httpd/conf.d/wsgi.conf
 
4) 安裝debmirror
 debmirror 可以用來下載 ubuntu 12.04的鏡像源 來做本地源.
 
 目前debmirrors, 只能使用rpm包安裝, 先裝依賴包
 yum -y install ed patch perl perl-Compress-Zlib perl-Cwd perl-Digest-MD5 perl-Digest-SHA1 perl-LockFile-Simple perl-libwww-perl
 
 安裝debmirrors : 
 rpm -Uvh 'http://mirrors.ustc.edu.cn/fedora/epel/5Server/x86_64/debmirror-20090807-1.el5.noarch.rpm'
 
 5) 關閉selinux 和防火牆
 sed -i '/^SELINUX=/ s/^SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
 setenforce 0
 
 //爲調試方便,暫時關閉防火牆
 service iptables stop
 
6) 啓動Cobbler服務
 /etc/init.d/cobblerd start
 
 7) 可能會缺少的包:
 請 注意察看 cobbler服務啓動的報錯信息
 我第一次安裝時候就遇到有關 ctypes的報錯,只能手動安裝
 yum -y install python-ctypes
  
 8) Cobbler相關配置
 根據需要修改 cobbler主配置文件: /etc/cobbler/settings
 
 //cobbler監聽IP是 192.168.100.1
 sed -i 's/server: 127.0.0.1/server: 192.168.100.1/g' /etc/cobbler/settings
 
//pxe安裝 只允許一次,防止誤操作 ( 在正式環境有用。實際測試來看,這個功能可以屏蔽掉 )
 sed -i 's/pxe_just_once: 0/pxe_just_once: 1/g' /etc/cobbler/settings
 
//dhcp 服務的IP地址,PXE過程中 會用到
 sed -i 's/next_server: 127.0.0.1/next_server: 192.168. 100.1 /g' /etc/cobbler/settings
 
//支持 對的dhcp管理,在做自定義配置時,需要修改dhcp相關配置,以配合PXE啓動用
 sed -i 's/manage_dhcp: 0/manage_dhcp: 1/g' /etc/cobbler/settings
 
 
 9) 進行cobbler系統檢查
 cobbler check
 可自動 檢查安裝環境是否滿足cobbler服務的需要
 
 出現如下結果提示:
 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.
//解決辦法 : 執行 cobbler get-loaders
 
2 : since iptables may be running, ensure 69, 80/443, and 25151 are unblocked
//解決辦法 : iptables 保證對 69 80 443 25151 端口的 數據沒有限制,如果僅僅只是在內部環境中使用,建議直接將防火牆關掉
 
3 : debmirror package is not installed, it will be required to manage debian deployments and repositories
//解決辦法 :  debian 安裝用,暫時可以不管;如果需要安裝,下載地址爲:http://rpmfind.net/linux/rpm2html/search.php?query=debmirror
 
4 : 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
//解決辦法 :  默認加密的密碼,可以修改
 
5 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them
//解決辦法 : 關於電源管理(跟DELl 遠程控制協議類似東西?),也暫時不管
 
10)重啓 cobbler,並更新相關配置
//重啓服務
/etc/init.d/cobblerd restart
 
//同步最新cobbler配置,它會根據配置自動修改dhcp,bind 等服務,因此我稱之爲容器的原因
cobbler sync
 
注:在 對cobbler進行研究的整個過程中,得到了前輩 陳沙克老師( www.chenshake.com ) 的大力支持和解惑,在編寫此文時,也借鑑了部分 沙克老師的文章,特此感謝!!!
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章