Centos7.6 下部署Cobbler

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管理界面

9532412c-726a-4456-bc56-cee34f3104b5

解決步驟:

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. 瀏覽器界面刷新即可

0ec1ee39-efb4-4751-8269-304391710a6c

79946132-7bde-453e-aeab-910eb8d3a128

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