小记centos7.5下yum安装cobbler遇到的问题
问题1:执行cobbler sync同步命令报错,提示dhcpd服务错误和Python源码错误
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | [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: <strong><em>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.</em></strong> Exception occured: <class 'cobbler.cexceptions.CX' > Exception value: 'cobbler trigger failed: cobbler.modules.sync_post_restart_services' Exception Info: <strong><em>File "/usr/lib/python2.7/site-packages/cobbler/remote.py" , line 82, in run</em></strong> rc = self._run(self) <em><strong>File "/usr/lib/python2.7/site-packages/cobbler/remote.py" , line 181, in runner</strong></em> return self.remote.api.sync(self.options.get( "verbose" ,False),logger=self.logger) <em><strong>File "/usr/lib/python2.7/site-packages/cobbler/api.py" , line 763, in sync</strong></em> 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) <em><strong>File "/usr/lib/python2.7/site-packages/cobbler/utils.py" , line 928, in run_triggers</strong></em> raise CX( "cobbler trigger failed: %s" % m.__name__) !!! TASK FAILED !!! |
解决办法:
1.修改 /etc/cobbler/dhcp.template,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | [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安装的话,会有问题)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | [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/* ./ #<===将重新编译的文件拷贝覆盖掉原来的 |
修改完成后,重启所有服务
1 2 3 4 5 | [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同步命令,发现已经正常
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | [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 *** <strong> #<===现在已经正常</strong> |
问题2:打开网页 https://10.0.0.6/cobbler_web,显示500错误(注意:centos7.x以上,cobbler只支持https方式访问)
解决办法:
首先查看以下路径日志,然后按照下面方法解决
1 2 3 4 5 6 7 8 9 | [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),已经能够正常访问了
1 | [root@server ~]# systemctl restart cobblerd.service |
Google参考帮助 https://bugzilla.redhat.com/show_bug.cgi?id=709151
分类:
故障解决
, pxe/cobbler
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 智能桌面机器人:用.NET IoT库控制舵机并多方法播放表情
· Linux glibc自带哈希表的用例及性能测试
· 深入理解 Mybatis 分库分表执行原理
· 如何打造一个高并发系统?
· .NET Core GC压缩(compact_phase)底层原理浅谈
· 手把手教你在本地部署DeepSeek R1,搭建web-ui ,建议收藏!
· 新年开篇:在本地部署DeepSeek大模型实现联网增强的AI应用
· Janus Pro:DeepSeek 开源革新,多模态 AI 的未来
· 互联网不景气了那就玩玩嵌入式吧,用纯.NET开发并制作一个智能桌面机器人(三):用.NET IoT库
· 【非技术】说说2024年我都干了些啥