• Cobbler


    Cobbler


    Cobbler简介

    Cobbler官网

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

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

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

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

    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/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
    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 ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
    
    #配置国内的yum源
    [root@localhost ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  2495  100  2495    0     0  12729      0 --:--:-- --:--:-- --:--:-- 12729
    [root@localhost ~]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
    [root@localhost ~]# yum makecache
    CentOS-8.5.2111 - Base - mirrors.aliyun.com                                       47 kB/s | 3.9 kB     00:00
    CentOS-8.5.2111 - Extras - mirrors.aliyun.com                                     29 kB/s | 1.5 kB     00:00
    CentOS-8.5.2111 - AppStream - mirrors.aliyun.com                                  59 kB/s | 4.3 kB     00:00
    Metadata cache created.
    
    #下载epel源
    [root@localhost ~]# dnf -y install epel-release
    
    #安装cobbler以及相关的软件
    [root@localhost ~]# yum module list | grep cobbler
    cobbler              3               default [d]                              Versatile Linux deployment server      
    cobbler              3.3             default [d]                              Versatile Linux deployment server 
    
    [root@localhost ~]# dnf -y module enable cobbler:3  //开启cobble模块
    [root@localhost ~]# dnf -y install httpd dhcp* tftp tftp-server cobbler cobbler-web pykickstart rsync rsync-daemon
    
    #启动服务并设为开机自启
    [root@localhost ~]# systemctl enable --now httpd
    Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
    [root@localhost ~]# systemctl enable --now rsyncd
    Created symlink /etc/systemd/system/multi-user.target.wants/rsyncd.service → /usr/lib/systemd/system/rsyncd.service.
    [root@localhost ~]# systemctl enable --now tftp
    Created symlink /etc/systemd/system/sockets.target.wants/tftp.socket → /usr/lib/systemd/system/tftp.socket.
    [root@localhost ~]# systemctl enable --now cobblerd
    Created symlink /etc/systemd/system/multi-user.target.wants/cobblerd.service → /usr/lib/systemd/system/cobblerd.service.
    
    #生成加密的密码,将新生成的加密密码加入到配置文件
    [root@localhost ~]# openssl passwd -1 -salt "$RANDOM" 'centos'
    $1$32355$b/BQ8gPCZVGXaJHylpPNe0
    [root@localhost ~]# vim /etc/cobbler/settings.yaml
    server: 192.168.188.128  //修改server的ip地址为本机ip
    next_server: 192.168.188.128  //设置tftp的ip地址为本机ip
    default_password_crypted: "$1$32355$b/BQ8gPCZVGXaJHylpPNe0"  //填写刚刚生成的密匙
    manage_dhcp: true //开启dhcp管理
    
    #改完上述配置,重启cobbler服务,建议reboot一下再执行错误检查
    [root@localhost ~]# systemctl restart cobblerd.service
    [root@localhost ~]# reboot
    
    #进行错误检查,需要解决这些错误。4和5不用管,那是Debian系统需要解决的问题
    [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. 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.
    
    #问题1的解决方法
    [root@localhost ~]# yum -y install syslinux*
    [root@localhost ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/cobbler/loaders/
    [root@localhost ~]# cp /usr/share/syslinux/menu.c32 /var/lib/cobbler/loaders/
    [root@localhost ~]# ls /var/lib/cobbler/loaders/
    menu.c32  pxelinux.0
    
    #问题2和3的解决方法
    [root@localhost ~]# yum -y install yum-utils
    
    #解决后再次检查可以发现还报问题1,如果你已完成问题1的解决方法可以不理
    [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. 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.
    
    #配置DHCP模板文件
    [root@localhost ~]# vim /etc/cobbler/dhcp.template
    subnet 192.168.188.0 netmask 255.255.255.0 {  //192.168.92.0是子网
         option routers             192.168.188.2;  //网关
         option domain-name-servers 8.8.8.8;  //DNS
         option subnet-mask         255.255.255.0;  //子网掩码
         range dynamic-bootp        192.168.188.100 192.168.188.130;  //地址池
         default-lease-time         21600;
         max-lease-time             43200;
         next-server                $next_server;
    
    #重启服务,生效配置
    [root@localhost ~]# systemctl restart httpd cobblerd
    
    #同步cobbler
    [root@localhost ~]# cobbler sync
    ......
    shell triggers finished successfully
    *** TASK COMPLETE ***
    
    #挂载镜像
    [root@localhost ~]# mount /dev/cdrom /mnt/
    
    #导入镜像
    #参数说明
    --path      //镜像路径
    --name      //为安装源定义一个名字
    --arch      //指定安装源平台
    #安装源的唯一标示就是根据name参数来定义,本例导入成功后,安装源的唯一标示就是:CentOS8-x86_64,如果重复,系统会提示导入失败
    [root@localhost ~]# cobbler import --path=/mnt/ --name=Centos8 arch=x86_64
    task started: 2022-09-25_163224_import
    task started (id=Media import, time=Sun Sep 25 16:32:24 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:
    creating new distro: Centos8-x86_64
    trying symlink: /var/www/cobbler/distro_mirror/Centos8 -> /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 for Centos8-x86_64
    processing repo at : /var/www/cobbler/distro_mirror/Centos8/AppStream
    need to process repo/comps: /var/www/cobbler/distro_mirror/Centos8/AppStream
    looking for /var/www/cobbler/distro_mirror/Centos8/AppStream/repodata/*comps*.xml
    Keeping repodata as-is :/var/www/cobbler/distro_mirror/Centos8/AppStream/repodata
    processing repo at : /var/www/cobbler/distro_mirror/Centos8/BaseOS
    need to process repo/comps: /var/www/cobbler/distro_mirror/Centos8/BaseOS
    looking for /var/www/cobbler/distro_mirror/Centos8/BaseOS/repodata/*comps*.xml
    Keeping repodata as-is :/var/www/cobbler/distro_mirror/Centos8/BaseOS/repodata
    *** TASK COMPLETE ***
    
    #生成kickstarts自动安装脚本
    [root@localhost ~]# cobbler profile get-autoinstall --name Centos8-x86_64 > /var/lib/cobbler/templates/centos8.ks
    
    #修改脚本
    [root@localhost ~]# vim /var/lib/cobbler/templates/centos8.ks
    ......
    firewall --disable
    ......
    %packages
    @^minimal-environment  //在%packages与%end中间添加此行,设置最小化安装
    %end
    
    #检查ks脚本文件语法是否有误
    [root@localhost ~]# cobbler validate-autoinstalls
    task started: 2022-09-25_164131_validate_autoinstall_files
    task started (id=Automated installation files validation, time=Sun Sep 25 16:41:31 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@localhost ~]# cd /usr/share/cobbler/bin/
    [root@localhost bin]# ls
    migrate-data-v2-to-v3.py  migrate-settings.sh  mkgrub.sh  settings-migration-v1-to-v2.sh
    
    #可以看到该脚本的执行会报一堆错误,先不用管
    [root@localhost bin]# bash 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
    
    #执行完上一步,去/var/lib/cobbler/loaders/下查看有没有grub与ldlinux.c32文件
    [root@localhost bin]# cd /var/lib/cobbler/loaders/
    [root@localhost loaders]# ll /var/lib/cobbler/loaders/
    total 72
    drwxr-xr-x  2 root root    79 Sep 25 16:44 grub
    lrwxrwxrwx  1 root root    31 Sep 25 16:44 ldlinux.c32 -> /usr/share/syslinux/ldlinux.c32
    -rw-r--r--. 1 root root 26272 Sep 25 16:08 menu.c32
    -rw-r--r--. 1 root root 42376 Sep 25 16:08 pxelinux.0
    
    #同步cobbler
    [root@localhost loaders]# cobbler sync
    
    #重启服务
    [root@localhost ~]# systemctl restart httpd cobblerd rsyncd dhcpd
    

    客户端安装系统

    新建一台虚拟机,设置好cpu,内存等配置,无需自行添加镜像。创建好直接开启虚拟机。

    需耐心等待,出现如下界面,选择刚刚制作的镜像

    在这里插入图片描述

    大约等待几分钟,密码就是生成的加密密码,我设置的是centos
    在这里插入图片描述

    定制安装

    //浏览器的地址栏访问cobbler的web界面必须是https+ip+cobbler_web的格式
    //默认的用户名与密码都是cobbler
    在这里插入图片描述
    在这里插入图片描述

    在这里插入图片描述

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

    创建虚拟机进行测试
    在这里插入图片描述

    虚拟机设置完成之后直接开启,开启后无需任何操作,他自动会执行直到用户界面,可以看到IP地址就是设置的未使用的IP地址

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

  • 相关阅读:
    python列表操作
    java计算机毕业设计springboot+vue教师支教系统(源码+系统+mysql数据库+Lw文档)
    qml入门
    功能农业育种 国稻种芯-何登骥:广西稻作文化园农业大健康
    3. 传统IO数据拷贝、同步阻塞IO在哪里阻塞、同步阻塞IO怎么解决、IO多路复用、多路复用的特点、常见多路复用方案
    SpringCloud 微服务全栈体系(十)
    java计算机毕业设计个人连锁民宿信息管理系统设计与开发系统(修改)MyBatis+系统+LW文档+源码+调试部署
    gitee配置流水线实现自动打包vue
    小技巧 - 中文detokenize(基于规则)
    【List篇】ArrayList 详解(含图示说明)
  • 原文地址:https://blog.csdn.net/ZJunWhite/article/details/127040599