新聞中心
Cobbler是一個(gè)快速網(wǎng)絡(luò)安裝linux的服務(wù),而且在經(jīng)過調(diào)整也可以支持網(wǎng)絡(luò)安裝windows。該工具使用python開發(fā),小巧輕便,使用簡(jiǎn)單的命令即可完成PXE網(wǎng)絡(luò)安裝環(huán)境的配置,同時(shí)還可以管理DHCP、DNS、以及yum倉庫、構(gòu)造系統(tǒng)ISO鏡像。

站在用戶的角度思考問題,與客戶深入溝通,找到云縣網(wǎng)站設(shè)計(jì)與云縣網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計(jì)與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個(gè)性化、用戶體驗(yàn)好的作品,建站類型包括:網(wǎng)站制作、網(wǎng)站設(shè)計(jì)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、域名與空間、網(wǎng)絡(luò)空間、企業(yè)郵箱。業(yè)務(wù)覆蓋云縣地區(qū)。
搭建 Cobbler 無人值守安裝服務(wù)器
1 環(huán)境初始化
Cobbler 服務(wù)端:CentOS Linux release 7.6.1810 Cobbler 服務(wù)端對(duì)內(nèi)存的要求不高,只要能把Cobbler服務(wù)跑起來就行。
#關(guān)閉 selinux 和防火墻
[root@Jaking ~]# systemctl stop firewalld.service && systemctl disable firewalld.service && iptables -F && setenforce 0
#永久關(guān)閉 selinux 執(zhí)行下面命令
[root@Jaking ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
2 安裝配置 Cobbler
首先安裝 epel-release,Cobbler 和 tftp-server 在 base 源中是沒有的
[root@Jaking ~]# yum install -y epel-release
安裝 Cobbler 其實(shí)有一部分軟件會(huì)被當(dāng)做依賴進(jìn)行安裝上去,比如 tftp 和 httpd 服務(wù),我們這里為了方便可以一并安裝,避免后續(xù)出現(xiàn)相關(guān)問題。
[root@Jaking ~]# yum install -y cobbler cobbler-web dhcp tftp-server pykickstart httpd rsync xinetd
注意:必須把yum源配好,否則無法全部安裝以上軟件!
[root@Jaking ~]# vim /etc/yum.repos.d/CentOS-Base.repo
#在CentOS-Base.repo配置文件中添加以下源
[aliyun-os]
name=aliyun-os
baseurl=https://mirrors.aliyun.com/centos/7/os/x86_64/
enabled=1
gpgcheck=0
[aliyun-epel]
name=aliyun-epel
baseurl=https://mirrors.aliyun.com/epel/7/x86_64/
enabled=1
gpgcheck=0
[aliyun-extra]
name=aliyun-extra
baseurl=https://mirrors.aliyun.com/centos/7/extras/x86_64/
enabled=1
gpgcheck=0
軟件作用說明
cobbler #Cobbler 程序包
cobbler-web #Cobbler 的 Web 服務(wù)包
pykickstart #Cobbler 檢查 kickstart 語法錯(cuò)誤
httpd #Apache Web 服務(wù)
Cobbler 工作目錄介紹
[root@Jaking ~]# ls /etc/cobbler/
auth.conf genders.template named.template secondary.template zone.template
cheetah_macros import_rsync_whitelist power settings zone_templates
cobbler_bash iso pxe tftpd.template
completions ldap reporting users.conf
dhcp.template modules.conf rsync.exclude users.digest
dnsmasq.template mongodb.conf rsync.template version
/etc/cobbler # 配置文件目錄
/etc/cobbler/settings # Cobbler 主配置文件,這個(gè)文件是 YAML 栺式,Cobbler 是 python 寫的程序。
/etc/cobbler/dhcp.template # DHCP服務(wù)的配置模板
/etc/cobbler/tftpd.template # tftp 服務(wù)的配置模板
/etc/cobbler/rsync.template # rsync 服務(wù)的配置模板
/etc/Cobbler/iso # iso 模板配置文件目錄
/etc/cobbler/pxe # pxe 模板文件目錄
/etc/cobbler/power # 電源的配置文件目錄
/etc/cobbler/users.conf # Web 服務(wù)授權(quán)配置文件
/etc/cobbler/users.digest # 用于 Web 訪問的用戶名密碼配置文件
/etc/cobbler/dnsmasq.template # DNS 服務(wù)的配置模板
/etc/cobbler/modules.conf # Cobbler 模塊配置文件
/var/lib/cobbler # Cobbler 數(shù)據(jù)目錄
/var/lib/cobbler/config # 配置文件
/var/lib/cobbler/kickstarts # 默認(rèn)存放 kickstart 文件
/var/lib/cobbler/loaders # 存放的各種引導(dǎo)程序
/var/www/cobbler # 系統(tǒng)安裝鏡像目錄
/var/www/cobbler/ks_mirror # 導(dǎo)入的系統(tǒng)鏡像列表
/var/www/cobbler/images # 導(dǎo)入的系統(tǒng)鏡像啟動(dòng)文件
/var/www/cobbler/repo_mirror # yum 源存儲(chǔ)目錄
/var/log/cobbler # 日志目錄
/var/log/cobbler/install.log # 客戶端系統(tǒng)安裝日志
/var/log/cobbler/cobbler.log # Cobbler 日志
首先啟動(dòng) Cobbler 和 httpd 服務(wù)
[root@Jaking ~]# systemctl start cobblerd httpd
檢查配置
[root@Jaking ~]# 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 : 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
Restart cobblerd and then run 'cobbler sync' to apply changes.
以上問題我們需要逐步解決。
問題 1:修改 server 地址為 192.168.1.7
[root@Jaking ~]# vim /etc/cobbler/settings
改:390 server: 127.0.1
為:390 server: 192.168.1.7
問題 2:修改 next_server 地址為 192.168.1.7
[root@Jaking ~]# vim /etc/cobbler/settings
改:278 next_server: 127.0.1
為:278 next_server: 192.168.1.7
問題 3:修改 tftp 服務(wù)被 xinetd 服務(wù)管理
[root@Jaking ~]# vim /etc/xinetd.d/tftp
改:14 disable = yes
為:14 disable = no
順便修改 xinetd 和 tftpd 服務(wù)開機(jī)啟動(dòng)
[root@Jaking ~]# systemctl start xinetd tftp && systemctl enable xinetd tftp
問題 4:下載操作系統(tǒng)引導(dǎo)文件
[root@Jaking ~]# cobbler get-loaders
task started: 2020-01-04_031204_get_loaders
task started (id=Download Bootloader Content, time=Sat Jan 4 03:12:04 2020)
downloading https://cobbler.github.io/loaders/README to /var/lib/cobbler/loaders/README
downloading https://cobbler.github.io/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilo
downloading https://cobbler.github.io/loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yaboot
downloading https://cobbler.github.io/loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.syslinux
downloading https://cobbler.github.io/loaders/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64.efi
downloading https://cobbler.github.io/loaders/yaboot-1.3.17 to /var/lib/cobbler/loaders/yaboot
downloading https://cobbler.github.io/loaders/pxelinux.0-3.86 to /var/lib/cobbler/loaders/pxelinux.0
downloading https://cobbler.github.io/loaders/menu.c32-3.86 to /var/lib/cobbler/loaders/menu.c32
downloading https://cobbler.github.io/loaders/grub-0.97-x86.efi to /var/lib/cobbler/loaders/grub-x86.efi
downloading https://cobbler.github.io/loaders/grub-0.97-x86_64.efi to /var/lib/cobbler/loaders/grub-x86_64.efi
*** TASK COMPLETE ***
問題 5:修改 rsyncd 服務(wù)為開機(jī)自啟動(dòng)狀態(tài)并啟用它。
[root@Jaking ~]# systemctl start rsyncd && systemctl enable rsyncd
問題 6:關(guān)于 debian 相關(guān)部署管理配置,忽略。
debmirror package is not installed, it will be required to manage debian
deployments and repositories # debmirror 包尚未安裝,需要它來管理 debian 部署和存儲(chǔ)庫
問題 7:修改操作系統(tǒng)默認(rèn)密碼
[root@Jaking ~]# openssl passwd -1 -salt 'root' '123456'
$1$root$j0bp.KLPyr.u9kgQ428D10
[root@Jaking ~]# vim /etc/cobbler/settings
改:101 default_password_crypted: "$1$mF86/UHC$WvcIcX2t6crBz2onWxyac."
為:101 default_password_crypted: "$1$root$j0bp.KLPyr.u9kgQ428D10"
注:root 為用戶描述,123456 為密碼
問題 8:電源管理相關(guān)服務(wù),忽略。
fencing tools were not found, and are required to use the (optional) power
management features. install cman or fence-agents to use them
修改完以上配置就可以檢查 DHCP 配置了,由于 Cobbler 自動(dòng)管理 DHCP 服務(wù),我們只需要修改 Cobbler 中的模板配置文件即可。
[root@Jaking ~]# vim /etc/cobbler/dhcp.template
改:22 option routers 192.168.1.5; #修改默認(rèn)網(wǎng)關(guān)地址
為:22 option routers 192.168.1.1; #以實(shí)際的網(wǎng)關(guān)為準(zhǔn)
改:23 option domain-name-servers 192.168.1.1; #修改 DNS 地址
為:23 option domain-name-servers 114.114.114.114;
如下:
21 subnet 192.168.1.0 netmask 255.255.255.0 {
22 option routers 192.168.1.1;
23 option domain-name-servers 114.114.114.114;
24 option subnet-mask 255.255.255.0;
25 range dynamic-bootp 192.168.1.100 192.168.1.254;
26 default-lease-time 21600;
27 max-lease-time 43200;
28 next-server $next_server;
注:配置默認(rèn)為 192.168.1.0 網(wǎng)段,具體要看你的裝機(jī) vlan 劃分,現(xiàn)在是實(shí)驗(yàn)環(huán)境所以保持配不變。 注:默認(rèn)網(wǎng)關(guān)地址為 192.168.1.5,這里需要改成你自己局域網(wǎng)中的網(wǎng)關(guān)。 $next_server 為變量值為我們前面修改的主配置文件中的地址 192.168.1.7
修改 Cobbler 管理 dhcp 服務(wù)
[root@Jaking ~]# vim /etc/cobbler/settings
改:242 manage_dhcp: 0
為:242 manage_dhcp: 1
同步配置文件,需要先重啟 Cobblerd
[root@Jaking ~]# systemctl restart cobblerd
[root@Jaking ~]# cobbler sync
task started: 2020-01-04_032552_sync
task started (id=Sync, time=Sat Jan 4 03:25:52 2020)
running pre-sync triggers
cleaning trees
removing: /var/lib/tftpboot/grub/images
copying bootloaders
trying hardlink /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
trying hardlink /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32
trying hardlink /var/lib/cobbler/loaders/yaboot -> /var/lib/tftpboot/yaboot
trying hardlink /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk
trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
copying distros to tftpboot
copying images
generating PXE configuration files
generating PXE menu structure
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
rendering TFTPD files
generating /etc/xinetd.d/tftp
cleaning link caches
running post-sync triggers
running python triggers from /var/lib/cobbler/triggers/sync/post/*
running python trigger cobbler.modules.sync_post_restart_services
running: dhcpd -t -q
received on stdout:
received on stderr:
running: service dhcpd restart
received on stdout:
received on stderr: Redirecting to /bin/systemctl restart dhcpd.service
running shell triggers from /var/lib/cobbler/triggers/sync/post/*
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.manage_genders
running python trigger cobbler.modules.scm_track
running shell triggers from /var/lib/cobbler/triggers/change/*
*** TASK COMPLETE ***
注意觀察 DHCP 服務(wù)是否啟動(dòng)。
重新檢查,剩下 2 個(gè)可以忽略的問題。
[root@Jaking ~]# cobbler check
The following are potential configuration items that you may want to fix:
1 : debmirror package is not installed, it will be required to manage debian deployments and repositories
2 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them
Restart cobblerd and then run 'cobbler sync' to apply changes.
導(dǎo)入鏡像以及配置
添加鏡像
搭建 Cobbler 無人值守安裝服務(wù)器搭建 Cobbler 無人值守安裝服務(wù)器
掛載光驅(qū)
[root@Jaking ~]# mount /dev/sr0 /mnt
導(dǎo)入鏡像(時(shí)間較長(zhǎng))
[root@Jaking ~]# cobbler import --path=/mnt/ --name=CentOS-7.6 --arch=x86_64
task started: 2020-01-04_033346_import
task started (id=Media import, time=Sat Jan 4 03:33:46 2020)
Found a candidate signature: breed=redhat, version=rhel6
Found a matching signature: breed=redhat, version=rhel6
Adding distros from path /var/www/cobbler/ks_mirror/CentOS-7.6-x86_64:
creating new distro: CentOS-7.6-x86_64
trying symlink: /var/www/cobbler/ks_mirror/CentOS-7.6-x86_64 -> /var/www/cobbler/links/CentOS-7.6-x86_64
creating new profile: CentOS-7.6-x86_64
associating repos
checking for rsync repo(s)
checking for rhn repo(s)
checking for yum repo(s)
starting descent into /var/www/cobbler/ks_mirror/CentOS-7.6-x86_64 for CentOS-7.6-x86_64
processing repo at : /var/www/cobbler/ks_mirror/CentOS-7.6-x86_64
need to process repo/comps: /var/www/cobbler/ks_mirror/CentOS-7.6-x86_64
looking for /var/www/cobbler/ks_mirror/CentOS-7.6-x86_64/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/CentOS-7.6-x86_64/repodata
*** TASK COMPLETE ***
查看鏡像,上面是鏡像名稱,下面是啟動(dòng)菜單。
[root@Jaking ~]# cobbler list
distros:
CentOS-7.6-x86_64
profiles:
CentOS-7.6-x86_64
同步 Cobbler 配置
[root@Jaking ~]# systemctl restart cobblerd
[root@Jaking ~]# cobbler sync
至此,搭建 Cobbler 無人值守安裝服務(wù)器完成! 接下來只需要在 VMware Workstation Pro 14 上面創(chuàng)建一臺(tái) CentOS 系統(tǒng),網(wǎng)絡(luò)模式選擇橋接即可實(shí)現(xiàn)無人值守安裝(不需要選擇鏡像)。
網(wǎng)頁名稱:Linux系統(tǒng)中安裝Cobbler自動(dòng)化部署
文章出自:http://fisionsoft.com.cn/article/djgjggg.html


咨詢
建站咨詢
