cobbler简单部署过程

1.安装epel以及cobbler

[root@ c7-42 ~]# yum -y install epel-release
[root@ c7-42 ~]# yum -y install cobbler cobbler-web dhcp tftp-server pykickstart httpd rsync xinetd debmirror

2.启动apache和cobblerd,查看是否启动,同时设置开机自启

[root@ c7-42 ~]# systemctl start httpd cobblerd
[root@ c7-42 ~]# systemctl enable httpd cobblerd
[root@ c7-42 ~]# systemctl status httpd cobblerd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2020-05-07 15:19:32 CST; 2min 32s ago
     Docs: man:httpd(8)
           man:apachectl(8)
 Main PID: 25985 (httpd)
   Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"
   CGroup: /system.slice/httpd.service
           ├─25985 /usr/sbin/httpd -DFOREGROUND
           ├─25989 (wsgi:cobbler_w -DFOREGROUND
           ├─25990 /usr/sbin/httpd -DFOREGROUND
           ├─25991 /usr/sbin/httpd -DFOREGROUND
           ├─25992 /usr/sbin/httpd -DFOREGROUND
           ├─25993 /usr/sbin/httpd -DFOREGROUND
           └─25994 /usr/sbin/httpd -DFOREGROUND

May 07 15:19:31 c7-42 systemd[1]: Starting The Apache HTTP Server...
May 07 15:19:32 c7-42 httpd[25985]: AH00558: httpd: Could not reliably determine the server's fully qualified doma...essage
May 07 15:19:32 c7-42 systemd[1]: Started The Apache HTTP Server.

● cobblerd.service - Cobbler Helper Daemon
   Loaded: loaded (/usr/lib/systemd/system/cobblerd.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2020-05-07 15:19:31 CST; 2min 33s ago
  Process: 25987 ExecStartPost=/usr/bin/touch /usr/share/cobbler/web/cobbler.wsgi (code=exited, status=0/SUCCESS)
 Main PID: 25986 (cobblerd)
   CGroup: /system.slice/cobblerd.service
           └─25986 /usr/bin/python2 -s /usr/bin/cobblerd -F

May 07 15:19:31 c7-42 systemd[1]: Starting Cobbler Helper Daemon...
May 07 15:19:31 c7-42 systemd[1]: Started Cobbler Helper Daemon.
Hint: Some lines were ellipsized, use -l to show in full.

3.检查

[root@ c7-42 ~]# 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 : change 'disable' to 'no' in /etc/xinetd.d/tftp
4 : 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.
5 : enable and start rsyncd.service with systemctl
6 : comment out 'dists' on /etc/debmirror.conf for proper debian support
7 : comment out 'arches' on /etc/debmirror.conf for proper debian support
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.

4.如果出现如上问题,进行修改配置文件并重新启动

[root@ c7-42 ~]# sed -ri '/allow_dynamic_settings:/c\allow_dynamic_settings: 1' /etc/cobbler/settings
[root@ c7-42 ~]# grep allow_dynamic_settings /etc/cobbler/settings
allow_dynamic_settings: 1
[root@ c7-42 ~]# systemctl restart cobblerd
[root@ c7-42 ~]# cobbler setting edit --name=next_server --value=10.0.0.42
[root@ c7-42 ~]# cobbler setting edit --name=server --value=10.0.0.42
[root@ c7-42 ~]# sed -ri '/disable/c\disable = no' /etc/xinetd.d/tftp
[root@ c7-42 ~]# systemctl enable xinetd
[root@ c7-42 ~]# systemctl restart xinetd
[root@ c7-42 ~]# cobbler get-loaders
task started: 2020-05-07_153202_get_loaders
task started (id=Download Bootloader Content, time=Thu May  7 15:32:02 2020)
downloading https://cobbler.github.io/loaders/README to /var/lib/cobbler/loaders/README
downloading https://cobbler.github.io/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilo
downloading https://cobbler.github.io/loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yaboot
downloading https://cobbler.github.io/loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.syslinux
downloading https://cobbler.github.io/loaders/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64.efi
downloading https://cobbler.github.io/loaders/yaboot-1.3.17 to /var/lib/cobbler/loaders/yaboot
downloading https://cobbler.github.io/loaders/pxelinux.0-3.86 to /var/lib/cobbler/loaders/pxelinux.0
downloading https://cobbler.github.io/loaders/menu.c32-3.86 to /var/lib/cobbler/loaders/menu.c32
downloading https://cobbler.github.io/loaders/grub-0.97-x86.efi to /var/lib/cobbler/loaders/grub-x86.efi
downloading https://cobbler.github.io/loaders/grub-0.97-x86_64.efi to /var/lib/cobbler/loaders/grub-x86_64.efi
*** TASK COMPLETE ***
[root@ c7-42 ~]# systemctl start rsyncd
[root@ c7-42 ~]# systemctl enable rsyncd
Created symlink from /etc/systemd/system/multi-user.target.wants/rsyncd.service to /usr/lib/systemd/system/rsyncd.service.
[root@ c7-42 ~]#  sed -i 's#@dists="sid";#\#@dists="sid";#gp' /etc/debmirror.conf
[root@ c7-42 ~]# sed -i 's#@arches="i386";#\#@arches="i386";#g' /etc/debmirror.conf
[root@ c7-42 ~]# openssl passwd -1 -salt `openssl rand -hex 4` '123456'
$1$b7902c32$PQzi1uStm5dJwCYfvLFQH0
[root@ c7-42 ~]# cobbler setting edit --name=default_password_crypted --value='$1$random-p$mzxQ/Sx848sXgvfwJCoZM0'
[root@ c7-42 ~]# yum -y install fence-agents

修改完以后再次重启cobbler并检查

[root@ c7-42 ~]# systemctl restart cobblerd
[root@ c7-42 ~]# cobbler sync
task started: 2020-05-07_155140_sync
task started (id=Sync, time=Thu May  7 15:51:40 2020)
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.efi -> /var/lib/tftpboot/grub/grub-x86.efi
trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.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 ***
[root@ c7-42 ~]# cobbler check
No configuration problems found.  All systems go.

5. 配置dhcp

[root@ c7-42 ~]# cobbler setting edit --name=manage_dhcp --value=1
[root@ c7-42 ~]# vim /etc/cobbler/dhcp.template
###修改如下配置
	subnet 10.0.0.0 netmask 255.255.255.0 {
	     option routers             10.0.0.254;
	     option domain-name-servers 223.5.5.5;
	     option subnet-mask         255.255.255.0;
	     range dynamic-bootp        10.0.0.100 10.0.0.200;
[root@ c7-42 ~]# cobbler sync
task started: 2020-05-07_155731_sync
task started (id=Sync, time=Thu May  7 15:57:31 2020)
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.efi
removing: /var/lib/tftpboot/grub/grub-x86_64.efi
removing: /var/lib/tftpboot/grub/efidefault
removing: /var/lib/tftpboot/s390x/profile_list
copying bootloaders
trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.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 ***

服务端配置完毕。

6.导入镜像

[root@ c7-42 ~]# mount /dev/sr0 /mnt
[root@ c7-42 ~]# cobbler import --path=/mnt/ --name=CentOS-7.7.1908 --arch=x86_64
task started: 2020-05-07_160234_import
task started (id=Media import, time=Thu May  7 16:02:34 2020)
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.7.1908-x86_64:
creating new distro: CentOS-7.7.1908-x86_64
trying symlink: /var/www/cobbler/ks_mirror/CentOS-7.7.1908-x86_64 -> /var/www/cobbler/links/CentOS-7.7.1908-x86_64
creating new profile: CentOS-7.7.1908-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.7.1908-x86_64 for CentOS-7.7.1908-x86_64
processing repo at : /var/www/cobbler/ks_mirror/CentOS-7.7.1908-x86_64
need to process repo/comps: /var/www/cobbler/ks_mirror/CentOS-7.7.1908-x86_64
looking for /var/www/cobbler/ks_mirror/CentOS-7.7.1908-x86_64/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/CentOS-7.7.1908-x86_64/repodata
*** TASK COMPLETE ***

查看镜像

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

重启cobbler,进行同步

[root@ c7-42 ~]# systemctl restart cobblerd
[root@ c7-42 ~]# cobbler sync
task started: 2020-05-07_161526_sync
task started (id=Sync, time=Thu May  7 16:15:26 2020)
running pre-sync triggers
cleaning trees
removing: /var/www/cobbler/images/CentOS-7.7.1908-x86_64
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/grub-x86.efi
removing: /var/lib/tftpboot/grub/grub-x86_64.efi
removing: /var/lib/tftpboot/grub/efidefault
removing: /var/lib/tftpboot/images/CentOS-7.7.1908-x86_64
removing: /var/lib/tftpboot/s390x/profile_list
copying bootloaders
trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
copying distros to tftpboot
copying files for distro: CentOS-7.7.1908-x86_64
trying hardlink /var/www/cobbler/ks_mirror/CentOS-7.7.1908-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/CentOS-7.7.1908-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/CentOS-7.7.1908-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/CentOS-7.7.1908-x86_64/initrd.img
copying images
generating PXE configuration files
generating PXE menu structure
copying files for distro: CentOS-7.7.1908-x86_64
trying hardlink /var/www/cobbler/ks_mirror/CentOS-7.7.1908-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/CentOS-7.7.1908-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/CentOS-7.7.1908-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/CentOS-7.7.1908-x86_64/initrd.img
Writing template files for CentOS-7.7.1908-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.7.1908-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 ***

7.定制kickstart文件

[root@ c7-42 ~]#  cd /var/lib/cobbler/kickstarts/
[root@ c7-42 kickstarts]# cp sample_end.ks centos7.7.ks
[root@ c7-42 kickstarts]# vim centos7.7.ks
###通过命令指定ks文件
[root@ c7-42 kickstarts]# cobbler profile edit --name=CentOS-7.7.1908-x86_64 --distro=CentOS-7.7.1908-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos7.7.ks
###验证
[root@ c7-42 kickstarts]# cobbler profile report --name=CentOS-7.7.1908-x86_64 | grep Kickstart
Kickstart                      : /var/lib/cobbler/kickstarts/centos7.7.ks
Kickstart Metadata             : {}
###修改完配置文件需要进行同步
[root@ c7-42 kickstarts]# cobbler sync

8.创建新的虚拟机进行测试

cobbler默认的web管理界面为https:ip/cobbler_web,账号和密码默认为cobbler

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值