Cobbler快速部署

2017-06-02  本文已影响0人  追阳_41

Cobbler 配置

1. 环境描述

2. 安装部署

  1. 安装前请先配好epel源,然后使用yum进行安装:

    rpm -ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm
    yum install cobbler cobbler-web pykickstart debmirror dhcp tftp-server httpd syslinux
    
  2. 安装好后,把/var/lib/tftpboot/ 目标下所有文件移动到另一位置,因为此目录下的文件全部由cobbler自己来生成。

    mkdir /root/pxeboot
    mv /var/lib/tftpboot/* /root/pxeboot/
    
  3. 这时再编辑/etc/dhcp/dhcpd.conf,内容如下:

    [root@localhost ~]# cat /etc/dhcp/dhcpd.conf
    #
    # DHCP Server Configuration file.
    #   see /usr/share/doc/dhcp*/dhcpd.conf.example
    #   see dhcpd.conf(5) man page
    #
    option domain-name "localhost.localdomain";
    option domain-name-servers 114.114.114.114,223.6.6.6;
    
    default-lease-time 3600;
    max-lease-time 7200;
    
    log-facility local7;
    
    subnet 172.16.1.0 netmask 255.255.255.0 {
        range 172.16.1.2 172.16.1.20;
        option routers 172.16.1.1;
        filename "pxelinux.0";
    }
    
  4. 确保第二块网卡网络配置正确,这里仅作测试临时配置:

    ifconfig enp6s0f1 172.16.1.1/24
    
  5. 依次启动服务:

    systemctl start dhcpd.service && systemctl enable dhcpd.service
    systemctl start cobblerd.service && systemctl enable cobblerd.service
    systemctl start httpd.service && systemctl enable httpd.service
    systemctl start rsyncd.service && systemctl enable rsyncd.service
    
  6. 环境检查修改:

    cobbler check
    

接着重启cobblerd服务,然后再执行cobbler check进行检查,直到只剩可忽略的问题:

    systemctl restart cobblerd.service
    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, 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.
        2 : 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.

3. cobbler_web

设置cobbler_web登录页面的用户和密码:

    htdigest /etc/cobbler/users.digest "Cobbler" cobbler
    Changing password for user cobbler in realm Cobbler
    New password: 
    Re-type new password: 

此时正常来说可以从浏览器中通过http(s)://YOUR_COBBLERD_IP/cobbler_web访问。

4. 镜像导入

在系统中将CentOS 7.3 镜像导入,此功能在cobbler_web上也应该可以操作,但没有研究过:

    mkdir /media/cdrom
    mount /var/local/iso/CentOS-7-x86_64-DVD-1611.iso /media/cdrom
    cobbler import --name="CentOS-7-x86_64-DVD-1611" --path=/media/cdrom

接着以同样的方式导入CentOS 6.5,此时在命令行可执行cobbler distro list 可查看到已经导入进来的镜像。默认在导入镜像的同时,已经有创建好了对应的profile,可以安装使用了,默认是最小化安装。profile可执行cobbler profile list查看。
如果要自定义profile,可以用下面命令操作:

    cobbler profile add --name="CentOS-7-x86_64-web" --distro=CentOS-7-x86_64-DVD-1611 --kickstart=/var/lib/cobbler/kickstarts/centos7-web.ks
    cobbler sync

最后要特别注意,每次操作后都要执行cobbler sync来同步操作生效。上面要用到的centos7-web.ks文件制作,这里不再介绍,可以通过system-config-kickstart图形化工具来生成和编辑,可以使用yum来安装:

    yum install system-config-kickstart
    
    # 启动可执行:
    system-config-kickstart

关于profile、ks文件制作、cobbler sync同步等,建议在cobbler_web界面上操作,比较方便。

个人同步博客地址

上一篇 下一篇

猜你喜欢

热点阅读