天天看點

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

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

·把生成的密碼複制到以下配置檔案中

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:

·可以安裝一個軟體tree,來檢視壓縮核心與引導檔案

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

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

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

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

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

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

驗證自動化安裝:

重新開機所有服務、在VMware建立一台Linux。如下圖:

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

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

驗證web管理:

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

實驗成功!