centos8安装cobbler

centos8安装cobbler

文章目录

    • centos8安装cobbler
      • 一. cobbler
        • 1. cobbler 批量装机
          • 1.1 简介
          • 1.2 Cobbler[官网](https://cobbler.github.io/)
          • 1.3 cobbler集成的服务
      • 二. 部署cobbler
        • 1. cobbler服务端部署
          • 1.1 安装epel源,cobbler,使用官方源
          • 1.2 安装cobbler以及相关的软件
          • 1.3 启动服务并设置开机自启,关闭selinux和防火墙并重启
          • 1.5 生成密码,将新生成的加密密码加入到配置文件
          • 1.4 配置cobbler 主配置文件
          • 1.5 修改模板配置文件
          • 1.6 通过cobbler check 核对当前设置是否有问题
          • 1.7 sync同步配置
        • 2. 导入镜像,必须选DVD镜像
          • 2.1 查看cobbler镜像列表
          • 2.2 列出对象详细信息
          • 2.3 检查dhcp是否正常
        • 3. 创建kickstarts自动安装脚本
          • 3.1 验证
          • 3.2 修改自动安装的文件和内核,改为自己写的
          • 3.3 重启服务
        • 4. 客户端安装虚拟机
          • 4.1 打开虚拟机,创建虚拟机时内存给4G
            • 4.1.1 错误1.
            • 4.1.2 错误2
          • 4.2 安装
        • 5. 批量安装
          • 5.1 定制安装步骤:
          • 5.2 登录[界面](https://192.168.232.132/cobbler_web)
          • 5.3 开机
      • 三. 配置文件
        • 1. cobbler配置文件详解`cobbler`配置文件目录在`/etc/cobbler`
        • 2. cobbler数据目录
        • 3. cobbler日志文件
        • 4. cobbler命令详解

一. cobbler

1. cobbler 批量装机

1.1 简介
  • Cobbler是一个Linux服务器安装的服务,可以通过网络启动(PXE)的方式来快速安装、重装物理服务器和虚拟机(真机,虚拟机,云主机),还可以管理DHCPDNS.

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

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

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

1.2 Cobbler官网
1.3 cobbler集成的服务
  • PXE服务支持,pxe从网络,局域网启动,从网络启动需要ip,网关
  • DHCP服务管理,自动分配IP
  • DNS服务管理(可选bind,dnsmasq)
  • 电源管理,自动开机,远程开机,重启
  • Kickstart服务支持,在安装系统,要设置系统,把需要设置的信息写入文件,通过文件批量应用
  • YUM仓库管理,通过Apache部署网络源
  • TFTP(PXE启动时需要)
  • Apache(提供kickstart的安装源,并提供定制化的kickstart配置)

二. 部署cobbler

1. cobbler服务端部署

1.1 安装epel源,cobbler,使用官方源
[root@node4 ~]# dnf install epel-release -y
[root@node4 ~]# dnf module list|grep cobbler
Failed to set locale, defaulting to C.UTF-8
cobbler              3               default [d]                              Versatile Linux deployment server                                                                                                                                                                                                
cobbler              3.3             default                                  Versatile Linux deployment server                                                                                                                                                                                                
[root@node4 ~]# dnf module enable cobbler:3 -y
Failed to set locale, defaulting to C.UTF-8
Last metadata expiration check: 0:00:24 ago on Fri Aug 12 16:19:33 2022.
Dependencies resolved.
================================================================
 Package       Architecture Version         Repository     Size
================================================================
Enabling module streams:
 cobbler                    3                                  

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

Complete!
[root@node4 ~]# 
1.2 安装cobbler以及相关的软件
[root@node4 ~]# dnf -y install httpd dhcp* tftp tftp-server cobbler cobbler-web pykickstart rsync-daemon
1.3 启动服务并设置开机自启,关闭selinux和防火墙并重启
[root@node4 ~]# systemctl enable --now httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service 鈫� /usr/lib/systemd/system/httpd.service.
[root@node4 ~]# systemctl enable --now cobblerd
Created symlink /etc/systemd/system/multi-user.target.wants/cobblerd.service 鈫� /usr/lib/systemd/system/cobblerd.service.
[root@node4 ~]# systemctl  enable --now rsyncd
Created symlink /etc/systemd/system/multi-user.target.wants/rsyncd.service 鈫� /usr/lib/systemd/system/rsyncd.service.


[root@node4 ~]# ss -antl
State  Recv-Q  Send-Q   Local Address:Port    Peer Address:Port Process                                                         
LISTEN 0       5            127.0.0.1:25151        0.0.0.0:*                                                                    
LISTEN 0       5              0.0.0.0:873          0.0.0.0:*                                                                    
LISTEN 0       128            0.0.0.0:22           0.0.0.0:*                                                                    
LISTEN 0       128                  *:443                *:*                                                                    
LISTEN 0       5                 [::]:873             [::]:*                                                                    
LISTEN 0       128                  *:80                 *:*                                                                    
LISTEN 0       128               [::]:22              [::]:*                                                                    
[root@node4 ~]# 



[root@node4 ~]# systemctl disable --now firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@node4 ~]# vim /etc/selinux/config 
[root@node4 ~]# reboot
1.5 生成密码,将新生成的加密密码加入到配置文件
[root@node4 ~]# openssl passwd -1
Password: 
Verifying - Password: 
$1$Fd0AJAGH$nkETxhZnhKmtHRBEOFSjE1
[root@node4 ~]# 
[root@node4 ~]# cd /etc/cobbler/
[root@node4 cobbler]# vim settings.yaml
default_password_crypted: "$1$Fd0AJAGH$nkETxhZnhKmtHRBEOFSjE1"
1.4 配置cobbler 主配置文件
修改server的ip地址为本机ip
[root@node4 ~]# cd /etc/cobbler/
[root@node4 cobbler]# vim settings.yaml
server: 192.168.232.132

设置tftp的ip地址为本机ip
[root@node4 ~]# cd /etc/cobbler/
[root@node4 cobbler]# vim settings.yaml
next_server: 192.168.232.132

打开DHCP功能
[root@node4 ~]# cd /etc/cobbler/
[root@node4 cobbler]# vim settings.yaml
manage_dhcp: true
1.5 修改模板配置文件
[root@node4 ~]# cd /etc/cobbler/
[root@node4 cobbler]# vim dhcp.template
subnet 192.168.232.0 netmask 255.255.255.0 {
     option routers             192.168.232.2;
     option domain-name-servers 114.114.114.114;
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        192.168.232.100 192.168.232.254;
     default-lease-time         21600;
     max-lease-time             43200;
     next-server                192.168.232.132;


重启服务
[root@node4 cobbler]# systemctl restart httpd cobblerd
1.6 通过cobbler check 核对当前设置是否有问题
[root@node4 ~]# 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@node4 ~]# 

  
解决问题:
第1个问题
[root@node4 ~]# dnf -y install syslinux syslinux-extlinux syslinux-tftpboot
Failed to set locale, defaulting to C.UTF-8
Last metadata expiration check: 0:44:35 ago on Fri Aug 12 16:25:56 2022.
Package syslinux-6.04-5.el8.x86_64 is already installed.
Package syslinux-extlinux-6.04-5.el8.x86_64 is already installed.
Package syslinux-tftpboot-6.04-5.el8.noarch is already installed.
Dependencies resolved.
Nothing to do.
Complete!
[root@node4 ~]#   
[root@node4 ~]# ls /usr/share/syslinux/
[root@node4 ~]# cd /var/lib/cobbler/loaders/
[root@node4 loaders]# ls
[root@node4 loaders]# cp /usr/share/syslinux/pxelinux.0 .
[root@node4 loaders]# cp /usr/share/syslinux/menu.c32 .
[root@node4 loaders]# ls
menu.c32  pxelinux.0
[root@node4 loaders]#       
  
23  安装包
[root@node4 ~]# dnf -y install yum-utils  
1.7 sync同步配置
[root@node4 ~]# cobbler sync
task started: 2022-08-12_171557_sync
task started (id=Sync, time=Fri Aug 12 17:15:57 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 ***
[root@node4 ~]# 

2. 导入镜像,必须选DVD镜像

挂载光盘
[root@node4 ~]# mount /dev/cdrom /mnt
mount: /mnt: WARNING: device write-protected, mounted read-only.
[root@node4 ~]# df -h
Filesystem           Size  Used Avail Use% Mounted on
devtmpfs             1.8G     0  1.8G   0% /dev
tmpfs                1.9G     0  1.9G   0% /dev/shm
tmpfs                1.9G  9.0M  1.9G   1% /run
tmpfs                1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/mapper/cs-root   17G  2.1G   15G  13% /
/dev/sda1           1014M  215M  800M  22% /boot
tmpfs                371M     0  371M   0% /run/user/0
/dev/sr0              11G   11G     0 100% /mnt
[root@node4 ~]# ls /mnt/
AppStream  EFI      TRANS.TBL  isolinux
BaseOS     LICENSE  images     media.repo
[root@node4 ~]# 

[root@node4 ~]# cobbler import --name=CentOS8 --arch=x86_64 --path=/mnt
task started: 2022-08-12_174134_import
task started (id=Media import, time=Fri Aug 12 17:41: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 ***
[root@node4 ~]# 

//说明:
    --path      //镜像路径
    --name      //为安装源定义一个名字
    --arch      //指定安装源平台

2.1 查看cobbler镜像列表
[root@node4 ~]# cobbler list
distros:
   CentOS8-x86_64

profiles:
   CentOS8-x86_64

systems:

repos:

images:

mgmtclasses:

packages:

files:
[root@node4 ~]# 
2.2 列出对象详细信息
列出对象
[root@node4 ~]# cobbler distro list
   CentOS8-x86_64
[root@node4 ~]# cobbler distro report
Name                           : CentOS8-x86_64
Architecture                   : x86_64
Automatic Installation Template Metadata : {'tree': 'http://@@http_server@@/cblr/links/CentOS8-x86_64'}//192.168.232.132/cobbler,镜像放的位置
TFTP Boot Files                : {}
Boot loader                    : grub
Breed                          : redhat
Comment                        : 
Fetchable Files                : {}
Initrd                         : /var/www/cobbler/distro_mirror/CentOS8-x86_64/images/pxeboot/initrd.img
Kernel                         : /var/www/cobbler/distro_mirror/CentOS8-x86_64/images/pxeboot/vmlinuz
Kernel Options                 : {}
Kernel Options (Post Install)  : {}
Management Classes             : []
OS Version                     : rhel8
Owners                         : ['admin']
Redhat Management Key          : 
Remote Boot Initrd             : ~
Remote Boot Kernel             : ~
Template Files                 : {}

[root@node4 ~]# 
2.3 检查dhcp是否正常
[root@node4 ~]# ss -an|grep 67
nl    UNCONN 0      0                                                         15:-67915378                  *            
nl    UNCONN 0      0                                                         15:-67915378                  *            
u_str ESTAB  0      0                                                          * 27820                     * 28867       
u_str ESTAB  0      0                                /run/systemd/journal/stdout 24967                     * 26042       
u_str ESTAB  0      0                                                          * 26042                     * 24967       
u_str ESTAB  0      0      /var/lib/sss/pipes/private/sbus-dp_implicit_files.925 28867                     * 27820       
u_str ESTAB  0      0                                                          * 46777                     * 0           
udp   ESTAB  0      0                                      192.168.232.132%ens33:68          192.168.232.254:67          
[root@node4 ~]# 

3. 创建kickstarts自动安装脚本

自动生成的ks文件使用这个
cobbler profile get-autoinstall --name CentOS8-x86_64

  
[root@node4 ~]# cd /var/lib/cobbler/templates/
[root@node4 templates]# vim centos8.ks
[root@node4 templates]# cat centos8.ks 
auth  --useshadow  --enablemd5
bootloader --location=mbr
clearpart --all --initlabel
text
# Firewall configuration
firewall --disabled
# 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.232.132/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.232.132/cobbler/distro_mirror/CentOS8-x86_64/AppStream
repo --name=source-2 --baseurl=http://192.168.232.132/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$19011$EN0oI8ADpyxa78MJ66DZ10
# 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

# 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
@^minimal-environment
%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.232.132/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.232.132" > /etc/profile.d/cobbler.sh
echo "setenv COBBLER_SERVER 192.168.232.132" > /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.232.132/cblr/svc/op/autoinstall/profile/CentOS8-x86_64" -o /root/cobbler.ks
# End final steps
%end
[root@node4 templates]#   
3.1 验证
[root@node4 ~]# cobbler validate-autoinstalls
task started: 2022-08-12_182626_validate_autoinstall_files
task started (id=Automated installation files validation, time=Fri Aug 12 18:26:26 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 ***
[root@node4 ~]# 
3.2 修改自动安装的文件和内核,改为自己写的
修改profile,将我们新建的ks文件设为默认的kickstarts安装文件
[root@node4 ~]# cobbler profile edit --name CentOS8-x86_64 --autoinstall centos8.ks


配置网卡名称为传统网卡名称eth0
[root@node4 ~]# cobbler profile edit --name CentOS8-x86_64 --kernel-options 'net.ifnames=0 biosdevname=0'
[root@node4 ~]# 

[root@node4 ~]# cobbler profile report --name CentOS8-x86_64
Name                           : CentOS8-x86_64
Automatic Installation Template : sample.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                 : {}
[root@node4 ~]# 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@node4 ~]# 

同步
[root@node4 ~]# cobbler sync
task started: 2022-08-12_183820_sync
task started (id=Sync, time=Fri Aug 12 18:38:20 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@node4 ~]#   
3.3 重启服务
[root@node4 ~]# systemctl restart httpd cobblerd rsyncd dhcpd

4. 客户端安装虚拟机

4.1 打开虚拟机,创建虚拟机时内存给4G
4.1.1 错误1.

centos8安装cobbler_第1张图片

  • tftp超时,解决TFTP未启动
[root@node4 ~]# systemctl enable --now tftp
Created symlink /etc/systemd/system/sockets.target.wants/tftp.socket 鈫� /usr/lib/systemd/system/tftp.socket.
[root@node4 ~]# 
4.1.2 错误2

centos8安装cobbler_第2张图片

  • 不能启动,没有启动程序
[root@node4 ~]# cd /var/lib/cobbler/loaders/
[root@node4 loaders]# ls
menu.c32  pxelinux.0
[root@node4 loaders]# 

[root@node4 ~]# ls /usr/share/cobbler/bin/mkgrub.sh 
/usr/share/cobbler/bin/mkgrub.sh
[root@node4 ~]# /usr/share/cobbler/bin/mkgrub.sh
+ grub2-mkimage -O arm64-efi -o /var/lib/cobbler/loaders/grub/grubaa64.efi --prefix= all_video boot cat configfile echo true font gfxmenu gfxterm gzio halt iso9660 jpeg minicmd normal part_apple part_msdos part_gpt password_pbkdf2 png reboot search search_fs_uuid search_fs_file search_label sleep test video fat loadenv linux btrfs ext2 xfs jfs reiserfs tftp http luks gcry_rijndael gcry_sha1 gcry_sha256 mdraid09 mdraid1x lvm serial regexp tr efinet
grub2-mkimage: error: cannot open `/usr/lib/grub/arm64-efi/moddep.lst': No such file or directory.
+ set +x
+ grub2-mkimage -O i386-pc-pxe -o /var/lib/cobbler/loaders/grub/grub.0 --prefix= all_video boot cat configfile echo true font gfxmenu gfxterm gzio halt iso9660 jpeg minicmd normal part_apple part_msdos part_gpt password_pbkdf2 png reboot search search_fs_uuid search_fs_file search_label sleep test video fat loadenv linux btrfs ext2 xfs jfs reiserfs tftp http luks gcry_rijndael gcry_sha1 gcry_sha256 mdraid09 mdraid1x lvm serial regexp tr chain pxe biosdisk
+ set +x
+ grub2-mkimage -O powerpc-ieee1275 -o /var/lib/cobbler/loaders/grub/grub.ppc64le --prefix= all_video boot cat configfile echo true font gfxmenu gfxterm gzio halt iso9660 jpeg minicmd normal part_apple part_msdos part_gpt password_pbkdf2 png reboot search search_fs_uuid search_fs_file search_label sleep test video fat loadenv linux btrfs ext2 xfs jfs reiserfs tftp http luks gcry_rijndael gcry_sha1 gcry_sha256 mdraid09 mdraid1x lvm serial regexp tr net ofnet
grub2-mkimage: error: cannot open `/usr/lib/grub/powerpc-ieee1275/moddep.lst': No such file or directory.
+ set +x
+ grub2-mkimage -O x86_64-efi -o /var/lib/cobbler/loaders/grub/grubx64.efi --prefix= all_video boot cat configfile echo true font gfxmenu gfxterm gzio halt iso9660 jpeg minicmd normal part_apple part_msdos part_gpt password_pbkdf2 png reboot search search_fs_uuid search_fs_file search_label sleep test video fat loadenv linux btrfs ext2 xfs jfs reiserfs tftp http luks gcry_rijndael gcry_sha1 gcry_sha256 mdraid09 mdraid1x lvm serial regexp tr chain efinet
grub2-mkimage: error: cannot open `/usr/lib/grub/x86_64-efi/moddep.lst': No such file or directory.
+ set +x
+ ln -s /usr/share/syslinux/ldlinux.c32 /var/lib/cobbler/loaders/ldlinux.c32
+ set +x
[root@node4 ~]# 

          
[root@node4 ~]# cd /var/lib/cobbler/loaders/
[root@node4 loaders]# ls
menu.c32  pxelinux.0
[root@node4 loaders]# ls
grub  ldlinux.c32  menu.c32  pxelinux.0
[root@node4 loaders]# 
          
然后同步一下          
[root@node4 ~]# cobbler sync
task started: 2022-08-12_185410_sync
task started (id=Sync, time=Fri Aug 12 18:54:10 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@node4 ~]#           
4.2 安装

centos8安装cobbler_第3张图片

centos8安装cobbler_第4张图片

5. 批量安装

5.1 定制安装步骤:
  • 统计服务器mac地址
  • 配置cobbler
  • 安装
5.2 登录界面
  • 账号密码为cobbler

centos8安装cobbler_第5张图片

  • 创建新系统

centos8安装cobbler_第6张图片

  • 默认配置inherit

  • 通用

centos8安装cobbler_第7张图片

  • 高级

centos8安装cobbler_第8张图片

  • 生成mac地址

centos8安装cobbler_第9张图片

  • 网络

centos8安装cobbler_第10张图片

  • 完成

centos8安装cobbler_第11张图片

  • 也可以创建多个

  • 同步

[root@node4 ~]# cobbler sync
task started: 2022-08-13_105246_sync
task started (id=Sync, time=Sat Aug 13 10:52:46 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/01-00-50-56-39-48-b4
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/grub.0
removing: /var/lib/tftpboot/grub/grub.ppc64le
removing: /var/lib/tftpboot/grub/grubaa64.efi
removing: /var/lib/tftpboot/grub/grubx64.efi
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: /var/lib/tftpboot/pxelinux.cfg/01-00-50-56-39-48-b4
generating: /var/lib/tftpboot/grub/system/00:50:56:39:48:b4
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@node4 ~]#
  • 界面同步

centos8安装cobbler_第12张图片

5.3 开机
  • centos8安装cobbler_第13张图片

三. 配置文件

1. cobbler配置文件详解cobbler配置文件目录在/etc/cobbler

配置文件 作用
/etc/cobbler/settings.yaml cobbler 主配置文件
/etc/cobbler/iso/ iso模板配置文件
/etc/cobbler/user.conf web服务授权配置文件
/etc/cobbler/users.digest web访问的用户名密码配置文件
/etc/cobbler/dhcp.template dhcp服务器的的配置模板
/etc/cobbler/dnsmasq.template dns服务器的配置模板
/etc/cobbler/modules.conf 模块的配置文件

2. cobbler数据目录

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

3. cobbler日志文件

日志文件路径 说明
/var/log/cobbler/cobbler.log cobbler日志
/var/log/cobbler/tasks/ 安装导入日志

4. cobbler命令详解

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

[root@node4 ~]# cobbler system
usage
=====
cobbler system add
cobbler system copy
cobbler system dumpvars
cobbler system edit
cobbler system find
cobbler system get-autoinstall
cobbler system list
cobbler system poweroff
cobbler system poweron
cobbler system powerstatus
cobbler system reboot
cobbler system remove
cobbler system rename
cobbler system report
[root@node4 ~]# 

你可能感兴趣的:(apache,linux,服务器)