当前位置: > CentOS > CentOS服务器 > 环境配置 >

CentOS 6.3上安装部署 Cobbler

时间:2014-11-29 15:17来源:linux.it.net.cn 作者:IT

每次給自己的电脑重装系统都是一件很无聊的事情,如果需要重装上百台虚拟机和服务器不但很无聊而且很耗时,面对现在云时代大量服务器和虚拟机的出现,运维必须要自动化。现在有很多开源工具可以帮助我们实现自动化安装系统,比如 FAI, Cobbler, Spacewalk, Ubuntu Orchestra 等,我们打算把 Cobbler 安装在某台虚拟机上,为我们新购的无数R410来搭建系统。 

Cobbler 是一个系统启动服务(boot server),可以通过网络启动(PXE)的方式用来快速安装、重装物理服务器和虚拟机,支持安装不同的 Linux 发行版和 Windows. Cobbler 是个轻量级 Python 程序,总共大概1.5万行代码,还可以用来管理 DHCP, DNS, yum 源等。Cobbler 使用命令行方式管理,也提供了基于 Web 的界面管理工具(cobbler-web),不过命令行方式已经很方便,实在没有必要为了不实用的 Web 界面再添加一个 Web 服务器。 

1.安装和配置 Cobbler

Cobbler 不在 CentOS 6.2 的基本源中,需要导入 EPEL 源: 

# rpm -Uvh http://dl.Fedoraproject.org/pub/epel/6/x86_64/epel-release-6-5.noarch.rpm
Retrieving http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-5.noarch.rpm
warning: /var/tmp/rpm-tmp.lo2Hd0: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing...                ########################################### [100%]
   1:epel-release           ########################################### [100%]

# yum update
# yum upgrade
安装 cobbler:
# yum install cobbler
修改配置,主要修改 cobbler 服务器所在的 IP 地址,以及开启dhcp管理(详见第3步)
# vi /etc/cobbler/settings
...
next_server: 192.168.10.1 #IP of Cobbler server
server: 192.168.10.1 #IP of Cobbler server
...
manage_dhcp: 1   # (*可选)
启用 httpd, xinetd 和 cobbler 服务并确认已经加到系统自动启动服务中:
# /etc/init.d/httpd start
# /etc/init.d/xinetd start
# /etc/init.d/cobblerd start  (可能需要先禁用selinux)

# chkconfig httpd on
# chkconfig xinetd on
# chkconfig cobblerd on
修改 rsync 和 tftp 这两个服务的 xinetd 配置:
# vi /etc/xinetd.d/rsync
service rsync
{
        disable = no
...
}

# vi /etc/xinetd.d/tftp
service tftp
{
        ...
        disable = no
        ...
}
关闭防火墙和 SELinux 后重启系统:
# /etc/init.d/iptables stop
# chkconfig iptables off

# vi /etc/sysconfig/selinux
...
SELINUX=disabled
...

# reboot
 

2.检查和修改Cobbler配置

# cobbler check

这是cobbler自带的检测命令,提供cobbler必须的一些设置的检查,运行之后根据不同的环境,检测出来的结果也是不同的,不过所有的检测中我们都可以按照他的提示,一步步的来完善配置。

我们这里运行之后发现如下的错误:

The following are potential configuration items that you may want to fix:
 
1: some network boot-loaders are missing from /var/lib/cobbler/loaders, you may run ‘cobbler get-loaders’ to download them, or, if you only want to handle x86/x86_64 netbooting, you may ensure that you have installed a *recent* version of the syslinux package installed and can ignore this message entirely.  Files in this directory, should you want to support all architectures, should include pxelinux.0, menu.c32, elilo.efi, and yaboot.The ‘cobbler get-loaders’ command is the easiest way to resolve these requirements.
2 : ksvalidator was not found, install pykickstart
3 : debmirror package is not installed, it will be required to manage debian deployments and repositories
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
5 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them
 
Restart cobblerd and then run ‘cobbler sync’ to apply changes.

我们一个个来解决:

修复问题1:

# cobbler get-loader
即可获取各ios的bootloader

修复问题2:

安装ksvalidator
# yum install pykickstart

修复问题3:

cobbler服务器能同时部署CentOS/Fedora/Debian/Ubuntu系统,所以需要安装debmirror,安装debmirror-20090807-1.el5.noarch.rpm,在此之前,需要先安装一些其他的依赖包:

# yum install ed patch perl perl-Compress-Zlib perl-Cwd perl-Digest-MD5 perl-Digest-SHA1 perl-LockFile-Simple perl-libwww-perl
# wget ftp://fr2.rpmfind.net/linux/epel/5/ppc/debmirror-20090807-1.el5.noarch.rpm (责任编辑:IT)

------分隔线----------------------------