说明: 此安装方法为centos6.5 系统安装方法,

cobbler版本为2.6   基它基于centos的安装方法可能略有不同

web管理用户名与密码:cobbler cobbler

安装完centos6.4后的root管理员密码:cobbler 

既用以下命令生成的密码: 

openssl passwd -1 -salt 'random-phrase-here' 'cobbler'


一. 安装配置epel配置源:

centos6.5  cobbler安装配置:

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


二. 安装相关依赖包软件

yum -y install gcc gcc-c++

yum -y install cman tftp-server cobbler cobbler-web pykickstart debmirror dnsmasq dhcp

yum -y install python-ctypes rsync 如果这个包没安装将会报错


三. 开启IP转发

echo 1 > /proc/sys/net/ipv4/ip_forward

sed -i 's/net.ipv4.ip_forward = 0/net.ipv4.ip_forward = 1/' /etc/sysctl.conf

sysctl -p   //使设置生效


设置机器的hostname和FQDN名字,这是习惯,不是必须

[root@rdo ~]# hostname

cobbler

[root@rdo ~]# hostname -f

cobbler.com

要实现这个效果,需要修改两个文件

编辑 /etc/sysconfig/network ,你需要加入一行,记住HOSTNAME,必须大写。

# cat /etc/sysconfig/network

NETWORKING=yes

HOSTNAME=cobbler

编辑 /etc/hosts,增加一行


192.168.785.133   cobbler.com    cobbler

退出ssh,再登陆,就应该生效。


==============================================

四.关闭防火墙与selinux

service iptables stop

setenforce 0


五. 启动

chkconfig httpd on 

chkconfig cobblerd on

chkconfig dnsmasq on

/etc/init.d/httpd restart

/etc/init.d/cobblerd restart

/etc/init.d/dnsmasq restart


开启tftp服务及rsync服务

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

disable                 = no   //更改完成后为no


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

disable                 = no   //更改完成后为no


service xinetd restart





六 . 启动菜单


cobbler get-loaders

[root@mfs-matelog ~]# cobbler get-loaders

以下显成“TASK COMPLETE”完成说明执行成功

task started: 2014-08-11_095152_get_loaders

task started (id=Download Bootloader Content, time=Mon Aug 11 09:51:52 2014)

downloading http://www.cobblerd.org/loaders/README to /var/lib/cobbler/loaders/README

downloading http://www.cobblerd.org/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilo

downloading http://www.cobblerd.org/loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yaboot

downloading http://www.cobblerd.org/loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.syslinux

downloading http://www.cobblerd.org/loaders/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64.efi

downloading http://www.cobblerd.org/loaders/yaboot-1.3.14-12 to /var/lib/cobbler/loaders/yaboot

downloading http://www.cobblerd.org/loaders/pxelinux.0-3.86 to /var/lib/cobbler/loaders/pxelinux.0

downloading http://www.cobblerd.org/loaders/menu.c32-3.86 to /var/lib/cobbler/loaders/menu.c32

downloading http://www.cobblerd.org/loaders/grub-0.97-x86.efi to /var/lib/cobbler/loaders/grub-x86.efi

downloading http://www.cobblerd.org/loaders/grub-0.97-x86_64.efi to /var/lib/cobbler/loaders/grub-x86_64.efi

*** TASK COMPLETE ***

[root@mfs-matelog ~]# 


web登陆认证


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


设置cobbler  web登陆,用户登陆密码


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


设置debmirror


sed -i -e 's|@dists=.*|#@dists=|'  /etc/debmirror.conf

sed -i -e 's|@arches=.*|#@arches=|'  /etc/debmirror.conf


七. 编辑dnsmasq.template 模板


这是重点

vi /etc/cobbler/dnsmasq.template 

# Cobbler generated configuration file for dnsmasq

# $date

#


# resolve.conf .. ?

#no-poll

#enable-dbus

read-ethers

addn-hosts = /var/lib/cobbler/cobbler_hosts


#dhcp-range=192.168.1.5,192.168.1.200

dhcp-range=192.168.75.200,192.168.75.210

dhcp-ignore=:tab:!known

dhcp-option=3,$next_server

dhcp-lease-max=1000

dhcp-authoritative

dhcp-boot=pxelinux.0

dhcp-boot=net:normalarch,pxelinux.0

dhcp-boot=net:ia64,$elilo


$insert_cobbler_system_definitions

八. 设置模块


/etc/cobbler/modules.conf


让cobbler去管理dnsmasq。默认他是使用bind管理dns,isc实现dhcp。


[dns]

#module = manage_bind

module = manage_dnsmasq


[dhcp]

#module = manage_isc

module = manage_dnsmasq


九. 动态更新设置

动态更新设置


对于Cobbler2.6来说,有一个重要的功能,就是让你可以不需要手工去编辑setting配置文件,直接使用命令去修改,默认这个功能是不启用,你需要启用。


cd /etc/cobbler/

cp settings settings.save

sed -i 's/^[[:space:]]\+/ /' /etc/cobbler/settings

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


重启cobbler服务


/etc/init.d/cobblerd restart

cobbler setting report   可以查看默认配置


在命令行指定以下设置IP地址为cobbler服务器IP地址


cobbler setting edit --name=server --value=192.168.75.133

cobbler setting edit --name=pxe_just_once --value=1

cobbler setting edit --name=next_server --value=192.168.75.133


cobbler setting edit --name=manage_rsync --value=1

cobbler setting edit --name=manage_dhcp --value=1

cobbler setting edit --name=manage_dns --value=1


设置root默认密码,当安装完centos6.4后默认的root密码就是cobbler


这个设置只针对centos有效。我默认的root密码是:root123


openssl passwd -1 -salt 'random-phrase-here' 'cobbler'

$1$random-p$99lAzJZEl9uunSaThe9oM0

 


修改配置


这个地方不能用命令修改,应该是bug,将上面生成的替换/etc/cobbler/settings 里面的default_password_crypted既可


#default_password_crypted: $1$mF86/UHC$WvcIcX2t6crBz2onWxyac.

default_password_crypted: $1$random-p$99lAzJZEl9uunSaThe9oM0

 

/etc/init.d/cobblerd restart

 

设置apache目录访问


# cat /etc/httpd/conf.d/welcome.conf

<LocationMatch "^/+$">

 Options Indexes FollowSymLinks

    Order allow,deny

    Allow from all

</LocationMatch>


/etc/init.d/httpd restart



cobbler repo add --mirror=http://mirrors.ustc.edu.cn/epel/6/x86_64/ --name=epel6-x86_64 --arch=x86_64 --breed=yum

cobbler repo add --mirror=http://mirrors.ustc.edu.cn/epel/testing/6/x86_64/ --name=epel6-x86_64-testing --arch=x86_64 --breed=yum

cobbler repo add --name=Centos6-UPDATES --mirror=http://mirrors.ustc.edu.cn/centos/6/updates/x86_64/ --arch=x86_64 --breed=yum


挂载ISO

mount -t auto -o loop /var/www/html/iso/CentOS-6.4-x86_64-bin-DVD1.iso /mnt

cobbler import --path=/mnt --name=CentOS6.4 --arch=x86_64


创建索引

[root@mfs-matelog CentOS6.4-x86_64]# pwd

/var/www/cobbler/ks_mirror/CentOS6.4-x86_64

[root@mfs-matelog CentOS6.4-x86_64]# createrepo -g repodata/2727fcb43fbe4c1a3588992af8c19e4d97167aee2f6088959221fc285cab6f72-c6-x86_64-comps.xml .


配置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;


option pxe-system-type code 93 = unsigned integer 16;


subnet 192.168.75.0 netmask 255.255.255.0 { //更改为本机Ip地址

     option routers             192.168.75.133;

     option domain-name-servers 192.168.75.133;

     option subnet-mask         255.255.255.0;

     range dynamic-bootp        192.168.75.100 192.168.75.254;

     default-lease-time         21600;

     max-lease-time             43200;

     next-server                $next_server;

     class "pxeclients" {

          match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";

          if option pxe-system-type = 00:02 {

                  filename "ia64/elilo.efi";

          } else if option pxe-system-type = 00:06 {

                  filename "grub/grub-x86.efi";

          } else if option pxe-system-type = 00:07 {

                  filename "grub/grub-x86_64.efi";

          } else {

                  filename "pxelinux.0";

          }

     }


启动cobbler服务


cobbler check

cobbler sync

/etc/init.d/cobbler restart



web访问cobbler 方式:

http://192.168.75.133/cobbler_web

用户名: cobbler

密码:   cobbler