cobbler簡介
Cobbler是一個快速網(wǎng)絡(luò)安裝linux的服務(wù),而且在經(jīng)過調(diào)整也可以支持網(wǎng)絡(luò)安裝windows硫椰。該工具使用python開發(fā),使用簡單的命令即可完成PXE網(wǎng)絡(luò)安裝環(huán)境的配置磁餐,同時還可以管理DHCP子漩、DNS、yum倉庫舆蝴、構(gòu)造系統(tǒng)ISO鏡像谦絮。支持命令行管理,web界面管理洁仗,還提供了API接口层皱,方便二次開發(fā)。
cobbler的核心概念
Distros(發(fā)行版):表示一個操作系統(tǒng)赠潦,它承載了內(nèi)核和initrd的信息叫胖,以及內(nèi)核參數(shù)等其他數(shù)據(jù)
Profile(配置文件):包含一個發(fā)行版、一個kickstart文件以及可能的存儲庫她奥,還包含更多特定的內(nèi)核參數(shù)等其他數(shù)據(jù)
Systems(系統(tǒng)):表示要配給的額機(jī)器瓮增。它包含一個配置文件或一個鏡像,還包含IP和MAC地址哩俭、電源管理(地址钉赁、憑據(jù)、類型)携茂、(網(wǎng)卡綁定你踩、設(shè)置valn等)
安裝配置cobbler
安裝cobbler之前,需要首先安裝cobbler依賴的一些服務(wù):httpd讳苦、tftp带膜、dhcp、rsync鸳谜。
yum -y install httpd tftp-server rsync dhcp
yum -y install cobbler
cobbler可行管理這些服務(wù)中的部分甚至全部膝藕,但需要配置/etc/cobbler/settings文件中的“manager_dhcp”、“manage_tftpd”咐扭、“manage_rsync”芭挽、“manage_dns”來定義滑废,同時各種服務(wù)都有著不同的實現(xiàn)方式,如果進(jìn)行自定義袜爪,需要通過修改/etc/cobbler/modules.conf配置文件中各個服務(wù)的模塊參數(shù)的值來實現(xiàn)蠕趁。
這里先不采用cobbler管理,手動配置dhcp服務(wù)
cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample? /etc/dhcp/dhcpd.conf
配置dhcp服務(wù),編輯配置文件/etc/dhcp/dhcpd.conf
#option domain-name"magedu.com";#option domain-name-servers172.16.253.85;subnet172.16.0.0netmask255.255.0.0{range172.16.0.1172.16.0.100;filename"pxelinux.0";next-server172.16.253.85;}
啟動服務(wù)辛馆,并設(shè)置為開機(jī)自動啟動
systemctl enable tftp.socket dhcpd
systemctl start? xinted tftp.socket dhcpd? httpd cobblerd
然后使用cobbler check檢查cobbler的運(yùn)行環(huán)境俺陋,第一次運(yùn)行可能會存在如下錯誤():
cobbler check1:The'server'fieldin/etc/cobbler/settings must besetto something other than localhost,or kickstarting features will not work.Thisshould be a resolvable hostname or IPforthe boot server as reachable by all machines that will use it.2:ForPXE to be functional,the'next_server'fieldin/etc/cobbler/settings must besetto something other than127.0.0.1,and should match the IP of the boot server on the PXE network.3:some network boot-loaders are missing from/var/lib/cobbler/loaders,you may run'cobbler get-loaders'to download them,or,ifyou 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.Filesinthis 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.4:change'disable'to'no'in/etc/xinetd.d/rsync5:comment out'dists'on/etc/debmirror.confforproper debian support6:comment out'arches'on/etc/debmirror.confforproper debian support7:Thedefault password used by the sample templatesfornewly installed machines(default_password_cryptedin/etc/cobbler/settings)is stillsetto'cobbler'and should be changed,try:"openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'"to generate new one
依次解決上述錯誤:
1、vim /etc/cobbler/settings
next_server: 172.16.253.85??????????????????????????????????????????? ? ? 解決第1個報錯
server: 172.16.253.85???????????????????????????????????????????????????????? 解決第2個報錯
default_password_crypted:”$6$ycj3gRS8$9DjGjCg4bmZMA06UbJc.XXxoX35RR66AfCDNqHMKWUeQ1xlIicJCMCA6Uq32itdaWri2MwxF4BrnbSqy8yQ0Z0″
解決第6個報錯
2昙篙、yum -y install syslinux????????????????????????????????????????????? 解決第3個報錯
3腊状、第4個報錯忽略
4、安裝ksvalidator
yum -y install pykickstart???????????????????????????? ? ? ? ? ? ? ?? 解決第5個報錯
5苔可、由于無fencing設(shè)備缴挖,忽略
修改完成后重啟cobbler服務(wù)
cobbler sync
systemctl restart cobblerd
定義cobbler
可以通過其指定外部的安裝引導(dǎo)內(nèi)核及ramdisk文件的方式實現(xiàn)》俑ǎ或使用已經(jīng)有現(xiàn)成的安裝樹(如OS的安裝鏡像)import導(dǎo)入的方式醇疼。
掛載光盤鏡像,這里以centos6.7為例
mount /dev/sr0 /data
cobbler import –name=centos6.7 –path=/data
mkdir /var/www/html/centos
ln -s /var/www/cobbler/ks_mirror/centos6.7/ /var/www/html/centos/
導(dǎo)入光盤鏡像,導(dǎo)入完成后法焰,在/var/www/cobbler/ks_mirror目錄下會生成一個–name指定的名稱的目錄,這個目錄與掛載在本地的光盤鏡像目錄一致
制作kickstart文件倔毙,在圖形界面啟動system-config-kickstart
注意:如果此處無法顯示埃仪,請嘗試修改/etc/yum.repo.d/xxx.repo中的yum源id為development? 如:
[development]
name=added from:file:///data/baseurl=file:///data/
enabled=1
gpgcheck=0
生成ks.cfg文件如下
#platform=x86,AMD64,orIntelEM64T#version=DEVEL#InstallOS instead of upgrade
install#Keyboardlayouts
keyboard'us'#Rootpassword
rootpw--iscrypted $1$iWvg.11Q$xWlQBI.14Ss9zbdWtqV.L1#Systemtimezone
timezoneAsia/Shanghai#Usenetwork installation
url--url="http://172.16.253.85/centos"#Systemlanguage
lang en_US#Firewallconfiguration
firewall--disabled#Systemauthorization information
auth--useshadow--passalgo=sha512#Usegraphical install
graphical
firstboot--disable#SELinuxconfiguration
selinux--disabled#Rebootafter installation
reboot#Systembootloader configuration
bootloader--location=mbr#Partitionclearing information
clearpart--all#Diskpartitioning information
part/boot--fstype="ext4"--size=200part/--fstype="ext4"--size=10240part swap--fstype="swap"--size=1024%packages@base%end
檢查ks文件語法,kickstart文件默認(rèn)放在/var/lib/cobbler/kickstarts/目錄下
ksvalidator? /var/lib/cobbler/kickstarts/ks.cfg?
[root@magedu~]#cobbler distro list
centos6.7-x86_64
指定kickstart文件
cobbler profile add--name=centos6.7--distro=centos6.7-x86_64--kickstart=/var/lib/cobbler/kickstarts/ks.cfg
[root@magedu~]#cobbler sync
task started:2016-08-11_125253_sync
task started(id=Sync,time=ThuAug1112:52:532016)..........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 ***
測試自動安裝
安裝過程基本無須手動干預(yù)陕赃,安裝過程不再贅述卵蛉,檢查系統(tǒng)及配置
cobbler服務(wù)器驗證
安裝完畢