cobbler安装 系统安装自动化

回复 收藏
Cobbler 是一个快速网络安装linux 的服务,而且在经过调整也可以支持网络安装windows。
Cobbler支持命令行管理,web 界面管理,还提供了API 接口,可以方便二次开发使用。
和Kickstart 不同的是,使用cobbler 不会因为在局域网中启动了dhcp 而导致有些机器因为默认从pxe启动在重启服务器后加载tftp 内容导致启动终止。

官网:https://fedorahosted.org/cobbler/wiki/UserDocs
官网:https://fedorahosted.org/cobbler/wiki/DownloadInstructions

Cobbler的安装环境准备
1、安装epel源
EPEL源选择地址: https://fedorahosted.org/cobbler/wiki/DownloadInstructions
  1. rpm -Uvh http://mirrors.ustc.edu.cn/fedora/epel/5/x86_64/epel-release-5-4.noarch.rpm
查看cobbler源
  1. # yum list |grep cobbler
  2. cobbler.noarch                             2.2.3-2.el5                 epel     
  3. cobbler-web.noarch                         2.2.3-2.el5                 epel     
  4. revisor-cobbler.noarch                     2.0.5.2-3.el5               epel  
2、安装DHCP服务
  1. yum -y install dhcp
3、其它服务的安装
额外需要的服务还有tftp,rsync,xinetd,httpd。
  1. yum install -y tftp-server
  2. yum install -y pykickstart
DHCP配置,简单配置启用即可,后面可以设置cobbler模板配置DHCP
  1. cp  /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf
dhcp配置详解: http://www.lishiming.net/thread-5317-1-1.html
启动DHCP
/etc/init.d/dhcpd start


cobbler安装
1、安装cobbler
  1. yum -y install cobbler
  2. /sbin/service cobblerd start
2、cobbler check查看有无报错
  1. # cobbler check
  2. The following are potential configuration items that you may want to fix:
  3. 1 : since iptables may be running, ensure 69, 80/443, and 25151 are unblocked
  4. 2 : debmirror package is not installed, it will be required to manage debian deployments and repositories
  5. 3 : ksvalidator was not found, install pykickstart
  6. 4 : 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. 5 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them
根据报错修改相应内容
提示debmirror未安装时,如果不是debian系统,可忽略

3、使用cobbler
修改cobbler配置,修改server、next-server为本机IP
  1. vi /etc/cobbler/settings
  2. # this is the address of the cobbler server -- as it is used
  3. # by systems during the install process, it must be the address
  4. # or hostname of the system as those systems can see the server.
  5. # if you have a server that appears differently to different subnets
  6. # (dual homed, etc), you need to read the --server-override section
  7. # of the manpage for how that works.
  8. server: 127.0.0.1
  9. # if using cobbler with manage_dhcp, put the IP address
  10. # of the cobbler server here so that PXE booting guests can find it
  11. # if you do not set this correct
ly, this will be manifested in TFTP open timeouts.
next_server: 127.0.0.1[/code]

4、自动下载loader 程序
  1. #cobbler get-loaders
5、修改 /etc/xinetd.d/tftp 、/etc/xinetd.d/rsync
  1. disable为no
  2. disable = no
6、修改cobbler 用户的默认密码,可以使用如下命令生成密码,并使用生成后的密码替换/etc/cobbler/settings 中的密码。生成密码命令:
  1. openssl passwd -1 -salt 'random-phrasehere' 'your-password-here'
其中“random-phrase-here”为干扰码,可为任意字符
less /etc/cobbler/settings |grep default_password_crypted

如果openssl不好使,可以手动修改执行opssl后会提示一串字符串,替换default_password_crypted后内容

7、全部完成后,重启cobbler
  1. /etc/init.d/cobblerd restart
8、修改cobbler,让其自动管理dhcp
  1. vi /etc/cobbler/settings
  2. manage_dhcp: 1
接下来修改/etc/cobbler/dhcp.template,此文件
是cobbler 管理dhcp 的模板
vi  /etc/cobbler/dhcp.template ,主要修改内容如下:
  1. subnet 192.168.52.0 netmask 255.255.255.0 {
  2.      option routers             192.168.52.254;
  3.      option domain-name-servers 61.135.142.198;
  4.      option subnet-mask         255.255.255.0;
  5.      range dynamic-bootp        192.168.52.87 192.168.52.89;
  6.      filename                   "/pxelinux.0";
  7.      default-lease-time         21600;
  8.      max-lease-time             43200;
  9.      next-server                $next_server;
  10. }
9、导入系统镜像文件
修改cobbler配置指向,原指向/var/www/cobbler;导入系统ISO时,文件较大,修改指向有足够空间的目录
  1. vi /etc/cobbler/settings
  2. webdir = /usr/local/cobbler
将系统ISO导入 cobbler中,
  1. mount -o loop /usr/local/myshare/CentOS5_5.iso  /mnt/
  2. cobbler import --path=/mnt  --name=centos-5.5 --arch=x86_64
--name后,会在webdir目录下建立相应名字的目录,--path可用系统dir,可以为网上链接
如:cobbler import --path=rsync://mirrors.163.com/centos/6.0/os/i386/ --name=centos-6.0-i386
导入的同时会创建一个名字为centos-5.5的一个发布版本,以及一个名字为centos-5.5的profile文件。

导入命令可通过 cobbler import --help 查看

10、同步cobbler配置
  1. # cobbler sync
cobbler 会自动进行初始化工作,移除已经存在的
启动项,然后根据模板拷贝loader 文件。之后再生成
pxe 的配置文件,生成dhcp 的配置文件,最后再重启
dhcp 服务。
至此,就可以使用虚拟机来测试cobbler 安装了。


11、虚拟机设置PXE方式启动
虚拟机装系统时,使用的kickstart文件为/var/lib/cobbler/kickstarts/sample.ks

12、设置启动项
  1. /sbin/service httpd start
  2. /sbin/service dhcpd start
  3. /sbin/service xinetd start
  4. /sbin/service cobblerd start
  5. /sbin/chkconfig httpd on
  6. /sbin/chkconfig dhcpd on
  7. /sbin/chkconfig xinetd on
  8. /sbin/chkconfig tftp on
  9. /sbin/chkconfig cobblerd on
安装过程中报错
1、启动HTTPD里,提示
  1. #/etc/init.d/httpd start
  2. Starting httpd: Syntax error on line 10 of /etc/httpd/conf.d/cobbler.conf:
  3. Invalid command 'WSGIScriptAliasMatch', perhaps misspelled or defined by a module not included in the server configuration[FAILED]
错误原因:模块mod_wsgi.so未启动
编辑/etc/httpd/conf.d/wsgi.conf ,取消注释"LoadModule wsgi_module modules/mod_wsgi.so"后重新启动


2、安装后报错
  1. Traceback (most recent call last):
  2.   File "/usr/bin/cobbler", line 35, in ?
  3.     sys.exit(app.main())
  4.   File "/usr/lib/python2.4/site-packages/cobbler/cli.py", line 558, in main
  5.     rc = cli.run(sys.argv)
  6.   File "/usr/lib/python2.4/site-packages/cobbler/cli.py", line 202, in run
  7.     self.token         = self.remote.login("", self.shared_secret)
  8.   File "/usr/lib64/python2.4/xmlrpclib.py", line 1096, in __call__
  9.     return self.__send(self.__name, args)
  10.   File "/usr/lib64/python2.4/xmlrpclib.py", line 1383, in __request
  11.     verbose=self.__verbose
  12.   File "/usr/lib64/python2.4/xmlrpclib.py", line 1147, in request
  13.     return self._parse_response(h.getfile(), sock)
  14.   File "/usr/lib64/python2.4/xmlrpclib.py", line 1286, in _parse_response
  15.     return u.close()
  16.   File "/usr/lib64/python2.4/xmlrpclib.py", line 744, in close
  17.     raise Fault(**self._stack[0])
  18. xmlrpclib.Fault:
解决办法:重新启动cobbler
/etc/init.d/cobblerd restart
2013-03-18 13:26 举报
已邀请:
0

九月微寒

赞同来自:

HI 大神,
我遇到一个cobbler 与puppet 整合的问题。如何直接让cobbler装上puppet ?
在cobbler 里有puppet的选项,但是开启后测试,实际并没有安装上puppet 。puppet的YUM 安装是需要epel源的, 对cobbler添加了epel-repo的路径还是无法实现。
目前我的临时解决方案是写命令堆栈脚本。

回复帖子,请先登录注册

退出全屏模式 全屏模式 回复
评分
可选评分理由: