搭建 Cobbler 無人值守安裝伺服器
Cobbler 是 RedHat 支援的一個開源專案,用來部署和安裝系統。所以對 Redhat 系列 OS 支援是比較好的。
Cobbler 不僅僅是一個 pxe 伺服器,他還可以管理 dns(bind),dhcp。一般資料中心裡戒者生產環境,是不允許 dhcp, 但是 pxe,必須需要 dhcp,所以我們需要根據 mac 地址來分配 IP,這樣 dhcp 就不會影響到網路。 Cobbler 的優點:自動管理各個伺服器間的配置,更強大的管理功能。而且它還有 Web 管理介面,可以通過點一點滑鼠就可以安裝一臺主機。Kickstart 的模板檔案可以配置多個。 |
網路安裝伺服器套件 Cobbler(補鞋匠)從前,我們一直在做裝機民工這份很有前途的職業。自打若干年前 Red Hat 推出了 Kickstart,此後我們頓覺身價倍增。不再需要刻了光碟一臺一臺地安裝 Linux,只要搞定 PXE、DHCP、TFTP,還有那滿屏眼花繚亂不知所云的 Kickstart 指令碼,我們就可以像哈里波特一樣,輕點魔棒,瞬間安裝上百臺伺服器。這一堆花裡胡哨的東西可不是一般人都能整明白的,沒有大專以上學歷,通不過英語四級, 根本別想玩轉。總而言之,這是一份多麼有前途,多麼有技術含量的工作啊。很不幸,Red Hat 最新(Cobbler專案最初在2008年左右釋出)釋出了網路安裝伺服器套件 Cobbler(補鞋匠),它已將 Linux 網路安裝的技術門檻,從大專以上文化水平,成功降低到初中以下,連補鞋匠都能學會。對於我們這些在裝機領域經營多年,經驗豐富,老驥伏櫪,志在千里的民工兄弟們來說,不啻為一個晴天霹靂。
環境:
CentOS Linux release 7.6.1810
VMware Workstation Pro 14
Server 端:
第一步:啟動 Cobbler 服務
第二步:進行 Cobbler 錯誤檢查,執行 Cobbler check
命令
第三步:進行配置同步,執行 Cobbler sync
命令
第四步:複製相關啟動檔案檔案到 TFTP 目錄中
第五步:啟動 DHCP 服務,提供地址分配
第六步:DHCP 服務分配 IP 地址
第七步:TFTP 傳輸啟動檔案
第八步:Server 端接收安裝資訊
第九步:Server 端傳送 ISO 映象不 Kickstart 檔案
Client 端:
第一步:客戶端以 PXE 模式啟動
第二步:客戶端獲取 IP 地址
第三步:通過 TFTP 伺服器獲取啟動檔案
第四步:進入 Cobbler 安裝選擇介面
第五步:客戶端確定載入資訊
第六步:根據配置資訊準備安裝系統
第七步:載入 Kickstart 檔案
第八步:傳輸系統安裝的其它檔案
第九步:進行安裝系統
Cobbler 服務端:CentOS Linux release 7.6.1810
Cobbler 服務端對記憶體的要求不高,只要能把Cobbler服務跑起來就行。
#關閉 selinux 和防火牆 [root@Jaking ~]# systemctl stop firewalld.service && systemctl disable firewalld.service && iptables -F && setenforce 0 #永久關閉 selinux 執行下面命令 [root@Jaking ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
首先安裝 epel-release,Cobbler 和 tftp-server 在 base 源中是沒有的
[root@Jaking ~]# yum install -y epel-release
安裝 Cobbler 其實有一部分軟體會被當做依賴進行安裝上去,比如 tftp 和 httpd 服務,我們這裡為了方便可以一併安裝,避免後續出現相關問題。
[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 服務包 pykickstart #Cobbler 檢查 kickstart 語法錯誤 httpd #Apache Web 服務
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 主配置檔案,這個檔案是 YAML 栺式,Cobbler 是 python 寫的程式。 /etc/cobbler/dhcp.template # DHCP服務的配置模板 /etc/cobbler/tftpd.template # tftp 服務的配置模板 /etc/cobbler/rsync.template # rsync 服務的配置模板 /etc/Cobbler/iso # iso 模板配置檔案目錄 /etc/cobbler/pxe # pxe 模板檔案目錄 /etc/cobbler/power # 電源的配置檔案目錄 /etc/cobbler/users.conf # Web 服務授權配置檔案 /etc/cobbler/users.digest # 用於 Web 訪問的使用者名稱密碼配置檔案 /etc/cobbler/dnsmasq.template # DNS 服務的配置模板 /etc/cobbler/modules.conf # Cobbler 模組配置檔案 /var/lib/cobbler # Cobbler 資料目錄 /var/lib/cobbler/config # 配置檔案 /var/lib/cobbler/kickstarts # 預設存放 kickstart 檔案 /var/lib/cobbler/loaders # 存放的各種載入程式 /var/www/cobbler # 系統安裝映象目錄 /var/www/cobbler/ks_mirror # 匯入的系統映象列表 /var/www/cobbler/images # 匯入的系統映象啟動檔案 /var/www/cobbler/repo_mirror # yum 源儲存目錄 /var/log/cobbler # 日誌目錄 /var/log/cobbler/install.log # 客戶端系統安裝日誌 /var/log/cobbler/cobbler.log # Cobbler 日誌
首先啟動 Cobbler 和 httpd 服務
[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 服務被 xinetd 服務管理
[root@Jaking ~]# vim /etc/xinetd.d/tftp 改:14 disable = yes 為:14 disable = no 順便修改 xinetd 和 tftpd 服務開機啟動 [root@Jaking ~]# systemctl start xinetd tftp && systemctl enable xinetd tftp
問題 4:下載作業系統引導檔案
[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 服務為開機自啟動狀態並啟用它。
[root@Jaking ~]# systemctl start rsyncd && systemctl enable rsyncd
問題 6:關於 debian 相關部署管理配置,忽略。
debmirror package is not installed, it will be required to manage debian deployments and repositories # debmirror 包尚未安裝,需要它來管理 debian 部署和儲存庫
問題 7:修改作業系統預設密碼
[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:電源管理相關服務,忽略。
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 自動管理 DHCP 服務,我們只需要修改 Cobbler 中的模板配置檔案即可。
[root@Jaking ~]# vim /etc/cobbler/dhcp.template 改:22 option routers 192.168.1.5; #修改預設閘道器地址 為:22 option routers 192.168.1.1; #以實際的閘道器為準 改: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;
注:配置預設為 192.168.1.0 網段,具體要看你的裝機 vlan 劃分,現在是實驗環境所以保持配不變。
注:預設閘道器地址為 192.168.1.5,這裡需要改成你自己區域網中的閘道器。
$next_server 為變數值為我們前面修改的主配置檔案中的地址 192.168.1.7
修改 Cobbler 管理 dhcp 服務
[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 服務是否啟動。
重新檢查,剩下 2 個可以忽略的問題。
[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.
新增映象
掛載光碟機
[root@Jaking ~]# mount /dev/sr0 /mnt
匯入映象(時間較長)
[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 ***
檢視映象,上面是映象名稱,下面是啟動選單。
[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 無人值守安裝伺服器完成!
接下來只需要在 VMware Workstation Pro 14 上面建立一臺 CentOS 系統,網路模式選擇橋接即可實現無人值守安裝(不需要選擇映象)。
原文地址: https://www.linuxprobe.com/cobbler-installation-server.html
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31559985/viewspace-2673941/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- PXE+Kickstart無人值守安裝安裝Centos7.9CentOS
- 無人值守自動化安裝系統
- kickstart無人值守方式安裝Linux 7.6Linux
- PXE高效網路裝機與Kickstart無人值守安裝
- Linux系統下手把手完成無人值守安裝服務Linux
- 無人值守智慧洗車
- 地磅無人值守系統
- kickstart+PXE+dhcp+nfs 批量無人值守自動化安裝作業系統NFS作業系統
- centos7下cobbler安裝配置CentOS
- Linux應該這麼學第19章使用 PXE+Kickstart 無人值守安裝服務Linux
- 使用 Cobbler 安裝一臺 CentOS 主機CentOS
- 實戰-使用 Cobbler 安裝作業系統作業系統
- Linux網路服務-----實驗---PXE和Kickstart的無人值守裝機Linux
- 變電站裝置狀態識別無人值守巡檢系統
- CentOS7中搭建cobbler自動裝機服務CentOS
- 實戰-使用 Cobbler 安裝一臺 CentOS 主機CentOS
- 無人值守的運維到底靠譜不靠譜?運維
- 實戰-使用 Cobbler 定製化安裝指定系統
- 無人值守汽車衡 掃碼自動過磅
- 維大殺器來了,未來雲上伺服器或將實現無人值守伺服器
- 停車機器人上崗 實現停車場無人值守機器人
- 伺服器搭建圖床:Chevereto安裝教程伺服器圖床
- 無人值守掃碼自助過磅系統 稱重管理
- 寶塔Linux皮膚搭建與安全狗安裝(WEB伺服器搭建與WAF安裝)LinuxWeb伺服器
- 微信掃碼過磅 無人值守稱重管理系統
- cobbler
- 透過自動化運維實現無人值守的故障自愈運維
- 智慧無人值守稱重行業車牌識別行業應用行業
- 按鍵大師:用Python實現無人值守的自動化操作Python
- 地磅無人值守自動稱重管理掃碼過磅的優點
- 變電站運維推陳出新?無人值守卻更勝一籌運維
- Cobbler 自動部署裝機(超詳細)
- Linux中的無人職守安裝指令碼kickstartLinux指令碼
- 伺服器安裝Linux中安裝 Apache伺服器LinuxApache
- MQTT 伺服器搭建:EMQ X 安裝指南和常見問題MQQT伺服器
- Ubuntu Server搭建個人伺服器UbuntuServer伺服器
- 無法安裝onethink
- JeeSite Spring Cloud安裝搭建SpringCloud