Cobbler自动化集群Linux系统安装

andyzhaojianhui 2014-10-13

Cobbler:是一个快速网络安装Linux的工具,使用简单的命令即可完成PXE网络安装环境的配置,同时还可以管理DHCP,DNS,以及yum包镜像。Cobbler支持命令行管理,web界面管理

主要由Repository,Distribution,Profile:各部分组成分别是

Repository:mirror url

Distribution:kernek ,initrd

Profile:distribution,kickstart file ,repositories

实验内容

1.1安装实验所需要的程序

    [root@node1 ~]# yum install cobbler  pykickstart debmirror

在安装cobbler时会自动安装httpd程序

1.2安装完成后启动

    [root@node1 ~]# service httpd start   
    Starting httpd:   
    [root@node1 ~]# service cobblerd start   
    Starting cobbler daemon:         

1.3检测cobbler存在哪些错误

[root@node1 ~]# cobbler check

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

    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 th    e PXE network.
    3 : some network boot-    loaders are missing from /var/lib/cobbler/loaders, you may ru    n '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.
    4 : change 'disable' to 'no' in /etc/xinetd.d/rsync
    5 : comment 'dists' on /etc/debmirror.conf for proper debian support
    6 : comment 'arches' on /etc/debmirror.conf for proper debian support
    7 : The default password used by the sample templates for newly installed machines (def    ault_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
    8 : fencing tools were not found, and are required to use the (optional) power manageme    nt features. install cman or fence-agents to use them
    Restart cobblerd and then run 'cobbler sync' to apply changes.

下来一个个排错

1,修改/etc/cobbler/settings文件中的server参数值为提供cobbler服务的主机相应的IP地址或主机名和next_server参数的值为PXE服务的主机相应的IP地址   

    server=172.16.18.1
    next_server=172.16.18.1

2,生成密码,替换默认密码

    [root@node1 ~]# openssl passwd -1 -salt $(openssl rand -hex 4)”     
    Password:      $1$d69ce09e$UNrtVcVkT.Rd5E6bSVxx8/
    default_password_crypted: " $1$d69ce09e$UNrtVcVkT.Rd5E6bSVxx8/"

3,复制/usr/share/syslinux/*所有文件去/var/lib/cobbler/loaders/目录中

    [root@node1 ~]# cp -r  /usr/share/syslinux/* /var/lib/cobbler/loaders/

4,注释/etc/debmirror.conf中的两个参数

    #@dists="sid";
    #@arches="i386";

5,安装相应的程序包

    yum install cman fence-agents

6,chkconfig rsync on

7,启动,检测

    [root@node1 ~]# service cobblerd start

8,cobbler check 检测是否还有错误

    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 ru    n '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.
    Restart cobblerd and then run 'cobbler sync' to apply changes.

此错误可以忽略了,我们已经将所需要的文件都复制过去了。

此时环境就算配置好了

2.1下来需要配置pxe所需要的服务。DHCP TFTP RSYNC DNS,其中dhcp tftp rsync为必须
    [root@node1 ~]# yum install dhcp
    [root@node1 ~]# service dhcpd start  Starting dhcpd:                        [ OK ]

复制/usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample到/etc/dhcp/dhcpd.conf覆盖原有文件,编辑

  [root@node1 ~]# vim /etc/dhcp/dhcpd.conf
    option domain-name "aolens.com";
    option domain-name-servers 172.16.18.1 ;
    default-lease-time 10000;
    max-lease-time 20000;
    log-facility local7;
    subnet 172.16.0.0 netmask 255.255.0.0 {
      range 172.16.18.100 172.16.18.110;
      option routers 172.16.18.1;
    }
    next-server 172.16.18.1;
    filename="pxelinux.0";

其他的全注释掉

    [root@node1 ~]# service dhcpd restart 
    Shutting down dhcpd:                                      [ OK ] 
    Starting dhcpd:                                          [ OK ]

2.2启动tftp服务器
    [root@node1 ~]#  chkconfig tftp on
    [root@node1 ~]#  service xinetd restart
3.1首先添加distro    ,这一步是定义ramdisk和内核文件。我们直接导入完整的光盘镜像。

我们先将光盘镜像装载上,挂载于/mnt下

    [root@node1 ~]# mount /dev/cdrom /mnt/
对光盘镜像进行导入
    cobbler import --name=CentOS-6.5-x86_64 --path=/mnt
导入成功后查看
    [root@node1 ~]# cobbler distro list  centos-6.5-x86_64
发现一个distro

3.2 提供一个kickstart文件

启动kickstart工具需要安装

    yum  install system-config-kickstart

然后运行system-config-kickstart

Cobbler自动化集群Linux系统安装

具体的操作过程去不做演示,将生成的kickstart文件放在/var/lib/cobbler/kickstarts/下

要确保url --url="http://172.16.0.1/cobbler/ks_mirror/centos-6.5-x86_64/"指向正确的yum源,也就是导入的光盘文件

也可以直接复制系统中的/root/anaconda-ks.cfg 做修改使用。

下边提供一个kickstart文件供大家参考

    #platform=x86, AMD64, or Intel EM64T
    firewall --disabled
    # Install OS instead of upgrade
    install
    # Use network installation
    url --url="http://172.16.0.1/cobbler/ks_mirror/centos-6.5-x86_64/"
    # Root password
    rootpw --iscrypted $1$iRHppr42$VMesh73wBqhUTjKp6OYOD.
    # System authorization information
    auth --useshadow --passalgo=sha512
    # Use text mode install
    text
    firstboot --disable
    # System keyboard
    keyboard us
    # SELinux configuration
    selinux --disabled
    # Reboot after installation
    reboot
    # System timezone
    timezone Asia/Shanghai
    # System bootloader configuration
    part /boot --fstype="ext4" --size=200
    part pv.008 --size=61440
    logvol swap --name=swap --vgname=vg0 --size=2048
    logvol /usr --fstype=ext4 --name=usr --vgname=vg0 --size=10240
    logvol /var --fstype=ext4 --name=var --vgname=vg0 --size=20480
    %post
    sed -i '1,$s@id:[0-9]:initdefault:@id:3:initdefault:@g' /etc/inittab
    [ ! -d /root/.ssh ] && mkdir /root/.ssh && chmod og=--- /root/.ssh
    cat >> /root/.ssh/authorized_keys > /etc/hosts
    %end
    %packages
    @base
    @basic-desktop
    @chinese-support
    @client-mgmt-tools
    @core
    @desktop-platform
    @fonts
    @general-desktop
    @graphical-admin-tools
    @legacy-x
    @network-file-system-client
    @perl-runtime
    @remote-desktop-clients
    @x11
    func
    lftp
    ibus-table-cangjie
    ibus-table-erbi
    ibus-table-wubi
    puppet
    %end

3.2创建profile

profile来为cobbler提供所需要安装配置,即在distro的基础上通过提供kickstart文件来生成一个特定的系统安装配置。distro的profile可以出现在PXE的引导菜单中作为安装的选择之一。
    [root@node1 ~]# cobbler profile add --name=centos-6.5-x86_64-basic --distro=centos-6.5-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos6.x86_64.cfg
查看profile文件是否创建成功,每一个kickstart都可以创建一个profile来安装不同配置的程序
    [root@node1 ~]# cobbler profile list  centos-6.5-x86-basic  centos-6.5-x86_64
    [root@node1 ~]# cobbler sync    同步一下

相关推荐