Cobbler應用
Cobbler簡介:
Cobbler是一個快速網絡安裝linux的服務,而且在經過調整也可以支持網絡安裝windows。該工具使用python開發,小巧輕便(才15k行代碼),使用簡單的命令即可完成PXE網絡安裝環境的配置,同時還可以管理DHCP,DNS,以及yum包鏡像。
實驗:安裝Cobbler,能夠自動安裝系統。
1, 安裝Cobbler,(在安裝cobbler之前 還需要安裝應用)
#yum install cobbler-web pykickstart debmirror
#yum install cobbler
2, 啓動服務
# service httpd start
#service cobblerd start
LISTEN 0 5 127.0.0.1:25151 *:*
3, 進行檢查
Cobbler check
1 : The'server' field in /etc/cobbler/settings must be set to something other thanlocalhost, or kickstarting features will not work. This should be a resolvable hostname or IPfor the boot server as reachable by all machines that will use it.
2 : ForPXE to be functional, the 'next_server' field in /etc/cobbler/settings must beset to something other than 127.0.0.1, and should match the IP of the bootserver on the PXE network.
3 : somenetwork boot-loaders are missing from /var/lib/cobbler/loaders, you may run'cobbler get-loaders' to download them, or, if you only want to handlex86/x86_64 netbooting, you may ensure that you have installed a *recent*version of the syslinux package installed and can ignore this messageentirely. 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 theeasiest way to resolve these requirements.
4 :change 'disable' to 'no' in /etc/xinetd.d/rsync
5 :debmirror package is not installed, it will be required to manage debiandeployments and repositories
6 :ksvalidator was not found, install pykickstart
7 : Thedefault 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
8 : fencing tools were not found, and are required to usethe (optional) power management features. install cman or fence-agents to usethem
如上各問題的解決方法如下所示:
(1)、修改/etc/cobbler/settings文件中的server參數的值爲提供cobbler服務的主機相應的IP地址或主機名,如172.16.100.15;
(2)、修改/etc/cobbler/settings文件中的next_server參數的值爲提供PXE服務的主機相應的IP地址,如172.16.100.16;
(3)、如果當前節點可以訪問互聯網,執行“cobbler get-loaders”命令即可;否則,需要安裝syslinux程序包,而後複製/usr/share/syslinux/{pxelinux.0,memu.c32}等文件至/var/lib/cobbler/loaders/目錄中;
(4)、執行“chkconfigrsync on”命令即可;
(5)、註釋/etc/debmirror.conf文件中的“@dists="sid";”一行;
(6)、註釋/etc/debmirror.conf文件中的“@arches="i386";”一行;
(7)、執行“opensslpasswd -1 -salt $(openssl rand -hex 4)”生成密碼,並用其替換/etc/cobbler/settings文件中default_password_crypted參數的值;
(8)、執行“yum install cman fence-agents”命令安裝相應的程序包即可;
4,# openssl passwd -1-salt `openssl rand -hex 4`
Password:(caoshujia)
$1$001ebc8f$VxYLBp0cdy/7TaGodSaxV0
default_password_crypted:"$1$mF86/UHC$WvcIcX2t6crBz2onWxyac."
然後把上面得出的替換掉現有的
default_password_crypted: "$1$001ebc8f$VxYLBp0cdy/7TaGodSaxV0"
然後保存退出
5,重啓cobbler
#service cobblerd restart
6,拷貝文件
#cd /usr/share/syslinux/
#cp-r ./* /var/lib/cobbler/loaders/
7,安裝dhcp服務,編輯配置文件,啓動服務
#yuminstall dhcp –y
#cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf
#vim /etc/dhcp/dhcpd.conf
optiondomain-name "mageedu.com"; 修改域名,根據實際情況而定
option domain-name-servers 172.16.0.1;
subnet 172.16.0.0 netmask 255.255.0.0 {
range 172.16.31.101172.16.31.201;
option routers 172.16.31.10;
}
next-server 172.16.31.10;
filename="pxelinux.0";
# service dhcpd start
UNCONN 0 0 *:67 *:*
8,啓動tftp服務
#chkconfig tftp on
#service xinetd start
#ss –tunl
udp UNCONN 0 0 *:69 *:*
9,使用distro
然後掛載
# mount /dev/cdrom /mnt –r
# ls /mnt
CentOS_BuildTag images repodata RPM-GPG-KEY-CentOS-Testing-6
EFI isolinux RPM-GPG-KEY-CentOS-6 TRANS.TBL
EULA Packages RPM-GPG-KEY-CentOS-Debug-6
GPL RELEASE-NOTES-en-US.html RPM-GPG-KEY-CentOS-Security-6
然後用cobbler import 導入
# cobbler import --path=/mnt--name=centos-6.5-x86_64
(開始導入,建議找一個小一點的導入,這一步很慢,請耐心等待)
# cobbler distro list
centos-6.5-x86_64 (表示已經完成系統導入)
然後cd /tmp
#wget http://172.16.0.1/centos6.x86_64.cfg(下載cfg文件,這個是系統配置信息)
# cobbler profile add--name=centos-6.5-x86_64-basic --distro=centos-6.5-x86_64 --kickstart=/tmp/centos6.x86_64.cfg(檢測文件是否有語法錯誤)
# cobbler profile list
centos-6.5-x86_64
centos-6.5-x86_64-basic
在修改# cd /tmp/ centos6.x86_64.cfg文件
url --url=http://172.16.31.10/cobbler/ks_mirror/centos-6.5-x86_64/ 修改爲提供服務的地址
# cobbler profile edit--name=centos-6.5-x86_64-basic --distro=centos-6.5-x86_64--kickstart=/tmp/centos6.x86_64.cfg
# cobbler sync