一、系統環境準備
1、系統環境:CentOS7.5 x86-64
2、軟件包:採用 yum 安裝方式,為提高軟件包下載速度,將源修改為阿里雲。
二、安裝Cobbler
2.1 安裝cobbler相關軟件包
shell> wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo shell> wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo shell> yum -y install cobbler cobbler-web pykickstart httpd rsync tftp-server dhcp xinetd shell> yum install fence-agents -y
2.2 安裝debmirror(提供對Debian的支持,其他系統可略過)
shell> yum -y install debmirror
三、配置Cobbler
3.1 設置tftp和rsync服務
shell> sed -i '/disable/c\\tdisable\t\t\t= no' /etc/xinetd.d/tftp shell> cat > /etc/rsyncd.conf << EOF read only = yes list = no max connections = 100 hosts allow=10.52.0.0/16,10.32.0.0/16,192.168.0.0/16 uid = nobody gid = nobody log file = /var/log/rsyncd.log pid file = /var/run/rsyncd.pid lock file = /var/run/rsync.lock EOF
3.2 設置 root 默認密碼(只對RedHat/CentOS系統有效)
# openssl passwd -1 -salt 'random-phrase-here' 'your-password-here' shell> openssl passwd -1 -salt '91donkey.com' '1q2w3e4r' $1$91donkey$KJwQNrYEdGksTB2L9v2bC0
3.3 修改 /etc/cobbler/settings 文件內容
# tftp服務器IP地址 next_server: 10.20.57.32 # cobbler管理DHCP manage_dhcp: 1 # cobbler管理rsync(可選) manage_rsnyc: 1 # cobbler管理dns(可選) manage_dns: 1 # 修改pxe_just_once值: # 1、預防由於服務器設置從網絡引導,導致循環安裝; # 2、激活此設置,機器會告訴Cobbler安裝已完成。Cobbler會將對象的netboot標誌改為false,這會強制服務器從本地引導。 pxe_just_once: 1 server: 10.20.57.32 default_password_crypted: "$1$91donkey$KJwQNrYEdGksTB2L9v2bC0"
3.4 配置 /etc/cobbler/dhcp.template 文件內容(節選)
subnet 10.20.48.0 netmask 255.255.248.0 { option routers 10.20.48.1; option domain-name-servers 114.114.114.114; option subnet-mask 255.255.248.0; range dynamic-bootp 10.20.49.1 10.20.49.20; default-lease-time 900; max-lease-time 1800; next-server $next_server; }
3.5 啟動相關服務
# rsync shell> systemctl enable rsyncd && systemctl start rsyncd # xinetd shell> systemctl enable xinetd && systemctl start xinetd # httpd shell> systemctl enable httpd && systemctl start httpd # cobbler shell> systemctl enable cobblerd && systemctl start cobblerd shell> cobbler sync # dhcp shell> systemctl enable dhcpd && systemctl start dhcpd
3.6 開啟動態更新
# 如果啟用,Cobbler將允許動態修改設置,而無需重新啟動到cobblerd守護程序。 shell> sed -i 's/allow_dynamic_settings: 0/allow_dynamic_settings: 1/' /etc/cobbler/settings shell> systemctl restart cobblerd
3.7 配置引導菜單
shell> cobbler get-loaders shell> cobbler signature update shell> cobbler sync
3.8 檢查 cobbler 配置結果
shell> cobbler check The following are potential configuration items that you may want to fix: 1 : enable and start rsyncd.service with systemctl 2 : debmirror package is not installed, it will be required to manage debian deployments and repositories Restart cobblerd and then run 'cobbler sync' to apply changes.
3.9 修改 cobbler 數據目錄
# 由於cobbler默認將數據放在/var目錄下,而按照我的系統安裝習慣,/var目錄一般不會分太大空間,需要修改文件存放路徑。 shell> mv /var/www/cobbler /export/ shell> ln -s /export/cobbler /var/www/cobbler
3.10 修改開機畫面顯示
shell> sed -i 's/cobbler.github.io/www.91donkey.com/' /etc/cobbler/pxe/pxedefault.template shell> cobbler sync
作者:龍龍小寶
原文:https://www.cnblogs.com/91donkey/p/11635375.html