RHEL6.5上安装配置Cobbler

Cobbler运行流程图

wKiom1VlNiXTpw_ZAAIHrmPBRsU175.jpg    

<特别声明: 该图来源“煮酒品茶”的博客,如有不妥,请联系本人删除,谢谢!>                  

加载epel

# rpm -Uvh http://mirrors.ustc.edu.cn/epel/6/x86_64/epel-release-6-8.noarch.rpm

或者

# rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

安装cobbler包及其组件

# yum install -y cobbler rsync tftp dhcphttpd cman pykickstart debmirror tftp-server xinetd python-ctypes

# yum install -y ed patch perlperl-Compress-Zlib perl-Digest-SHA1 perl-LockFile-Simple perl-libwww-perl

设置服务开机启动

# chkconfig httpd on

# chkconfig dhcpd on

# chkconfig xinetd on

# chkconfig cobblerd on

系统环境设置selinux/iptables

# sed -i '/SELINUX/s/enforcing/disabled/'/etc/selinux/config

# setenforce 0

# chkconfig iptables off

# service iptables stop

修改httpd配置并启动

# vim /etc/httpd/conf/httpd.conf

ServerName 127.0.0.1:80

# service httpd start

修改cobbler配置并启动

设置目标系统root密码

# PASSWORD=”`echo "zhangdh.com" |openssl passwd -1 -salt 'randomstr' �Cstdin`”

# sed -is@"^default_password_crypted.*$"@"default_password_crypted:\"$PASSWORD\""@g /etc/cobbler/settings

设置cobbler serverIP

# sed -i 's/server: 127.0.0.1/server:10.240.216.1/g' /etc/cobbler/settings

设置DHCP serverIP

# sed -i 's/next_server:127.0.0.1/next_server: 10.240.216.1/g' /etc/cobbler/settings

设置允许cobbler管理DHCP

# sed -i 's/manage_dhcp: 0/manage_dhcp:1/g' /etc/cobbler/settings

设置允许cobbler管理rsync

# sed -i 's/manage_rsync: 0/manage_rsync:1/g' /etc/cobbler/settings

设置一次安装开关(可选)

# sed -i 's/pxe_just_once: 0/pxe_just_once:1/g' /etc/cobbler/settings

修改cobbler管理DHCP的模板

# cat /etc/cobbler/dhcp.template

ddns-update-style interim;

 

allow booting;

allow bootp;

 

ignore client-updates;

set vendorclass = optionvendor-class-identifier;

 

option pxe-system-type code 93 = unsignedinteger 16;

 

subnet 10.240.216.0 netmask 255.255.255.0 {

    option routers            10.240.216.254;     #路由地址

    #option domain-name-servers 8.8.8.8;                            #DNSserver地址

    option subnet-mask        255.255.255.0;             #子网掩码

     #rangedynamic-bootp        10.240.216.210.240.216.200;  #分配IP地址段

    default-lease-time         21600;

    max-lease-time             43200;

    next-server               $next_server;

    filename                  "pxelinux.0";

}

subnet 10.240.217.0 netmask 255.255.255.0 {

    option routers            10.240.217.254;

    option subnet-mask        255.255.255.0;

    filename                  "/pxelinux.0";

    default-lease-time         21600;

    max-lease-time             43200;

    next-server               $next_server;

}

注:可添加很多个子网...

启动cobbler

# service cobblerd start

校验cobbler安装条件

# cobbler check

更新loader信息

# cobbler get-loaders

修改xinetd关于tftprsync的配置并启动

# sed -i '/disable/c\\tdisable\t\t\t= no'/etc/xinetd.d/tftp

# sed -i -e 's/\=\ yes/\=\ no/g'/etc/xinetd.d/rsync

# service xinetd start

配置dhcp server并启动

# cat /etc/dhcp/dhcpd.conf

ddns-update-style interim;

 

allow booting;

allow bootp;

 

ignore client-updates;

set vendorclass = optionvendor-class-identifier;

 

option pxe-system-type code 93 = unsignedinteger 16;

#可以添加多子网(保持和dhcp.template一致)

subnet 10.240.216.0 netmask 255.255.255.0 {

    option routers            10.240.216.254;

    option subnet-mask        255.255.255.0;

    filename                  "/pxelinux.0";

     #rangedynamic-bootp        10.240.216.210.240.216.200;

    default-lease-time         21600;

    max-lease-time             43200;

    next-server               10.240.216.1;

}

subnet 10.240.217.0 netmask 255.255.255.0 {

    option routers            10.240.217.254;

    option subnet-mask         255.255.255.0;

    filename                  "/pxelinux.0";

    default-lease-time         21600;

    max-lease-time             43200;

    next-server               10.240.216.1;

}

# group for Cobbler DHCP tag: default

group {

}

# service dhcpd start

修改debmirror.conf去掉仅对debian系统的支持参数

# sed -i "s/^@dists/#@dists/g"/etc/debmirror.conf

# sed -i "s/^@arches/#@arches/g"/etc/debmirror.conf

Cobbler配置同步

# service cobblerd restart

# cobbler sync

挂载安装镜像并导入distro

# mkdir /mnt/rhel6.5

# mkdir /mnt/rhel7.0

# mount -t iso9660 -o loop,ro/opt/rhel-server-6.5-x86_64-dvd.iso /mnt/rhel6.5

# cobbler import --name=redhat6.5--arch=x86_64 --path=/mnt/rhel6.5

查看生成的项目

# cobbler distro list

# cobbler profile list

查看项目明细

# cobbler report

自定义KS文件

# vim rhel6.5.ks

install

text

key --skip

keyboard us

lang en_US.UTF-8

skipx

network --device eth0 --bootproto dhcp

rootpw root

firewall --disabled

authconfig --enableshadow --enablemd5

selinux --disabled

timezone --utc Asia/Shanghai

url --url=$tree             

$SNIPPET('network_config')

bootloader --location=mbr --driveorder=sda

zerombr yes

clearpart --all

 

part /boot --fstype ext4 --size=200

#part /    --fstype ext4 --size=20000

part swap --fstype swap --size=4096

#part /u01 --fstype ext4 --grow --size=200

reboot

 

%packages

@base

@core

@server-policy

ipmitool

OpenIPMI

openssh-clients

net-snmp

%post


将自定义的kickstart文件与镜像相关联

# cobbler profile edit--name=redhat6.5-x86_64 --distro=redhat6.5-x86_64--kickstart=/var/lib/cobbler/kickstarts/rhel6.5.ks

再次同步cobbler配置

# cobbler sync                         ###下面贴出完整信息,注意红色部分

task started: 2015-05-25_154818_sync

task started (id=Sync, time=Mon May 2515:48:18 2015)

running pre-sync triggers

cleaning trees

removing:/var/www/cobbler/images/redhat6.5-x86_64

removing:/var/lib/tftpboot/pxelinux.cfg/default

removing: /var/lib/tftpboot/grub/efidefault

removing: /var/lib/tftpboot/grub/images

removing:/var/lib/tftpboot/images/redhat6.5-x86_64

removing:/var/lib/tftpboot/s390x/profile_list

copying bootloaders

trying hardlink/var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0

trying hardlink/var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32

trying hardlink /var/lib/cobbler/loaders/yaboot-> /var/lib/tftpboot/yaboot

trying hardlink/var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi

trying hardlink/var/lib/cobbler/loaders/grub-x86_64.efi ->/var/lib/tftpboot/grub/grub-x86_64.efi

copying distros to tftpboot

copying files for distro: redhat6.5-x86_64

trying hardlink/var/www/cobbler/ks_mirror/redhat6.5-x86_64/images/pxeboot/vmlinuz ->/var/lib/tftpboot/images/redhat6.5-x86_64/vmlinuz

trying hardlink/var/www/cobbler/ks_mirror/redhat6.5-x86_64/images/pxeboot/initrd.img ->/var/lib/tftpboot/images/redhat6.5-x86_64/initrd.img

copying images

generating PXE configuration files

generating PXE menu structure

copying files for distro: redhat6.5-x86_64

trying hardlink/var/www/cobbler/ks_mirror/redhat6.5-x86_64/images/pxeboot/vmlinuz ->/var/www/cobbler/images/redhat6.5-x86_64/vmlinuz

trying hardlink/var/www/cobbler/ks_mirror/redhat6.5-x86_64/images/pxeboot/initrd.img ->/var/www/cobbler/images/redhat6.5-x86_64/initrd.img

Writing template files for redhat6.5-x86_64

rendering DHCP files

generating /etc/dhcp/dhcpd.conf

rendering TFTPD files

generating /etc/xinetd.d/tftp

processing boot_files for distro:redhat6.5-x86_64

cleaning link caches

rendering Rsync files

running post-sync triggers

running python triggers from/var/lib/cobbler/triggers/sync/post/*

running python triggercobbler.modules.sync_post_restart_services

running: dhcpd -t -q

received on stdout:

received on stderr:

running: service dhcpd restart

received on stdout: Shutting down dhcpd: [  OK  ]

Starting dhcpd: [ OK  ]          <-- 必须要看到dhcpd服务启动才行

 

received on stderr:

running shell triggers from/var/lib/cobbler/triggers/sync/post/*

running python triggers from/var/lib/cobbler/triggers/change/*

running python trigger cobbler.modules.scm_track

running shell triggers from/var/lib/cobbler/triggers/change/*

*** TASK COMPLETE ***

<--到此就可以从一台新机器通过pxe启动系统了 -->

配置Cobblerweb管理界面

# yum -y install cobbler-web

# sed -i's/authn_denyall/authn_configfile/g' /etc/cobbler/modules.conf

# /etc/init.d/cobblerd restart

# /etc/init.d/httpd restart

访问地址:https://10.240.216.1/cobbler_web

你可能感兴趣的:(cobbler,自动化安装)