1. 程式人生 > >Cobbler 全自動化安裝、簡介、Web界面管理【附送源碼包】

Cobbler 全自動化安裝、簡介、Web界面管理【附送源碼包】

防火 target mach sam eas shadow 特點 owin epel

Cobbler簡介


Cobbler這個英文翻譯過來的意思是補鞋匠,為什麽會是補鞋匠的意思,很簡單,因為它簡單得連補鞋匠都能學會安裝系統。

Cobbler通過將部署系統所涉及的所有服務集中在一起,來提供一個全自動批量快速建立Linux系統的網絡安裝環境。

在學習Cobbler之前可以看看PXE無人值守安裝系統。


Cobbler特點:

·Cobbler支持多種Linux操作系統得快速部署,對PXE、DHCP、HTTP、TFTP、Kiskstart、YUM倉庫、電源等進行統一管理

·Cobbler提供實現不同用戶需求得可定制系統部署方案

·Cobbler分別提供命令管理和Web界面管理、方便Cobbler管理員使用。


部署準備:

·VMware虛擬機

·Cobbler服務器(我這裏是Ctenos7)

·在虛擬機中網絡連接改為NAT模式、IP地址為:192.168.106.131

·Cobbler源碼包epel-release-latest-7.noarch.rpm 密碼:9sxj


部署開始:

·安裝epel-release-latest-7.noarch軟件包(Cobbler是由這個軟件包提供服務得,源碼包在準備前提供了連接。可以用共享或者其他工具存放到 Linux中

[root@localhost ~]# rpm -ivh epel-release-latest-7.noarch.rpm


·掛載自己的鏡像文件到 /mnt 目錄下

[root@localhost ~]# mount /dev/sr0 /mnt


·因為後面需要用YUM安裝服務,這裏需要重新加載YUM倉庫

[root@localhost ~]# yum list


·安裝cobbler cobbler-web dhcp tftp-sever pykickstart httpd rsync xinetd服務,這些包都需要安裝哦!

[root@localhost ~]# yum install cobbler cobbler-web dhcp tftp-sever pykickstart httpd rsync xinetd -y


·修改cobbler主配置文件

[root@localhost ~]# vim /etc/cobbler/settings


next_server: 192.168.106.131 #指定cobbler服務器地址

server:192.168.106.131 #指定TFTP服務器地址(因為tftp在cobbler中,所以指向的地址都一樣)

manage_dhcp: 1 #把對dhcp管理服務開啟(1:開啟 0:關閉)


·啟動httpd服務、啟動Cobblerd服務、關閉防火墻、光比增強×××

[root@localhost ~]# systemctl start httpd.service

[root@localhost ~]# systemctl start cobblerd.service

[root@localhost ~]# systemctl disable firewalld.service

[root@localhost ~]# setenforce 0


·對cobbler做檢查設置

[root@localhost ~]# cobbler check


1 : SELinux is enabled. Please review the following wiki page for details on ensuring cobbler works correctly in your SELinux environment:

https://github.com/cobbler/cobbler/wiki/Selinux

2 : change 'disable' to 'no' in /etc/xinetd.d/tftp

3 : 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.

4 : enable and start rsyncd.service with systemctl

5 : debmirror package is not installed, it will be required to manage debian deployments and repositories

6 : 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

7 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them


·接下來我們需要對上述檢查結果進行修改。修改tftp配置文件

[root@localhost ~]# vim /etc/xinetd.d/tftp

disable = no#開啟tftp服務


·啟動遠程同步服務、重啟cobbler服務

[root@localhost ~]# systemctl enable rsyncd.service

[root@localhost ~]# systemctl restart cobblerd.service


·設置鹽值加密(就是給客戶機root的密碼),會出現一串加密字符,把字符添加到cobbler主配置文件相應的位置

[root@localhost ~]# openssl passwd -1 -salt 'abc123' 'abc123'

$1$abc123$9v8z2./E/PZihXrVcy3II0


·把生成的密碼復制到以下配置文件中

[root@localhost ~]# vim /etc/cobbler/settings


default_password_crypted: "$1$abc123$9v8z2./E/PZihXrVcy3II0"


·重啟xinetd服務

[root@localhost ~]# systemctl restart xinetd.service


·修改被cobbler所管理的dhcp模板


subnet 192.168.106.0 netmask 255.255.255.0 { #指定自己的網段

option routers 192.168.106.1;#修改網關

option domain-name-servers 192.168.106.2;#修改DNS

option subnet-mask 255.255.255.0;

range dynamic-bootp 192.168.106.100 192.168.106.200;#修改地址池


·同步生成DHCP配置文件

[root@localhost ~]# cobbler sync


·下載引導操作系統文件


[root@localhost ~]# cobbler get-loaders


·在過程中,我們不一定知道那些服務啟動、或者修改了忘記重啟,就幹脆全部重啟一次。

[root@localhost ~]# systemctl start dhcpd.service //啟動dhcp

[root@localhost ~]# systemctl start cobblerd.service //啟動cobbler

[root@localhost ~]# systemctl start xinetd.service //啟動tftp


·在開始之前我們就把鏡像文件掛載到了/mnt 目錄下,現在需要把鏡像文件導入cobbler默認存在的位子

[root@localhost ~]# cobbler import --path=/mnt/ --name=CentOS-7-x86_64 --arch=x86_64 //文件較大,需要等待


/var/www/cobbler/ks_mirror/CentOS-7-x86_64 //導入的鏡像文件存放的位子


·使用cobbler list 查看發行版本,和模板

[root@localhost ~]# cobbler list

distros:

CentOS-7-x86_64


profiles:

CentOS-7-x86_64



·可以安裝一個軟件tree,來查看壓縮內核與引導文件

[root@localhost ~]# yum install tree -y

[root@localhost ~]# tree /var/lib/tftpboot/images

技術分享圖片


·添加配置讓cobbler受web管理,這樣方便。添加一個管理者(cbamin)到指定的路徑下

[root@localhost ~]# htdigest -c /etc/cobbler/users.digest cobbler cbadmin

技術分享圖片

驗證自動化安裝:

重啟所有服務、在VMware新建一臺Linux。如下圖:

技術分享圖片

技術分享圖片

技術分享圖片

技術分享圖片

技術分享圖片

到此幾乎不出意外就沒問題了。

驗證web管理:

技術分享圖片

實驗成功!





Cobbler 全自動化安裝、簡介、Web界面管理【附送源碼包】