安装系统:centos_6.5


sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config
setenforce 0
chkconfig iptables off
service iptables stop


重启机器



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

yum clean all

sleep 2

yum install -y cobbler tftp dhcp httpd cman pykickstart debmirror
yum install -y ed patch perl perl-Compress-Zlib perl-Digest-SHA1 perl-LockFile-Simple perl-libwww-perl

sleep 10

chkconfig httpd on
chkconfig dhcpd on
chkconfig xinetd on
chkconfig cobblerd on
sleep 2

sed -i 's/#ServerName www.example.com:80/ServerName 127.0.0.1:80/g' /etc/httpd/conf/httpd.conf
service httpd start
netstat -ntulp | grep :80

sleep 5

service cobblerd restart
sleep 1
cobbler check

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

sleep 5
sed -i '/disable/ s/^.*$/        disable                 = no/g' /etc/xinetd.d/tftp

sed -i '/disable/ s/^.*$/        disable         = no/g' /etc/xinetd.d/rsync
service xinetd start
sleep 1

sed -i 's/@dists="sid";/#@dists="sid";/g'  /etc/debmirror.conf
sed -i 's/@arches="i386";/#@arches="i386";/g'  /etc/debmirror.conf
sed -i '/default_password_crypted/ s/^.*$/default_password_crypted: "$1$hahaha$vsb1I2cBmYBaA0VxRyixp1"/g' /etc/cobbler/settings
sed -i 's/manage_dhcp: 0/manage_dhcp: 1/g' /etc/cobbler/settings

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


/etc/init.d/cobblerd restart


上传附件里的所有文件到/var/lib/cobbler/loaders/目录


cobbler check    #这步会报错,说dhcp没启动,按备注dhcp部分修改即可


cobbler sync



备注

1、DHCP 部分

[root@hscloud_cobbler ~]# vi /etc/dhcp/dhcpd.conf

# ******************************************************************
# Cobbler managed dhcpd.conf file
# generated from cobbler dhcp.conf template (Fri Apr  3 07:54:17 2015)
# 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.10.0 netmask 255.255.255.0 {
     option routers             192.168.10.1;
     option subnet-mask         255.255.255.0;
     filename                   "/pxelinux.0";
     default-lease-time         21600;
     max-lease-time             43200;
     next-server                192.168.10.240;

}

subnet 192.168.100.0 netmask 255.255.255.0 {
     option routers             192.168.100.254;
     option subnet-mask         255.255.255.0;
     filename                   "/pxelinux.0";
     default-lease-time         21600;
     max-lease-time             43200;
     next-server                192.168.10.240;
}

# group for Cobbler DHCP tag: default
group {
}




[root@hscloud_cobbler ~]# 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.10.0 netmask 255.255.255.0 {
     option routers             192.168.10.1;
     option subnet-mask         255.255.255.0;
     filename                   "/pxelinux.0";
     default-lease-time         21600;
     max-lease-time             43200;
     next-server                $next_server;

}

subnet 192.168.100.0 netmask 255.255.255.0 {
     option routers             192.168.100.254;
     option subnet-mask         255.255.255.0;
     filename                   "/pxelinux.0";
     default-lease-time         21600;
     max-lease-time             43200;
     next-server                $next_server;
}

#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.netmask:
        option subnet-mask $iface.netmask;
        #end if
        #if $iface.gateway:
        option routers $iface.gateway;
        #end if
        #if $iface.enable_gpxe:
        if exists user-class and option user-class = "gPXE" {
            filename "http://$cobbler_server/cblr/svc/op/gpxe/system/$iface.owner";
        } else if exists user-class and option user-class = "iPXE" {
            filename "http://$cobbler_server/cblr/svc/op/gpxe/system/$iface.owner";
        } else {
            filename "undionly.kpxe";
        }
        #else
        filename "$iface.filename";
        #end if
        ## 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

启动DHCP服务 /etc/init.d/dhcpd restart

注:此方式配置的DHCP可以分配多个网段

2、web界面安装部分

可以配置cobbler的web管理界面

(1)、安装软件包

[root@localhost ~]# yum -y install cobbler-web

(2)、设置用户名密码

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

[root@localhost ~]# htdigest /etc/cobbler/users.digest "Cobbler" cobbler

   添加新用户

[root@localhost ~]# htdigest /etc/cobbler/users.digest "Cobbler" admin

(3)、配置cobbler web可以登录

[root@localhost ~]# sed -i 's/authn_denyall/authn_configfile/g' /etc/cobbler/modules.conf

(4)、重启Cobbler与http

[root@localhost ~]# /etc/init.d/cobblerd restart

Stopping cobbler daemon: [  OK  ]

Starting cobbler daemon: [  OK  ]

[root@localhost ~]# /etc/init.d/httpd restart

Stopping httpd: [  OK  ]

Starting httpd: [  OK  ]

[root@localhost ~]#

(5)访问Cobbler Web页面

https://10.240.240.210/cobbler_web