Cobbler简介
Cobbler是一个快速网络安装Linux的服务,在大批量系统安装的环境中及其方便。
Cobbler功能
使用 Cobbler,您无需进行人工干预即可安装机器。
Cobbler 支持众多的发行版:Red Hat、Fedora、CentOS、Debian、Ubuntu 和 SuSE。
为了协助管理系统,Cobbler 可通过 fence scripts 连接到各种电源管理环境。
首先也是最重要的,Cobbler需要Python,任何版本大于2.6的;官网说明(http://www.cobblerd.org/manuals/2.6.0/2/1_-_Prerequisites.html)
Cobbler也需要安装以下的安装包:
createrepo httpd (apache2 for Debian/Ubuntu) mkisofs mod_wsgi (libapache2-mod-wsgi for Debian/Ubuntu) mod_ssl (libapache2-mod-ssl)python-cheetah python-netaddr python-simplejson python-urlgrabber PyYAML (python-yaml for Debian/Ubuntu) rsync xinetd(system default installed ) syslinux tftp-server (atftpd for Debian/Ubuntu, though others may work) yum-utils
一、安装和修改Cobbler相关的配置
1.安装Cobbler
cobbler可以手动编译安装,也可以基于yum源的安装, 如果需要通过yum源安装,则需要配置epel源。
epel源可以通过下载官方给的epel源的目录来实现安装!http://fedoraproject.org/wiki/EPEL
# rpm -Uvh # yum install cobbler -y
PS:新版的Fedora安装系统存放在“testing”存储库中一段时间来检查有没有bug,如果你想通过EPEL安装最新版的cobbler(未通过生产环境验证有没有bug),可在安装或升级时启动-testing模式。
$ sudo yum install –enablerepo=epel-testing cobbler
# or
$ sudo yum update –enablerepo=epel-testing cobbler
2.安装DHCP服务
yum install dhcp -y
3.启动各服务并设为开机启动
service httpd start (cobblerd/xinetd依次启动 )
chkconfig httpd on (dhcpd/xinetd/tftp/cobblerd依次设置)
4.修改Cobbler配置:
# vim /etc/cobbler/setting ‘next_server: 127.0.0.1‘ 替换本机IP地址 (DHCP服务地址) ‘server: 127.0.0.1‘ 替换本机IP地址(cobbler服务地址) ‘manage_dhcp: 0‘ 替换为 1(cobbler管理dhcp,后面用于同步更新配置信息cobbler sync) ‘manage_rsync: 0‘ 替换为 1 (cobbler管理rsync功能)
5.启动tftp和rsync服务
# vim /etc/xinetd.d/tftp
# vim /etc/xinetd.d/rsync
分别将disable项修改成:disable = no
6.修改DHCP模板,确保DHCP分配的地址和Cobbler在同一网段
# vim /etc/cobbler/dhcp.template
根据实际情况只修改subnet段的内容如下:
subnet 10.1.1.0 netmask 255.255.255.0 { option routers 10.1.1.1; option domain-name-servers 202.106.0.20; option subnet-mask 255.255.255.0; range dynamic-bootp 10.1.1.100 10.1.1.254;# filename "/pxelinux.0"; default-lease-time 21600; max-lease-time 43200; next-server 10.1.1.10; 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 { filename "pxelinux.0"; } }}
注意:网上有些资料把上面的改为了如下的格式,我觉得官方的方法更好一些,它有客户端类型应怎么引导的判断!
subnet 192.168.0.0 netmask 255.255.255.0 {
#修改自己的路由
option routers 192.168.0.1;
#域名服务器地址
option domain-name-servers 202.106.0.20;
#子网掩码
option subnet-mask 255.255.255.0;
#分配IP地址段
range dynamic-bootp 192.168.0.100 192.168.0.254;
filename “/pxelinux.0″;
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
}
7.检查配置
# /etc/init.d/httpd start # /etc/init.d/cobblerd start # cobbler check The following are potential configuration items that you may want to fix: 1 : SELinux is enabled. Please review the following wiki page for details on ensuring cobbler works correctly in your SELinux environment: 2 : change ‘disable‘ to ‘no‘ in /etc/xinetd.d/rsync 3 : since iptables may be running, ensure 69, 80/443, and 25151 are unblocked 4 : debmirror package is not installed, it will be required to manage debian deployments and repositories 5 : ksvalidator was not found, install pykickstart 6 : The default password used by the sample templates for newly installed machines (default_password_crypted in /etc/cobbler/settings) is still set to ‘cobbler‘ and should be changed, try: "openssl passwd -1 -salt ‘random-phrase-here‘ ‘your-password-here‘" to generate new one 7 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them
然后根据提示,逐一解决上面出现的问题。
1.禁用SELINUX
# vim /etc/sysconfig/selinux
SELINUX=disabled
重启系统使之生效。
2. 编辑rsync文件
# vim /etc/xinetd.d/rsync
disable = no //修改此处,将yes改为no
3. 如果开启了防火墙,确保允许69、80/443、25151端口通信
为了方便,这里直接关闭防火墙
# service iptables stop
4.如果是安装Debian这样的系统,需要安装debmirror (不是的话可以忽略)
5.需要安装pykickstart。
# yum install debmirror pykickstart -y //4、5一块处理了。
6.修改cobbler用户的默认密码
# openssl passwd -1 -salt ‘suibianxie’ ‘cobblerpass’
$1$suibianx$z76PIFOEknPi2.WhUujho.
# vim /etc/cobbler/settings
default_password_crypted: $1$suibianx$z76PIFOEknPi2.WhUujho. //修改此处,将上面生成的加密字符串写到这里。
7.安装cman或fence-agents启动电源管理功能
# yum install cman -y //这里我用cman
重启服务,在检查一下
# service cobblerd restart Stopping cobbler daemon: [ OK ] Starting cobbler daemon: [ OK ] # cobbler checkThe following are potential configuration items that you may want to fix: 1 : comment out ‘dists‘ on /etc/debmirror.conf for proper debian support 2 : comment out ‘arches‘ on /etc/debmirror.conf for proper debian support Restart cobblerd and then run ‘cobbler sync‘ to apply changes.
解决上面的两个提示:
# vim /etc/debmirror.conf //找到并注释下面两行的内容
#@dists=”sid”;
#@arches=”i386″;
检查,发现没有问题后继续之后的操作!
# cobbler check
No configuration problems found. All systems go.
# cobbler sync
二、导入ISO系统文件
1.上传镜像到服务器
2.创建镜像挂载目录
3.挂载镜像到创建目录上
4. 从iso中导入客户端要安装的OS。
# cobbler import --path=/media/Centos6.5/ --name=Centos6.5 --arch=x86_64 task started: 2015-04-29_111745_import task started (id=Media import, time=Wed Apr 29 11:17:45 2015) Found a candidate signature: breed=redhat, version=rhel6 Found a matching signature: breed=redhat, version=rhel6 Adding distros from path /var/www/cobbler/ks_mirror/Centos6.5-x86_64: creating new distro: Centos6.5-x86_64 trying symlink: /var/www/cobbler/ks_mirror/Centos6.5-x86_64 -> /var/www/cobbler/links/Centos6.5-x86_64 creating new profile: Centos6.5-x86_64 associating repos checking for rsync repo(s) checking for rhn repo(s) checking for yum repo(s) starting descent into /var/www/cobbler/ks_mirror/Centos6.5-x86_64 for Centos6.5-x86_64 processing repo at : /var/www/cobbler/ks_mirror/Centos6.5-x86_64 need to process repo/comps: /var/www/cobbler/ks_mirror/Centos6.5-x86_64 looking for /var/www/cobbler/ks_mirror/Centos6.5-x86_64/repodata/*comps*.xml Keeping repodata as-is :/var/www/cobbler/ks_mirror/Centos6.5-x86_64/repodata *** TASK COMPLETE ***
这个过程需要一些时间,可查看/var/www/cobbler/ks_mirror/下相关目录文件的生成情况!
# cobbler sync # cobbler list distros: Centos6.5-x86_64 profiles: Centos6.5-x86_64 systems: repos: images: mgmtclasses: packages: files:
三、Client部署测试
客户机与服务端在同一网段,并设置为PXE启动!启动后就可以看到 Cobbler 引导界面,选择相应的系统条目就可以顺利开始无人工干预安装系统!
完成自动化安装后,使用root用户账号登录,密码为之前在配置文件中写入的值!(本文中为 cobblerpass)
问题BUG:
配置检查出错
# cobbler check
Traceback (most recent call last):
File “/usr/bin/cobbler”, line 36, in <module>
sys.exit(app.main())
File “/usr/lib/python2.6/site-packages/cobbler/cli.py”, line 655, in main
rc = cli.run(sys.argv)
File “/usr/lib/python2.6/site-packages/cobbler/cli.py”, line 270, in run
self.token = self.remote.login(“”, self.shared_secret)
File “/usr/lib64/python2.6/xmlrpclib.py”, line 1199, in __call__
return self.__send(self.__name, args)
File “/usr/lib64/python2.6/xmlrpclib.py”, line 1489, in __request
verbose=self.__verbose
File “/usr/lib64/python2.6/xmlrpclib.py”, line 1253, in request
return self._parse_response(h.getfile(), sock)
File “/usr/lib64/python2.6/xmlrpclib.py”, line 1392, in _parse_response
return u.close()
File “/usr/lib64/python2.6/xmlrpclib.py”, line 838, in close
raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault 1: “<class ‘cobbler.cexceptions.CX’>:’login failed‘”>
这是一个GUB,解决方法:
# service cobblerd restart
# cobbler get-loaders
本文出自 “贵在坚持_IT博客” 博客,请务必保留此出处http://fdgui.blog.51cto.com/3484207/1640241
原文地址:http://fdgui.blog.51cto.com/3484207/1640241