cobbler自建过程

说明:cobbler server安装环境是Red Hat Enterprise Linux Server release 7.2,使用的centos 7的yum源。

1)安装yum源、epel源和cobbler

①、优先设置yum源(由于redhat系统默认没有配置yum源,yum源关系到系统是否能够启用repos,进而影响到下一步的epel包设置,此处用本地yum源也可以)

[root@Cobbler yum.repos.d]# more 163.repo

[163]

name=163.repo

baseurl=http://mirrors.163.com/centos/7/os/x86_64/

gpgcheck=0

enabled=1

②、Cobbler不在CentOS的基本源中,需要导入EPEL源升级软件包, 确保epel-release包的版本为最新,当前最新版本为7-11:

[root@cobbler ~]# yum -y install http://mirrors.163.com/centos/7/extras/x86_64/Packages/epel-release-7-11.noarch.rpm

[root@cobbler ~]# yum repolist

③、关闭selinux和防火墙(firewall or iptables)

[root@Cobbler ~]# systemctl disable firewalld.service

[root@Cobbler ~]# setenforce 0

[root@Cobbler ~]# vim /etc/selinux/config 

SELINUX=disabled  (此处修改为disabled)

④、安装cobbler、http、dhcp、tftp、xinetd、rsync服务

[root@Cobbler ~]# yum install cobbler cobbler-web dhcp tftp-server pykickstart httpd xinetd  rsync -y     

⑤、设置各个服务的开机自启动并开启服务

[root@Cobbler ~]# systemctl start httpd.service cobblerd.service xinetd.service rsyncd.service

[root@Cobbler ~]# systemctl enable httpd.service cobblerd.service xinetd.service rsyncd.service

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/multi-user.target.wants/cobblerd.service to /usr/lib/systemd/system/cobblerd.service.

Created symlink from /etc/systemd/system/multi-user.target.wants/rsyncd.service to /usr/lib/systemd/system/rsyncd.service.

2)配置cobbler

检查cobbler:

[root@Cobbler ~]# 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 : debmirror package is not installed, it will be required to manage debian deployments and repositories

6 : 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

7 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them

出现以上信息说明安装成功,按照提示修改cobbler的配置文件:

[root@cobbler ~]# vim /etc/cobbler/settings

# if you do not set this correctly, this will be manifested in TFTP open timeouts.

将“next_server: 127.0.0.1”修改为“next_server: 192.168.1.131”    #此处修改为本机地址(DHCP服务器地址)

将“server: 127.0.0.1”修改为“server: 192.168.1.131”                      #此处修改为本机地址(cobbler服务器地址)

将“manage_dhcp: 0 ”修改为1                    # set to 1 to enable Cobbler's DHCP management features.

将“manage_rsync: 1” 修改为1                  # set to 1 to enable Cobbler's RSYNC management features.

[root@Cobbler ~]# cobbler get-loaders  (加载部分缺失的网络boot-loaders)

task started: 2019-02-23_215401_get_loaders

task started (id=Download Bootloader Content, time=Sat Feb 23 21:54:01 2019)

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@Cobbler ~]#

[root@Cobbler ~]# openssl passwd -1 -salt 'mbcloud' 'Cmb@2019'

$1$mbcloud$j6ma9giXVRXZq8cwbXmT5.

[root@Cobbler ~]# vim /etc/cobbler/settings 

将“default_password_crypted: "$1$mF86/UHC$WvcIcX2t6crBz2onWxyac."”修改为“default_password_crypted: "$1$mbcloud$j6ma9giXVRXZq8cwbXmT5."”

[root@Cobbler ~]# vim /etc/xinetd.d/tftp

将“disable                = yes”修改为“disable                = no”

重启rsync服务:

[root@Cobbler ~]# systemctl start rsyncd.service

[root@Cobbler ~]# systemctl enable rsyncd.service

Created symlink from /etc/systemd/system/multi-user.target.wants/rsyncd.service to /usr/lib/systemd/system/rsyncd.service.

12. 如果要部署Debian/Ubuntu系统则需要debmirror软件包

# yum -y install ed patch perl perl-Compress-Zlib perl-Cwd perl-Digest-MD5 perl-LockFile-Simple perl-libwww-perl  perl-Digest-SHA  perl-Net-INET6Glue

# wget http://mirrors.ustc.edu.cn/epel/7Server/x86_64/Packages/d/debmirror-2.30-1.el7.noarch.rpm

[root@Cobbler ~]# rpm -ivh debmirror-2.30-1.el7.noarch.rpm

Preparing...                          ################################# [100%]

Updating / installing...

  1:debmirror-2.30-1.el7            ################################# [100%]

[root@Cobbler ~]# systemctl restart cobblerd.service

[root@Cobbler ~]# yum install fence-agents

[root@Cobbler ~]# cobbler check

No configuration problems found.  All systems go.

注意,一定要修复完全部的configuration problems,否则tftp会出现连接超时,cobbler无法通过PXE进行系统批量安装的操作。

[root@Cobbler ~]# ls /etc/cobbler/

auth.conf      completions      genders.template      ldap     named.template  reporting      secondary.template  users.conf    zone.template    cheetah_macros  dhcp.template    import_rsync_whitelist  modules.conf  power    rsync.exclude  settings   users.digest  zone_templates   cobbler_bash   dnsmasq.template  iso  mongodb.conf  pxe    rsync.template  tftpd.template      version

[root@Cobbler ~]#

11. 修改DHCP模板,确保DHCP分配的地址和Cobbler在同一网段

# vi /etc/cobbler/dhcp.template

cobbler自建过程_第1张图片

[root@Cobbler ~]# systemctl restart dhcpd.service     # 启动DHCP服务

[root@Cobbler ~]# cobbler sync

task started: 2019-02-23_233251_sync

.....................此处内容省略.....................

*** TASK COMPLETE ***

二、导入ISO镜像

1. 上传ISO镜像至服务器

2. 创建文件夹&&挂载ISO镜像到/mnt/ubuntu16.04目录

[root@Cobbler ~]# mkdir /mnt/ubuntu16.4 && mount /dev/cdrom /mnt/ubuntu16.4

4. 从iso中导入客户端的OS。这将自动设置了“x86_64”,并将其命名为ubuntu12.04。

# cobbler import --path=/mnt/ubuntu16.04/ --name=ubuntu16.04 --arch=x86_64

可查看/var/www/cobbler/ks_mirror/ubuntu16.04-x86_64/目录文件生成情况。

# cobbler sync

# cobbler list





问题总结:

1、导入镜像时报错

[root@Cobbler ~]# cobbler import --path=/mnt/ubuntu16.04/ --name=ubuntu16.04 --arch=x86_64

task started: 2019-02-23_234323_import

task started (id=Media import, time=Sat Feb 23 23:43:23 2019)

Exception occured:

Exception value: 'Command failed'

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 227, in runner

    self.logger

  File "/usr/lib/python2.7/site-packages/cobbler/api.py", line 876, in import_tree

    utils.run_this(rsync_cmd, (spacer, mirror_url, path), self.logger)

  File "/usr/lib/python2.7/site-packages/cobbler/utils.py", line 899, in run_this

    die(logger,"Command failed")

  File "/usr/lib/python2.7/site-packages/cobbler/utils.py", line 114, in die

    raise CX(msg)

!!! TASK FAILED !!!

修复建议:检查path的路径是否正确,参数中命名最好不要有空格

2、启动cobbler和http服务后无法登陆cobbler web界面

cobbler自建过程_第2张图片

查看日志报错如下:# tail -f /var/log/httpd/ssl_error_log

[Sun Feb 24 00:08:13.454823 2019] [:error] [pid 10138] [remote 192.168.16.1:16]    self._setup(name)

[Sun Feb 24 00:08:13.454829 2019] [:error] [pid 10138] [remote 192.168.16.1:16]  File "/usr/lib/python2.7/site-packages/django/conf/__init__.py", line 41, in _setup

[Sun Feb 24 00:08:13.454838 2019] [:error] [pid 10138] [remote 192.168.16.1:16]    self._wrapped = Settings(settings_module)

[Sun Feb 24 00:08:13.454843 2019] [:error] [pid 10138] [remote 192.168.16.1:16]  File "/usr/lib/python2.7/site-packages/django/conf/__init__.py", line 110, in __init__

[Sun Feb 24 00:08:13.454851 2019] [:error] [pid 10138] [remote 192.168.16.1:16]    mod = importlib.import_module(self.SETTINGS_MODULE)

[Sun Feb 24 00:08:13.454856 2019] [:error] [pid 10138] [remote 192.168.16.1:16]  File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module

[Sun Feb 24 00:08:13.454867 2019] [:error] [pid 10138] [remote 192.168.16.1:16]    __import__(name)

[Sun Feb 24 00:08:13.454872 2019] [:error] [pid 10138] [remote 192.168.16.1:16]  File "/usr/share/cobbler/web/settings.py", line 89, in

[Sun Feb 24 00:08:13.454880 2019] [:error] [pid 10138] [remote 192.168.16.1:16]    from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS

[Sun Feb 24 00:08:13.454896 2019] [:error] [pid 10138] [remote 192.168.16.1:16] ImportError: cannot import name TEMPLATE_CONTEXT_PROCESSORS



yum -y install python2-pip

你可能感兴趣的:(cobbler自建过程)