歡迎您光臨本站 註冊首頁

cobbler 無人值守安裝Linux

←手機掃碼閱讀     火星人 @ 2014-03-08 , reply:0

1.Cobbler介紹

Cobbler是一個快速網路安裝linux的服務,而且在經過調整也可以支持網路安裝windows.該工具使用python開發,小巧輕便(才15k行代碼),使用簡單的命令即可完成PXE網路安裝環境的配置,同時還可以管理DHCP,DNS,以及yum包鏡像.

Cobbler支持命令行管理,web界面管理,還提供了API介面,可以方便二次開發使用.

和Kickstart不同的是,使用cobbler不會在區域網中啟動了dhcp而導致有些機器默認從pxe啟動在重啟伺服器后載入tftp內容導致啟動終止.

2.開始安裝cobbler

註:默認的centos6沒有cobbler包,需要到其它鏡像去下載

wget http://download.fedora.redhat.com/pub/epel/6/i386/epel-release-xx..noarch.rpm

epel-release-xx..noarch.rpm 下載對應的系統包,centos6 對應的是 epel-release-6-5.noarch.rpm

rpm –Uvh epel-release-6-5.noarch.rpm

yum install cobbler cobbler-web tftp rsync httpd dhcp xinetd

3.開始配置

#service httpd start

#service cobblerd start

#cobbler 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 works 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 : 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. 5 : change 'disable' to 'no' in /etc/xinetd.d/tftp 6 : change 'disable' to 'no' in /etc/xinetd.d/rsync 7 : since iptables may be running, ensure 69, 80, and 25151 are unblocked 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.

上面這段信息大意就是:

1. 編輯/etc/cobbler/settings文件,找到 server選項,修改為適當的ip地址,本實例配置ip為:192.168.1.13(這個根據自己的可以設置);

2. 編輯/etc/cobbler/settings文件,找到 next_server選項,修改為適當的ip地址,本實例配置ip為:192.168.1.13;

3. SELinux的設置.如果上面已經關閉了SELinux就不用管了;

4. 執行 cobbler get-loaders,系統將自動下載loader程序,完成提示4的修復工作;

5. 編輯/etc/xinetd.d/tftp文件,將文件中的disable欄位的配置由yes改為no;

6. 編輯/etc/xinetd.d/rsync文件,將文件中的disable欄位的配置由yes改為no;

7. 在iptables中將69,80,25151埠打開.如果僅僅只是在內部環境中使用,建議直接將防火牆關掉;

8. 提示說debmirror沒安裝.如果不是安裝 debian之類的系統,此提示可以忽略,如果需要安裝,下載地址為;

http://rpmfind.net/linux/rpm2html/search.php?query=debmirror

CentOS 6使用RHEL 5的包就可以.

9. 修改cobbler用戶的默認密碼,可以使用如下命令生成密碼,並使用生成后的密碼替換/etc/cobbler/settings中的密碼.生成密碼命令:

openssl passwd -1 -salt 'random-phrase-here' 'your-password-here' 其中“random-phrase-here”為干擾碼 (默認的用戶名和密碼都是cobbler);

4.cobbler的使用 導入鏡像文件,把dvd光碟掛載到cobbler伺服器上 一般都是mount /dev/cdrom /media 然後就是同步你的鏡像文件了 cobbler import --path=/media/CentOS_6.0_Final --name='CentOS_6.0_Final' 這個時間很長,要等, 完成後 cobbler會將鏡像中的拷貝到本地一份,放在/var/www/cobbler/ks_mirrors下的CentOS_6.0_Final目錄下. 同時會創建一個名字為CentOS_6.0_Final的一個發布版本,以及一個名字為CentOS_6.0_Final的profile文件.

5.配置dhcp服務 編輯文件/etc/cobbler/settings把 manage_dhcp 改為 1 讓cobbler來管理dhcp服務 接下來修改/etc/cobbler/dhcp.template,此文件是cobbler管理dhcp的模板,對於此文件,本例中只需要修改如下部分

ddns-update-style interim;

allow booting;
allow bootp;

ignore client-updates;
set vendorclass = option vendor-class-identifier;

subnet 192.168.1.0 netmask 255.255.255.0 {
option routers 192.168.1.1;
option domain-name-servers 202.102.192.68;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.1.14 192.168.1.254;
filename "/pxelinux.0";
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
}

其餘部分維持默認值即可

我這裡有個問題是測試的時候老是找不到dhcp,我明明配置了dhcp,然後我就改成dnsmasq去管理dhcp和dns

先編輯/etc/cobbler/modules.conf

[dns]
module = manage_bind 改為 manage_dnsmasq

[dns]
module = manage_bind 改為 manage_dnsmasq

在編輯一下/etc/dnsmasq.conf,內容像這樣

read-ethers
addn-hosts = /var/lib/cobbler/cobbler_hosts

dhcp-range=192.168.1.5,192.168.1.200
dhcp-option=3,192.168.1.13
dhcp-lease-max=1000
dhcp-authoritative
dhcp-boot=pxelinux.0
dhcp-boot=net:normalarch,pxelinux.0
dhcp-boot=net:ia64,/var/lib/cobbler/elilo-3.6-ia64.efi

然後啟動service dnsmasq start

在同步一下cobbler

#cobbler sync; #service cobblerd restart 測試一下: 打開一個新的虛擬機

cobbler 的一些信息可以到

http://pkgs.org/centos-6-rhel-6/epel-i386/cobbler-web-2.0.11-2.el6.noarch.rpm.html

找找!


[火星人 ] cobbler 無人值守安裝Linux已經有481次圍觀

http://coctec.com/docs/linux/show-post-46794.html