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



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