品運維自動化之cobbler的安裝序

weixin_34377065發表於2012-11-01

品運維自動化之cobbler的安裝序

品茶提示:

1、安裝如遇錯誤,請檢視錯誤報告收集。

2、如遇文章出現錯誤之處請指出並回覆以便幫助更多的朋友,或者發郵件至zwhset@163.com,我將定期回覆。

2013/10/24更新內容:

1、新增ks.cfg檔案


2012/11/2更新內容:

1、新增安裝條件。
2、新增圖片。
3、新增cobbler工作流程。
4、增加CentOS6的下載源


2012/11/3更新內容:

1、更新視平教程,建議全屏觀看,挺清楚的。{注:聲音啞了,不是太好。中間有一個卡頓是由於cobbler improt載入時間太長,將近半個小時。所以後期剪了一下。}



使用前提:

1、你有一個DVD或ISO檔案,您的作業系統的分佈。
2、伺服器有足夠的本地磁碟的可用空間在/var/www/cobbler 解壓縮DVD/ISO。
3、伺服器和客戶端都有一個共同的IP網路。
4、這個網路上的DHCP伺服器的伺服器是唯一的例項。
5、在此網路上的客戶端是支援PXE網路啟動。


Cobbler工作流程:


102451202.jpg

一、載入Fedor的Epel源

CentOS 5 x86_64
rpm -ivh http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
CentOS6 x86_64:
rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-7.noarch.rpm
CentOS6 i386:
rpm -ivh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-7.noarch.rpm


二、開始安裝
1、Yum安裝所需檔案
yum install cobbler httpd rsync tftp-server xinetd dhcp python-ctypes -y
2、效驗cobbler安裝條件
cobbler check
3、更改配置以適用於cobbler執行
vi /etc/cobbler/settings
'next_server: 127.0.0.1' 替換成 'next_server:本機IP地址' {注:此為DHCP服務地址}
'server: 127.0.0.1' 替換成 'server: 192.168.0.28' {此為cobbler服務地址}
'manage_dhcp: 0' 替換成 'manage_dhcp: 1' {注:此為使cobbler管理dhcp也就是後面用於同步更新配置資訊[cobbler sync]}
'manage_rsync: 0' 替換成 'manage_rsync: 1' {注:此為使cobbler管理rsync功能}
2、針對SELinux許可權設定,在此我們關閉SELinux,也可根據提示進行更改。
3、進行更新fedora的loader資訊
cobbler get-loaders
4、設定 'disable' 為 'no'
vi /etc/xinetd.d/tftp
5、設定 'disable' 為 'no'
vi /etc/xinetd.d/rsync
6、#your-password-here處設定你需要的密碼。此為防止誤裝。
openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'
7、修改預設dhcp。{注:一例例項,詳細可檢視以前部落格kickstart相關。}
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;
}
三、匯入映象進行配置
1、上傳ISO映象至伺服器
2、建立資料夾
mkdir -p /system/centos5.4-i686
3、掛載ISO映象到/system/centos5.4-i686目錄
mount -o loop ~/install/CentOS-5.5-x86-bin-DVD.iso /system/centos5.4-i686/
4、從DVD中匯入客戶端的OS。這將自動設定了“x86_64”,並將其命名為centos5.4-i686。{注:這需要一點時間,不要急。可檢視/var/www/cobbler/ks_mirror/centos5.4-i686-x86_64/目錄檔案生成情況。}
cobbler import --path=/system/centos5.4-i686/ --name=centos5.4-i686 --arch=x86_64
5、比較一下大小
[root@cobbler ~]# du -sh /var/www/cobbler/ks_mirror/centos5.4-i686-x86_64/
3.9G/var/www/cobbler/ks_mirror/centos5.4-i686-x86_64/
[root@cobbler ~]# du -sh /system/centos5.4-i686/
4.1G/system/centos5.4-i686/
6、更改kickstart檔案,可為http等,具體cobbler --help檢視 {可選擇執行}
cobbler profile edit --name=centos5.4-i686-x86_64 --kickstart=???
7、cobbler report進行資訊檢視{注:下面取一段。方便更加詳細瞭解cobbler結構。}
Name : centos5.4-i686-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : centos5.4-i686-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart : /var/lib/cobbler/kickstarts/sample.ks
Kickstart Metadata : {}
Management Classes : []
Management Parameters : <<inherit>>
Name Servers : []
Name Servers Search Path : []
Owners : ['admin']
Parent Profile :
Proxy :
Red Hat Management Key : <<inherit>>
Red Hat Management Server : <<inherit>>
Repos : []
Server Override : <<inherit>>
Template Files : {}
Virt Auto Boot : 1
Virt Bridge : xenbr0
Virt CPUs : 1
Virt Disk Driver Type : raw
Virt File Size(GB) : 5
Virt Path :
Virt RAM (MB) : 512
Virt Type : qemu
8、檢視匯入列表
cobbler distro list
9、獲取上述所有配置的cobbler(包括啟動DHCP等)
cobbler sync

10、正確安裝後客戶端啟動出現圖為如下:

091527891.jpg

四、資訊區:
1、coobler check提示資訊:
The following are potential configuration items that you may want to fix:
1 : The 'server' field in /etc/cobbler/settings must be set to something other than localhost, or kickstarting features will not work. This should be a resolvable hostname or IP for the boot server as reachable by all machines that will use it.
2 : For PXE to be functional, the 'next_server' field in /etc/cobbler/settings must be set to something other than 127.0.0.1, and should match the IP of the boot server on the PXE network.
3 : you need to set some SELinux content rules to ensure cobbler serves content correctly in your SELinux environment, run the following: /usr/sbin/semanage fcontext -a -t public_content_t "/tftpboot/.*" && /usr/sbin/semanage fcontext -a -t public_content_t "/var/www/cobbler/images/.*"
4 : you need to set some SELinux rules if you want to use cobbler-web (an optional package), run the following: /usr/sbin/semanage fcontext -a -t httpd_sys_content_rw_t "/var/lib/cobbler/webui_sessions/.*"
5 : 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.
6 : change 'disable' to 'no' in /etc/xinetd.d/tftp
7 : change 'disable' to 'no' in /etc/xinetd.d/rsync
8 : debmirror package is not installed, it will be required to manage debian deployments and repositories
9 : 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
Restart cobblerd and then run 'cobbler sync' to apply changes.

2、什麼是Rsync

rsync is an open source utility that provides fast incremental file transfer. rsync is freely available under the GNU General Public License and is currently being maintained by Wayne Davison.

Rsync是一個
開源的 應用程式,提供快速增量檔案傳輸。Rsync是免費提供根據GNU通用公共許可證,目前正在維護 韋恩·戴維森

3、收集常用命令:
#重新命名安裝選項名字:
cobbler profile rename --name='old name' –newname='new name'
#冊除選項:
cobbler profile rename --name='old name'

4、KickStart options詳解:
引用:
kickstart是什麼

許多系統管理員寧願使用自動化的安裝方法來安裝紅帽企業 Linux.為了滿足這種需要,紅帽建立了kickstart安裝方法.使用kickstart,系統管理員可以建立一個檔案,這個檔案包含了在典型的安裝過程中所遇 到的問題的答案.


Kickstart檔案可以存放於單一的伺服器上,在安裝過程中被獨立的機器所讀取.這個安裝方法可以支援使用單一kickstart檔案在多臺機器上安裝紅帽企業Linux,這對於網路和系統管理員來說是個理想的選擇.


Kickstart給使用者提供了一種自動化安裝紅帽企業Linux的方法.



如何執行kickstart安裝


kickstart 安裝可以使用本地光碟,本地硬碟驅動器,或通過 NFS,FTP,HTTP 來執行.


要使用 kickstart,必須:


1.建立一個kickstart檔案.


2.建立有kickstart檔案的引導介質或者使這個檔案在網路上可用.


3.籌備安裝樹.


4.開始kickstart安裝.
更多:可檢視下載附件。或者網頁地址,


http://blog.chinaunix.net/uid-17240700-id-2813881.html


五、錯誤報告:
1、cobblerd校驗錯誤:
cobblerd does not appear to be running/accessible
解決方法:
service cobblerd start
service httpd start
2、重啟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。
3、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,重啟使之生效。
4、較驗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
六、參考地址:
https://github.com/cobbler/cobbler/wiki/Start%20Here
http://dl528888.blog.51cto.com/2382721/1004298
#cobbler設定相關:
煮酒品茶:遇錯誤多看/var/log/message再根據百度谷歌解決。

未完待續......


kickstart file:

注:這是從51CTO一網友搞過來的,忘了地址。

#set $swap= $getVar('$swap', '12000')

autostep --autoscreenshot

install

url --url=$tree

# If any cobbler repo definitions were referenced in the kickstart profile, include them here.

$yum_repo_stanza

text

skipx

lang en_US.UTF-8

keyboard us

network --onboot yes --bootproto dhcp --noipv6 --nodns

rootpw --iscrypted $1$xzY0mzCP$bBhzWwNV.ECfF.MV9PRkC1

firewall --disabled

firstboot --disabled

authconfig --enableshadow --passalgo=sha512

selinux --disabled

#timezone --isUtc Asia/Shanghai

timezone --utc Asia/Shanghai

# The following is the partition information you requested

# Note that any partitions you deleted are not expressed

# here so unless you clear all partitions first, this is

# not guaranteed to work

logging --level=info

#bootloader --append="nohz=off" --location=mbr

bootloader --location=mbr

#bootloader --location=mbr --driveorder=sda --append="biosdevname=0 nohz=off thash_entries=1048576 rhash_entries=1048576 selinux=0"

zerombr yes

# clearpart --all --initlabel --drives=sda

clearpart --all --initlabel

# ignoredisk --only-use=sda

#part / --fstype=ext4 --asprimary --size=50000 --maxsize=50000 --label=/

#part swap --asprimary --size=$swap --maxsize=$swap --label=swap

#part /data --fstype=xfs --grow --asprimary --size=12000 --label=/data

part /boot --fstype="ext4" --size=200

part swap --fstype="swap" --size=1024

part / --fstype="ext4" --grow --size=1


%pre

$SNIPPET('pre_install_network_config')

# Add Pre-Installation Script here

date

%end

%packages --excludedocs --ignoremissing

@base

@core

@development

@server-policy

telnet

-iptables

%end

$SNIPPET('services_disable_enable')

%post

$SNIPPET('post_install_network_config')

$SNIPPET('env_init')

$SNIPPET('kis_cobbler_api')

$SNIPPET('cactirelease')

$SNIPPET('kisyum_install')

/usr/sbin/eject -rv /dev/sr* # eject P cdrom

echo 'v1.3' > ~root/VERSION

%end

# finish

reboot

#reboot --eject



煮酒品茶記於2012/11/1日


相關文章