实验:在服务端部署cobbler

实验:在服务端部署cobbler

1.准备工作
wget -P /etc/yum.reposd.d https://mirrors.aliyun.com/repo/Centos-7.repo
wget -P /etc/yum.repos.d/ https://mirrors.aliyun.com/repo/epel-7.repo
yum -y install httpd dhcp tftp cobbler cobbler-web
2.cobbler组件介绍

  • httpd 和cobbler-web 提供cobbler的web管理界面

  • dhcp 提供IP地址分配服务

  • 其中cobbelr是最核心的安装包,期安装后的主要目录如下:

/etc/cobbler                  # cobbler的主配置文件目录,保存了与cobbler相关的配置文件
/etc/cobbler/settings         # cobble服务的默认主配置文件
/etc/cobbler/dhcp.template    # DHCP服务的配置模板,打开DHCP管理后可以根据此文件生成dhcpd.conf文件
/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日志 

3.启动cobbler

[root@Centos7 ~]#systemctl start httpd tftp cobblerd 
[root@Centos7 ~]#systemctl enable httpd tftp cobblerd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
Created symlink from /etc/systemd/system/sockets.target.wants/tftp.socket to /usr/lib/systemd/system/tftp.socket.
Created symlink from /etc/systemd/system/multi-user.target.wants/cobblerd.service to /usr/lib/systemd/system/cobblerd.service.

ss- nutl // 查看TCP80 UDP69端口

cobbler check

  • 运行cobbler check 会出现经典的八项错误,无用的忽略不提
[root@Centos7 ~]#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.
#解决办法修改 /etc/cobbler/settings 文件 server: 192.168.39.7
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.
#解决办法修改 /etc/cobbler/settings 文件 net_server: 192.168.39.7
3 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 
#解决办法 'cobbler get-loaders' 
4 : enable and start rsyncd.service with systemctl
#解决办法
[root@Centos7 ~]#systemctl start rsyncd
[root@Centos7 ~]#systemctl enable rsyncd.service 
Created symlink from /etc/systemd/system/multi-user.target.wants/rsyncd.service to /usr/lib/systemd/system/rsyncd.service.

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
#解决办法
[root@Centos7 ~]#openssl passwd -1 
Password: 
Verifying - Password: 
$1$SKgTybDF$0i0xOuhFqVrhL8nVyFUPm1
vim /etc/cobbler/settings
default_password_crypted: "$1$SKgTybDF$0i0xOuhFqVrhL8nVyFUPm1"

在这里插入图片描述

DHCP配置

  • 修改/etc/cobbler/settings manage_dhcp: 1
  • 重启服务
    [root@Centos7 ~]#systemctl restart cobblerd.service
vim /etc/cobbler/dhcp.template
subnet 192.168.39.0 netmask 255.255.255.0 {
     option routers             192.168.39.1;      // 网关
     option domain-name-servers 180.76.76.76;     // DNS
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        192.168.39.100 192.168.39.254;   //  地址范围
     default-lease-time         21600;
     max-lease-time             43200;
     next-server                $next_server; 
  • systemctl restart cobblerd
  • cobbler rsync
    在这里插入图片描述

配置源镜像

  • cobbler --help
[root@Centos7 ~]#cobbler import --help
Usage: cobbler import [options]

Options:
  -h, --help            show this help message and exit
  --arch=ARCH           OS architecture being imported
  --breed=BREED         the breed being imported
  --os-version=OS_VERSION
                        the version being imported
  --path=PATH           local path or rsync location
  --name=NAME           name, ex 'RHEL-5'
  --available-as=AVAILABLE_AS
                        tree is here, don't mirror
  --kickstart=KICKSTART_FILE
                        assign this kickstart file
  --rsync-flags=RSYNC_FLAGS
  • 导入centos6的ISO
[root@Centos7 ~]#cobbler import --path=/mnt --name=Centos6.0
task started: 2019-11-14_111658_import
task started (id=Media import, time=Thu Nov 14 11:16:58 2019)
Found a candidate signature: breed=redhat, version=rhel6
Found a matching signature: breed=redhat, version=rhel6
Adding distros from path /var/www/cobbler/ks_mirror/Centos6.0:
creating new distro: Centos6.0-x86_64
trying symlink: /var/www/cobbler/ks_mirror/Centos6.0 -> /var/www/cobbler/links/Centos6.0-x86_64
creating new profile: Centos6.0-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/Centos6.0 for Centos6.0-x86_64
processing repo at : /var/www/cobbler/ks_mirror/Centos6.0
need to process repo/comps: /var/www/cobbler/ks_mirror/Centos6.0
looking for /var/www/cobbler/ks_mirror/Centos6.0/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/Centos6.0/repodata
*** TASK COMPLETE ***
[root@Centos7 ~]#ls /var/www/cobbler/ks_mirror/Centos6.0/
CentOS_BuildTag  isolinux                  RPM-GPG-KEY-CentOS-Debug-6
EFI              Packages                  RPM-GPG-KEY-CentOS-Security-6
EULA             RELEASE-NOTES-en-US.html  RPM-GPG-KEY-CentOS-Testing-6
GPL              repodata                  TRANS.TBL
images           RPM-GPG-KEY-CentOS-6

  • 导入centos7的ISO
    mount /dev/sr0 /mnt
    cobbler import --path=/mnt --name=Centos7.10

  • 导入centos8的ISO
    mount /dev/sr0 /mnt
    cobbler import --path=/mnt --name=Centos8.10

  • 查看系统镜像列表

[root@Centos7 ~]#cobbler distro list
   Centos6.0-x86_64
   Centos7.10-x86_64
   Centos8.0-x86_64
  • tree变量
[root@Centos7 /var/lib/cobbler/kickstarts]#cobbler distro report --name=Centos6.0-x86_64
Name                           : Centos6.0-x86_64
Architecture                   : x86_64
TFTP Boot Files                : {}
Breed                          : redhat
Comment                        : 
Fetchable Files                : {}
Initrd                         : /var/www/cobbler/ks_mirror/Centos6.0/images/pxeboot/initrd.img
Kernel                         : /var/www/cobbler/ks_mirror/Centos6.0/images/pxeboot/vmlinuz
Kernel Options                 : {}
Kernel Options (Post Install)  : {}
Kickstart Metadata             : {'tree': 'http://@@http_server@@/cblr/links/Centos6.0-x86_64'}
# 导入ISO文件的时候,这个安装源已经自动加入到元数据里面指定给tree变量
Management Classes             : []
OS Version                     : rhel6
Owners                         : ['admin']
Red Hat Management Key         : <<inherit>>
Red Hat Management Server      : <<inherit>>
Template Files                 : {}

查询官方文档
在这里插入图片描述

  • 关联kickstart 应该文件
    rpm -ql cobbler | grep kickstart // 找到cobbler的kick文件目录

  • 导入做好的ks6.cfg ks7.cfg ks8.cfg应答文件

  • 编辑三个应答文件路径
    url --url=$tree // tree变量的意思上面有
    cobbler profile add --name=Centos6.0MIN --distro=Centos6.0-x86_64 --kickstart=/var/lib/cobbler/kickstarts/ks6.cfg
    cobbler profile add --name=Centos7.0MIN --distro=Centos7.10-x86_64 --kickstart=/var/lib/cobbler/kickstarts/ks7.cfg
    cobbler profile add --name=Centos8.0MIN --distro=Centos8.0-x86_64 --kickstart=/var/lib/cobbler/kickstarts/ks8.cfg

[root@Centos7 ~]#cobbler profile list
   Centos6.0-x86_64
   Centos6.0MIN
   Centos7.0MIN
   Centos7.10-x86_64
   Centos8.0-x86_64
   Centos8.0MIN
[root@Centos7 ~]#cobbler profile remove --name=Centos6.0-x86_64
[root@Centos7 ~]#cobbler profile remove --name=Centos7.10-x86_64
[root@Centos7 ~]#cobbler profile remove --name=Centos8.0-x86_64
[root@Centos7 ~]#cobbler profile list
   Centos6.0MIN
   Centos7.0MIN
   Centos8.0MIN
  • 查看镜像配位文件信息,核对设置对错
    [root@Centos7 ~]#cobbler profile report --name=Centos6.0MIN
    [root@Centos7 ~]#cobbler profile report --name=Centos7.0MIN
    [root@Centos7 ~]#cobbler profile report --name=Centos8.0MIN
[root@Centos7 ~]#cobbler profile report --name=Centos6.0MIN
Name                           : Centos6.0MIN
TFTP Boot Files                : {}
Comment                        : 
DHCP Tag                       : default
Distribution                   : Centos6.0-x86_64
Enable gPXE?                   : 0
Enable PXE Menu?               : 1
Fetchable Files                : {}
Kernel Options                 : {}
Kernel Options (Post Install)  : {}
Kickstart                      : /var/lib/cobbler/kickstarts/ks6.cfg
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                      : xenpv
  • 修改启动头条
    vim /etc/cobbler/pxe/pxedefault.template
    MENU TITLE Cainiao | http://studylinux.xyz/

  • 重启服务并同步
    systemctl restart cobblerd
    cobbler sync
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述

  • 访问web界面
    https://192.168.39.7/cobbler_web
    注意:这个是不安全连接要用https访问
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值