安装RPM源

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

安装NTP

1
2
3
# yum install -y ntp 
# ntpdate 202.120.2.101
# hwclock -w

停止防火墙和SElinux

1
2
3
4
# service iptables stop 
# chconfig iptables off
# getenforce
Disable

安装cobbler

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

配置服务开机启动

1
2
3
4
5
6
7
8
9
#chkconfig httpd on
#chkconfig dhcpd on
#chkconfig xinetd on
#chkconfig cobblerd on

#vim /etc/httpd/conf/httpd.conf
ServerName 192.168.56.20:80
# service httpd start
# service cobblerd start

执行配置检查

1
2
3
4
5
6
7
8
9
10
11
12
13
# 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.
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.
3 : SELinux is enabled. Please review the following wiki page for details on ensuring cobbler works correctly in your SELinux environment:
https://github.com/cobbler/cobbler/wiki/Selinux
4 : service dhcpd is not running
5 : 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.
6 : change 'disable' to 'no' in /etc/xinetd.d/rsync
7 : comment out 'dists' on /etc/debmirror.conf for proper debian support
8 : comment out 'arches' on /etc/debmirror.conf for proper debian support
9 : 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

1.server IP 替换为cobblerserver IP

1
2
#vim /etc/cobbler/settings
server: 192.168.56.20

2.next-server

1
2
#vim /etc/cobbler/settings
next-server: 192.168.56.20

3.关闭SElinux

4.启动dhcpd

1
#service dhcpd start

5.下载启动资源

1
#cobbler get-loaders

6.修改rsync配置

1
2
#vi /etc/xinetd.d/rsync
disable = no

7.debmmirror错误,注释掉如下两行

1
2
3
#vi /etc/debmirror.conf
#@dists="sid";
#@arches="i386";

8.设置默认root密码

这里设置的就是客户端安装好系统的root密码

1
2
3
4
5
6
7
#生成你想要的密码的加密字符串,然后复制运行命令之后的加密代码;
# openssl passwd -1 -salt 'serverpa' '123456'
$1$serverpa$p60qEVNGw9Y6qbfvUW0SJ/

#然后替换/etc/cobbler/settings 中选项双引号中的加密代码;
# vi /etc/cobbler/settings
default_password_crypted: "$1$serverpa$p60qEVNGw9Y6qbfvUW0SJ/"

重启cobbler, 检查配置

1
2
3
4
5
# service cobblerd restart
Stopping cobbler daemon: [ OK ]
Starting cobbler daemon: [ OK ]
# cobbler check
No configuration problems found. All systems go.

配置Cobbler

主要的 Cobbler 配置文件是 /etc/cobbler/settings

1
2
3
4
5
6
7
8
manage_dhcp:1
manage_dns:1
manage_tftpd:1
restart_dhcp:1
restart_dns:1
pxe_just_once:1
next_server:<服务器的 IP 地址>
server:<服务器的 IP 地址>

选项 manage_*restart_* 无需加以说明。选项 next_server 用在 DHCP 配置文件中,向客户端告知提供引导文件的服务器地址。选项 server 在客户端安装期间用于引用 Cobbler 服务器地址。最后,选项 pxe_just_once 预防将机器中的安装循环配置为始终从网络引导。激活此选项时,机器告诉 Cobbler 安装已完成。Cobbler 将系统对象的 netboot 标志更改为 false,这会强制机器从本地磁盘引导。好了,下面我们配置并管理dhcp服务与http服务

1.让Cobbler管理DHCP

1
2
# vi /etc/cobbler/settings
manage_dhcp: 1

2.修改DHCP模版

1
2
3
4
5
6
7
8
9
10
11
# vi /etc/cobbler/dhcp.template 
subnet 192.168.56.0 netmask 255.255.255.0 {
option routers 192.168.56.254;
option domain-name-servers 8.8.8.8;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.56.221 192.168.56.225;
filename "/pxelinux.0";
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
}

3.重新启动Cobbler服务,同步cobbler

1
2
3
4
# service cobblerd restart
Stopping cobbler daemon: [ OK ]
Starting cobbler daemon: [ OK ]
# cobbler sync