问题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. 【5min+】闪电光速拳? .NetCore 中的Span

    系列介绍 简介 [五分钟的DotNet]是一个利用您的碎片化时间来学习和丰富.net知识的博文系列.它所包含了.net体系中可能会涉及到的方方面面,比如C#的小细节,AspnetCore,微服务中的. ...

  2. Spring学习记录5——数据库事务基础知识

    何为数据库事务 “一荣共荣,一损共损”这句话很能体现事务的思想,很多复杂的事务要分步进行,但它们组成了一个整体,要么整体生效,要么整体失效.这种思想反映到数据库上,就是多条SQL语句,要么全部成功,要 ...

  3. 计算机基础——常用的Dos命令

    d:——切换指定硬盘分区 cd——切换目录,例如:cd D:\下载(使用此命令之前先使用 d: 命令) netstat -ano——查看所有端口号 netstat -a——查看开启了哪些端口 nets ...

  4. Java中整数值的4中表示方式u

    Java中整数值有4中表示方式:十进制.二进制.八进制和十六进制,其中二进制的整数以0b或0B开头:八进制的整数以0开头: 十六进制的整数以0x或0X开头,其中10-15分别以a-f(此处的a-f不区 ...

  5. [bzoj4872] [洛谷P3750] [六省联考2017] 分手是祝愿

    Description Zeit und Raum trennen dich und mich. 时空将你我分开. \(B\) 君在玩一个游戏,这个游戏由 \(n\) 个灯和 \(n\) 个开关组成, ...

  6. 关于Xen

    尝试了各种方法搭建xen,尝试过从xenserver入手,但似乎最近时间端不允许访问,感谢我的老师,叫我从kvm入手,暂时记下xen中种种的坑,以后有缘再战.欢迎交流

  7. CTRL_IKun团队项目总结

    1. 团队项目-总结 这个作业属于哪个课程 课程链接 这个作业要求在哪里 作业要求 团队名称 CTRP-lkun 这个作业的目标 团队项目总结,每个人的收获和感悟 Github地址 Github 2. ...

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

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

  9. MAVEN报错Cannot access alimaven / idea data注解不好使

    BUG 记录 报错页面的代码和截图: Cannot access alimaven (maven.aliyun.com/nexus/conte…..... 解决方法: 报错页面的代码和截图: JAR ...

  10. Java基于OpenCV实现走迷宫(图片+路线展示)

    Java基于OpenCV实现走迷宫(图片+路线展示) 由于疫情,待在家中,太过无聊.同学发了我张迷宫图片,让我走迷宫来缓解暴躁,于是乎就码了一个程序出来.特此记录. 原图: 这张图,由于不是非常清晰, ...