您的位置:首页 > 运维架构 > Linux

Centos7.6 下部署Cobbler

2019-05-28 17:40 2531 查看

1、Cobbler安装

1.1  基础环境准备

查看当前系统版本

[root@localhost ~]# cat /etc/redhat-release 

CentOS Linux release 7.6.1810 (Core) 

关闭selinux防火墙 

[root@localhost ~]# vim /etc/sysconfig/selinux 

# This file controls the state of SELinux on the system.

# SELINUX= can take one of these three values:

# enforcing - SELinux security policy is enforced.

# permissive - SELinux prints warnings instead of enforcing.

# disabled - No SELinux policy is loaded.

SELINUX=disabled

[root@localhost ~]# setenforce 0

关闭ebtables firewalld 防火墙

[root@localhost ~]# systemctl stop ebtables firewalld

[root@localhost ~]# systemctl disable ebtables firewalld

安装base epel源

[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

[root@localhost ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

2. 安装cobbler服务

2.1 安装cobbler及各个组件

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

3. Cobbler安装配置文件概述

/etc/cobbler                                              #配置文件目录

/etc/cobbler/sttings                              #cobbler主配置文件

/etc/cobbler/dhcp.template             #DHCP服务的配置模版

/etc/cobbler/tftpd.template             #TFTP服务的配置模版

/etc/cobbler/rsync.template            #Rsync服务的配置模版

/var/lib/cobbler/kickstarts                #默认存放ksickstarts文件

/var/lib/cobbler/loaders                    #存放的各种引导程序

/var/www/cobbler                               #系统安装镜像目录

/var/www/cobbler/images               #导入的系统镜像列表

/var/www/cobbler/ks_mirror          #导入的系统镜像启动文件

/var/www/cobbler/repo_mirror    #yum源存储目录

/var/log/cobbler                                    #日志目录

/var/log/cobbler/install.log             #客户端系统安装日志

/var/log/cobbler/cobbler.log           #cobbler日志

4. 启动httpd服务以及cobbler

[root@localhost ~]# systemctl start httpd cobblerd

[root@localhost ~]# systemctl enable httpd cobblerd

5. 执行cobbler检测

[root@localhost ~]# 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 : SELinux is enabled. Please review the following wiki page for details on ensuring cobbler works correctly in your SELinux environment:    https://github.com/cobbler/cobbler/wiki/Selinux





4 : change 'disable' to 'no' in /etc/xinetd.d/tftp



                                 [root@localhost ~]# systemctl restart xinetd.service

5 : 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.



6 : enable and start rsyncd.service with systemctl



       
7 : debmirror package is not installed, it will be required to manage debian deployments and repositories





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 cmanor fence-agents to use them



Restart cobblerd and then run 'cobbler sync' to apply changes.

6. 重启cobbler服务,并cobbler sync执行同步

[root@localhost ~]# systemctl restart cobblerd
[root@localhost ~]# cobbler sync

7. 重新检测

[root@localhost ~]# cobbler check
No configuration problems found.  All systems go.  ##没有发现配置问题。 所有系统都去了。
[root@localhost ~]#

8. 使用cobbler管理,配置DHCP服务,修改cobbler配置文件

[root@localhost ~]# vim /etc/cobbler/settings
 manage_dhcp: 1

9. 配置cobbler的DHCP模版

[root@localhost ~]# vim /etc/cobbler/dhcp.template
subnet 192.168.1.0 netmask 255.255.255.0 {
     option routers             192.168.1.1;
     option domain-name-servers 192.168.1.1;
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        192.168.1.100 192.168.1.254;
     default-lease-time         21600;
     max-lease-time             43200;
     next-server                $next_server;

10. 重启一下cobbler服务

[root@localhost ~]# systemctl restart cobblerd


11. 添加管理cobbler的用户

[root@localhost ~]# htdigest -c /etc/cobbler/users.digest Cobbler cobbler
Adding password for cobbler in realm Cobbler.
New password:
Re-type new password:
[root@localhost ~]# systemctl restart cobblerd httpd

12. 浏览器打开web管理界面

解决步骤:

1. SSL 的报错日志如下:

[root@localhost ~]# tail -f /var/log/httpd/ssl_error_log
[Tue May 28 16:54:16.665181 2019] [:error] [pid 7001] [remote 192.168.1.109:44]     self._setup(name)
[Tue May 28 16:54:16.665190 2019] [:error] [pid 7001] [remote 192.168.1.109:44]   File "/usr/lib/python2.7/site-packages/django/conf/__init__.py", line 41, in _setup[Tue May 28 16:54:16.665205 2019] [:error] [pid 7001] [remote 192.168.1.109:44]     self._wrapped = Settings(settings_module)
[Tue May 28 16:54:16.665209 2019] [:error] [pid 7001] [remote 192.168.1.109:44]   File "/usr/lib/python2.7/site-packages/django/conf/__init__.py", line 110, in __init__[Tue May 28 16:54:16.665217 2019] [:error] [pid 7001] [remote 192.168.1.109:44]     mod = importlib.import_module(self.SETTINGS_MODULE)
[Tue May 28 16:54:16.665223 2019] [:error] [pid 7001] [remote 192.168.1.109:44]   File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module[Tue May 28 16:54:16.665445 2019] [:error] [pid 7001] [remote 192.168.1.109:44]     __import__(name)
[Tue May 28 16:54:16.665455 2019] [:error] [pid 7001] [remote 192.168.1.109:44]   File "/usr/share/cobbler/web/settings.py", line 89, in <module>
[Tue May 28 16:54:16.665500 2019] [:error] [pid 7001] [remote 192.168.1.109:44]     from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS
[Tue May 28 16:54:16.665516 2019] [:error] [pid 7001] [remote 192.168.1.109:44] ImportError: cannot import name TEMPLATE_CONTEXT_PROCESSORS

2. 查看cobbler的py配置文件

[root@localhost ~]# sed -n '38,41p' /usr/share/cobbler/web/settings.py
if django.VERSION[0] == 1 and django.VERSION[1] < 4:
    ADMIN_MEDIA_PREFIX = '/media/'
else:
    STATIC_URL = '/media/'
[root@localhost ~]# sed -n '89p' /usr/share/cobbler/web/settings.py
from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS

3. 初步判断应该是pythone-django版本问题

##下载get-pip.py
[root@localhost ~]# wget http://bootstrap.pypa.io/get-pip.py
--2019-05-28 16:59:57--  http://bootstrap.pypa.io/get-pip.py
正在解析主机 bootstrap.pypa.io (bootstrap.pypa.io)... 151.101.76.175, 2a04:4e42:12::175
正在连接 bootstrap.pypa.io (bootstrap.pypa.io)|151.101.76.175|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 301 Moved Permanently
位置:https://bootstrap.pypa.io/get-pip.py [跟随至新的 URL]
--2019-05-28 16:59:58--  https://bootstrap.pypa.io/get-pip.py
正在连接 bootstrap.pypa.io (bootstrap.pypa.io)|151.101.76.175|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1709825 (1.6M) [text/x-python]
正在保存至: “get-pip.py”

100%[=========================================================================================================>] 1,709,825   84.2KB/s 用时 22s

2019-05-28 17:00:21 (76.6 KB/s) - 已保存 “get-pip.py” [1709825/1709825])

##调用本地python运行pip.py脚本
[root@localhost ~]# python get-pip.py
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after t
t date. A future version of pip will drop support for Python 2.7.Collecting pip
  Downloading https://files.pythonhosted.org/packages/5c/e0/be401c003291b56efc55aeba6a80ab790d3d4cece2778288d65323009420/pip-19.1.1-py2.py3-none-
y.whl (1.4MB)     |████████████████████████████████| 1.4MB 134kB/s
Collecting wheel
  Downloading https://files.pythonhosted.org/packages/bb/10/44230dd6bf3563b8f227dbf344c908d412ad2ff48066476672f3a72e174e/wheel-0.33.4-py2.py3-non
any.whlInstalling collected packages: pip, wheel
Successfully installed pip-19.1.1 wheel-0.33.4

##安装pip
[root@localhost ~]# pip install Django==1.8.9
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after t
t date. A future version of pip will drop support for Python 2.7.Collecting Django==1.8.9
  Downloading https://files.pythonhosted.org/packages/a7/a2/f4e7926062f5c61d98e87b9d0365ca1a0fab6be599dbea90ce2fab27f395/Django-1.8.9-py2.py3-non
any.whl (6.2MB)     |████████████████████████████████| 6.2MB 65kB/s
Installing collected packages: Django
  Found existing installation: Django 1.11.20
    Uninstalling Django-1.11.20:
      Successfully uninstalled Django-1.11.20
Successfully installed Django-1.8.9

##查看pip版本号
[root@localhost ~]# python -c "import django; print(django.get_version())"
1.8.9

4. 重启HTTP服务

[root@localhost ~]# systemctl restart httpd

5. 浏览器界面刷新即可

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: