问题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. 机器学习-特征工程-Feature generation 和 Feature selection

    概述:上节咱们说了特征工程是机器学习的一个核心内容.然后咱们已经学习了特征工程中的基础内容,分别是missing value handling和categorical data encoding的一些 ...

  2. struts2 convention插件

    1.struts2自2.1以后推荐使用Convention Plugin支持struts零配置支持(引入jar:struts2-convention-plugin-2.x.x.jar)①convent ...

  3. 8、python运算符

    前言:本文主要介绍python中经常使用的6种运算符,分别是算术运算符.比较运算符.赋值运算符.逻辑运算符.身份运算符和成员运算符. (因为用法比较简单,这里只做介绍,有兴趣的可以自己敲代码运行一下) ...

  4. js 获取元素坐标 和鼠标点击坐标

    js 获取元素的位置 var odiv=document.getElementById('divid'); alert(odiv.getBoundingClientRect().left); aler ...

  5. 推荐一个学java的网站

    最近在接触Java发现一个可以用来学习的 很不错的网站  直接扔链接 http://how2j.cn?p=77451

  6. 完美实现STM32单总线挂多个DS18B20

    一般常见的STM32的关于DS18B20的例程都是检测一个传感器,代码一般都是跳过ROM检测,直接获取温度值.这种写法并不适用于单总线上挂载多个DS18B20的情况,Sandeepin的这个代码就是针 ...

  7. lua 中 . 和 : 的区别

    lua 中 . 和 : 的区别 首先在lua中使用":"定义的函数会自动传入一个名为self的变量,这个变量是隐含的,self同c++中的this一样,表示当前对象的指针:而&qu ...

  8. 【WPF学习】第二十六章 Application类——应用程序的生命周期

    在WPF中,应用程序会经历简单的生命周期.在应用程序启动后,将立即创建应用程序对象,在应用程序运行时触发各种应用程序事件,你可以选择监视其中的某些事件.最后,当释放应用程序对象时,应用程序将结束. 一 ...

  9. MySQL 清理缓存—flush tablesFlush tables的影响

    摘自:http://blog.chinaunix.net/uid-31401119-id-5781305.html 1  Flush tables简介 官方手册中关于Flush tables的介绍, ...

  10. Spring Cloud中Eureka注册显示UNKNOWN问题

    这是由于application.yml里spring没有配置实例造成的