Cobbler批量装机

1 Cobbler简介

Cobbler是一个免费开源系统安装部署软件,用于自动化网络安装操作系统。Cobbler 集成了 DNS, DHCP, 软件包更新,带外管理以及配置管理,方便操作系统安装自动化。Cobbler 可以支持PXE启动, 操作系统重新安装,以及虚拟化客户机创建,包括Xen, KVM or VMware. Cobbler透过koan程序以支持虚拟化客户机安装。Cobbler可以支持管理复杂网路环境,如建立在链路聚合以太网的桥接环境。

该工具使用python开发,小巧轻便(才15k行python代码),使用简单的命令即可完成PXE网络安装环境的配置,同时还可以管理DHCP、DNS、以及yum仓库、构造系统ISO镜像。

Cobbler支持命令行管理,web界面管理,还提供了API接口,可以方便二次开发使用。Cobbler客户端Koan支持虚拟机安装和操作系统重新安装,使重装系统更便捷

2 Cobbler介绍

  1. Cobbler是一个Linux系统安装的服务,可以通过网络启动(PXE)的方式来快速安装、重装物理服务器和虚拟机,同时还可以管理DHCP,DNS等。
  2. Cobbler可以使用命令行方式管理,也提供了基于Web的界面管理工具(cobbler-web),还提供了API接口,可以方便二次开发使用。
  3. Cobbler是较早前的kickstart的升级版,优点是比较容易配置,还自带web界面比较易于管理。
  4. cobbler是Python开发编写的
  5. 提供了CLI字符界面和web图像界面的管理形式

3 Cobbler原理

Cobbler是通过将DHCP、TFTP、DNS、HTTP等服务进行集成,创建一个中央管理节点,其可以实现的功能有配置服务,创建存储库,解压缩操作系统媒介,代理或集成一个配置管理系统,控制电源管理等。 Cobbler的最终目的是实现无需进行人工干预即可安装机器。在进行进一步的操作之前,我们有必要先了解下pxe和kickstart

4 PXE简介

PXE,就是预启动执行环境,是一种引导启动的方式。这种协议一般由两部分构成,一部分是服务器端,一个是客户端。简单来说,我们通过这种方式可以自己创建一个“安装源”,在安装系统的时候只要能找到这个“源”便可以实现系统的安装。

在实现无人值守的安装前,我们必须要搭建一些服务,来实现“安装源”的建立,例如ftp、http、tftp、dhcp等。当一台主机启动时,标准输入输出会将PXE客户端调入我们的内存中进行相关的操作,并提示相关的选项,在这里我们可以进行选择。PXE的客户端通过网络下载(download)启动文件到本地运行。具体过程是,PXE客户端通过网卡向局域网内发送ip请求,然后DHCP服务器会提供给给它一个ip地址和系统安装所需要的文件,接下使用接收到的文件进行系统安装。而安装的过程又需要其他服务器提供的资源,例如:yum源,内核文件等,当主机拿到这些资源,便可以顺利的安装了。最终结果是:任意一台主机在选着网络启动时会获取DHCP服务器分发的ip,通过通过获取到的ip地址与局域网内的TFTP服务器通信并获取启动文件,与FTP或者HTTP通信并获取yum源文件及内核文件等。之后开始自动安装,而这个过程不需要人在做任何操作。

PXE安装优点,这种安装系统的方式可以不受光驱,光盘以及一些外部设备的限制,还可以做到无人值守,大大减轻了运维人员的工作负荷

5 kickstart简介

KickStart是一种无人职守安装方式。KickStart的工作原理是通过记录典型的安装过程中所需人工干预填写的各种参数,并生成一个名为ks.cfg的文件;在其后的安装过程中(不只局限于生成KickStart安装文件的机器)当出现要求填写参数的情况时,安装程序会首先去查找KickStart生成的文件,当找到合适的参数时,就采用找到的参数,当没有找到合适的参数时,才需要安装者手工干预。这样,如果KickStart文件涵盖了安装过程中出现的所有需要填写的参数时,安装者完全可以只告诉安装程序从何处取ks.cfg文件,然后去忙自己的事情。等安装完毕,安装程序会根据ks.cfg中设置的重启选项来重启系统,并结束安装

6 Cobbler工作流程

在这里插入图片描述

  1. client裸机配置了从网络启动后,开机后会广播包请求DHCP服务器(cobbler server)发送其分配好的一个IP
  2. DHCP服务器(cobbler server)收到请求后发送responese,包括其ip地址
  3. client裸机拿到ip后再向cobbler server发送请求OS引导文件的请求
  4. cobbler server告诉裸机OS引导文件的名字和TFTP server的ip和port
  5. client裸机通过上面告知的TFTPserver地址通信,下载引导文件
  6. client裸机执行执行该引导文件,确定加载信息,选择要安装的os,期间会再向cobbler server请求kickstart文件和os image
  7. cobbler server发送请求的kickstart和os iamge
  8. client裸机加载kickstart文件 .client裸机接收os image,安装该os image

7 cobbler集成的服务

  1. DHCP服务分配IP地址
  2. Client(获取IP地址、Next_server IP地址)
  3. Next_server(获取启动内核、initrd等文件)
  4. tftp (PXE引导文件、启动Cobbler选择界面)
  5. kickstart (确定加载项,根据NFS,httpd,ftp等共享)

8 cobbler配置文件详解

8.1 配置文件

cobbler配置文件目录在/etc/cobbler

yum install cobbler:安装
/etc/cobbler:配置文件目录
/etc/cobbler/settings : cobbler 主配置文件
/etc/cobbler/iso/: iso模板配置文件
/etc/cobbler/pxe: pxe模板文件
/etc/cobbler/power: 电源配置文件
/etc/cobbler/user.conf: web服务授权配置文件
/etc/cobbler/users.digest: web访问的用户名密码配置文件
/etc/cobbler/dhcp.template : dhcp服务器的的配置末班
/etc/cobbler/dnsmasq.template : dns服务器的配置模板
/etc/cobbler/tftpd.template : tftp服务的配置模板
/etc/cobbler/modules.conf : 模块的配置文件

8.2 cobbler数据目录

/var/lib/cobbler/config/    用于存放distros,system,profiles等信息配置文件
/var/lib/cobbler/triggers/	用于存放用户定义的cobbler命令
/var/lib/cobbler/kickstart/	默认存放kickstart文件
/var/lib/cobbler/loaders/	存放各种引导程序以及镜像目录
/var/www/cobbler/ks_mirror/	导入的发行版系统的所有数据
/var/www/cobbler/images/	导入发行版的kernel和initrd镜像用于远程网络启动
/var/www/cobbler/repo_mirror/	yum仓库存储目录

8.3 cobbler镜像目录

/var/www/cobbler/ks_mirror/   导入的发行版系统的所有数据
/var/www/cobbler/images/   导入发行版的kernel和initrd镜像用于远程网络启动
/var/www/cobbler/repo_mirror/   yum 仓库存储目录

8.4 cobbler日志文件

日志文件路径说明
/var/log/cobbler/installing客户端安装日志
/var/log/cobbler/cobbler.logcobbler日志

8.5 cobbler命令详解

cobbler check 核对当前设置是否有问题
cobbler list 列出所有的cobbler元素
cobbler report 列出元素的详细信息
cobbler sync 同步配置到数据目录,更改配置最好都要执行下
cobbler reposync 同步yum仓库
cobbler distro 查看导入的发行版系统信息
cobbler system 查看添加的系统信息
cobbler profile 查看配置信息

9 cobbler服务部署

// 关闭防火墙
[root@localhost ~]# systemctl disable --now firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

[root@localhost ~]# cat /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these three values:

[root@localhost ~]# reboot
SELINUX=disabled
[root@localhost ~]# getenforce 
Disabled


// 下载epel源
[root@localhost ~]# yum -y install epel-release

// 查看是否有cobbler包
[root@localhost ~]# yum list all | grep cobbler
cobbler.x86_64                           2.8.5-0.3.el7                 epel     
cobbler-web.noarch                       2.8.5-0.3.el7                 epel     

//安装cobbler以及相关的软件
[root@localhost ~]# yum -y install httpd dhcp tftp python-ctypes cobbler  xinetd cobbler-web pykickstart net-tools

//查看服务是否安装
[root@localhost ~]# rpm -qa | grep httpd
httpd-filesystem-2.4.37-40.module_el8.5.0+852+0aafc63b.noarch
centos-logos-httpd-85.8-1.el8.noarch
httpd-2.4.37-40.module_el8.5.0+852+0aafc63b.x86_64
httpd-tools-2.4.37-40.module_el8.5.0+852+0aafc63b.x86_64
[root@localhost ~]# rpm -qa | grep dhcp
dhcp-libs-4.3.6-42.el8.x86_64
dhcp-common-4.3.6-42.el8.noarch
dhcp-client-4.3.6-42.el8.x86_64
[root@localhost ~]# rpm -qa | grep tftp
tftp-server-5.2-24.el8.x86_64


/ 启动服务并设置开机自启
[root@localhost ~]# systemctl enable --now httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[root@localhost ~]# systemctl enable --now cobblerd
Created symlink /etc/systemd/system/multi-user.target.wants/cobblerd.service → /usr/lib/systemd/system/cobblerd.service.
[root@localhost ~]# ss -antl
State   Recv-Q  Send-Q    Local Address:Port      Peer Address:Port  Process  
LISTEN  0       128             0.0.0.0:22             0.0.0.0:*              
LISTEN  0       5             127.0.0.1:25151          0.0.0.0:*              
LISTEN  0       128                   *:80                   *:*              
LISTEN  0       128                [::]:22                [::]:*              
LISTEN  0       128                   *:443                  *:*              

// 修改server的ip地址为本机ip
[root@localhost ~]# sed -i 's/^server: 127.0.0.1/server: 192.168.25.150/' /etc/cobbler/settings

// 设置tftp的ip地址为本机ip
[root@localhost ~]# sed -i 's/^next_server: 127.0.0.1/next_server: 192.168.25.150/' /etc/cobbler/settings

//开启tftp
[root@localhost ~]# sed -i '/disable/s/yes/no/g' /etc/xinetd.d/tftp

//生成加密的密码
[root@localhost ~]# openssl passwd -1 -salt "$RANDOM" '123456'
$1$6643$2QxqmK786Ie/i7OLJ0AJu.    //生成的加密密码

//将新生成的加密密码加入到配置文件
[root@localhost ~]# vim /etc/cobbler/settings 
# and put the output between the "" below.
default_password_crypted: "$1$6643$2QxqmK786Ie/i7OLJ0AJu."     // 将此处的密码改为刚刚生成的

//启动rsync并设置开机自启
[root@localhost ~]# systemctl enable --now rsyncd
Created symlink from /etc/systemd/system/multi-user.target.wants/rsyncd.service to /usr/lib/systemd/system/rsyncd.service.
[root@localhost ~]# systemctl status rsyncd
● rsyncd.service - fast remote file copy program daemon
   Loaded: loaded (/usr/lib/systemd/system/rsyncd.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2021-10-13 09:27:09 EDT; 15s ago
 Main PID: 11874 (rsync)
   CGroup: /system.slice/rsyncd.service
           └─11874 /usr/bin/rsync --daemon --no-detach

Oct 13 09:27:09 localhost.localdomain systemd[1]: Started fast remote file ...
Oct 13 09:27:09 localhost.localdomain systemd[1]: Starting fast remote file...
Oct 13 09:27:09 localhost.localdomain rsyncd[11874]: rsyncd version 3.1.2 s...
Hint: Some lines were ellipsized, use -l to show in full.

// 重启cobbler
[root@localhost ~]# systemctl restart cobblerd

//通过cobbler check 核对当前设置是否有问题
[root@localhost ~]# cobbler check
The following are potential configuration items that you may want to fix:

1 : 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.
2 : debmirror package is not installed, it will be required to manage debian deployments and repositories

Restart cobblerd and then run 'cobbler sync' to apply changes.

// 解决设置报错
[root@localhost ~]# yum -y install fence-agents debmirror yum-utils syslinux
[root@localhost ~]# sed -i  's|@dists=.*|#@dists=|'  /etc/debmirror.conf
[root@localhost ~]# sed -i  's|@arches=.*|#@arches=|'  /etc/debmirror.conf  
[root@localhost loaders]# systemctl restart cobblerd

//因为centos7下载不了cobbler get-loaders所以在centos8上传过来
[root@localhost ~]# ls /var/lib/cobbler/loaders/
menu.c32  pxelinux.0
[root@localhost ~]# rm -rf /var/lib/cobbler/loaders/*
[root@localhost ~]# ls /var/lib/cobbler/loaders/
[root@localhost ~]#
[root@localhost cobbler]# scp loaders/* root@192.168.25.150:/var/lib/cobbler/loaders     //从8上传到7上
[root@localhost cobbler]# ls loaders/
COPYING.syslinux  grub-x86_64.efi  menu.c32    README
COPYING.yaboot    grub-x86.efi     pxelinux.0  yaboot

//再次检查
[root@localhost ~]# cobbler check 
The following are potential configuration items that you may want to fix:

1 : 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.
// 此报错不用理会,因为文件已经从centos8传到、var/lib/cobbler/loaders目录中,只要后面的同步不报错就会好l
Restart cobblerd and then run 'cobbler sync' to apply changes.    

//配置cobbler dhcp
//修改cobbler配置文件,让cobbler控制dhcp
[root@localhost ~]# sed -i '/^manage_dhcp/s/0/1/g' /etc/cobbler/settings
[root@localhost ~]# sed -n '/^manage_dhcp/p' /etc/cobbler/settings
manage_dhcp: 1

//配置dhcp配置文件
[root@localhost ~]# vim /etc/cobbler/dhcp.template
subnet 192.168.25.0 netmask 255.255.255.0 {    //192.168.25.0为本机网段
     option routers             192.168.25.150;    //本机IP
     option domain-name-servers 192.168.25.2;    //本机网段
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        192.168.25.100 192.168.25.254;    //获取的IP范围
     default-lease-time         21600;
     max-lease-time             43200;
     next-server                $next_server;
     class "pxeclients" {
          match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";

//重启服务并同步配置,改完dhcp必须要sync同步配置
[root@localhost ~]# systemctl restart cobblerd
[root@localhost ~]# systemctl status cobblerd
● cobblerd.service - Cobbler Helper Daemon
   Loaded: loaded (/usr/lib/systemd/system/cobblerd.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2021-10-13 10:31:04 EDT; 11s ago
  Process: 12491 ExecStartPost=/usr/bin/touch /usr/share/cobbler/web/cobbler.wsgi (code=exited, status=0/SUCCESS)
 Main PID: 12490 (cobblerd)
   CGroup: /system.slice/cobblerd.service
           └─12490 /usr/bin/python2 -s /usr/bin/cobblerd -F

Oct 13 10:31:04 localhost.localdomain systemd[1]: Starting Cobbler Helper Da...
Oct 13 10:31:04 localhost.localdomain systemd[1]: Started Cobbler Helper Dae...
Hint: Some lines were ellipsized, use -l to show in full.

[root@localhost ~]# cobbler sync   
task started: 2021-10-13_103227_sync
task started (id=Sync, time=Wed Oct 13 10:32:27 2021)
running pre-sync triggers
cleaning trees
removing: /var/lib/tftpboot/grub/images
copying bootloaders
trying hardlink /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
trying hardlink /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32
trying hardlink /var/lib/cobbler/loaders/yaboot -> /var/lib/tftpboot/yaboot
trying hardlink /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk
trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
copying distros to tftpboot
copying images
generating PXE configuration files
generating PXE menu structure
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
rendering TFTPD files
generating /etc/xinetd.d/tftp
cleaning link caches
running post-sync triggers
running python triggers from /var/lib/cobbler/triggers/sync/post/*
running python trigger cobbler.modules.sync_post_restart_services
running: dhcpd -t -q
received on stdout: 
received on stderr: 
running: service dhcpd restart
received on stdout: 
received on stderr: Redirecting to /bin/systemctl restart dhcpd.service

running shell triggers from /var/lib/cobbler/triggers/sync/post/*
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.manage_genders
running python trigger cobbler.modules.scm_track
running shell triggers from /var/lib/cobbler/triggers/change/*
*** TASK COMPLETE ***

//检查dhcp是否正常
[root@localhost ~]# netstat -anulp|grep dhcp
udp        0      0 0.0.0.0:67              0.0.0.0:*                           12543/dhcpd         

//设置dhcp服务开机自启
[root@localhost ~]# systemctl enable --now dhcpd
Created symlink from /etc/systemd/system/multi-user.target.wants/dhcpd.service to /usr/lib/systemd/system/dhcpd.service.


//导入镜像
[root@localhost ~]# mount /dev/sr0 /mnt    //挂载光盘
mount: /dev/sr0 is write-protected, mounting read-only

[root@localhost ~]# cobbler import --path=/mnt --name=centos-7 --arch=x86_64
task started: 2021-10-13_103558_import
task started (id=Media import, time=Wed Oct 13 10:35:58 2021)
Found a candidate signature: breed=redhat, version=rhel6
Found a candidate signature: breed=redhat, version=rhel7
Found a matching signature: breed=redhat, version=rhel7
Adding distros from path /var/www/cobbler/ks_mirror/centos-7-x86_64:
creating new distro: centos-7-x86_64
trying symlink: /var/www/cobbler/ks_mirror/centos-7-x86_64 -> /var/www/cobbler/links/centos-7-x86_64
creating new profile: centos-7-x86_64
associating repos
checking for rsync repo(s)
checking for rhn repo(s)
checking for yum repo(s)
starting descent into /var/www/cobbler/ks_mirror/centos-7-x86_64 for centos-7-x86_64
processing repo at : /var/www/cobbler/ks_mirror/centos-7-x86_64    //导入镜像的位置
need to process repo/comps: /var/www/cobbler/ks_mirror/centos-7-x86_64
looking for /var/www/cobbler/ks_mirror/centos-7-x86_64/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/centos-7-x86_64/repodata
*** TASK COMPLETE ***
//说明:
    --path      //镜像路径
    --name      //为安装源定义一个名字
    --arch      //指定安装源平台

//安装源的唯一标示就是根据name参数来定义,本例导入成功后,安装源的唯一标示就是:CentOS-7-x86_64,如果重复,系统会提示导入失败

//查看cobbler镜像列表
[root@localhost ~]# ls /var/www/cobbler/ks_mirror/
centos-7-x86_64  config
[root@localhost ~]# cobbler list
distros:
   centos-7-x86_64

profiles:
   centos-7-x86_64

systems:

repos:

images:

mgmtclasses:

packages:

files:

//创建kickstarts自动安装脚本
[root@localhost ~]# cat /var/lib/cobbler/kickstarts/centos-7-x86_64.ks
auth --enableshadow --passalgo=sha512
bootloader --location=mbr
clearpart --all --initlabel
part /boot --asprimary --fstype="ext4" --size=500
part swap --fstype="swap" --size=4096
part / --fstype="ext4" --grow --size=15000
text
firewall --disabled
firstboot --disable
keyboard us
lang en_US
url --url=http://192.168.25.150/cobbler/ks_mirror/centos-7-x86_64      // 修改为本机IP目录为刚刚生成的导入镜像名
$yum_repo_stanza
reboot

rootpw --iscrypted $6$kv4t7yVcr87J3s/J$TojvQgt5jYV7yJFsaRaSdhasN.4kf0y9mzAuxEE2lwmDyDv1kySHDIsp78695w9gXEMpe1aqnWjwlz.CuID42.    //复制本机上anaconda-ks.cfg中的

selinux --disabled
skipx
timezone Asia/Shanghai --isUtc --nontp
install
zerombr

%packages    //跟本机上的anaconda-ks.cfg中的一致
@^minimal
@core
chrony
kexec-tools

%end

%addon com_redhat_kdump --enable --reserve-mb='auto'

%end

%anaconda
pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
%end

//检查ks文件语法是否有误
[root@localhost ~]# cobbler validateks
task started: 2021-10-13_105214_validateks
task started (id=Kickstart Validation, time=Wed Oct 13 10:52:14 2021)
----------------------------
osversion: rhel7
checking url: http://192.168.25.150/cblr/svc/op/ks/profile/centos-7-x86_64
running: /usr/bin/ksvalidator -v "rhel7" "http://192.168.25.150/cblr/svc/op/ks/profile/centos-7-x86_64"
received on stdout: 
received on stderr: 
*** all kickstarts seem to be ok ***
*** TASK COMPLETE ***

//查看当前cobbler有哪些配置文件
[root@localhost ~]# cobbler profile list
   centos-7-x86_64

//修改profile,将我们新建的ks文件设为默认的kickstarts安装文件
[root@localhost ~]# cobbler profile edit --name centos-7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos-7-x86_64.ks
[root@localhost ~]# cobbler profile report
Name                           : centos-7-x86_64
TFTP Boot Files                : {}
Comment                        : 
DHCP Tag                       : default
Distribution                   : centos-7-x86_64
Enable gPXE?                   : 0
Enable PXE Menu?               : 1
Fetchable Files                : {}
Kernel Options                 : {}
Kernel Options (Post Install)  : {}
Kickstart                      : /var/lib/cobbler/kickstarts/centos-7-x86_64.ks
Kickstart Metadata             : {}
Management Classes             : []
Management Parameters          : <<inherit>>
Name Servers                   : []
Name Servers Search Path       : []
Owners                         : ['admin']
Parent Profile                 : 
Internal proxy                 : 
Red Hat Management Key         : <<inherit>>
Red Hat Management Server      : <<inherit>>
Repos                          : []
Server Override                : <<inherit>>
Template Files                 : {}
Virt Auto Boot                 : 1
Virt Bridge                    : xenbr0
Virt CPUs                      : 1
Virt Disk Driver Type          : raw
Virt File Size(GB)             : 5
Virt Path                      : 
Virt RAM (MB)                  : 512
Virt Type                      : kvm

//配置网卡名称为传统网卡名称eth0
[root@localhost ~]# cobbler profile edit --name centos-7-x86_64 --kopts='net.ifnames=0 biosdevname=0'
[root@localhost ~]# cobbler profile report
Name                           : centos-7-x86_64
TFTP Boot Files                : {}
Comment                        : 
DHCP Tag                       : default
Distribution                   : centos-7-x86_64    //仓库名字
Enable gPXE?                   : 0
Enable PXE Menu?               : 1
Fetchable Files                : {}
Kernel Options                 : {'biosdevname': '0', 'net.ifnames': '0'}    //网卡设为传统命名方式
Kernel Options (Post Install)  : {}
Kickstart                      : /var/lib/cobbler/kickstarts/centos-7-x86_64.ks    //使用的kickstarts配置文件的路径,必须为我们新建的ks文件的路径
Kickstart Metadata             : {}
Management Classes             : []
Management Parameters          : <<inherit>>
Name Servers                   : []
Name Servers Search Path       : []
Owners                         : ['admin']
Parent Profile                 : 
Internal proxy                 : 
Red Hat Management Key         : <<inherit>>
Red Hat Management Server      : <<inherit>>
Repos                          : []
Server Override                : <<inherit>>
Template Files                 : {}
Virt Auto Boot                 : 1
Virt Bridge                    : xenbr0
Virt CPUs                      : 1
Virt Disk Driver Type          : raw
Virt File Size(GB)             : 5
Virt Path                      : 
Virt RAM (MB)                  : 512
Virt Type                      : kvm

//同步cobbler
[root@localhost ~]# cobbler sync
task started: 2021-10-13_105641_sync
task started (id=Sync, time=Wed Oct 13 10:56:41 2021)
running pre-sync triggers
cleaning trees
removing: /var/www/cobbler/images/centos-7-x86_64
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/grub-x86_64.efi
removing: /var/lib/tftpboot/grub/grub-x86.efi
removing: /var/lib/tftpboot/grub/efidefault
removing: /var/lib/tftpboot/images/centos-7-x86_64
removing: /var/lib/tftpboot/s390x/profile_list
copying bootloaders
trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
copying distros to tftpboot
copying files for distro: centos-7-x86_64
trying hardlink /var/www/cobbler/ks_mirror/centos-7-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/centos-7-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/centos-7-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/centos-7-x86_64/initrd.img
copying images
generating PXE configuration files
generating PXE menu structure
copying files for distro: centos-7-x86_64
trying hardlink /var/www/cobbler/ks_mirror/centos-7-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/centos-7-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/centos-7-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/centos-7-x86_64/initrd.img
Writing template files for centos-7-x86_64
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
rendering TFTPD files
generating /etc/xinetd.d/tftp
processing boot_files for distro: centos-7-x86_64
cleaning link caches
running post-sync triggers
running python triggers from /var/lib/cobbler/triggers/sync/post/*
running python trigger cobbler.modules.sync_post_restart_services
running: dhcpd -t -q
received on stdout: 
received on stderr: 
running: service dhcpd restart
received on stdout: 
received on stderr: Redirecting to /bin/systemctl restart dhcpd.service

running shell triggers from /var/lib/cobbler/triggers/sync/post/*
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.manage_genders
running python trigger cobbler.modules.scm_track
running shell triggers from /var/lib/cobbler/triggers/change/*
*** TASK COMPLETE ***

// 解决安装时报错
[root@localhost ~]# cp /usr/share/syslinux/pxelinux.0  /var/lib/cobbler/loaders/
cp: overwrite ‘/var/lib/cobbler/loaders/pxelinux.0’? y
[root@localhost ~]# cp /usr/share/syslinux/menu.c32 /var/lib/cobbler/loaders/
cp: overwrite ‘/var/lib/cobbler/loaders/menu.c32’? y

//为避免发生未知问题,先把服务端所有服务重启
[root@localhost ~]# systemctl restart xinetd
[root@localhost ~]# systemctl restart cobblerd
[root@localhost ~]# systemctl restart httpd
[root@localhost ~]# ss -antl
State       Recv-Q Send-Q Local Address:Port               Peer Address:Port              
LISTEN      0      5      127.0.0.1:25151                   *:*                  
LISTEN      0      5           *:873                     *:*                  
LISTEN      0      128         *:22                      *:*                  
LISTEN      0      100    127.0.0.1:25                      *:*                  
LISTEN      0      5          :::873                    :::*                  
LISTEN      0      128        :::80                     :::*                  
LISTEN      0      128        :::22                     :::*                  
LISTEN      0      100       ::1:25                     :::*                  
LISTEN      0      128        :::443                    :::*                  

10 客户端安装

在这里插入图片描述
在这里插入图片描述

11 定制安装

定制安装步骤

  • 统计服务器mac地址
  • 配置cobbler
  • 安装
    在这里插入图片描述
    在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

同步配置并重启相关服务
[root@localhost ~]# cobbler sync
[root@localhost ~]# systemctl restart httpd
[root@localhost ~]# systemctl restart cobblerd
[root@localhost ~]# systemctl restart xinetd
最后开机自动会安装系统

在这里插入图片描述
在这里插入图片描述

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值