使用cobbler安装CentOS-8系统

1. cobbler简介

Cobbler是一个Linux服务器安装的服务,可以通过网络启动(PXE)的方式来快速安装、重装物理服务器和虚拟机,同时还可以管理DHCP,DNS等。

Cobbler可以使用命令行方式管理,也提供了基于Web的界面管理工具(cobbler-web),还提供了API接口,可以方便二次开发使用。

Cobbler是较早前的kickstart的升级版,优点是比较容易配置,还自带web界面比较易于管理。

Cobbler内置了一个轻量级配置管理系统,但它也支持和其它配置管理系统集成,如Puppet,暂时不支持SaltStack。

Cobbler官网

cobbler集成的服务

  • PXE服务支持
  • DHCP服务管理
  • DNS服务管理(可选bind,dnsmasq)
  • 电源管理
  • Kickstart服务支持
  • YUM仓库管理
  • TFTP(PXE启动时需要)
  • Apache(提供kickstart的安装源,并提供定制化的kickstart配置)

cobbler配置文件详解
cobbler配置文件目录在/etc/cobbler
在这里插入图片描述
cobbler数据目录
在这里插入图片描述
cobbler日志文件
在这里插入图片描述
cobbler命令详解


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

2. cobbler服务端部署


//切记要使用centos8自带的源
[root@localhost ~]# ls /etc/yum.repos.d/
CentOS-Stream-AppStream.repo         CentOS-Stream-Media.repo
CentOS-Stream-BaseOS.repo            CentOS-Stream-NFV.repo
CentOS-Stream-Debuginfo.repo         CentOS-Stream-PowerTools.repo
CentOS-Stream-Extras-common.repo     CentOS-Stream-RealTime.repo
CentOS-Stream-Extras.repo            CentOS-Stream-ResilientStorage.repo
CentOS-Stream-HighAvailability.repo  CentOS-Stream-Sources.repo
//安装epel源
[root@localhost ~]# dnf install epel-release -y
Failed to set locale, defaulting to C.UTF-8
Last metadata expiration check: 0:00:39 ago on Sat Aug 13 04:27:52 2022.
Dependencies resolved.
=====================================================================================
 Package                Architecture     Version              Repository        Size
=====================================================================================
Installing:
 epel-release           noarch           8-11.el8             extras            24 k

Transaction Summary
=====================================================================================
Install  1 Package

Total size: 24 k
Installed size: 35 k
Downloading Packages:
[SKIPPED] epel-release-8-11.el8.noarch.rpm: Already downloaded                      
CentOS Stream 8 - Extras                             1.6 MB/s | 1.6 kB     00:00    
Importing GPG key 0x8483C65D:
 Userid     : "CentOS (CentOS Official Signing Key) <security@centos.org>"
 Fingerprint: 99DB 70FA E1D7 CE22 7FB6 4882 05B5 55B3 8483 C65D
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                             1/1 
  Installing       : epel-release-8-11.el8.noarch                                1/1 
  Running scriptlet: epel-release-8-11.el8.noarch                                1/1 
  Verifying        : epel-release-8-11.el8.noarch                                1/1 

Installed:
  epel-release-8-11.el8.noarch                                                       

Complete!
//开启cobbler
[root@localhost ~]# dnf -y module enable cobbler:3
Failed to set locale, defaulting to C.UTF-8
Extra Packages for Enterprise Linux 8 - x86_64       521 kB/s |  13 MB     00:24    
Extra Packages for Enterprise Linux Modular 8 - x86_  94 kB/s | 857 kB     00:09    
Last metadata expiration check: 0:00:08 ago on Sat Aug 13 04:31:03 2022.
Dependencies resolved.
=====================================================================================
 Package            Architecture      Version               Repository          Size
=====================================================================================
Enabling module streams:
 cobbler                              3                                             

Transaction Summary
=====================================================================================

Complete!
[root@localhost ~]# dnf -y install httpd dhcp* tftp tftp-server cobbler cobbler-web pykickstart     //安装这些包
//过程以省略...

//开启服务
[root@localhost ~]# systemctl enable --now httpd cobblerd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
Created symlink /etc/systemd/system/multi-user.target.wants/cobblerd.service → /usr/lib/systemd/system/cobblerd.service.
[root@localhost ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: di>
   Active: active (running) since Sat 2022-08-13 04:38:18 EDT; 14s ago
     Docs: man:httpd.service(8)
 Main PID: 54242 (httpd)
   Status: "Running, listening on: port 443, port 80"
    Tasks: 231 (limit: 23458)
   Memory: 55.6M
   CGroup: /system.slice/httpd.service
           ├─54242 /usr/sbin/httpd -DFOREGROUND
           ├─54244 /usr/sbin/httpd -DFOREGROUND
           ├─54245 (wsgi:cobbler_w -DFOREGROUND
           ├─54246 /usr/sbin/httpd -DFOREGROUND
           ├─54247 /usr/sbin/httpd -DFOREGROUND
           └─54248 /usr/sbin/httpd -DFOREGROUND

Aug 13 04:38:18 localhost.localdomain systemd[1]: Starting The Apache HTTP Server...
Aug 13 04:38:18 localhost.localdomain httpd[54242]: AH00558: httpd: Could not reliab>
Aug 13 04:38:18 localhost.localdomain systemd[1]: Started The Apache HTTP Server.
Aug 13 04:38:18 localhost.localdomain httpd[54242]: Server configured, listening on:>
[root@localhost ~]# systemctl status cobblerd
● cobblerd.service - Cobbler Helper Daemon
   Loaded: loaded (/usr/lib/systemd/system/cobblerd.service; enabled; vendor preset:>
   Active: active (running) since Sat 2022-08-13 04:38:17 EDT; 26s ago
  Process: 54178 ExecStartPost=/usr/bin/touch /usr/share/cobbler/web/cobbler.wsgi (c>
 Main PID: 54177 (cobblerd)
    Tasks: 1 (limit: 23458)
   Memory: 32.0M
   CGroup: /system.slice/cobblerd.service
           └─54177 /usr/bin/python3.6 -s /usr/bin/cobblerd -F

Aug 13 04:38:17 localhost.localdomain systemd[1]: Starting Cobbler Helper Daemon...
Aug 13 04:38:17 localhost.localdomain systemd[1]: Started Cobbler Helper Daemon.
//关闭防火墙和selinux
[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 ~]# setenforce 0
[root@localhost ~]# vi /etc/selinux/config 
[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     //这里修改成disabled
# SELINUXTYPE= can take one of these three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted
  1. 配置settings.yaml文件

//生成一个加密密码
[root@localhost ~]# openssl passwd -1
Password:      //我输入的是1234567
Verifying - Password: 
$1$R2hpxJ6Q$0cu7zB/wNvgkt2.SUjuqH/
[root@localhost ~]# cd /etc/cobbler/
[root@localhost cobbler]# vim settings.yaml 

default_password_crypted: "$1$R2hpxJ6Q$0cu7zB/wNvgkt2.SUjuqH/"       //引号里面修改成刚才加密的密码
server: 192.168.106.20    //改为当前主机的IP
next_server: 192.168.106.20     //改为当前主机的IP
manage_dhcp: true    // 改为true 开启自动分配IP

配置dhcp.template文件


[root@localhost cobbler]# vim dhcp.template

subnet 192.168.106.0 netmask 255.255.255.0 {
     option routers             192.168.106.2;       //改为当前主机的网关
     option domain-name-servers 114.114.114.114;  //域名服务器改为114.114.114.114
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        192.168.106.100 192.168.106.200;    //分配范围
     default-lease-time         21600;
     max-lease-time             43200;
     next-server                192.168.106.20;   //改为当前主机的IP
//重启服务
[root@localhost cobbler]# systemctl restart httpd cobblerd

//安装rsync-daemon服务并开启开机自启
[root@localhost cobbler]# dnf -y install rsync-daemon
[root@localhost cobbler]# systemctl enable --now rsyncd
Created symlink /etc/systemd/system/multi-user.target.wants/rsyncd.service → /usr/lib/systemd/system/rsyncd.service.

检查cobbler是否还存在问题


[root@localhost cobbler]# 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. 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, and yaboot.
2: reposync is not installed, install yum-utils or dnf-plugins-core
3: yumdownloader is not installed, install yum-utils or dnf-plugins-core
4: debmirror package is not installed, it will be required to manage debian deployments and repositories
5: 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@localhost cobbler]# dnf -y install yum-utils   
[root@localhost cobbler]# 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. 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, and yaboot.
2: debmirror package is not installed, it will be required to manage debian deployments and repositories
3: 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@localhost cobbler]# dnf -y install syslinux //安装最新版syslinux
[root@localhost cobbler]# cp /usr/share/syslinux/pxelinux.0 /usr/share/syslinux/menu.c32 /var/lib/cobbler/loaders/     //将这两个文件放到/var/lib/cobbler/loaders/下
[root@localhost cobbler]# ls /var/lib/cobbler/loaders/
menu.c32  pxelinux.0
//问题就基本解决了

//同步
[root@localhost cobbler]# cobbler sync
task started: 2022-08-13_051432_sync
task started (id=Sync, time=Sat Aug 13 05:14:32 2022)
running python triggers from /var/lib/cobbler/triggers/task/sync/pre/*
running shell triggers from /var/lib/cobbler/triggers/task/sync/pre/*
shell triggers finished successfully
running pre-sync triggers
cleaning trees
removing: /var/lib/tftpboot/grub/system
removing: /var/lib/tftpboot/grub/system_link
removing: /var/lib/tftpboot/grub/images
copying bootloaders
running: ['rsync', '-rpt', '--copy-links', '--exclude=.cobbler_postun_cleanup', '/var/lib/cobbler/loaders/', '/var/lib/tftpboot']
received on stdout: 
received on stderr: 
running: ['rsync', '-rpt', '--copy-links', '--exclude=README.grubconfig', '/var/lib/cobbler/grub_config/', '/var/lib/tftpboot']
received on stdout: 
received on stderr: 
copying distros to tftpboot
copying images
generating PXE configuration files
generating PXE menu structure
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
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/*
shell triggers finished successfully
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.scm_track
running python trigger cobbler.modules.managers.genders
running shell triggers from /var/lib/cobbler/triggers/change/*
shell triggers finished successfully
*** TASK COMPLETE ***     //看到TASK COMPLETE才算成功
//挂载镜像。一定要是DVD格式的镜像
[root@localhost cobbler]# mount /dev/cdrom /mnt
mount: /mnt: WARNING: device write-protected, mounted read-only.
//同步镜像
[root@localhost cobbler]# cobbler import --name=CentOS8 --arch=x86_64 --path=/mnt
task started: 2022-08-13_051934_import
task started (id=Media import, time=Sat Aug 13 05:19:34 2022)
running python triggers from /var/lib/cobbler/triggers/task/import/pre/*
running shell triggers from /var/lib/cobbler/triggers/task/import/pre/*
shell triggers finished successfully
Found a candidate signature: breed=redhat, version=rhel8
Found a matching signature: breed=redhat, version=rhel8
Adding distros from path /var/www/cobbler/distro_mirror/CentOS8-x86_64:
creating new distro: CentOS8-x86_64
trying symlink: /var/www/cobbler/distro_mirror/CentOS8-x86_64 -> /var/www/cobbler/links/CentOS8-x86_64
creating new profile: CentOS8-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/distro_mirror/CentOS8-x86_64 for CentOS8-x86_64
processing repo at : /var/www/cobbler/distro_mirror/CentOS8-x86_64/AppStream
need to process repo/comps: /var/www/cobbler/distro_mirror/CentOS8-x86_64/AppStream
looking for /var/www/cobbler/distro_mirror/CentOS8-x86_64/AppStream/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/distro_mirror/CentOS8-x86_64/AppStream/repodata
processing repo at : /var/www/cobbler/distro_mirror/CentOS8-x86_64/BaseOS
need to process repo/comps: /var/www/cobbler/distro_mirror/CentOS8-x86_64/BaseOS
looking for /var/www/cobbler/distro_mirror/CentOS8-x86_64/BaseOS/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/distro_mirror/CentOS8-x86_64/BaseOS/repodata
*** TASK COMPLETE ***      //同样要看到TASK COMPLETE才算成功
//列出对象
[root@localhost cobbler]# cobbler list
distros:
   CentOS8-x86_64

profiles:
   CentOS8-x86_64

systems:

repos:

images:

mgmtclasses:

packages:

files:
//创建kickstarts自动安装脚本
[root@localhost cobbler]# cobbler profile get-autoinstall --name CentOS8-x86_64   //将会自动生成一个kickstarts脚本
# Sample kickstart file for current EL, Fedora based distributions.

#platform=x86, AMD64, or Intel EM64T
# System authorization information
auth  --useshadow  --enablemd5
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all --initlabel
# Use text mode install
text
# Firewall configuration
firewall --enabled
# Run the Setup Agent on first boot
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# Use network installation
url --url=http://192.168.106.20/cblr/links/CentOS8-x86_64
# If any cobbler repo definitions were referenced in the kickstart profile, include them here.
repo --name=source-1 --baseurl=http://192.168.106.20/cobbler/distro_mirror/CentOS8-x86_64/AppStream
repo --name=source-2 --baseurl=http://192.168.106.20/cobbler/distro_mirror/CentOS8-x86_64/BaseOS

# Network information
network --bootproto=dhcp --device=eth0 --onboot=on  

# Reboot after installation
reboot

#Root password
rootpw --iscrypted $1$R2hpxJ6Q$0cu7zB/wNvgkt2.SUjuqH/
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# System timezone
timezone  America/New_York
# Install OS instead of upgrade
install
# Clear the Master Boot Record
zerombr
# Allow anaconda to partition the system as needed
autopart

%pre
set -x -v
exec 1>/tmp/ks-pre.log 2>&1

# Once root's homedir is there, copy over the log.
while : ; do
    sleep 10
    if [ -d /mnt/sysimage/root ]; then
        cp /tmp/ks-pre.log /mnt/sysimage/root/
        logger "Copied %pre section log to system"
        break
    fi
done &



# Enable installation monitoring

%end

%packages
%end

%post --nochroot
set -x -v
exec 1>/mnt/sysimage/root/ks-post-nochroot.log 2>&1

%end

%post
set -x -v
exec 1>/root/ks-post.log 2>&1

# Start yum configuration
curl "http://192.168.106.20/cblr/svc/op/yum/profile/CentOS8-x86_64" --output /etc/yum.repos.d/cobbler-config.repo

# End yum configuration



# Start post_install_network_config generated code
# End post_install_network_config generated code

# Start download cobbler managed config files (if applicable)
# End download cobbler managed config files (if applicable)

# Start koan environment setup
echo "export COBBLER_SERVER=192.168.106.20" > /etc/profile.d/cobbler.sh
echo "setenv COBBLER_SERVER 192.168.106.20" > /etc/profile.d/cobbler.csh
# End koan environment setup

$SNIPPET('redhat_register')
# Begin cobbler registration
# cobbler registration is disabled in /etc/cobbler/settings.yaml
# End cobbler registration

# Enable post-install boot notification

# Start final steps

curl "http://192.168.106.20/cblr/svc/op/autoinstall/profile/CentOS8-x86_64" -o /root/cobbler.ks
# End final steps
%end
//将上面的内容复制
[root@localhost cobbler]# cd /var/lib/cobbler/templates/
[root@localhost templates]# vim centos8.ks    //粘贴到这个文件中并修改成以下内容
# Sample kickstart file for current EL, Fedora based distributions.
  
#platform=x86, AMD64, or Intel EM64T
# System authorization information
auth  --useshadow  --enablemd5
bootloader --location=mbr
clearpart --all --initlabel
text
firewall --disabled
firstboot --disable
keyboard us
lang en_US
url --url=http://192.168.106.20/cblr/links/CentOS8-x86_64

# Network information
network --bootproto=dhcp --device=eth0 --onboot=on

# Reboot after installation
reboot

#Root password
rootpw --iscrypted $1$R2hpxJ6Q$0cu7zB/wNvgkt2.SUjuqH/
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# System timezone
timezone  America/New_York
# Install OS instead of upgrade
install
# Clear the Master Boot Record
zerombr
# Allow anaconda to partition the system as needed
autopart

%pre
set -x -v
exec 1>/tmp/ks-pre.log 2>&1

# Once root's homedir is there, copy over the log.
while : ; do
    sleep 10
    if [ -d /mnt/sysimage/root ]; then
        break
    fi
done &

# Enable installation monitoring

%end

%packages
%end

%post --nochroot
set -x -v
keyboard us
lang en_US
url --url=http://192.168.106.20/cblr/links/CentOS8-x86_64

# Network information
network --bootproto=dhcp --device=eth0 --onboot=on

# Reboot after installation
reboot

#Root password
rootpw --iscrypted $1$R2hpxJ6Q$0cu7zB/wNvgkt2.SUjuqH/
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# System timezone
timezone  Asia/Shanghai --isUtc --nontp
# Install OS instead of upgrade
install
# Clear the Master Boot Record
zerombr
# Allow anaconda to partition the system as needed
autopart

%pre
set -x -v
exec 1>/tmp/ks-pre.log 2>&1

# Start final steps

curl "http://192.168.106.20/cblr/svc/op/autoinstall/profile/CentOS8-x86_64" -o /root/cobbler.ks
# End final steps
%end
//检查ks文件语法是否有误
[root@localhost templates]# cobbler validate-autoinstalls
task started: 2022-08-13_054457_validate_autoinstall_files
task started (id=Automated installation files validation, time=Sat Aug 13 05:44:57 2022)
running python triggers from /var/lib/cobbler/triggers/task/validate_autoinstall_files/pre/*
running shell triggers from /var/lib/cobbler/triggers/task/validate_autoinstall_files/pre/*
shell triggers finished successfully
*** TASK COMPLETE ***      //出现TASK COMPLETE表示没问题
[root@localhost templates]# cobbler profile edit --name CentOS8-x86_64 --autoinstall centos8.ks    //将默认的安装文件改成我们创建的centos.ks
[root@localhost templates]# cobbler profile edit --name Centos8-x86_64 --kernel-options 'net.ifnames=0 biosdevname=0'     //配置内核选项
[root@localhost templates]# cobbler profile report --name CentOS8-x86_64
Name                           : Centos8-x86_64
Automatic Installation Template : centos8.ks
Automatic Installation Metadata : {}
TFTP Boot Files                : {}
Comment                        : 
DHCP Tag                       : default
Distribution                   : CentOS8-x86_64
Enable gPXE?                   : False
Enable PXE Menu?               : True
Fetchable Files                : {}
DHCP Filename Override         : <<inherit>>
Kernel Options                 : {'net.ifnames': '0', 'biosdevname': '0'}          //显示已经添加
Kernel Options (Post Install)  : {}
Management Classes             : []
Management Parameters          : <<inherit>>
Name Servers                   : []
Name Servers Search Path       : []
Next Server Override           : <<inherit>>
Owners                         : ['admin']
Parent Profile                 : 
Proxy                          : 
Red Hat Management Key         : <<inherit>>
Repos                          : []
Server Override                : <<inherit>>
Template Files                 : {}
Virt Auto Boot                 : True
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
//同步数据
[root@localhost templates]# cobbler sync
task started: 2022-08-13_055747_sync
task started (id=Sync, time=Sat Aug 13 05:57:47 2022)
running python triggers from /var/lib/cobbler/triggers/task/sync/pre/*
running shell triggers from /var/lib/cobbler/triggers/task/sync/pre/*
shell triggers finished successfully
running pre-sync triggers
cleaning trees
removing: /var/www/cobbler/images/CentOS8-x86_64
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/system
removing: /var/lib/tftpboot/grub/system_link
removing: /var/lib/tftpboot/grub/grub.cfg
removing: /var/lib/tftpboot/grub/local_efi.cfg
removing: /var/lib/tftpboot/grub/local_legacy.cfg
removing: /var/lib/tftpboot/grub/local_powerpc-ieee1275.cfg
removing: /var/lib/tftpboot/grub/x86_64_menu_items.cfg
removing: /var/lib/tftpboot/images/CentOS8-x86_64
copying bootloaders
running: ['rsync', '-rpt', '--copy-links', '--exclude=.cobbler_postun_cleanup', '/var/lib/cobbler/loaders/', '/var/lib/tftpboot']
received on stdout: 
received on stderr: 
running: ['rsync', '-rpt', '--copy-links', '--exclude=README.grubconfig', '/var/lib/cobbler/grub_config/', '/var/lib/tftpboot']
received on stdout: 
received on stderr: 
copying distros to tftpboot
copying files for distro: CentOS8-x86_64
trying hardlink /var/www/cobbler/distro_mirror/CentOS8-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/CentOS8-x86_64/vmlinuz
trying hardlink /var/www/cobbler/distro_mirror/CentOS8-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/CentOS8-x86_64/initrd.img
copying images
generating PXE configuration files
generating PXE menu structure
copying files for distro: CentOS8-x86_64
trying hardlink /var/www/cobbler/distro_mirror/CentOS8-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/CentOS8-x86_64/vmlinuz
trying hardlink /var/www/cobbler/distro_mirror/CentOS8-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/CentOS8-x86_64/initrd.img
Writing template files for CentOS8-x86_64
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
processing boot_files for distro: CentOS8-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/*
shell triggers finished successfully
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.scm_track
running python trigger cobbler.modules.managers.genders
running shell triggers from /var/lib/cobbler/triggers/change/*
shell triggers finished successfully
*** TASK COMPLETE ***
//重启所有服务
[root@localhost templates]# systemctl restart httpd cobblerd rsyncd dhcpd tftp
[root@localhost templates]# /usr/share/cobbler/bin/mkgrub.sh   //执行这个脚本
[root@localhost ~]# ls /var/lib/cobbler/loaders/
grub  ldlinux.c32  menu.c32  pxelinux.0     //出现两个文件
//再次同步
[root@localhost ~]# cobbler sync
task started: 2022-08-13_060854_sync
task started (id=Sync, time=Sat Aug 13 06:08:54 2022)
running python triggers from /var/lib/cobbler/triggers/task/sync/pre/*
running shell triggers from /var/lib/cobbler/triggers/task/sync/pre/*
shell triggers finished successfully
running pre-sync triggers
cleaning trees
removing: /var/www/cobbler/images/CentOS8-x86_64
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/system
removing: /var/lib/tftpboot/grub/system_link
removing: /var/lib/tftpboot/grub/grub.cfg
removing: /var/lib/tftpboot/grub/local_efi.cfg
removing: /var/lib/tftpboot/grub/local_legacy.cfg
removing: /var/lib/tftpboot/grub/local_powerpc-ieee1275.cfg
removing: /var/lib/tftpboot/grub/x86_64_menu_items.cfg
removing: /var/lib/tftpboot/images/CentOS8-x86_64
copying bootloaders
running: ['rsync', '-rpt', '--copy-links', '--exclude=.cobbler_postun_cleanup', '/var/lib/cobbler/loaders/', '/var/lib/tftpboot']
received on stdout: 
received on stderr: 
running: ['rsync', '-rpt', '--copy-links', '--exclude=README.grubconfig', '/var/lib/cobbler/grub_config/', '/var/lib/tftpboot']
received on stdout: 
received on stderr: 
copying distros to tftpboot
copying files for distro: CentOS8-x86_64
trying hardlink /var/www/cobbler/distro_mirror/CentOS8-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/CentOS8-x86_64/vmlinuz
trying hardlink /var/www/cobbler/distro_mirror/CentOS8-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/CentOS8-x86_64/initrd.img
copying images
generating PXE configuration files
generating PXE menu structure
copying files for distro: CentOS8-x86_64
trying hardlink /var/www/cobbler/distro_mirror/CentOS8-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/CentOS8-x86_64/vmlinuz
trying hardlink /var/www/cobbler/distro_mirror/CentOS8-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/CentOS8-x86_64/initrd.img
Writing template files for CentOS8-x86_64
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
processing boot_files for distro: CentOS8-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/*
shell triggers finished successfully
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.scm_track
running python trigger cobbler.modules.managers.genders
running shell triggers from /var/lib/cobbler/triggers/change/*
shell triggers finished successfully
*** TASK COMPLETE ***

配置就已经完成了,接下来就是创建一台新的虚拟机通过cobbler装机

在这里插入图片描述

开启此虚拟机
在这里插入图片描述
选择下面的CentOS8-x86_64 回车就会进行自动安装
在这里插入图片描述
登录root用户查看以下IP地址可以看到也是我们设置的范围
在这里插入图片描述

3. 定制安装

定制安装步骤:

  • 统计服务器mac地址
  • 配置cobbler
  • 安装
    在 cobbler 的web界面上配置:
    https://192.168.106.20/cobbler_web 通过这个网址能进到cobbler的web界面这里的IP地址填当前虚拟机的IP
    在这里插入图片描述
    账号和密码都是cobbler
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    如何获取mac地址
    在这里插入图片描述
    在这里插入图片描述
    回到网页
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    同步完成后就可以打开刚才绑定mac的主机了,该主机要是没有安装任何系统的状态,然后就会自动装机了
    在这里插入图片描述
    能看到主机名称为node1 ip地址也是刚才设置的IP地址。到此为止cobbler装机就已经全部完成
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值