问题1:执行cobbler sync同步命令报错,提示dhcpd服务错误和Python源码错误

[root@server ~]# cobbler sync    #<===执行cobbler同步的时候,报Python源码和dhcpd服务错误
task started: 2019-04-16_184408_sync
task started (id=Sync, time=Tue Apr 16 18:44:08 2019)
running pre-sync triggers
cleaning trees
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/grub-x86.efi
removing: /var/lib/tftpboot/grub/grub-x86_64.efi
removing: /var/lib/tftpboot/grub/efidefault
removing: /var/lib/tftpboot/s390x/profile_list
copying bootloaders
trying hardlink /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
copying: /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
trying hardlink /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32
copying: /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32
trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
copying distros to tftpboot
copying images
generating PXE configuration files
generating PXE menu structure
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
rendering TFTPD files
generating /etc/xinetd.d/tftp
cleaning link caches
running post-sync triggers
running python triggers from /var/lib/cobbler/triggers/sync/post/*
running python trigger cobbler.modules.sync_post_restart_services
running: dhcpd -t -q
received on stdout:
received on stderr:
running: service dhcpd restart
received on stdout:
received on stderr: Redirecting to /bin/systemctl restart dhcpd.service
Job for dhcpd.service failed because the control process exited with error code. See "systemctl status dhcpd.service" and "journalctl -xe" for details.
Exception occured: <class 'cobbler.cexceptions.CX'>
Exception value: 'cobbler trigger failed: cobbler.modules.sync_post_restart_services'
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 181, in runner
return self.remote.api.sync(self.options.get("verbose",False),logger=self.logger)
File "/usr/lib/python2.7/site-packages/cobbler/api.py", line 763, in sync
return sync.run()
File "/usr/lib/python2.7/site-packages/cobbler/action_sync.py", line 144, in run
utils.run_triggers(self.api, None, "/var/lib/cobbler/triggers/sync/post/*", logger=self.logger)
File "/usr/lib/python2.7/site-packages/cobbler/utils.py", line 928, in run_triggers
raise CX("cobbler trigger failed: %s" % m.__name__) !!! TASK FAILED !!!

解决办法:

1.修改 /etc/cobbler/dhcp.template,

[root@server ~]# cat /etc/dhcp/dhcpd.conf       #<===查看dhcpd服务配置文件,因hcpd服务由cobbler服务管理,所以需修改/etc/cobbler/dhcp.template此文件才生效
# ******************************************************************
# Cobbler managed dhcpd.conf file
# generated from cobbler dhcp.conf template (Tue Apr 16 10:44:09 2019)
# Do NOT make changes to /etc/dhcpd.conf. Instead, make your changes #<===注释说的很明白
# in /etc/cobbler/dhcp.template, as /etc/dhcpd.conf will be
# overwritten.
# ****************************************************************** [root@server ~]# cat /etc/cobbler/dhcp.template #<===修改dhcpd服务器为本机IP地址(就改动2个地方,很简单)
# ******************************************************************
# Cobbler managed dhcpd.conf file
#
# generated from cobbler dhcp.conf template ($date)
# Do NOT make changes to /etc/dhcpd.conf. Instead, make your changes
# in /etc/cobbler/dhcp.template, as /etc/dhcpd.conf will be
# overwritten.
#
# ****************************************************************** ddns-update-style interim; allow booting;
allow bootp; ignore client-updates;
set vendorclass = option vendor-class-identifier; option pxe-system-type code 93 = unsigned integer 16; subnet 10.0.0.0 netmask 255.255.255.0 { #<===这里需改为dhcpd服务器的网段地址
option subnet-mask 255.255.255.0;
range dynamic-bootp 10.0.0.100 10.0.0.150; #<===这个需改为dhcp服务器地址(就这2个地方需改动,其他无需改动)
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
class "pxeclients" {
match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
if option pxe-system-type = 00:02 {
filename "ia64/elilo.efi";
} else if option pxe-system-type = 00:06 {
filename "grub/grub-x86.efi";
} else if option pxe-system-type = 00:07 {
filename "grub/grub-x86_64.efi";
} else if option pxe-system-type = 00:09 {
filename "grub/grub-x86_64.efi";
} else {
filename "pxelinux.0";
}
} } #for dhcp_tag in $dhcp_tags.keys():
## group could be subnet if your dhcp tags line up with your subnets
## or really any valid dhcpd.conf construct ... if you only use the
## default dhcp tag in cobbler, the group block can be deleted for a
## flat configuration
# group for Cobbler DHCP tag: $dhcp_tag
group {
#for mac in $dhcp_tags[$dhcp_tag].keys():
#set iface = $dhcp_tags[$dhcp_tag][$mac]
host $iface.name {
#if $iface.interface_type == "infiniband":
option dhcp-client-identifier = $mac;
#else
hardware ethernet $mac;
#end if
#if $iface.ip_address:
fixed-address $iface.ip_address;
#end if
#if $iface.hostname:
option host-name "$iface.hostname";
#end if
#if $iface.netmask:
option subnet-mask $iface.netmask;
#end if
#if $iface.gateway:
option routers $iface.gateway;
#end if
#if $iface.enable_gpxe:
if exists user-class and option user-class = "gPXE" {
filename "http://$cobbler_server/cblr/svc/op/gpxe/system/$iface.owner";
} else if exists user-class and option user-class = "iPXE" {
filename "http://$cobbler_server/cblr/svc/op/gpxe/system/$iface.owner";
} else {
filename "undionly.kpxe";
}
#else
filename "$iface.filename";
#end if
## Cobbler defaults to $next_server, but some users
## may like to use $iface.system.server for proxied setups
next-server $next_server;
## next-server $iface.next_server;
}
#end for
}
#end for 

接着,修改yum安装cobbler的Python源码(cobbler在centos7上yum安装的话,会有问题)

[root@server tmp]# mkdir ~/123
[root@server modules]# cd /usr/lib/python2.7/site-packages/cobbler/modules/
[root@server modules]# cp sync_post_restart_services.py ~/123/
[root@server modules]# mv sync_post_restart_services.py sync_post_restart_services.py.original #<===操作前先备份
[root@server modules]# mv sync_post_restart_services.pyo sync_post_restart_services.pyo.original
[root@server modules]# mv sync_post_restart_services.pyc sync_post_restart_services.pyc.original
[root@server modules]# cd ~/123
[root@server 123]# vi sync_post_restart_services.py #<===此步骤主要修改Python源码,更改dhcpd由systemd管理
import cobbler.module_loader as module_loader
import cobbler.utils as utils def register():
# this pure python trigger acts as if it were a legacy shell-trigger, but is much faster.
# the return of this method indicates the trigger type
return "/var/lib/cobbler/triggers/sync/post/*" def run(api,args,logger): settings = api.settings() manage_dhcp = str(settings.manage_dhcp).lower()
manage_dns = str(settings.manage_dns).lower()
restart_dhcp = str(settings.restart_dhcp).lower()
restart_dns = str(settings.restart_dns).lower() which_dhcp_module = module_loader.get_module_from_file("dhcp","module",just_name=True).strip()
which_dns_module = module_loader.get_module_from_file("dns","module",just_name=True).strip() # special handling as we don't want to restart it twice
has_restarted_dnsmasq = False rc = 0
if manage_dhcp != "0":
if which_dhcp_module == "manage_isc":
if restart_dhcp != "0":
rc = utils.subprocess_call(logger, "dhcpd -t -q", shell=True)
if rc != 0:
logger.error("dhcpd -t failed")
return 1
dhcp_service_name = utils.dhcp_service_name(api) #<===主要修改下面2个地方,修改dhcpd由systemd管理
dhcp_restart_command = "/usr/bin/systemctl restart %s" % dhcp_service_name
rc = utils.subprocess_call(logger, "/bin/systemctl restart dhcpd", shell=True)
elif which_dhcp_module == "manage_dnsmasq":
if restart_dhcp != "0":
rc = utils.subprocess_call(logger, "service dnsmasq restart")
has_restarted_dnsmasq = True
else:
logger.error("unknown DHCP engine: %s" % which_dhcp_module)
rc = 411 if manage_dns != "0" and restart_dns != "0":
if which_dns_module == "manage_bind":
named_service_name = utils.named_service_name(api)
dns_restart_command = "service %s restart" % named_service_name
rc = utils.subprocess_call(logger, dns_restart_command, shell=True)
elif which_dns_module == "manage_dnsmasq" and not has_restarted_dnsmasq:
rc = utils.subprocess_call(logger, "service dnsmasq restart", shell=True)
elif which_dns_module == "manage_dnsmasq" and has_restarted_dnsmasq:
rc = 0
else:
logger.error("unknown DNS engine: %s" % which_dns_module)
rc = 412 return rc
[root@server 123]# python -m compileall * #<===重新编译文件
Compiling sync_post_restart_services.py ...
[root@server 123]# python -O -m compileall *
Compiling sync_post_restart_services.py ...
[root@server 123]# ls
sync_post_restart_services.py sync_post_restart_services.pyc sync_post_restart_services.pyo
[root@server 123]# cd /usr/lib/python2.7/site-packages/cobbler/modules/
[root@server modules]# \cp ~/123/* ./ #<===将重新编译的文件拷贝覆盖掉原来的

修改完成后,重启所有服务

[root@server ~]# systemctl restart httpd.service
[root@server ~]# systemctl restart dhcpd.service
[root@server ~]# systemctl restart rsyncd.service
[root@server ~]# systemctl restart tftp.socket
[root@server ~]# systemctl restart cobblerd.service
重新执行cobbler sync同步命令,发现已经正常
[root@server ~]# cobbler sync
task started: 2019-04-16_143521_sync
task started (id=Sync, time=Tue Apr 16 14:35:21 2019)
running pre-sync triggers
cleaning trees
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/grub-x86.efi
removing: /var/lib/tftpboot/grub/grub-x86_64.efi
removing: /var/lib/tftpboot/grub/efidefault
removing: /var/lib/tftpboot/s390x/profile_list
copying bootloaders
trying hardlink /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
copying: /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
trying hardlink /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32
copying: /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32
trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
copying distros to tftpboot
copying images
generating PXE configuration files
generating PXE menu structure
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
rendering TFTPD files
generating /etc/xinetd.d/tftp
cleaning link caches
running post-sync triggers
running python triggers from /var/lib/cobbler/triggers/sync/post/*
running python trigger cobbler.modules.sync_post_restart_services
running: dhcpd -t -q
received on stdout:
received on stderr:
running: /bin/systemctl restart dhcpd
received on stdout:
received on stderr:
running shell triggers from /var/lib/cobbler/triggers/sync/post/*
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.manage_genders
running python trigger cobbler.modules.scm_track
running shell triggers from /var/lib/cobbler/triggers/change/*
*** TASK COMPLETE *** #<===现在已经正常
问题2:打开网页 https://10.0.0.6/cobbler_web,显示500错误(注意:centos7.x以上,cobbler只支持https方式访问)
解决办法:
首先查看以下路径日志,然后按照下面方法解决
[root@server ~]# cat /var/log/httpd/error_log
[root@server ~]# cat /var/log/cobbler/cobbler.log
[root@server ~]# rpm -qa | grep "python2-django" python2-django-1.11.13-4.el7.noarch
这个包是1.11,只要这个包在1.8以上,就有问题 TEMPLATE_CONTEXT_PROCESSORS was deprecated in Django 1.8 and removed in Django 1.10. It's not possible to import it anymore.
然后执行以下命令

[root@server ~]# rpm -e --nodeps python2-django
[root@server ~]# yum -y install python2-pip #<===安装pip软件
[root@server ~]# pip install --upgrade pip
[root@server ~]# pip install Django==1.8.17 #<===将此软件包改为1.8.17版本
重启cobblerd服务,输入网址 https://10.0.0.6/cobbler_web(账号和密码都是cobbler),已经能够正常访问了
[root@server ~]# systemctl restart cobblerd.service 


Google参考帮助https://bugzilla.redhat.com/show_bug.cgi?id=709151

小记centos7.5下yum安装cobbler遇到的问题的更多相关文章

  1. centos7.5下yum安装php-5.6.40(LNMP环境)

    cd /etc/yum.repos.d/ yum -y install epel-release #<===安装centos7下php5.6的epel和remi源 rpm -ivh http:/ ...

  2. centos7.5下yum安装mysql-5.6.43

    cd ~/ && cat /etc/redhat-release yum list installed |grep mysql #<===查看是否安装mysql,如果已经安装,使 ...

  3. centos7.5下yum 安装mariadb数据库

    前言 mariadb 和mysql就像亲兄弟的关系,各种语法.驱动啥的,在mysql上能上的,在mariadb上基本都可以直接使用.更多的细节在此不多说. 1.删除旧版本 centos7下默认安装有m ...

  4. CentOS7 linux下yum安装mysql5.7

    文章参考(https://www.cnblogs.com/jorzy/p/8455519.html) 1.创建存放安装包的位置,并且进入该目录 命令mkdir /share 命令cd /share 2 ...

  5. CentOS7系统下YUM安装安装Mongodb 3.4

    第一步 查看是否存在Mongodb配置yum源 切换到yum目录 cd /etc/yum.repos.d/ 查看文件 ls 第二部 不存在添加yum 源 创建文件 touch mongodb-3.4. ...

  6. Zabbix之CentOS7.3下yum安装Zabbix3.5

    Zabbix特点介绍 (此介绍来源于https://www.zabbix.com/documentation/3.4/zh/manual/introduction/features) 概述Zabbix ...

  7. CentOS7.3下yum安装MariaDB10.3.12并指定utf8字符集

    添加MariaDB的yum源,指定安装的版本,然后使用 yum 工具进行安装 参考MariaDB官方网站对应安装方法和步骤 https://downloads.mariadb.org/mariadb/ ...

  8. CentOS7 linux下yum安装redis以及使用

    1.安装redis数据库 yum install redis 2.下载fedora的epel仓库 yum install epel-release 3.启动redis服务 systemctl star ...

  9. centos7.5下yum安装nginx-1.14.2

    rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm ...

随机推荐

  1. unittest模块使用方法

    unittest模块常用属性 1. unittest.TestCase类:所有的测试用例类继承的基类 定义一个测试用例类,需要继承TestCase,比如: class BaiduTest(unitte ...

  2. 用PHP写下HELLO WORLD!

    一.选择PHP开发工具 1.phpstorm最新版本 2.打开phpstorm界面 按create键,选择new window ,出下如下页面: 鼠标放在文件夹上,右键单击,弹出以下对话框:做如下操作 ...

  3. Oracle Autonomous Health Framework (AHF) 解读

    AHF介绍 Oracle在2019年10月18日发布自治健康框架Autonomous Health Framework (AHF) 19.3,将ORAchk,EXAchk,TFA三种诊断工具合并入AH ...

  4. CSS中设置元素的圆角矩形

    圆角矩形介绍 在CSS中通过border-radius属性可以实现元素的圆角矩形. border-radius属性值一共有4个,左上.右上.左下.右下. border-radius属性值规则如下:第一 ...

  5. KD-tree 学习小记

    考 \(NOI\) 时不会,感觉很亏.于是学了一上午,写了一晚上. 感觉这东西就是个复杂度玄学的高级暴力 (大雾 KD-tree 基本信息 \(D\) 就是 \(Dimension\) ,维度的意思. ...

  6. Xen+OpenQRM快速部署

    一.选择系统平台 a)   Ubuntu-11.10-server-amd64 二.Xen安装 a)   Xen安装 # apt-get -y install xen-hypervisor-4.1-a ...

  7. requests快速构造请求头的方法

    上图请求头内容,内容多不说,也不确认哪些数据是必须的,网上找到一个懒办法 快速一键生成 Python 爬虫请求头 实战演练 抓取网站:https://developer.mozilla.org... ...

  8. Python单元测试unittest测试框架

    本文的主题是自动化测试框架的实现,在实现之前,先了解一下关于unittest模块的相关知识: Python中有一个自带的单元测试框架是unittest模块,用它来做单元测试,它里面封装好了一些校验返回 ...

  9. linux下redis的部署

    https://www.cnblogs.com/wangchunniu1314/p/6339416.html https://www.linuxidc.com/Linux/2017-09/146894 ...

  10. php7 mongodb 扩展windows 安装

    1. 打开phpinfo 查看 nts(非线程) 还是 ts (线程),然后查看操作位数 注: 86 等于 32 位  2. 下载对应的版本的php_mongodb.dll 文件 下载链接: pecl ...