Cobbler部署指南之电源管理篇

2019-07-13 23:44发布


1、《Cobbler部署指南之安装篇》http://dreamway.blog.51cto.com/blog/1281816/1166589
2、《Cobbler部署指南之配置管理篇[上文]》http://dreamway.blog.51cto.com/blog/1281816/1166921
3、《Cobbler部署指南之配置管理篇[下文]》http://dreamway.blog.51cto.com/blog/1281816/1166932
4、《Cobbler部署指南之yum仓库配置管理篇》http://dreamway.blog.51cto.com/blog/1281816/1166936
5、《Cobbler部署指南之Cobbler安装操作系统篇》http://dreamway.blog.51cto.com/blog/1281816/1166947
6、《Cobbler部署指南之安装虚拟化Xen系统篇》http://dreamway.blog.51cto.com/blog/1281816/1166950
7、《Cobbler部署指南之电源管理篇》http://dreamway.blog.51cto.com/blog/1281816/1166957
8、《Cobbler部署指南之FAQ处理篇》http://dreamway.blog.51cto.com/blog/1281816/1167078  

八、电源管理

8.1 测试机环境

DELL PE1950 系统CentOS5.8 64bit 安装ipmitool yum install ipmitool -y  

8.2 安装电源管理工具cman

yum install cman -y Cobbler代码维护者jimi告知:某些系统版本将执行程序安装在/sbin/目录下,通过rpm -ql cman查看,CentOS5.8下如此解决即可 ln -s /sbin/fence_* /usr/sbin/

8.3 修改电源管理python脚本

备份 cp  /usr/lib/python2.4/site-packages/cobbler/action_power.py /usr/lib/python2.4/site-packages/cobbler/action_power.py.$(date +%F) 编辑 vim /usr/lib/python2.4/site-packages/cobbler/action_power.py  删除或注释此文件如下代码 utils.die(self.logger,"command succeeded (rc=%s), but output ('%s') was not understood" % (rc, output)) 删除文件action_power.pyo 、 action_power.pyc 这两个文件在目录/usr/lib/python2.4/site-packages/cobbler/下 重启cobbler,注意一定是重启cobbler cobbler reboot 步骤8.2、8.3是我在使用电源管理中发现的问题,后通过github与Cobbler代码维护者jimi沟通解决的,非常感谢他的帮助,详见 https://github.com/cobbler/cobbler/issues/426    

8.4 配置电源管理参数

为指定的系统配置host-188116增加电源管理参数 cobbler system edit --name=host-188116  --power-address=172.17.11.20  --power-type='ipmilan'  --power-user=root  --power-pass=djxxxx  

8.5 检查、同步配置

cobbler check cobbler sync

8.6 查看配置信息

cobbler system report | egrep -i "system|profile|power" Power Management Address       : 172.17.11.20 Power Management ID            : Power Management Password      : djxxxx Power Management Type          : ipmilan Power Management Username      : root Profile                        : centos5.8-x86_64  

8.7 Cobbler默认的电源管理配置

/etc/cobbler/settings # settings for power management features.  optional. # see https://github.com/cobbler/cobbler/wiki/Power-management to learn more # choices (refer to codes.py): #    apc_snmp bladecenter bullpap drac ether_wake ilo integrity #    ipmilan ipmitool lpar rsa virsh wti power_management_default_type: 'ipmitool'   # the commands used by the power management module are sourced # from what directory? power_template_dir: "/etc/cobbler/power"

8.8 使用电源管理

8.8.1 命令行操作
8.8.1.1 相关命令
cobbler system poweroff cobbler system poweron cobbler system powerstatus cobbler system reboot
8.6.1.2 查看服务器电源状态
cobbler system powerstatus --name=host-188116 task started: 2013-03-29_095803_power task started (id=Power management (status), time=Fri Mar 29 09:58:03 2013) cobbler power configuration is:       type   : ipmilan       address: 172.17.11.20       user   : root       id     : running: /usr/sbin/fence_ipmilan received on stdout: Getting status of IPMI:172.17.11.20...Chassis power = On Done   received on stderr: *** TASK COMPLETE ***
8.8.1.3 关闭服务器电源
cobbler system poweroff  --name=host-188116 task started: 2013-03-29_100218_power task started (id=Power management (off), time=Fri Mar 29 10:02:18 2013) cobbler power configuration is:       type   : ipmilan       address: 172.17.11.20       user   : root       id     : running: /usr/sbin/fence_ipmilan received on stdout: Powering off machine @ IPMI:172.17.11.20...Done   received on stderr: *** TASK COMPLETE ***
8.8.1.4 启动服务器电源
cobbler system poweron  --name=host-188116  task started: 2013-03-29_100314_power task started (id=Power management (on), time=Fri Mar 29 10:03:14 2013) cobbler power configuration is:       type   : ipmilan       address: 172.17.11.20       user   : root       id     : running: /usr/sbin/fence_ipmilan received on stdout: Powering on machine @ IPMI:172.17.11.20...Done   received on stderr: *** TASK COMPLETE *** 启动服务器后再通过查看服务器电源状态为On
8.8.1.5 重启服务器
cobbler system  reboot --name=host-188116            task started: 2013-03-29_100508_power task started (id=Power management (reboot), time=Fri Mar 29 10:05:08 2013) cobbler power configuration is:       type   : ipmilan       address: 172.17.11.20       user   : root       id     : running: /usr/sbin/fence_ipmilan received on stdout: Powering off machine @ IPMI:172.17.11.20...Done   received on stderr: cobbler power configuration is:       type   : ipmilan       address: 172.17.11.20       user   : root       id     : running: /usr/sbin/fence_ipmilan received on stdout: Powering on machine @ IPMI:172.17.11.20...Done   received on stderr: *** TASK COMPLETE ***
8.8.1.6 通过电源管理命令自动部署操作系统
  重启从PXE引导启动,并指定安装的操作系统配置,如下命令, cobbler system edit  --name=host-188116  --netboot-enabled=1 --profile=centos5.8-x86_64 检查、同步配置 cobbler check cobbler sync   测试上面的命令默认还是直接从硬盘启动,功能还不够完善,我们借助ipmitool工具设置下次启动从PXE引导,原理都是一样的。 ipmitool -I lan -H 172.17.11.20 -U root -P djxxxx chassis bootdev pxe      Set Boot Device to pxe 更多参数详见 cobbler system edit --help 重启服务器,重装系统 cobbler system  reboot --name=host-188116 PXE引导已经生效,如图 从指定的系统配置引导正常 可以看到引导文件及客户机MAC配置文件名   检查依赖关系及格式化过程图略 安装系统软件包如下图   到这里自动部署系统已经基本完成,系统重装启动后会关闭默认从PXE引导启动。
8.8.2 Cobbler Web方式管理电源
参考资料https://github.com/cobbler/cobbler/wiki/Power-management 请看《Cobbler部署指南》系列续文 《Cobbler部署指南》系列文档下载:http://down.51cto.com/data/745895 本文出自 “Dreamway的运维点滴” 博客,请务必保留此出处http://dreamway.blog.51cto.com/1281816/1166957