cobbler(批量装机工具)

一、cobbler简介

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

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

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

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

Cobbler官网:http://cobbler.github.io/

cobbler集成的服务

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

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

配置文件作用
/etc/cobbler/settingscobbler 主配置文件
/etc/cobbler/iso/iso模板配置文件
/etc/cobbler/pxepxe模板配置文件
/etc/cobbler/power电源配置文件
/etc/cobbler/user.confweb服务授权配置文件
/etc/cobbler/users.digestweb访问的用户名密码配置文件
/etc/cobbler/dhcp.templatedhcp服务器的的配置模板
/etc/cobbler/dnsmasq.templatedns服务器的配置模板
/etc/cobbler/tftpd.templatetftp服务的配置模板
/etc/cobbler/modules.conf模块的配置文件

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仓库存储目录

cobbler日志文件

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

cobbler命令详解

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

二、cobbler服务端部署

// 关闭防火墙和selinux
[root@localhost ~]# systemctl disable --now firewalld.service
[root@localhost ~]# getenforce
Disabled

//配置yum源
[root@localhost ~]# dnf install epel-release vim

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

[root@localhost ~]# dnf list all|grep cobbler
cobbler.noarch                                                    3.2.2-3.module_el8+13166+f291d70c                 epel-modular
cobbler-tests.noarch                                              3.2.2-3.module_el8+13166+f291d70c                 epel-modular
cobbler-web.noarch                                                3.2.2-3.module_el8+13166+f291d70c                 epel-modular

//启动服务并设置开机自启
[root@localhost ~]# systemctl enable --now httpd
[root@localhost ~]# systemctl enable --now cobblerd
[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              *:*     

//设置tftp的ip地址为本机ip,修改server的ip地址为本机ip
[root@localhost ~]# cd /etc/cobbler/
[root@localhost cobbler]# vim settings
255 next_server: 192.168.47.161
353 server: 192.168.47.161

//启动rsync并设置开机自启
[root@localhost cobbler]# systemctl enable --now rsyncd

//开启tftp
[root@localhost cobbler]# vim /etc/xinetd.d/tftp 
  8         socket_type             = dgram
  9         protocol                = udp
 10         wait                    = yes
 11         user                    = root
 12         server                  = /usr/sbin/in.tftpd
 13         server_args             = -s /var/lib/tftpboot
 14         disable                 = no     // 把yes改为no
 15         per_source              = 11
 16         cps                     = 100 2
 17         flags                   = IPv4

//生成加密的密码,然后再打开DHCP功能
[root@localhost cobbler]# openssl passwd -1
Password: 
Verifying - Password: 
$1$jCCcAMB9$XrS0Hzf.ZPPavYOhb1wLk0
[root@localhost cobbler]# vim settings 
103 default_password_crypted: "$1$jCCcAMB9$XrS0Hzf.ZPPavYOhb1wLk0"

// 把centos8 上的/var/lib/cobbler/loaders里面的所有东西复制到centos7上去
[root@localhost cobbler]# scp root@192.168.47.160:/var/lib/cobbler/loaders/* /var/lib/cobbler/loaders/
The authenticity of host '192.168.47.160 (192.168.47.160)' can't be established.
ECDSA key fingerprint is SHA256:y8UuseADpYv8QEpZIVRu4glCDufNJsCHp1dNWVOpSyQ.
ECDSA key fingerprint is MD5:e8:10:b3:e7:cc:fc:fc:b7:11:a9:17:aa:5d:99:8f:74.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.47.160' (ECDSA) to the list of known hosts.
root@192.168.47.160's password: 
COPYING.syslinux                 100% 9339     8.2MB/s   00:00    
COPYING.yaboot                   100% 9339     9.7MB/s   00:00    
grub-x86_64.efi                  100% 9339    13.4MB/s   00:00    
grub-x86.efi                     100% 9339    17.8MB/s   00:00    
menu.c32                         100%   26KB  31.2MB/s   00:00    
pxelinux.0                       100%   41KB  33.7MB/s   00:00    
README                           100% 9339    16.5MB/s   00:00    
yaboot                           100% 9339    17.5MB/s   00:00    
[root@localhost cobbler]# ls /var/lib/cobbler/loaders/
COPYING.syslinux  grub-x86_64.efi  menu.c32    README
COPYING.yaboot    grub-x86.efi     pxelinux.0  yaboot

//通过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
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 ~]# yum -y install fence-agents

// 下载缺失文件
[root@localhost ~]# cobbler get-loaders
task started: 2021-10-13_194728_get_loaders
task started (id=Download Bootloader Content, time=Wed Oct 13 19:47:28 2021)
path /var/lib/cobbler/loaders/README already exists, not overwriting existing content, use --force if you wish to update
downloading https://cobbler.github.io/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilo
Exception occured: <class 'urlgrabber.grabber.URLGrabError'>
Exception value: [Errno 14] HTTPS Error 404 - Not Found
Exception Info:
  File "/usr/lib/python2.7/site-packages/cobbler/remote.py", line 82, in run
    rc = self._run(self)
   File "/usr/lib/python2.7/site-packages/cobbler/remote.py", line 176, in runner
    return self.remote.api.dlcontent(self.options.get("force",False), self.logger)
   File "/usr/lib/python2.7/site-packages/cobbler/api.py", line 735, in dlcontent
    return grabber.run(force)
   File "/usr/lib/python2.7/site-packages/cobbler/action_dlcontent.py", line 73, in run
    urlgrabber.grabber.urlgrab(src, filename=dst, proxies=proxies)
   File "/usr/lib/python2.7/site-packages/urlgrabber/grabber.py", line 755, in urlgrab
    return default_grabber.urlgrab(url, filename, **kwargs)
   File "/usr/lib/python2.7/site-packages/urlgrabber/grabber.py", line 1201, in urlgrab
    return _run_callback(opts.failfunc, opts)
   File "/usr/lib/python2.7/site-packages/urlgrabber/grabber.py", line 1052, in _run_callback
    return cb(obj)
   File "/usr/lib/python2.7/site-packages/urlgrabber/grabber.py", line 1046, in _do_raise
    raise obj.exception

!!! TASK FAILED !!!

// 重启服务并sync同步配置
[root@localhost ~]# systemctl restart cobblerd
[root@localhost ~]# cobbler sync
task started: 2021-10-13_194906_sync
task started (id=Sync, time=Wed Oct 13 19:49:06 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 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 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 ***

/配置cobbler dhcp
//修改cobbler配置文件,让cobbler控制dhcp
[root@localhost cobbler]# vim settings 
220 manage_dhcp: 1    //把0改成1

//配置dhcp
[root@localhost ~]# vim /etc/cobbler/dhcp.template
 23 subnet 192.168.47.0 netmask 255.255.255.0 {        // 前面为本机IP同一网段
 24      option routers             192.168.47.161;    // 填写本机IP
 25      option domain-name-servers 192.168.47.2;      // 默认网关
 26      option subnet-mask         255.255.255.0;
 27      range dynamic-bootp        192.168.47.200 192.168.47.254;     // 分配的IP地址范围
 28      default-lease-time         21600;
 29      max-lease-time             43200;
 30      next-server                $next_server;

//重启服务并同步配置,改完dhcp必须要sync同步配置
[root@localhost cobbler]# systemctl restart cobblerd
[root@localhost cobbler]# cobbler sync
task started: 2021-10-13_195638_sync
task started (id=Sync, time=Wed Oct 13 19:56:38 2021)
running pre-sync triggers
cleaning trees
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/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 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 cobbler]# ss -anulp|grep dhcp
UNCONN     0      0            *:67                       *:*                   users:(("dhcpd",pid=28242,fd=7))


//导入centos7镜像
[root@localhost ~]# mount /dev/cdrom /mnt
mount: /dev/sr0 写保护,将以只读方式挂载
[root@localhost ~]# ls /mnt/
CentOS_BuildTag  GPL       LiveOS    RPM-GPG-KEY-CentOS-7
EFI              images    Packages  RPM-GPG-KEY-CentOS-Testing-7
EULA             isolinux  repodata  TRANS.TBL
[root@localhost ~]# cobbler import --path=/mnt --name=centos-7 --arch=x86_64
task started: 2021-10-13_195922_import
task started (id=Media import, time=Wed Oct 13 19:59:22 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 ***

[root@localhost ~]# ls /var/www/cobbler
images     links        misc  rendered     svc
ks_mirror  localmirror  pub   repo_mirror
[root@localhost ~]# ls /var/www/cobbler/ks_mirror/
centos-7-x86_64  config
[root@localhost ~]# ls /var/www/cobbler/ks_mirror/centos-7-x86_64/     // 查看光盘的内容
CentOS_BuildTag  GPL       LiveOS    RPM-GPG-KEY-CentOS-7
EFI              images    Packages  RPM-GPG-KEY-CentOS-Testing-7
EULA             isolinux  repodata  TRANS.TBL

//查看cobbler镜像列表
[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 <<'EOF'
auth --enableshadow --passalgo=sha512     // 密码认证
bootloader --location=mbr    
clearpart --all --initlabel     //情况所有的分区
part /boot --asprimary --fstype="ext4" --size=500       // boot分区
part swap --fstype="swap" --size=4096      // swap分区
part / --fstype="ext4" --grow --size=15000    //根分区
text     //  文本方式安装的
firewall --disabled
firstboot --disable
keyboard us      // 键盘用的us格式
lang en_US       // 语言格式
url --url=http://192.168.47.161/cobbler/ks_mirror/centos-7-x86_64     // yum仓库的地址
$yum_repo_stanza
reboot

rootpw --iscrypted     // 设置root用户的管理员密码    $6$2WTFvfNvAMgCUPuC$MJgWGzhakgxrRObcEbAwSe8vkz0s//xyiTllGwxRsHHruQhcskO69u2LVTU9u0eemHXH2pzcGawyAJ54R2E/x0

selinux --disabled
skipx       // 跳过图形化
timezone Asia/Shanghai --isUtc --nontp
install
zerombr

%packages
@^minimal
@core
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
EOF

//检查ks文件语法是否有误
[root@localhost kickstarts]# cobbler validateks
task started: 2021-10-13_202037_validateks
task started (id=Kickstart Validation, time=Wed Oct 13 20:20:37 2021)
----------------------------
osversion: rhel7
checking url: http://192.168.47.161/cblr/svc/op/ks/profile/centos-7-x86_64
running: /usr/bin/ksvalidator -v "rhel7" "http://192.168.47.161/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 kickstarts]# cobbler profile list
   centos-7-x86_64

//修改profile,将我们新建的ks文件设为默认的kickstarts安装文件
[root@localhost kickstarts]# cobbler profile edit --name centos-7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos-7-x86_64.ks

//配置网卡名称为传统网卡名称eth0
[root@localhost kickstarts]# cobbler profile edit --name centos-7-x86_64 --kopts='net.ifnames=0 biosdevname=0'    // 设置内核参数,回归传统域名

//检查当前系统cobbler配置文件信息
[root@localhost kickstarts]#  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
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_203146_sync
task started (id=Sync, time=Wed Oct 13 20:31:46 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 ~]# systemctl restart cobblerd httpd
[root@localhost ~]# systemctl start xinetd

// pxelinux.0 和menu.c32 这两个文件要用系统自带的,不能用从centos8那边复制过来的
[root@localhost ~]# cd /var/lib/cobbler/loaders/
[root@localhost loaders]# ls
COPYING.elilo     grub-x86_64.efi  pxelinux.0
COPYING.syslinux  grub-x86.efi     README
COPYING.yaboot    menu.c32         yaboot
[root@localhost loaders]# find / -name pxelinux.0 
/var/lib/tftpboot/pxelinux.0
/var/lib/cobbler/loaders/pxelinux.0
/usr/share/syslinux/pxelinux.0
[root@localhost loaders]# ll pxelinux.0  /usr/share/syslinux/pxelinux.0 
-rw-r--r-- 2 root root 42376 1013 18:58 pxelinux.0
-rw-r--r-- 1 root root 26759 1031 2018 /usr/share/syslinux/pxelinux.0
[root@localhost loaders]# \cp /usr/share/syslinux/pxelinux.0 . 
[root@localhost loaders]# ll pxelinux.0  
-rw-r--r-- 2 root root 26759 1013 20:46 pxelinux.0

[root@localhost loaders]# find / -name menu.c32 
find: ‘/proc/125304’: 没有那个文件或目录
find: ‘/proc/125349’: 没有那个文件或目录
find: ‘/proc/125365’: 没有那个文件或目录
find: ‘/proc/125368’: 没有那个文件或目录
/var/lib/tftpboot/menu.c32
/var/lib/cobbler/loaders/menu.c32
/usr/share/syslinux/menu.c32
[root@localhost loaders]# ll /usr/share/syslinux/menu.c32  menu.c32 
-rw-r--r-- 2 root root 26272 1013 18:58 menu.c32
-rw-r--r-- 1 root root 55140 1031 2018 /usr/share/syslinux/menu.c32
[root@localhost loaders]# \cp /usr/share/syslinux/menu.c32 menu.c32

三、客户端安装

新建虚拟机,内存给2G,网络适配器为NAT,不要给镜像,从pxe启动,若出现以下界面则表示成功:
在这里插入图片描述

四、定制安装

定制安装步骤:

统计服务器mac地址
配置cobbler
安装

在 cobbler 的web界面上配置:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
同步配置并重启相关服务:

[root@localhost ~]# cobbler sync
task started: 2021-10-13_213839_sync
task started (id=Sync, time=Wed Oct 13 21:38:39 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/pxelinux.cfg/01-00-50-56-2b-ec-22
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/grub/01-00-50-56-2B-EC-22
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: /var/lib/tftpboot/pxelinux.cfg/01-00-50-56-2b-ec-22
generating: /var/lib/tftpboot/grub/01-00-50-56-2B-EC-22
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 ~]# systemctl restart xinetd
[root@localhost ~]# systemctl restart httpd
[root@localhost ~]# systemctl restart cobblerd

在centos7上安装centos8

// 导入centos8的光盘
[root@localhost ~]# mount /dev/cdrom /mnt
mount: /dev/sr0 写保护,将以只读方式挂载
[root@localhost ~]# cobbler import --name=centos-8 --path=/mnt/  --arch=x86_64
task started: 2021-10-14_141118_import
task started (id=Media import, time=Thu Oct 14 14:11:18 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-8-x86_64:
creating new distro: centos-8-x86_64
trying symlink: /var/www/cobbler/ks_mirror/centos-8-x86_64 -> /var/www/cobbler/links/centos-8-x86_64
creating new profile: centos-8-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-8-x86_64 for centos-8-x86_64
processing repo at : /var/www/cobbler/ks_mirror/centos-8-x86_64
need to process repo/comps: /var/www/cobbler/ks_mirror/centos-8-x86_64
looking for /var/www/cobbler/ks_mirror/centos-8-x86_64/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/centos-8-x86_64/repodata
*** TASK COMPLETE ***
[root@localhost ~]# cobbler list
distros:
   centos-7-x86_64
   centos-8-x86_64

profiles:
   centos-7-x86_64
   centos-8-x86_64

systems:
   wjjvm1

repos:

images:

mgmtclasses:

packages:

files:
[root@localhost ~]# cd /var/lib/cobbler/kickstarts/
[root@localhost kickstarts]# mv centos-7-x86_64.ks centos-8-x86_64.ks 
[root@localhost kickstarts]# vim centos-8-x86_64.ks 
[root@localhost kickstarts]# cat /root/anaconda-ks.cfg 
#version=DEVEL
# System authorization information
auth --enableshadow --passalgo=sha512
# Use CDROM installation media
cdrom
# Use graphical install
graphical
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=sda
# Keyboard layouts
keyboard --vckeymap=cn --xlayouts='cn'
# System language
lang zh_CN.UTF-8

# Network information
network  --bootproto=dhcp --device=ens33 --ipv6=auto --activate
network  --hostname=localhost.localdomain

# Root password
rootpw --iscrypted $6$Yu/pr.elNzSxG.oi$aKTuVyIurxFK5uAwI8B9k4rpPhEaGK7DPxbcMfGtaGIbU67cftDadt6zb2zUWbBZn3YoDB3K4eFdNepjOCSPF/
# System services
services --enabled="chronyd"
# System timezone
timezone Asia/Shanghai --isUtc
user --name=wjj --password=$6$0hOwc6Sz6JQnas6W$UTAy4OEDoCLCgMz9LYBmt00ueC1xdBdrdrkYa9jIGl8.Lg93ug8gEliDA3S8gnQS5IByfdRDPQECc9fBwlZRl1 --iscrypted --gecos="wjj"
# System bootloader configuration
bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
autopart --type=lvm
# Partition clearing information
clearpart --none --initlabel

%packages
@^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
[root@localhost kickstarts]# vim centos-8-x86_64.ks 
[root@localhost kickstarts]# cobbler validateks
task started: 2021-10-14_142047_validateks
task started (id=Kickstart Validation, time=Thu Oct 14 14:20:47 2021)
----------------------------
osversion: rhel7
checking url: http://192.168.47.161/cblr/svc/op/ks/profile/centos-8-x86_64
running: /usr/bin/ksvalidator -v "rhel7" "http://192.168.47.161/cblr/svc/op/ks/profile/centos-8-x86_64"
received on stdout: 
received on stderr: 
----------------------------
osversion: rhel7
checking url: http://192.168.47.161/cblr/svc/op/ks/profile/centos-7-x86_64
running: /usr/bin/ksvalidator -v "rhel7" "http://192.168.47.161/cblr/svc/op/ks/profile/centos-7-x86_64"
received on stdout: 
received on stderr: 
----------------------------
osversion: rhel7
checking url: http://192.168.47.161/cblr/svc/op/ks/system/wjjvm1
running: /usr/bin/ksvalidator -v "rhel7" "http://192.168.47.161/cblr/svc/op/ks/system/wjjvm1"
received on stdout: 
received on stderr: 
*** all kickstarts seem to be ok ***
*** TASK COMPLETE ***
[root@localhost kickstarts]# cobbler profile edit --name centos-8-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos-8-x86_64.ks
[root@localhost kickstarts]# cobbler profile edit --name centos-8-x86_64 --kopts='net.ifnames=0 biosdevname=0'
[root@localhost kickstarts]# cobbler profile report
Name                           : centos-8-x86_64
TFTP Boot Files                : {}
Comment                        : 
DHCP Tag                       : default
Distribution                   : centos-8-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-8-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

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
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

[root@localhost kickstarts]# cobbler sync
task started: 2021-10-14_142149_sync
task started (id=Sync, time=Thu Oct 14 14:21:49 2021)
running pre-sync triggers
cleaning trees
removing: /var/www/cobbler/images/centos-7-x86_64
removing: /var/www/cobbler/images/centos-8-x86_64
removing: /var/lib/tftpboot/pxelinux.cfg/01-00-50-56-2b-ec-22
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/01-00-50-56-2B-EC-22
removing: /var/lib/tftpboot/grub/efidefault
removing: /var/lib/tftpboot/images/centos-7-x86_64
removing: /var/lib/tftpboot/images/centos-8-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-8-x86_64
trying hardlink /var/www/cobbler/ks_mirror/centos-8-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/centos-8-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/centos-8-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/centos-8-x86_64/initrd.img
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: /var/lib/tftpboot/pxelinux.cfg/01-00-50-56-2b-ec-22
generating: /var/lib/tftpboot/grub/01-00-50-56-2B-EC-22
generating PXE menu structure
copying files for distro: centos-8-x86_64
trying hardlink /var/www/cobbler/ks_mirror/centos-8-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/centos-8-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/centos-8-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/centos-8-x86_64/initrd.img
Writing template files for centos-8-x86_64
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-8-x86_64
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 kickstarts]# systemctl restart xinetd
[root@localhost kickstarts]# systemctl restart cobblerd
[root@localhost kickstarts]# systemctl resta

在这里插入图片描述

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值