Cobbler是PXE的二次封裝,使用Python語言開發, 可以用來快速建立 Linux 網絡安裝環境,它已將 Linux 網絡安裝的技術門檻,從大專以上文化水平,成功降低到初中以下,連補鞋匠都能學會。
cobbler配置過程需要基於PXE環境,cobbler是pxe環境的二次封裝
(演示環境centos7,centos6請自行完成)
一:安裝cobbler、httpd
yum
install -y cobbler httpd
二:啟動cobbler、httpd
systemctl
start cobblerd.service
systemctl
start httpd.service
三:創建cobbler的配置環境
cobbler
check
四:解決報錯信息
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 : change 'disable' to 'no' in /etc/xinetd.d/tftp
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 : enable and start rsyncd.service with systemctl
6 : debmirror package is not installed, it will be required to manage debian deployments and repositories
7 : 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
8 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them
五:解決錯誤( 注意每一個問題解決要查看效果,需要重啟cobblerd服務)
(
1)解決第一個問題
這里需要將/etc/cobbler/
settings這個文件中的server這一項的主機地址改為 server: 192.168.10.10
(
2)解決第二個問題
這里需要將/etc/cobbler/
settings這個文件中的next_server這一項的主機地址改為 next_server: 192.168.10.10
(
3)解決第三個問題
啟動rsync, 讓其開機自啟: systemctl
start rsyncd.service,systemctl enable rsyncd.service
(
4)解決第四個問題
在/etc/xinetd.d/tftp配置文件中修改
disable = no ,讓tftp服務開機自啟動 , 再重啟tftp服務,systemctl start tftp.socket ,systemctl enable tftp.socket
(
5)解決第五個問題
在/etc/cobbler/
settings這個文件中的default_password_crypted: 后面的密碼改掉,先創建一個用戶,給這個用戶設定密碼,然后就將這個用戶的密碼貼在這個選項的后面就是
(
6)解決第六個問題
yum
install -y debmirror
將/etc/debmirror.conf文件的dists和arches那兩行注釋掉
(
7)解決第七個問題
運行cobbler命令,下載對於的安裝包
cobbler
get-loaders
(
8)解決第八個問題
yum
install -y fence-agents
六:解決全部的cobbler配置問題之后,最后再重啟cobbler,檢查
systemctl restart cobblerd.service
cobbler
check
No configuration problems found. All systems go
七:配置好dhcp、tftp之后,開始配置cobbler,(dhcp、tftp、服務的配置與PXE環境一樣)
確保dhcp、tftp、httpd服務都已經啟動
八:准備創建distro
(
1)掛載centos 7的光盤鏡像到/media/cdrom目錄下
mount -r /dev/cdrom /media/cdrom/
(
2)使用cobbler import 命令生成一個distro
cobbler
import --name="CentOS-7_x86_64-1611" --path=/media/cdrom
(
3)查看生成的cobbler distro
[root@
7 ks_mirror]# cobbler distro list
CentOS
-7-1611-x86_64
(
4)查看生成的cobbler profile
[root@
7 ks_mirror]# cobbler profile list
CentOS
-7-1611-x86_64
(
5)同步cobbler 或 重啟
cobbler
sync 或 systemctl restart cobblerd
(
6)此時cobbler已經簡單部署完畢,在內網192.168.10.0網段啟動一個虛擬機,選擇網卡啟動,可以像PXE環境一樣,可以直接安裝系統了。
九:可以給安裝的引導選項改名,就是給profile改名
cobbler profile
rename --name=CentOS-7-1611-x86_64 --newname=RedHat-minimal
十:在/
var/lib/cobbler/kickstarts/目錄下拷貝sample_end.ks文件,命名為self.ks
cd /
var/lib/cobbler/kickstarts/
cp sample_end.ks self.ks
修改一下self.ks文件,可以在里面修改自己自定義的設置,比如說:添加安裝的包組
十一:基於現有的kickstart文件創建一個profile
cobbler profile
add --name=RedHad-self --distro=CentOS-7-1611-x86_64 --kickstart=/var/lib/cobbler/kickstarts/self.ks
十二:查看profile
[root@
7 ~]# cobbler profile list
RedHad-minimal-
self
RedHad-
self
十三:同步一下,每一次修改完成都要做一次同步
cobbler
sync
十四:啟動一台機器,然后安裝F12進入boot
sequence選項,按 l 鍵選擇LAN啟動
十五:如果想刪除一個profile
cobbler profile remove
--name=RedHad-minimal-self
cobbler
sync