Linux之DHCP+tftp+syslinux+PXE+Cobbler


DHCP簡介
DHCP全稱爲:Dynamic host configuration protocol協議,其協議前身爲Boot protocol, 其工作於67,68/UDP端口,服務端工作於67端口,客戶端監聽於68端口. 在某此情況下, dhcp server可能會與客戶端通信,故需要監聽在67端口,接收服務端的通訊請求. 在客戶端操作系統開機系統加載時, 有一個特定的服務可以激活client程序,激活後,客戶端通過網卡向外發送rarp報文,向局域網的DHCP server請求獲取IP地址.
DHCP的工作原理:

Client啓動時, 有一個服務激活Client客戶端程序,它通過本地網卡發送rarp報文.
Client:
發送DHCP Discover(發現報文),其是廣播方式


Server:
發送DHCP Offer報文,其有lease(租約時間),其是廣播方式


Client:
先檢測本地有沒有主機使用此IP地址, 再發送DHCP Request確認報文,其是廣播方式


Server:
發送DHCP ACK確認報文,其是廣播方式


地址租約到期的工作原理

Client
可用時間達到50%的時候,就要向server端續租,發送dhcp request報文,其是單播的方式


Server
發送dhcp ack報文給予確認, 把時間延長至指定期約


如果地址不可用了

server
發送dhcp nak報文,通知其IP地址不可用


Client
發送dhcp discover報文,重新開始申請地址的過程.


續租的服務器不存在

Client
在租期到50%的時候開始發送dhcp request報文,如果服務器不在線, 將在剩下的50%租約中(75%),再發送dhcp request報文,如果服務器還是不在線, 將在剩下的50%租約中(87.5%),再發送dhcp request報文,如果服務器還是不在線, 重新發起dchp discover報文廣播,向網絡中的主機申請新的IP地址.


DCHP Relay工作原理
relay就是中斷,類似於代理. 由路由器監聽在本地的67號端口,當本地網絡有dchp discover報文到達路由器的端口時, 路由器將discover廣播報文發送至指定的DHCP Server(路由器到DHCP SERVER是單播的方式).
=====
DHCP服務的安裝

yum install dhcp

DHCP服務的管理

Centos 6
service dhcpd start


Centso 7
systemctl start dhcpd.service


DHCP服務的配置文件

工作目錄:
/etc/dhcp/


配置文件:

/etc/dhcp/dhcpd.conf : IPv4的配置文件
/etc/dhcp/dhcpd6.conf : IPv6的配置文件


各Unit file文件:

/usr/lib/systemd/system/dhcpd.service
/usr/lib/systemd/system/dhcpd6.service
/usr/lib/systemd/system/dhcrelay.service


配置示例文件:

/usr/share/doc/dhcp-4.2.5/dhcpd.conf.example


/etc/dhcp/dhcpd.conf配置文件參數說明:

每個參數結尾都以;號結尾

option : 定義向外分配的網絡屬性

非option : DHCP自己的工作特性

option domain-name : 定義域名稱

option domain-name-servers :定義DNS地址

default-lease-time 600 : 定義租約時長

max-lease-time 7200 : 定義最大租約時長

log-facility local7; : 日誌發給那個facility來記錄

subnet 172.16.36.0 netmask 255.255.255.0 {} : 來定義一個作用域

range IP IP : 作用域的IP地址範圍

options routers IP : 默認分配的網關地址

filename : 基於網卡引導時, 需要加載的啓動初始化文件名稱

next-server IP : 初始化文件存放服務器地址,其需要一個tftp server來支撐並提供服務

host NAME {} : 能夠固定爲某主機分配某IP地址,NAME是全局唯一名稱

hardware ehernet 00:00:00:00:00:00 : 需要綁定IP的主機的MAC地址

fixed-address IP : 爲其保留的IP地址, 其IP地址不能爲地址池中的地址, 以名衝突

配置示例:
option domain-name "zhenping.me";
option domain-name-servers 172.16.0.1;
default-lease-time 600;
max-lease-time 7200;
log-facility local7;
subnet 172.16.36.0 netmask 255.255.255.0 {
  range 172.16.36.80 172.16.36.90;
  option routers 172.16.36.70;
  filename "pxelinux.0";
  next-server 172.16.36.70;
}
host web_srvs {
  hardware ethernet 00:00:00:00:00:00;
  fixed-address 172.16.200.200;
配置文件簡述格式:
option
    default-lease-time
    max-lease-time
    subnet NETWORK netmask MASK {
        range START END;
        option routers;
        option domain-name;
        option domain-servers;
        filename;12222222222222
        next-server;
    }
    host HOST_ID {
        hardware ethernet;
        fixed-address;
    }
dhclient命令
其是基於dhcp協議來獲取IP地址, 其在Linux平臺系統啓動時, 就已經啓動了此工具並且已運行於後臺,如果主機是DHCP獲取的地址, 那麼需要它來測試時, 需要先將其強制kill掉,再運行其命令.


-d : 將dhclient命令工作於前臺

操作示例:
[root@Centos7 ~]# dhclient -d
Internet Systems Consortium DHCP Client 4.2.5
Copyright 2004-2013 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/eno16777736/00:0c:29:f2:94:ac
Sending on   LPF/eno16777736/00:0c:29:f2:94:ac
Sending on   Socket/fallback
DHCPREQUEST on eno16777736 to 255.255.255.255 port 67 (xid=0x798803b8)
DHCPACK from 172.16.0.1 (xid=0x798803b8)
bound to 172.16.249.82 -- renewal in 36368 seconds.


DHCP Server是172.16.0.1
獲取到的IP地址爲: 172.16.249.82
TFTP Server
其是基於udp文件傳輸的協議, 工作於69/udp端口,在Centos 6平臺依賴於xinetd服務,其也是C/S架構, 服務端爲:tftp-server, 客戶端爲:tftp.
TFTP的安裝

服務端的安裝:
yum install tftp-server


客戶端的安裝:
yum install tftp


TFTP共享的默認路徑:

/var/lib/tftpboot/

各平臺TFTP服務器的啓動

Centos 6:
chkconfig tftp on
service xinetd start


Centos 7:
systemctl start tftp.socket


需要確認TFTP Server在Xinetd服務下是否啓用:
如果disable = no , 表示已經啓用,需要將其也改爲no.
[root@Centos7 ~]# cat /etc/xinetd.d/tftp
# default: off
# description: The tftp server serves files using the trivial file transfer \
#       protocol.  The tftp protocol is often used to boot diskless \
#       workstations, download configuration files to network-aware printers, \
#       and to start the installation process for some operating systems.
service tftp
{
        disable                 = no
        socket_type             = dgram
        protocol                = udp
        wait                    = yes
        user                    = root
        server                  = /usr/sbin/in.tftpd
        server_args             = -B 1380 -v -s /var/lib/tftpboot
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
}
=======
syslinux
什麼是syslinux
其是一個套件, 是各種bootloaders的合集.
syslinux的安裝

yum install syslinux

各bootloaders的文件合集的存放路徑

/usr/share/syslinux/

[root@Centos7 ~]# ls /usr/share/syslinux/
altmbr.bin          diag/               gptmbr_f.bin        int18.com           kbdmap.c32          memdump.com         reboot.c32          vesainfo.c32
altmbr_c.bin        disk.c32            gpxecmd.c32         isohdpfx.bin        linux.c32           meminfo.c32         rosh.c32            vesamenu.c32
altmbr_f.bin        dmitest.c32         gpxelinux.0         isohdpfx_c.bin      ls.c32              menu.c32            sanboot.c32         vpdtest.c32
cat.c32             dosutil/            gpxelinuxk.0        isohdpfx_f.bin      lua.c32             pcitest.c32         sdi.c32             whichsys.c32
chain.c32           elf.c32             hdt.c32             isohdppx.bin        mboot.c32           pmload.c32          sysdump.c32         zzjson.c32
cmd.c32             ethersel.c32        host.c32            isohdppx_c.bin      mbr.bin             poweroff.com        syslinux64.exe
config.c32          gfxboot.c32         ifcpu64.c32         isohdppx_f.bin      mbr_c.bin           pwd.c32             syslinux.com
cpuid.c32           gptmbr.bin          ifcpu.c32           isolinux.bin        mbr_f.bin           pxechain.com        syslinux.exe
cpuidtest.c32       gptmbr_c.bin        ifplop.c32          isolinux-debug.bin  memdisk             pxelinux.0          ver.com
=====
PXE服務
簡介
PXE(preboot execute environment,預啓動執行環境)是由Intel公司開發的最新技術,工作於Client/Server的網絡模式,支持工作站通過網絡從遠端服務器下載映像,並由此支持通過網絡啓動操作系統,在啓動過程中,終端要求服務器分配IP地址,再用TFTP(trivial file transfer protocol)或MTFTP(multicast trivial file transfer protocol)協議下載一個啓動軟件包到本機內存中執行,PXE可以引導多種操作系統,如:Windows95/98/2000/windows2003/windows2008/winXP/win7/win8,linux等。
PXE環境依賴的服務

DHCP
TFTP
fileserver(yum repository), 可以由httpd服務提供

PXE環境的安裝示例:
####配置dhcp服務
yum install dhcp
cp  /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example dhcpd.conf  #複製DHCP自帶示例文件
vim /etc/dhcp/dhcpd.conf
option domain-name "zhenping.me";  #域名稱爲zhenping.me
option domain-name-servers 172.16.0.1; # DNS server IP.
default-lease-time 600;        #默認租約時間
max-lease-time 7200;    #最大租約時間
log-facility local7;     #日誌文件由哪個facility來記錄

######配置作用域及提供TFTP SERVER服務的服務器及FILENMAE
subnet 172.16.36.0 netmask 255.255.255.0 {
    range 172.16.36.80 172.16.36.90;
    option routers 172.16.0.1;
    filename "pxelinux.0";
    next-server 172.16.36.70;
}

######安裝syslinux套件,獲取各bootloader文件.
yum install syslinux

######安裝tftp server服務
yum install tftp-server

######將pxelinux.0文件複製到tftp共享路徑,此文件爲引導文件.
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/

#######插入系統光盤

# mkdir /media/cdrom
# mount -r /dev/cdrom /media/cdrom/
# cd /media/cdrom/p_w_picpaths/pxeboot

######複製系統啓動時所需的kernel文件及ramdisk文件
# cp vmlinuz initrd.img /var/lib/tftpboot/

######複製系統引導過程中的所需要文件
# cd /usr/share/syslinux
# cp chain.c32 mboot.c32 menu.c32 memdisk /var/lib/tftpboot/

######創建pxelinux.cfg目錄,並建立default文件,其是引導界面中的各選項配置
# mkdir /var/lib/tftpboot/pxelinux.cfg
# vim /var/lib/tftpboot/pxelinux.cfg/default
default menu.c32
    prompt 5
    timeout 30
    MENU TITLE CentOS 7 PXE Menu

    LABEL linux        #此LABEL的linux,可以在引導界面下輸入linux來引導
    MENU LABEL Install CentOS 7 X86_64        #引導界面的名稱
    KERNEL vmlinuz        #所需要的kernel文件
    APPEND initrd=initrd.img inst.repo=http://172.16.36.70/centos7 ks=http://172.16.36.70/centos7.cfg        #指定所需的ramdisk文件,及repo的地址(即光盤就是一個repo倉庫), ks文件的訪問路徑. 以HTTP方式訪問的路徑文件, 都是以httpd服務提供的頁面.

######安裝並配置httpd服務

#yum install httpd
# mkdir /var/www/html/centos7

######將光盤的掛載內容直接與httpd的網站根目錄下的centos7文件夾綁定
# mount --bind /media/cdrom/ /var/www/html/centos7

#######配置安裝所需要的kickstart文件
# vim /var/www/html/centos7.cfg

#platform=x86, AMD64, 或 Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# X Window System configuration information
xconfig  --startxonboot
# Keyboard layouts
# old format: keyboard us
# new format:
keyboard --vckeymap=cn --xlayouts='cn'
# Reboot after installation
reboot
# Root password
rootpw --iscrypted $1$HDHf2v4i$LMo.xGHfxQDOf8e043C.g/
# System timezone
timezone Asia/Shanghai
# Use network installation
url --url="http://172.16.36.70/centos7"     #這是安裝的repository地址.
# System language
lang zh_CN
user --groups=wheel --name=mageedu --password=$6$1eWrOetY$DfLZgquGiOaNkwpEF4ItMipz.1kpn7Q.s6oXyoW2bALkWesRWHCCACICkJ.2zBXDbwEw0ibR.wxStLI41ZhfF1 --iscrypted --gecos="MageEdu"
# Firewall configuration
firewall --disabled
# Network information
network  --bootproto=dhcp --device=eth0
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use text mode install
text
firstboot --disable
# SELinux configuration
selinux --permissive

ignoredisk --only-use=sda
# System bootloader configuration
bootloader --location=mbr --boot-drive=sda
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --asprimary --fstype="xfs" --size=512
part swap --fstype="swap" --size=2048
part /usr --fstype="xfs" --size=20480
part / --fstype="xfs" --size=20480

%packages
@base
@core
@fonts
@internet-browser
@java-platform
@kde-apps
@kde-desktop
@network-file-system-client
@networkmanager-submodules
@x11
lftp
screen
wget
tree

%end

%post
systemctl set-default multi-user.target
rm -f /etc/yum.repos.d/CentOS-Base.repo
wget -q -O /etc/yum.repos.d/CentOS-Base.repo http://172.16.0.1/repos/CentOS-Base.repo
wget -q -O /etc/yum.repos.d/epel.repo http://172.16.0.1/repos/epel.repo
echo -e 'Mage Education Learning Services\nhttp://www.magedu.com\n' >> /etc/issue
%end

######啓動各項服務並查看其服務的監聽狀態:
# systemctl start httpd.service
#    systemctl start dhcpd.service
#    systemctl start tftp.socket
====
Cobbler服務
簡介
由Readhat公司於2008年推出,cobbler是pxe的二次封裝, 其是由python語言研發,其也依賴於DHCP, TFTP, FILESERVER(repository,即http服務),rsync服務.cobbler可以使用模塊化的管理DHCP,TFTP和http服務. cobbler軟件是由epel源提供.故需要配置好epel源.
Cobbler的術語:

distro : repository(repo倉庫), 表示一個發行版,標記一個發行版的最關鍵資源是kernel和ramdisk
profile : kickstart(不同的kickstart文件,製作不同的安裝項)
system : 做MAC與IP綁定的

Cobbler的安裝

yum install cobbler

Cobbler的配置文件

/etc/cobbler/settings

Cobbler的配置文件參數


server IP : 提供cobbler服務的主機相應的IP地址或主機名

next_server : 提供PXE服務的主機相應的IP地址

default_password_crypted 密碼串 : 可以使用`openssl passwd -1 -salt $(openssl rand -hex 4),生成密碼串,並替換配置文件中的此參數的密碼串

manage_dhcp:0 : 0表示不由cobbler來管理,1表示由cobbler來管理

注意:在平常的配置中, 只需要上面三項參數即可使用
Cobbler的服務管理

Centos 6
service cobblerd start


Centso 7
systemctl start cobblerd


cobbler命令


cobbler distro

add : 添加
remove : 刪除
list : 查看
rename : 重命名


cobbler profile

add : 添加
remove : 刪除
list : 查看

rename : 重命名


注意: 添加的kickstart文件將存放於:/var/lib/cobbler/kickstarts/路徑下面.



cobbler profile rename --name=Centos7-1503-x86_64 --newname=Centos-7-1503-x86_64-minimal
cobbler profile add --name=Centos-7-x86_64-1503-server --distro=Centos-7-1503-x86_64 --kickstart=/var/lib/cobbler/kickstart/centos7.cfg

對Centos-7-1503-x86_64倉庫鏡像文件, 在引導界面中,添加一個Centos-7-x86_64-1503-server的安裝條目,且利用指定的kickstart文件/var/lib/cobbler/kickstart/centos7.cfg, 來引導安裝過程

cobbler import
--name : 配電室導入的distro名稱
--path : 指定從那個鏡像文件導入


cobbler import --name="Centos-7_X86_64-1503" --path=/media/cdrom

此命令將把光盤中的所有內容都複製至本地磁盤, 在/var/www/目錄下生成一個cobbler文件夾
配置示例1:
Cobbler:

一、安裝

前提:cobbler由epel源提供,故此需要事先配置指向epel的yum源方可進行類似下面的安裝過程。

# yum install cobbler cobbler-web pykickstart debmirror

# service httpd start
# service cobblerd start

執行“cobbler check命令檢查存的問題,而後逐一按提示解決之。常見的問題如下所示:
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 : 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 : change 'disable' to 'no' in /etc/xinetd.d/rsync
5 : comment 'dists' on /etc/debmirror.conf for proper debian support
6 : comment 'arches' on /etc/debmirror.conf for proper debian support
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、修改/etc/cobbler/settings文件中的server參數的值爲提供cobbler服務的主機相應的IP地址或主機名,如172.16.100.15;
2、修改/etc/cobbler/settings文件中的next_server參數的值爲提供PXE服務的主機相應的IP地址,如172.16.100.16;
3、如果當前節點可以訪問互聯網,執行“cobbler get-loaders”命令即可;否則,需要安裝syslinux程序包,而後複製/usr/share/syslinux/{pxelinux.0,memu.c32}等文件至/var/lib/cobbler/loaders/目錄中;
4、執行“chkconfig rsync on”命令即可;
5、註釋/etc/debmirror.conf文件中的“@dists="sid";”一行;
6、註釋/etc/debmirror.conf文件中的“@arches="i386";”一行;
7、執行“openssl passwd -1 -salt $(openssl rand -hex 4)”生成密碼,並用其替換/etc/cobbler/settings文件中default_password_crypted參數的值;
8、執行“yum install cman fence-agents”命令安裝相應的程序包即可;

接着重啓cobblerd,而後執行“cobbler sync”同步新的配置至cobbler。

二、配置及啓動cobbler所依賴的各服務

cobbler的運行依賴於dhcp、tftp、rsync及dns服務。其中dhcp可由dhcpd(isc)提供,也可由dnsmasq提供;tftp可由tftp-server程序包提供,也可由cobbler自帶的tftp功能提供;rsync由rsync程序包提供;dns可由bind提供,也可由dnsmasq提供。

cobbler可自行管理這些服務中的部分甚至是全部,但需要配置/etc/cobbler/settings文件中的“manage_dhcp”、“manage_tftpd”、“manage_rsync”和“manage_dns”分別進行定義。另外,由於每種服務都有着不同的實現方式,如若需要進行自定義,需要通過修改/etc/cobbler/modules.conf配置文件中各服務的模塊參數的值來實現。

本文采用了獨立管理的方式,即不通過cobbler來管理這些服務。

2.1 配置dhcp服務

定義好所需的“subnet”及其它參數或選項,而後啓動dhcpd守護進程即可。本示例中所用的dhcpd的配置如下所示:

option domain-name "magedu.com";
option domain-name-servers 192.168.10.254,172.16.0.1;

default-lease-time 43200;
max-lease-time 86400;

log-facility local7;

subnet 172.16.0.0 netmask 255.255.0.0 {
    range 172.16.100.121 172.16.100200;
    option routers 172.16.100.7;
}

next-server 172.16.100.7;
filename="pxelinux.0";

接着使用“service dhcpd start”啓動服務即可。


2.2 配置tftp服務

# chkconfig tftp on
# service xinetd restart



三、配置cobbler

cobbler的各主要組件間的關係如下圖所示。


3.1 管理distro

使cobbler變得可用的第一步爲定義distro,其可以通過爲其指定外部的安裝引導內核及ramdisk文件的方式實現。而如果已經有完整的系統安裝樹(如CentOS6的安裝鏡像)則推薦使用import直接導入的方式進行。

例如,對於已經掛載至/media/cdrom目錄的CentOS 6.5 x86_64的安裝鏡像,則可以使用類似如下命令進行導入。
# cobbler import --name=centos-6.5-x86_64 --path=/media/cdrom

可使用“cobbler distro list”列出所有的distro。

如果有kickstart文件,也可以使用“--kickstart=/path/to/kickstart_file”進行導入,因此import會自動爲導入的distro生成一個profile。

3.2 管理profile

cobbler使用profile來爲特定的需求類別提供所需要安裝配置,即在distro的基礎上通過提供kickstart文件來生成一個特定的系統安裝配置。distro的profile可以出現在PXE的引導菜單中作爲安裝的選擇之一。

因此,如果需要爲前面創建的centos-6.5-x86_64這個distro提供一個可引導安裝條目,其用到的kickstart文件爲/tmp/centos-6.5-x86_64.cfg(只提供了最基本的程序包),則可通過如下命令實現。
# cobbler profile add --name=centos-6.5-x86_64-basic --distro=centos-6.5-x86_64 --kickstart=/tmp/centos-6.5-x86_64.cfg

可使用“cobbler profile list”查看已經創建的profile。


四、使用cobbler_web

4.1 配置cobbler_web的認證功能

cobbler_web支持多種認證方式,如authn_configfile、authn_ldap或authn_pam等,默認爲authn_denyall,即拒絕所有用戶登錄。下面說明兩種能認證用戶登錄cobbler_web的方式。

4.1.1 使用authn_pam模塊認證cobbler_web用戶

首先修改modules中[authentication]段的module參數的值爲authn_pam。

接着添加系統用戶,用戶名和密碼按需設定即可,例如下面的命令所示。
# useradd cblradmin
# echo 'cblrpass' | passwd --stdin cblradmin

而後將cblradmin用戶添加至cobbler_web的admin組中。修改/etc/cobbler/users.conf文件,將cblradmin用戶名添加爲admin參數的值即可,如下所示。
[admins]
admin = "cblradmin"

最後重啓cobblerd服務,通過http://YOUR_COBBLERD_IP/cobbler_web訪問即可。

4.1.2 使用authn_configfile模塊認證cobbler_web用戶

首先修改modules.conf中[authentication]段的module參數的值爲authn_configfile。

接着創建其認證文件/etc/cobbler/users.digest,並添加所需的用戶即可。需要注意的是,添加第一個用戶時,需要爲htdigest命令使用“-c”選項,後續添加其他用戶時不能再使用;另外,cobbler_web的realm只能爲Cobbler。如下所示。

# htdigest -c /etc/cobbler/users.digest Cobbler cblradmin 

最後重啓cobblerd服務,通過http://YOUR_COBBLERD_IP/cobbler_web訪問即可。
安裝配置示例二:
cobbler的安裝及配置
安裝所依賴的服務-DHCP
~]# yum install dhcp
~]# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
~]# vim /etc/dhcp/dhcpd.conf
option domain-name "zhenping.me";
option domain-name-servers 172.16.0.1;
default-lease-time 600;
max-lease-time 7200;
log-facility local7;
subnet 172.16.36.0 netmask 255.255.255.0 {
  range 172.16.36.80 172.16.36.90;
  option routers 172.16.36.70;
  filename "pxelinux.0";
  next-server 172.16.36.70;
}
~]# systemctl start dhcpd.service
~]# ss -nulp
State      Recv-Q Send-Q                                                         Local Address:Port                                                           Peer Address:Port
UNCONN     0      0                                                                          *:67                                                                        *:*

~]# yum install syslinux -y
~]# yum install tftp-server -y
~]# cp /usr/share/syslinux/pxelinux.0  /var/lib/cobbler/loaders
~]# cp /usr/share/syslinux/menu.c32  /var/lib/cobbler/loaders
~]# systemctl start tftp.socket
~]# systemctl start httpd.service

~]# vim /etc/cobbler/settings
default_password_crypted: "$6$OjGi5IvB$ybqkSzKw9oQEuZj1FVfyuweW924H.MXed9OSXDPjz1YZY2t95jYxaeX15C10zwe032Dh4qCOa9OXiEcGey86E0:16854" (此密碼串可以使用openss passwd生成,也可以使用添加用戶設置的密碼)
server: 172.16.36.70
next_server: 172.16.36.70

~]# systemctl restart cobblerd
~]# cobbler check

~]# systemctl start rsyncd.socket

掛載系統鏡像文件:
~]# cobbler import --name="CentOS-7-1503-X86_64" --path=/media/cdrom
~]# cobbler sync
~]# cobbler distro list
   CentOS-7-1503-X86_64-x86_64

插入Centos 6的系統光盤,進行6的製作
~]# mount /dev/cdrom /media/cdrom/
~]# cobbler import --name=Centos-6-X86_64 --path=/media/cdrom
~]# cobbler sync

爲Centos7提供定製的kickstart文件,並製作cobbler的profile
~]# cp centos7.cfg /var/lib/cobbler/kickstarts/
 ~]# cobbler profile add --name=CentOS-7-X86_64_1503-Web_Server --distro=CentOS-7-1503-X86_64-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos7.cfg
[root@Centos7 ~]# cobbler profile list
   CentOS-7-1503-X86_64-x86_64
   CentOS-7-X86_64_1503-Web_Server
   Centos-6-X86_64-x86_64

查看Cobbler的啓動界面配置文件(此文件可以修改,但在重啓服務或者cobbler sync命令後,文件將復原):
~]# cat /var/lib/tftpboot/pxelinux.cfg/default
DEFAULT menu
PROMPT 0
MENU TITLE Cobbler | http://cobbler.github.com
TIMEOUT 200
TOTALTIMEOUT 6000
ONTIMEOUT local

LABEL local
        MENU LABEL (local)
        MENU DEFAULT
        LOCALBOOT -1

LABEL CentOS-7-1503-X86_64-x86_64
        kernel /p_w_picpaths/CentOS-7-1503-X86_64-x86_64/vmlinuz
        MENU LABEL CentOS-7-1503-X86_64-x86_64
        append initrd=/p_w_picpaths/CentOS-7-1503-X86_64-x86_64/initrd.img ksdevice=bootif lang=  kssendmac text  ks=http://172.16.36.70/cblr/svc/op/ks/profile/CentOS-7-1503-X86_64-x86_64
        ipappend 2

LABEL CentOS-7-X86_64_1503-Web_Server
        kernel /p_w_picpaths/CentOS-7-1503-X86_64-x86_64/vmlinuz
        MENU LABEL CentOS-7-X86_64_1503-Web_Server
        append initrd=/p_w_picpaths/CentOS-7-1503-X86_64-x86_64/initrd.img ksdevice=bootif lang=  kssendmac text  ks=http://172.16.36.70/cblr/svc/op/ks/profile/CentOS-7-X86_64_1503-Web_Server
        ipappend 2

LABEL Centos-6-X86_64-x86_64
        kernel /p_w_picpaths/Centos-6-X86_64-x86_64/vmlinuz
        MENU LABEL Centos-6-X86_64-x86_64
        append initrd=/p_w_picpaths/Centos-6-X86_64-x86_64/initrd.img ksdevice=bootif lang=  kssendmac text  ks=http://172.16.36.70/cblr/svc/op/ks/profile/Centos-6-X86_64-x86_64
        ipappend 2


MENU end

總結:   
    cobbler的依賴服務,需要確認如下:
        systemctl start dhcpd.service
        systemctl start tftp.socket
        systemctl start rsyncd.socket
        systemctl start cobblerd.service
        systemctl start httpd.service
    Centos 7的xinet.d服務未存在,但需要將/etc/xinet.d/服務腳本中的disable = yes , 修改爲disable = no


安裝配置cobbler-web服務
vim /etc/cobbler/modules.conf
確認其使用的認證配置方式
~]# htdigest -c /etc/cobbler/users.digest cobbler cblradmin



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