cobbler自建過(guò)程

說(shuō)明:cobbler server安裝環(huán)境是Red Hat Enterprise Linux Server release 7.2,使用的centos 7的yum源。

1)安裝yum源、epel源和cobbler

①、優(yōu)先設(shè)置yum源(由于redhat系統(tǒng)默認(rèn)沒(méi)有配置yum源,yum源關(guān)系到系統(tǒng)是否能夠啟用repos,進(jìn)而影響到下一步的epel包設(shè)置,此處用本地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的基本源中,需要導(dǎo)入EPEL源升級(jí)軟件包,?確保epel-release包的版本為最新,當(dāng)前最新版本為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

③、關(guān)閉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服務(wù)

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

⑤、設(shè)置各個(gè)服務(wù)的開(kāi)機(jī)自啟動(dòng)并開(kāi)啟服務(wù)

[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

出現(xiàn)以上信息說(shuō)明安裝成功,按照提示修改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” ?? #此處修改為本機(jī)地址(DHCP服務(wù)器地址)

將“server: 127.0.0.1”修改為“server: 192.168.1.131” ? ? ? ? ? ? ? ? ? ?? #此處修改為本機(jī)地址(cobbler服務(wù)器地址)

將“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? (加載部分缺失的網(wǎng)絡(luò)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服務(wù):

[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系統(tǒng)則需要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.

注意,一定要修復(fù)完全部的configuration problems,否則tftp會(huì)出現(xiàn)連接超時(shí),cobbler無(wú)法通過(guò)PXE進(jìn)行系統(tǒng)批量安裝的操作。

[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在同一網(wǎng)段

# vi /etc/cobbler/dhcp.template

[root@Cobbler ~]# systemctl restart dhcpd.service ? ? # 啟動(dòng)DHCP服務(wù)

[root@Cobbler ~]# cobbler sync

task started: 2019-02-23_233251_sync

.....................此處內(nèi)容省略.....................

*** TASK COMPLETE ***

二、導(dǎo)入ISO鏡像

1.?上傳ISO鏡像至服務(wù)器

2.?創(chuàng)建文件夾&&掛載ISO鏡像到/mnt/ubuntu16.04目錄

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

4.?從iso中導(dǎo)入客戶端的OS。這將自動(dòng)設(shè)置了“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





問(wèn)題總結(jié):

1、導(dǎo)入鏡像時(shí)報(bào)錯(cuò)

[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: <class 'cobbler.cexceptions.CX'>

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 !!!

修復(fù)建議:檢查path的路徑是否正確,參數(shù)中命名最好不要有空格

2、啟動(dòng)cobbler和http服務(wù)后無(wú)法登陸cobbler web界面

查看日志報(bào)錯(cuò)如下:# 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 <module>

[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

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容