Cobbler部署

环境介绍

centos7 64位
外网:10.0.0.42
内网:176.16.1.42
说明:虚拟机网卡采用NAT模式或者仅主机模式,不要使用桥接模式,因为后面会搭建DHCP服务器,在同一个局域网多个DHCP服务会有冲突。VMware的NAT模式的dhcp服务也关闭,避免干扰。

1、安装

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

cobbler          #cobbler程序包
cobbler-web      #cobbler的web服务包
pykickstart      #cobbler检查kickstart语法错误
httpd            #Apache web服务
dhcp             #Dhcp服务
tftp             #tftp服务
xinetd          #诸多服务的超级守护进程

2、启动cobbler及httpd并加入开机启动

[root@ c7-42 ~]# systemctl start httpd cobblerd
[root@ c7-42 ~]# systemctl enable httpd cobblerd

3、配置cobbler

检查Cobbler的配置,如果看不到下面的结果,再次重启cobbler。

[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 kickstartingfeatures 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.

看到上面出现的问题,然后一个一个的进行解决,先进行设置为可以动态配置,也可以直接更改配置文件。

[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

逐个解决上面的问题

#1.配置server地址
[root@ c7-42 ~]# cobbler setting edit --name=server --value=10.0.0.42

#2.配置next_server地址
[root@ c7-42 ~]# cobbler setting edit --name=next_server --value=10.0.0.42

#3.配置xinetd管理tftp
[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

#4.boot-loaders
[root@ c7-42 ~]# cobbler get-loaders

#5.启动rsync
[root@ c7-42 ~]# systemctl start rsyncd
[root@ c7-42 ~]# systemctl enable rsyncd

#6和7.debian support
[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

#8.default_password_crypted
# 注意:这里设置的密码是clbbler安装完系统后,默认root用户初始化登录密码,用 openssl 生成一串密码后加入到 cobbler 的配置文件(/etc/cobbler/settings)里,替换 default_password_crypted 字段
[root@ c7-42 ~]# openssl passwd -1 -salt `openssl rand -hex 4` '123456'
$1$4f5894cc$Gs7/0cTiy/T8t9JwXX3qX0
[root@ c7-42 ~]# cobbler setting edit --name=default_password_crypted --value='$1$random-p$mzxQ/Sx848sXgvfwJCoZM0'

#9.安装fencing tools
[root@ c7-42 ~]# yum -y install fence-agents

#解决完后再次检查
[root@ c7-42 ~]# systemctl restart cobblerd
[root@ c7-42 ~]# cobbler sync
[root@ c7-42 ~]# cobbler check
No configuration problems found.  All systems go.

4、配置DHCP

[root@ c7-42 ~]# cobbler setting edit --name=manage_dhcp --value=1
[root@ c7-42 ~]#  vim /etc/cobbler/dhcp.template
##修改的21到25行
subnet 10.0.0.0 netmask 255.255.255.0 {    #这里改为分配的网段和掩码
     option routers             10.0.0.254;  #如果有网关,这里改为网关地址
     option domain-name-servers 223.5.5.5;   #如果有DNS,这里改为DNS地址
     option subnet-mask         255.255.255.0; #改为分配的IP的掩码
     range dynamic-bootp        10.0.0.100 10.0.0.200; #改为分配的IP的范围

5、同步cobbler配置

[root@ c7-42 ~]# cobbler sync

查看一下dhcp,查看cobbler是否可以管理dhcp

[root@ c7-42 ~]# cat /etc/dhcp/dhcpd.conf
# ******************************************************************
# Cobbler managed dhcpd.conf file
# generated from cobbler dhcp.conf template (Mon Apr 27 07:41:35 2020)
# Do NOT make changes to /etc/dhcpd.conf. Instead, make your changes
# in /etc/cobbler/dhcp.template, as /etc/dhcpd.conf will be
# overwritten.
# ******************************************************************

ddns-update-style interim;

allow booting;
allow bootp;

ignore client-updates;
set vendorclass = option vendor-class-identifier;

option pxe-system-type code 93 = unsigned integer 16;

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;
     default-lease-time         21600;
     max-lease-time             43200;
     next-server                10.0.0.42;
     class "pxeclients" {
          match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
          if option pxe-system-type = 00:02 {
                  filename "ia64/elilo.efi";
          } else if option pxe-system-type = 00:06 {
                  filename "grub/grub-x86.efi";
          } else if option pxe-system-type = 00:07 {
                  filename "grub/grub-x86_64.efi";
          } else if option pxe-system-type = 00:09 {
                  filename "grub/grub-x86_64.efi";
          } else {
                  filename "pxelinux.0";
          }
     }

}

# group for Cobbler DHCP tag: default
group {
}

这时候创建一个新虚拟机可以获取到如下信息,没有镜像选择,只能从本地启动。
在这里插入图片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章