问题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. OpenGLES思维导图

    两本书到头来就只剩下了这三张图了吧.想要原图:https://github.com/wangwangla/biji/blob/master/%E8%AF%BB%E4%B9%A6%E7%AC%94%E8 ...

  2. Oauth2的使用(第三方授权登录)

    例子: 京东商城 ,微博 ,用户三者之间的关系 第一方:用户 第二方:京东商城 第三方:微博 用户不希望在京东商城上注册,可以授权微博使用微博上的用户信息进行登录京东商城. 授权流程: 地址一:授权页 ...

  3. spring boot 的 userRepository无法注入的问题

    No qualifying bean of type 'xxx.xxx.xxx' available: expected at least 1 bean which qualifies as auto ...

  4. 如何修改win7文件夹的显示方式为详细信息

    1.首先对着空白处,鼠标右键单击,然后点击“排列方式” 选一个 还有 你还可以点击“查看” 选择图标大小.详细信息.平铺.列表 等2.点击我的电脑左上角的 组织 按钮 随后选择“文件夹和搜索选项” 再 ...

  5. printf 函数笔记

    函数声明 int printf (const char*, ...); 说明 <返回值> printf ("<格式化字符串>", <参数表>); ...

  6. Git详解之特殊工具

    前言 现在,你已经学习了管理或者维护 Git 仓库,实现代码控制所需的大多数日常命令和工作流程.你已经完成了跟踪和提交文件的基本任务,并且发挥了暂存区和轻量级的特性分支及合并的威力. 接下来你将领略到 ...

  7. 024.Python模块OS模块

    一 OS模块 对系统进行操作 1.1 popen 可以把运行的结果,这个字符串转化成utf-8这样的编码格式在进行输出 import os res = os.popen("ifconfig& ...

  8. 温故知新,.NET 重定向深度分析

    在早期的.NET Framework程序员心里,重定向Redirect其实分为两种: Response.Redirect: Response对象的Redirect方法提供了一种实现客户端重定向的方法 ...

  9. C++ 强制类型转换详解

    类型转换只不过是让编译器以另外一种方式解释一块内存而已.C++兼容C语言的强制类型转换方式,同时也提供了新型的基于模板的类型转换方式,来提供更多的安全性. 一.C风格的强制类型转换 double k ...

  10. pyhton3之进程

    一 什么是进程 首先要了解什么是进程,程序是写出来没有被执行的代码,它是没有生命的实体,只有处理器赋予程序生命时,及程序被操作系统运行起来,他是一个活动的实体,我们称其为进程. 进程是计算机中的程序关 ...