一步步调教Cobbler安装、配置、部署

原地址:https://blog.csdn.net/TzuHenry_AZ/article/details/121883604

1.准备环境:

关闭防火墙、配好yum源、服务器配好IP、SElinux关闭。

2.安装epel源:

[root @solomon 11:49 ~ ]# yum install -y epel-release

3.安装对应的软件包:

cobbler-web可安装可不安装,它要依赖Python-django环境,版本而且还要对应

[root @solomon 11:54 ~ ]# yum install -y cobbler cobbler-web tftp-server dhcp httpd xinetd

(下载完之后就可以去配置dhcp的网段之类的了,到时候cobbler就会根据这个配置信息去给机器部署IP)

4.开启httpd和cobblerd服务,并设置成开机自启动:

    [root @solomon 15:33 ~ ]# systemctl restart httpd cobblerd
    [root @solomon 15:34 ~ ]# systemctl enable httpd
    cobblerd Created symlink from /etc/systemd/system/multi-user.target.wants/cobblerd.service to /usr/lib/systemd/system/cobblerd.service.

5.查看相关配置文件:

    [root @solomon 15:34 ~ ]# rpm -ql cobbler
    /etc/cobbler                  # 配置文件目录
    /etc/cobbler/settings         # cobbler主配置文件,这个文件是YAML格式,Cobbler是python写的程序。
    /etc/cobbler/dhcp.template    # DHCP服务的配置模板
    /etc/cobbler/tftpd.template   # tftp服务的配置模板
    /etc/cobbler/rsync.template   # rsync服务的配置模板
    /etc/cobbler/iso              # iso模板配置文件目录
    /etc/cobbler/pxe              # pxe模板文件目录
    /etc/cobbler/power            # 电源的配置文件目录
    /etc/cobbler/users.conf       # Web服务授权配置文件
    /etc/cobbler/users.digest     # 用于web访问的用户名密码配置文件
    /etc/cobbler/dnsmasq.template # DNS服务的配置模板
    /etc/cobbler/modules.conf     # Cobbler模块配置文件
    /var/lib/cobbler              # Cobbler数据目录
    /var/lib/cobbler/config       # 配置文件
    /var/lib/cobbler/kickstarts   # 默认存放kickstart文件
    /var/lib/cobbler/loaders      # 存放的各种引导程序
    /var/www/cobbler              # 系统安装镜像目录
    /var/www/cobbler/ks_mirror    # 导入的系统镜像列表
    /var/www/cobbler/images       # 导入的系统镜像启动文件
    /var/www/cobbler/repo_mirror  # yum源存储目录
    /var/log/cobbler              # 日志目录
    /var/log/cobbler/install.log  # 客户端系统安装日志
    /var/log/cobbler/cobbler.log  # cobbler日志

6.配置cobbler,执行cobbler check查看当前配置是否出现问题,如果看不到下列显示信息,则重启cobbler再查一次:

    [root @solomon 17:54 ~ ]# cobbler check
    The following are potential configuration items that you may want to fix:
     
    1 : The 'server' field in /etc/cobbler/settings must be set to something other than localhost, or kickstarting features will not work.  This should be a resolvable hostname or IP for the boot server as reachable by all machines that will use it.
    2 : For PXE to be functional, the 'next_server' field in /etc/cobbler/settings must be set to something other than 127.0.0.1, and should match the IP of the boot server on the PXE network.
    3 : SELinux is enabled. Please review the following wiki page for details on ensuring cobbler works correctly in your SELinux environment:
        https://github.com/cobbler/cobbler/wiki/Selinux
    4 : change 'disable' to 'no' in /etc/xinetd.d/tftp
    5 : 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.
    6 : enable and start rsyncd.service with systemctl
    7 : debmirror package is not installed, it will be required to manage debian deployments and repositories
    8 : The default password used by the sample templates for newly installed machines (default_password_crypted in /etc/cobbler/settings) is still set to 'cobbler' and should be changed, try: "openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'" to generate new one
    9 : 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.

以上就是存在的问题,要一个一个去解决,一般会有7-9条显示(因为每台机器环境可能不一样),根据上述提示去更改配置的。

首先要进行的设置是为:可以动态设置。(也可以直接更改配置文件)

7.设置可以动态修改配置文件:

    [root @solomon 18:30 ~ ]# sed -ri '/allow_dynamic_settings:/c\allow_dynamic_settings: 1' /etc/cobbler/settings
    [root @solomon 18:31 ~ ]# grep allow_dynamic_setting /etc/cobbler/settings allow_dynamic_settings: 1
    [root @solomon 18:31 ~ ]# systemctl restart cobblerd

allow_dynamic_settings: 1' 如果为0的话,意思就是不能动态修改配置文件,只能静态。

8.开始逐个解决上述问题:

(1)server问题:即server字段=必须设置为localhost之外的IP,即不能是127.0.0.1

[root @solomon 18:38 ~ ]# cobbler setting edit --name=server --value=192.168.61.146

(2)next_server:为了PXE用户booting能够找到它

[root @solomon 18:39 ~ ]# cobbler setting edit --name=next_server --value=192.168.61.146

上面是命令行直接用命令修改的。

下面图片是进入文件内修改:vim /etc/cobbler/settings

(3)tftp_server:

用sed命令直接更改:

    [root @solomon 18:41 ~ ]# sed -ri '/disable/c\disable = no' /etc/xinetd.d/tftp
    [root @solomon 18:41 ~ ]# systemctl enable xinetd
    [root @solomon 18:43 ~ ]# systemctl restart xinetd

修改配置文件:vim /etc/xinetd.d/tftp

前面三步改完之后,重启一下cobbler和xinetd

    [root @solomon 10:03 ~ ]# systemctl restart cobblerd
    [root @solomon 10:03 ~ ]# systemctl restart xinetd

配置没有错误,就会重启成功,不会报错。

(4)boot-loaders:

    [root @solomon 18:44 ~ ]# cobbler get-loaders
    task started: 2021-12-10_184446_get_loaders
    task started (id=Download Bootloader Content, time=Fri Dec 10 18:44:46 2021)
    downloading https://cobbler.github.io/loaders/README to /var/lib/cobbler/loaders/README
    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 !!!

如果如上述一样失败了,则进行下面的操作来解决,因为需要相关引导文件:

[root @solomon 18:44 ~ ]# yum install -y syslinux

pxelinux.0(引导文件)和menu.c32(菜单文件),这两个文件是从sysliunx里面来的,所需复制之前,先要保证下载好syslinux,下面进行复制:

    [root @solomon 18:47 ~ ]# cp /usr/share/syslinux/pxelinux.0 /var/lib/cobbler/loaders/
    [root @solomon 18:47 ~ ]# cp /usr/share/syslinux/menu.c32 /var/lib/cobbler/loaders/
    [root @solomon 18:49 ~ ]# systemctl restart cobblerd

    [root @solomon 18:49 ~ ]# cobbler get-loaders
    task started: 2021-12-10_184936_get_loaders
    task started (id=Download Bootloader Content, time=Fri Dec 10 18:49:36 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 !!!

糟糕,还是不行...不过没有关系,先不用管。你有syslinux就行,保证要有启动文件。

咱们继续接着修改那几个提示:

    [root @solomon 10:21 ~ ]# cobbler check
    The following are potential configuration items that you may want to fix:
     
    1 : SELinux is enabled. Please review the following wiki page for details on ensuring cobbler works correctly in your SELinux environment:
        https://github.com/cobbler/cobbler/wiki/Selinux
    2 : 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.
    3 : enable and start rsyncd.service with systemctl
    4 : debmirror package is not installed, it will be required to manage debian deployments and repositories
    5 : The default password used by the sample templates for newly installed machines (default_password_crypted in /etc/cobbler/settings) is still set to 'cobbler' and should be changed, try: "openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'" to generate new one
    6 : 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

(5)rsyncd:其实这一步,改不改都无所谓,因为目前还没有这个服务,但我们还是去改一下吧。

    [root @solomon 10:22 ~ ]# systemctl start rsyncd
    [root @solomon 10:24 ~ ]# systemctl enable rsyncd
    Created symlink from /etc/systemd/system/multi-user.target.wants/rsyncd.service to /usr/lib/systemd/system/rsyncd.service.

(6)debmirror

这步骤可以忽略,用不上。

(7)default_password_crypted更改密码:#注意:这里设置的密码,是后面安装完系统的初始化登录密码。

用openssl passwd -1 -salt生成密码。而`openssl rand -hex 4`每次生成的哈希值都是随机的,

    [root @solomon 10:37 ~ ]# openssl rand -hex 4 976bff78
    [root @solomon 10:40 ~ ]# openssl rand -hex 4 02784522
    [root @solomon 10:40 ~ ]# openssl rand -hex 4 16714fcf

openssl passwd -1 -salt `openssl rand -hex 4` 'admin',设置被安装机器的密码为admin:

[root @solomon 10:40 ~ ]# openssl passwd -1 -salt `openssl rand -hex 4` 'admin' $1$21fb21cc$N5c.7LfjLxn/afFlCGAmi1

openssl rand -hex 4生成的是1$21fb21cc,可以理解为相当于一个干扰字符串,为了安全。

admin对应的密码是:N5c.7LfjLxn/afFlCGAmi1

然后下一步去文件内修改:

[root @solomon 10:47 ~ ]# vim /etc/cobbler/settings

 改完密码重启一下:

[root @solomon 11:06 ~ ]# systemctl restart cobblerd

(8)fence-agent:

[root @solomon 10:51 ~ ]# yum install -y fence-agents

(9)前面的配置步骤都修改后check一下,下面剩下的3个就不用管了,忽略。

    [root @solomon 11:11 ~ ]# cobbler check
    The following are potential configuration items that you may want to fix:
     
    1 : SELinux is enabled. Please review the following wiki page for details on ensuring cobbler works correctly in your SELinux environment:
        https://github.com/cobbler/cobbler/wiki/Selinux
    2 : 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.
    3 : debmirror package is not installed, it will be required to manage debian deployments and repositories
     
    Restart cobblerd and then run 'cobbler sync' to apply changes.

弄完所有之后,进行同步操作:

    [root @solomon 11:12 ~ ]# cobbler sync
    task started: 2021-12-11_111233_sync
    task started (id=Sync, time=Sat Dec 11 11:12:33 2021)
    running pre-sync triggers
    cleaning trees
    removing: /var/lib/tftpboot/grub/images
    copying bootloaders
    copying: /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
    copying: /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32
    copying: /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk
    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 ***

看到complete就万事大吉了!没有问题。

9.接下来配置DHCP:

命令行操作:cobbler setting edit --name=manage_dhcp --value=1

把0改为1,cobbler就可以管理DHCP了

修改配置文件操作:

[root @solomon 11:16 ~ ]# vim /etc/cobbler/settings

10.修改cobbler的dhcp模块,不要直接修改dhcp本身的配置文件,因为cobbler会覆盖。

[root @solomon 11:18 ~ ]# vim /etc/cobbler/dhcp.template

    “XX”代表你要修改的内容,对应你本身的网段:
    subnet 192.168.XX.0 netmask 255.255.255.0 {   #这里改为分配的网段和掩码
         option routers             192.168.XX.2; #如果有网关,这里改为网关地址
         option domain-name-servers 192.168.XX.2;  #如果有DNS,这里改为DNS地址
         option subnet-mask         255.255.255.0; #改为分配的IP的掩码
         range dynamic-bootp        192.168.XX.100 192.168.XX.254; #改为分配的IP的范围,
         default-lease-time         21600;
         max-lease-time             43200;
         next-server                $next_server;

修改后,记得进行sync同步操作,它会根据配置自动修改dhcp等服务:

    [root @solomon 11:27 ~ ]# cobbler sync
    task started: 2021-12-11_112753_sync
    task started (id=Sync, time=Sat Dec 11 11:27:53 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/efidefault
    removing: /var/lib/tftpboot/s390x/profile_list
    copying bootloaders
    copying: /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
    copying: /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32
    copying: /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk
    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 ***

到此,DHCP服务已经配好了。

11.镜像挂载,把镜像翻到服务器里面去:

    [root @solomon 11:52 ~ ]# cd Desktop/
    [root @solomon 11:53 Desktop ]# ll
    total 24300
    -rw-r--r--. 1 root root 24883200 Dec 11 11:51 rhel-server-7.3-x86_64-dvd.is

(1)上传到服务器之后,创建挂载点:

    [root @solomon 12:08 Desktop ]# mkdir /mnt/rhel7
    [root @solomon 12:08 Desktop ]# cd /mnt/rhel7/
    [root @solomon 12:08 rhel7 ]# mount -o loop /root/Desktop/rhel-server-7.3-x86_64-dvd.iso /mnt/rhel7
    mount: /dev/loop0 is write-protected, mounting read-only
    [root @solomon 12:09 rhel7 ]# df -h
    Filesystem              Size  Used Avail Use% Mounted on
    /dev/mapper/rhel-root    17G   14G  3.8G  78% /
    devtmpfs                473M     0  473M   0% /dev
    tmpfs                   489M   88K  489M   1% /dev/shm
    tmpfs                   489M   51M  439M  11% /run
    tmpfs                   489M     0  489M   0% /sys/fs/cgroup
    /dev/sr0                3.6G  3.6G     0 100% /yum
    /dev/sda1              1014M  173M  842M  18% /boot
    /dev/mapper/storage-lv  190M  1.6M  175M   1% /lv
    tmpfs                    98M   20K   98M   1% /run/user/0
    overlay                  17G   14G  3.8G  78% /var/lib/docker/overlay2/42eadaacae76423c0ec6bef3cb24de1953e96c3607a54477b28fac9cdb597e20/merged
    /dev/loop0              3.6G  3.6G     0 100% /mnt/rhel7

(2)导入镜像:

--path:指定镜像路径 --name:定义安装源名称 --arch:指定安装源加工后,目前支持的选项有:x86 x86_64 ia64,安装源唯一标识通过name参数来定义。

[root @solomon 12:09 rhel7 ]# cobbler import --path=/mnt/rhel7 --name=rhel7.3 --arch=x86_64

不过我发现,上面的导入不行(看你个人情况)。我就尝试使用我原本已有的镜像,用的也是rhel7,这是我机器上早就挂好了的。

    [root @solomon 17:00 var ]# df -h
    Filesystem              Size  Used Avail Use% Mounted on
    /dev/sr0                3.6G  3.6G     0 100% /yum

再次尝试导入:

    [root @solomon 17:34 var ]# cobbler import --path=/yum --name=rhel7.3 --arch=x86_64
    task started: 2021-12-11_173502_import
    task started (id=Media import, time=Sat Dec 11 17:35:02 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/rhel7.3-x86_64:
    creating new distro: rhel7.3-x86_64
    trying symlink: /var/www/cobbler/ks_mirror/rhel7.3-x86_64 -> /var/www/cobbler/links/rhel7.3-x86_64
    creating new profile: rhel7.3-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/rhel7.3-x86_64 for rhel7.3-x86_64
    processing repo at : /var/www/cobbler/ks_mirror/rhel7.3-x86_64
    need to process repo/comps: /var/www/cobbler/ks_mirror/rhel7.3-x86_64
    looking for /var/www/cobbler/ks_mirror/rhel7.3-x86_64/repodata/*comps*.xml
    Keeping repodata as-is :/var/www/cobbler/ks_mirror/rhel7.3-x86_64/repodata
    processing repo at : /var/www/cobbler/ks_mirror/rhel7.3-x86_64/addons/HighAvailability
    need to process repo/comps: /var/www/cobbler/ks_mirror/rhel7.3-x86_64/addons/HighAvailability
    looking for /var/www/cobbler/ks_mirror/rhel7.3-x86_64/addons/HighAvailability/repodata/*comps*.xml
    Keeping repodata as-is :/var/www/cobbler/ks_mirror/rhel7.3-x86_64/addons/HighAvailability/repodata
    processing repo at : /var/www/cobbler/ks_mirror/rhel7.3-x86_64/addons/ResilientStorage
    need to process repo/comps: /var/www/cobbler/ks_mirror/rhel7.3-x86_64/addons/ResilientStorage
    looking for /var/www/cobbler/ks_mirror/rhel7.3-x86_64/addons/ResilientStorage/repodata/*comps*.xml
    Keeping repodata as-is :/var/www/cobbler/ks_mirror/rhel7.3-x86_64/addons/ResilientStorage/repodata
    *** TASK COMPLETE ***

居然成功了...

(3)cobbler distro report --name=rhel7.3-x86_64查看导入后镜像信息:

    [root @solomon 17:38 ~ ]# cobbler distro report --name=rhel7.3-x86_64
    Name                           : rhel7.3-x86_64
    Architecture                   : x86_64
    TFTP Boot Files                : {}
    Breed                          : redhat
    Comment                        :
    Fetchable Files                : {}
    Initrd                         : /var/www/cobbler/ks_mirror/rhel7.3-x86_64/images/pxeboot/initrd.img
    Kernel                         : /var/www/cobbler/ks_mirror/rhel7.3-x86_64/images/pxeboot/vmlinuz
    Kernel Options                 : {}
    Kernel Options (Post Install)  : {}
    Kickstart Metadata             : {'tree': 'http://@@http_server@@/cblr/links/rhel7.3-x86_64'}
    Management Classes             : []
    OS Version                     : rhel7
    Owners                         : ['admin']
    Red Hat Management Key         : <<inherit>>
    Red Hat Management Server      : <<inherit>>
    Template Files                 : {}

(4)cobbler profile report --name=rhel7.3-x86_64查看profile信息:

    [root @solomon 17:39 ~ ]# cobbler profile report --name=rhel7.3-x86_64
    Name                           : rhel7.3-x86_64
    TFTP Boot Files                : {}
    Comment                        :
    DHCP Tag                       : default
    Distribution                   : rhel7.3-x86_64
    Enable gPXE?                   : 0
    Enable PXE Menu?               : 1
    Fetchable Files                : {}
    Kernel Options                 : {}
    Kernel Options (Post Install)  : {}
    Kickstart                      : /var/lib/cobbler/kickstarts/sample_end.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

(5)查看kickstart安装文件:

    [root @solomon 17:39 ~ ]# cd /var/lib/cobbler/
    [root @solomon 17:41 cobbler ]# ll
    total 64
    drwxr-xr-x. 10 root   root   143 Dec 10 11:58 config
    -rw-r--r--.  1 root   root 50604 Aug 30  2019 distro_signatures.json
    drwxr-xr-x.  3 root   root  4096 Dec 10 11:58 kickstarts
    drwxr-xr-x.  2 root   root    97 Dec 11 15:44 loaders
    -rw-r--r--.  1 root   root     0 Dec 10 15:34 lock
    drwxr-xr-x.  2 root   root    63 Dec 10 11:58 scripts
    drwxr-xr-x.  2 root   root  4096 Dec 10 11:58 snippets
    drwxr-xr-x.  7 root   root    72 Dec 10 11:58 triggers
    -rw-------.  1 apache root  1024 Dec 11 16:54 web.ss
    drwx------.  2 apache root     6 Oct 15  2019 webui_sessions
    [root @solomon 17:41 cobbler ]# cd kickstarts/
    [root @solomon 17:41 kickstarts ]# ls
    default.ks    install_profiles  sample_autoyast.xml  sample_esxi4.ks  sample.ks        sample.seed.28
    esxi4-ks.cfg  legacy.ks         sample_end.ks        sample_esxi5.ks  sample_old.seed
    esxi5-ks.cfg  pxerescue.ks      sample_esx4.ks       sample_esxi6.ks  sample.seed

cobbler默认使用的是ks文件为sample.ks,编辑sample.ks文件可以修改部署系统的用户、分区、网络等安装参数,可根据实际需求进行更改。其实在kickstarts中。template版本不一样。

(6)再次同步cobbler配置:

    [root @solomon 17:43 kickstarts ]# cobbler sync
    task started: 2021-12-11_174323_sync
    task started (id=Sync, time=Sat Dec 11 17:43:23 2021)
    running pre-sync triggers
    cleaning trees
    removing: /var/www/cobbler/images/rhel7.3-x86_64
    removing: /var/lib/tftpboot/pxelinux.cfg/default
    removing: /var/lib/tftpboot/grub/images
    removing: /var/lib/tftpboot/grub/efidefault
    removing: /var/lib/tftpboot/images/rhel7.3-x86_64
    removing: /var/lib/tftpboot/s390x/profile_list
    copying bootloaders
    copying: /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
    copying: /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32
    copying: /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk
    copying distros to tftpboot
    copying files for distro: rhel7.3-x86_64
    trying hardlink /var/www/cobbler/ks_mirror/rhel7.3-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/rhel7.3-x86_64/vmlinuz
    trying hardlink /var/www/cobbler/ks_mirror/rhel7.3-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/rhel7.3-x86_64/initrd.img
    copying images
    generating PXE configuration files
    generating PXE menu structure
    copying files for distro: rhel7.3-x86_64
    trying hardlink /var/www/cobbler/ks_mirror/rhel7.3-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/rhel7.3-x86_64/vmlinuz
    trying hardlink /var/www/cobbler/ks_mirror/rhel7.3-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/rhel7.3-x86_64/initrd.img
    Writing template files for rhel7.3-x86_64
    rendering DHCP files
    generating /etc/dhcp/dhcpd.conf
    rendering TFTPD files
    generating /etc/xinetd.d/tftp
    processing boot_files for distro: rhel7.3-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 ***

12.新建一台虚拟机,开始部署安装系统:

(1)开机

(2)然后这一步,在开机延迟时间内,选择rhel7.3:

可以看到引导程序在跑着了,这个就是放在tftp下面的引导文件,来自于syslinux。

还有之前说到的cobbler get-loaders那个错误,不用管它,保证有syslinux就行了,作用就在此。

(3)过程截图展示:

 没有报错就行,等着吧

(4)看最终效果:IP就是从服务器中的dhcp服务那边来的。


————————————————
版权声明:本文为CSDN博主「Dorte7」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/TzuHenry_AZ/article/details/121883604

posted @ 2023-02-07 09:57  angelfzt  阅读(550)  评论(0编辑  收藏  举报