Cobbler部署

環境介紹

centos7 64位
外網:10.0.0.42
內網:176.16.1.42
說明:虛擬機網卡採用NAT模式或者僅主機模式,不要使用橋接模式,因爲後面會搭建DHCP服務器,在同一個局域網多個DHCP服務會有衝突。VMware的NAT模式的dhcp服務也關閉,避免干擾。

1、安裝

[root@ c7-42 ~]# yum -y install cobbler cobbler-web tftp-server pykickstart httpd dhcp xinetd debmirror

cobbler          #cobbler程序包
cobbler-web      #cobbler的web服務包
pykickstart      #cobbler檢查kickstart語法錯誤
httpd            #Apache web服務
dhcp             #Dhcp服務
tftp             #tftp服務
xinetd          #諸多服務的超級守護進程

2、啓動cobbler及httpd並加入開機啓動

[root@ c7-42 ~]# systemctl start httpd cobblerd
[root@ c7-42 ~]# systemctl enable httpd cobblerd

3、配置cobbler

檢查Cobbler的配置,如果看不到下面的結果,再次重啓cobbler。

[root@ c7-42 ~]# 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 kickstartingfeatures 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 : comment out 'dists' on /etc/debmirror.conf for proper debian support
7 : comment out 'arches' on /etc/debmirror.conf for proper debian support
8 : 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
9 : 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@ c7-42 ~]# sed -ri '/allow_dynamic_settings:/c\allow_dynamic_settings: 1' /etc/cobbler/settings
[root@ c7-42 ~]# grep allow_dynamic_settings /etc/cobbler/settings
allow_dynamic_settings: 1
[root@ c7-42 ~]# systemctl restart cobblerd

逐個解決上面的問題

#1.配置server地址
[root@ c7-42 ~]# cobbler setting edit --name=server --value=10.0.0.42

#2.配置next_server地址
[root@ c7-42 ~]# cobbler setting edit --name=next_server --value=10.0.0.42

#3.配置xinetd管理tftp
[root@ c7-42 ~]# sed -ri '/disable/c\disable = no' /etc/xinetd.d/tftp
[root@ c7-42 ~]# systemctl enable xinetd
[root@ c7-42 ~]# systemctl restart xinetd

#4.boot-loaders
[root@ c7-42 ~]# cobbler get-loaders

#5.啓動rsync
[root@ c7-42 ~]# systemctl start rsyncd
[root@ c7-42 ~]# systemctl enable rsyncd

#6和7.debian support
[root@ c7-42 ~]# sed -i 's#@dists="sid";#\#@dists="sid";#gp' /etc/debmirror.conf
[root@ c7-42 ~]# sed -i 's#@arches="i386";#\#@arches="i386";#g' /etc/debmirror.conf

#8.default_password_crypted
# 注意:這裏設置的密碼是clbbler安裝完系統後,默認root用戶初始化登錄密碼,用 openssl 生成一串密碼後加入到 cobbler 的配置文件(/etc/cobbler/settings)裏,替換 default_password_crypted 字段
[root@ c7-42 ~]# openssl passwd -1 -salt `openssl rand -hex 4` '123456'
$1$4f5894cc$Gs7/0cTiy/T8t9JwXX3qX0
[root@ c7-42 ~]# cobbler setting edit --name=default_password_crypted --value='$1$random-p$mzxQ/Sx848sXgvfwJCoZM0'

#9.安裝fencing tools
[root@ c7-42 ~]# yum -y install fence-agents

#解決完後再次檢查
[root@ c7-42 ~]# systemctl restart cobblerd
[root@ c7-42 ~]# cobbler sync
[root@ c7-42 ~]# cobbler check
No configuration problems found.  All systems go.

4、配置DHCP

[root@ c7-42 ~]# cobbler setting edit --name=manage_dhcp --value=1
[root@ c7-42 ~]#  vim /etc/cobbler/dhcp.template
##修改的21到25行
subnet 10.0.0.0 netmask 255.255.255.0 {    #這裏改爲分配的網段和掩碼
     option routers             10.0.0.254;  #如果有網關,這裏改爲網關地址
     option domain-name-servers 223.5.5.5;   #如果有DNS,這裏改爲DNS地址
     option subnet-mask         255.255.255.0; #改爲分配的IP的掩碼
     range dynamic-bootp        10.0.0.100 10.0.0.200; #改爲分配的IP的範圍

5、同步cobbler配置

[root@ c7-42 ~]# cobbler sync

查看一下dhcp,查看cobbler是否可以管理dhcp

[root@ c7-42 ~]# cat /etc/dhcp/dhcpd.conf
# ******************************************************************
# Cobbler managed dhcpd.conf file
# generated from cobbler dhcp.conf template (Mon Apr 27 07:41:35 2020)
# Do NOT make changes to /etc/dhcpd.conf. Instead, make your changes
# in /etc/cobbler/dhcp.template, as /etc/dhcpd.conf will be
# overwritten.
# ******************************************************************

ddns-update-style interim;

allow booting;
allow bootp;

ignore client-updates;
set vendorclass = option vendor-class-identifier;

option pxe-system-type code 93 = unsigned integer 16;

subnet 10.0.0.0 netmask 255.255.255.0 {
     option routers             10.0.0.254;
     option domain-name-servers 223.5.5.5;
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        10.0.0.100 10.0.0.200;
     default-lease-time         21600;
     max-lease-time             43200;
     next-server                10.0.0.42;
     class "pxeclients" {
          match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
          if option pxe-system-type = 00:02 {
                  filename "ia64/elilo.efi";
          } else if option pxe-system-type = 00:06 {
                  filename "grub/grub-x86.efi";
          } else if option pxe-system-type = 00:07 {
                  filename "grub/grub-x86_64.efi";
          } else if option pxe-system-type = 00:09 {
                  filename "grub/grub-x86_64.efi";
          } else {
                  filename "pxelinux.0";
          }
     }

}

# group for Cobbler DHCP tag: default
group {
}

這時候創建一個新虛擬機可以獲取到如下信息,沒有鏡像選擇,只能從本地啓動。
在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章