Chinaunix首页 | 论坛 | 博客
  • 博客访问: 277048
  • 博文数量: 41
  • 博客积分: 2660
  • 博客等级: 大尉
  • 技术积分: 442
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-11 17:33
文章分类

全部博文(41)

文章存档

2012年(15)

2011年(21)

2010年(5)

分类: LINUX

2012-01-01 01:21:58

       默认的rhel 光盘中没有 cobbler 软件,必须使用第三方的软件源才能安装 cobbler 软件 。但是呢光是安装这一个软件包是不能帮助我们完成大批量安装这个工作滴。那么问题来了。看见这个标题有童鞋问了。为什么不用 Kickstart部署呢?你这种部署有啥与众不同呢? Cobbler 批量部署的原理其实和 Kickstart 部署的原理有类似之处。 在此 就不予以深究,没有理解的童鞋请回顾 Kickstart 网络安装的原理以及实施方式。

    直奔Cobbler 的主题吧,这才是今天讨论的重点。 Cobbler 项目最初在 2008 年左右发布。是红帽软件 Fedora 项目社区的一个子项目。是新一代网络安装套件可以快速建立网络安装环境。降低大批量部署安装的难度。兄弟们苦逼的日子来啦啊。 原因你懂的!

      cobbler官方网站: 

Cobbler作为一个预备工具,使部署 RedHat/Centos/Fedora 系统更容易,同时也支持 Suse  Debian 系统的部署。(据说支持WINDOWS,还么测试哦。不过有个东西可以再LINUX上快速部署WIN系统。已经测试很成功。下回分享给大家)

它提供以下服务集成:

* PXE服务支持

* DHCP服务管理

* DNS服务管理

* Kickstart服务支持

* yum仓库管理

Cobbler客户端 Koan 支持虚拟机安装和操作系统重新安装。

Cobbler服务器部署:

1、  确保EPEL 仓库可用,如果不可用先安装 epel 包: 同时确保本地仓库也是可用的。 (确保机器可以联网)需要注意一点,注意 /var/www/cobbler  目录必须具有足够容纳  Linux  安装文件的空间 ( 移动,建软链接 ) 一本 5G 左右吧,但是你要同步不了 YUM 源了。这个后面再探讨。

# rpm -Uvh  

# wget 

# rpm -ivh  epel-release-5-4.noarch.rpm 

#yum list 

2、安装 cobbler server 需要的的所有包:

# yum install cobbler httpd rsync tftp-server xinetd dhcp

修改 tftp:


# sed '/disable/s/no/yes/g' /etc/xinetd.d/tftp

# sed '/disable/s/no/yes/g' /etc/xinetd.d/rsync

# /etc/init.d/xinetd restart

3、启动 httpd  cobblerd ,并设置为开机自启动:

# service httpd start

# service cobblerd start

chkconfig httpd on

chkconfig dhcpd on

sbin/chkconfig xinetd on

sbin/chkconfig tftp on

sbin/chkconfig cobblerd on

4、检查 cobbler 相关配置:

下面是执行# cobbler check 出来的信息:

The following are potential configuration items that you may want to fix:

1 : The 'server' field in /etc/cobbler/settings must be set to something other than localhost, or kickstarting features will not work.  This should be a resolvable hostname or IP for the boot server as reachable by all machines that will use it.

#修改 server 选项为主机名或是 IP 地址

2 : For PXE to be functional, the 'next_server' field in /etc/cobbler/settings must be set to something other than 127.0.0.1, and should match the IP of the boot server on the PXE network.

#修改 next-server 对应的 IP  地址

3 : Must enable a selinux boolean to enable vital web services components, run: setsebool -P httpd_can_network_connect true

#修改 SELINUX setsebool -P httpd_can_network_connect true 

4 : you need to set some SELinux content rules to ensure cobbler serves content correctly in your SELinux environment, run the following: /usr/sbin/semanage fcontext -a -t public_content_t "/tftpboot/.*" && /usr/sbin/semanage fcontext -a -t public_content_t "/var/www/cobbler/images/.*"

#修改 selinux 安全上下文标签

5 : you need to set some SELinux rules if you want to use cobbler-web (an optional package), run the following: /usr/sbin/semanage fcontext -a -t httpd_sys_content_rw_t "/var/lib/cobbler/webui_sessions/.*"

#修改   cobbler 对应的安全上下文标签

6 : 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.

#运行 cobbler get-loaders   以获取 PXE 启动需要的文件

7 : change 'disable' to 'no' in /etc/xinetd.d/tftp

#开启 tftp

8 : change 'disable' to 'no' in /etc/xinetd.d/rsync

#开启 rsync

9 : since iptables may be running, ensure 69, 80, and 25151 are unblocked

#确保 69,80,25151 这个几个端口没有 iptables 阻止

10 : debmirror package is not installed, it will be required to manage debian deployments and repositories

# debian的镜像包没有安装,如果不安装 debian ,这条可忽略

11 : 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

要求使用以上命令行创建新的密码

12 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them

没有安装 fencing 工具,

Restart cobblerd and then run 'cobbler sync' to apply changes.上面已经说的够清楚的了吧?你看懂了嘛?下面给出我的应对之策:

修正上面错误:

1)、 vi /etc/cobbler/settings

server: 192.168. 1.40    #设置 cobbler server  IP 地址

next-server: 192.168. 1 . 40   #设置 PXE server  IP 地址

manage_dhcp: 1   #开启管理 DHCP 服务

default_kickstart: /var/lib/cobbler/kickstarts/default.ks    #设置默认的 kickstart 配置文件,用 system-config-kickstart (需要 图形 环境)生成 。直接写得了。

2)、关闭防火墙和 SElinux

3)、获取启动镜像

# cobbler get-loaders

4)、启动 tftp  rsync

vi /etc/xinetd.d/tftp

disable                 = yes 改为: disable                 = no

vi /etc/xinetd.d/rsync

disable                 = yes 改为: disable                 = no

重启xinetd 服务:

/etc/init.d/xinetd restart

5)、修改 DHCP 模板,确保 DHCP 分配的地址和 Cobbler 在同一网段 (这个可用不这么做。你可以直接架设一个 DHCP

vi 

/etc/cobbler/dhcp.template

# ******************************************************************

# 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;

subnet 192.168. 1 .0 netmask 255.255.255.0    {

     option routers             192.168. 1 . 254 ;

     # option domain-name-servers 192.168. 1.1 ;

     option subnet-mask         255.255.255.0;

     range dynamic-bootp        192.168. 1 .100 192.168. 1 .200;

     filename                   "/pxelinux.0";

     next-server                $next_server;

     default-lease-time         21600;

     max-lease-time             43200;

}

#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 {

        hardware ethernet $mac;

        #if $iface.ip_address:

        fixed-address $iface.ip_address;

        #end if

        #if $iface.hostname:

        option host-name "$iface.hostname";

        #end if

        #if $iface.subnet:

        option subnet-mask $iface.subnet;

        #end if

        #if $iface.gateway:

        option routers $iface.gateway;

        #end if

        filename "$iface.filename";

        ## 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

5、同步 cobbler 配置,使修改生效:

# cobbler sync

6、挂载 Linux 光盘 ,生成安装镜像:

# mount /dev/cdrom /mnt/

# cobbler import --path=/mnt/ --name= RHEL5.6-x86-64

7 RPM 仓库管理 (根据需要自己决定吧)

相关阅读:

我们可以为cobbler 添加 RPM 仓库:

cobbler repo add --name=  RHEL5.6-x86-64   --mirror= 

cobbler repo add --name= EPEL5.-x86-64    --mirror=   

同步仓库到本地:

cobbler reposync

也可以通过设置--mirror-locally=0 不下载到本地,而通过 kickstart server 去仓库下载 rpm 包。

添加计划任务,每天凌晨两点进行一次同步:

crontab -e

0 2 * * * cobbler reposync --tries=3 --no-fail

8、设置 profile  system (这个功能比较牛 P。需要深入研究哈)

profile可以理解为按角色进行分类。

cobbler profile add --name=webserver --distro=CentOS-5-i386 --repos=EPEL-5-i386 --kickstart=/var/lib/cobbler/kickstarts/webserver.ks

system是对待安装机器做具体设置,如设置主机名、 IP 地址、 hostname 等,这些设置根据 MAC 应用到具体机器上。

# cobbler system add --name=webserver1 --ip=192.168.0.110 --mac=00:0C:29:77:89:c7 --profile=webserver --kickstart=/var/lib/cobbler/kickstarts/webserver.ks --static=1

# cobbler system edit --name=webserver1 --dns-name=webserver1.grid.house.sina.com.cn --hostname=webserver1.grid.house.sina.com.cn

cobbler system edit --name=webserver1 --gateway=192.168.0.1 --subnet=255.255.255.0

cobbler system edit --name=webserver1 --interface=eth1 --static=0

可以通过访问 来查看真正的 kickstart 配置。

9、启动待安装的服务器,开始安装。

10、重新安装

yum install koan

koan --server=192.168. 1 . 40  --list=profiles

koan --replace-self --server=192.168. 1 . 40  --profile=webserver

reboot

11、设置 Cobbler web 界面

Cobbler web界面是一个很好的前端,非常容易管理很多 Cobbler 操作。可以用它列出和编辑distros, profiles, subprofiles, systems, repos and kickstart 文件。

安装Cobbler web 

yum install cobbler-web

Cobbler web界面访问地址:

 1.40 /cobbler_web/

  (192.168. 1.40 Cobbler web server 地址)

设置用户名密码:

为已存在的用户重置密码:

htdigest /etc/cobbler/users.digest "Cobbler" cobbler 

添加新用户:

htdigest /etc/cobbler/users.digest "Cobbler"  username

设置/etc/cobbler/modules 如下:

[authentication]  

module = authn_configfile  

[authorization]  

module = authz_allowall   

重启Cobbler 服务:

service cobblerd restart 

12 Cobbler 命令说明

cobbler check - 核对当前设置是否有问题

cobbler list - 列出所有的 cobbler 元素

cobbler report - 详细的列出个元素

cobbler sync - 同步配置到 dhcp/pxe 和数据目录

cobbler reposync - 同步 yum 仓库

13 Cobbler 配置文件说明

Cobbler配置文件存放在 /etc/cobbler 下。 /etc/cobbler/settings 为主配置文件;在 /etc/cobbler 下你还能看到 dhcp  dns  pxe  dnsmasq 的模板配置文件; /etc/cobbler/users.digest 为用于 web 访问的用户名密码配置文件; /etc/cobbler/modules.conf  为模块配置文件;/etc/cobbler/users.conf  Cobbler WebUI/Web service 授权配置文件。

Repo数据目录 /var/www/cobbler

导入的发行版,repos 镜像和 kickstart 文件都放置在 /var/www/cobbler 目录下。确保 /var 目录有足够的空间来存储这些文件。

images/ - 存储所有导入发行版的 Kernel  initrd 镜像用于远程网络启动  

ks_mirror/ - 存储导入的发行版  

repo_mirror/ - yum repos存储目录

/var/log/cobbler用于存放日志文件 /var/log/cobbler/cobbler.log

Cobbler数据目录 /var/lib/cobbler ,此目录存储和 Cobbler profiles  systems  distros 相关的配置。

configs/ - 此目录用于存储 distros  repos  systems  profiles 相关信息

backup/ - 备份目录 

snippets/  - 用于放置一些可以在 kickstarts 导入的脚本小片段

triggers/  - 此目录用来放置一些可执行脚本

kickstarts/  - 此目录用来放置 kickstart 模板文件

Puppet 整合进行配置管理: 这个功能后续在研究吧。先写到这里。感谢你的支持。

参考文献:

 

http://candon123.blog.51cto.com/704299/596302  

http://hi.baidu.com/lenvol/blog/item/8e8b123d038f98fb55e72342.html  

 

 

 

 

http://myhat.blog.51cto.com/391263/684485  

阅读(4638) | 评论(0) | 转发(2) |
给主人留下些什么吧!~~