1、采用yum epel源安装 Cobbler 、dhcp、httpd等服务及相关依赖包
[[email protected] ~]# wget -c http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
[[email protected] ~]# rpm -ivh epel-release-6-8.noarch.rpm
[[email protected] ~]# yum clean all
[[email protected] ~]# yum makecache
[[email protected] ~]# yum install cobbler cobbler-web httpd rsync tftp-server xinetd dhcp python-ctypes debmirror pykickstart
2、修改cobbler配置文件 /etc/cobbler/settings
#DHCP服务器地址
next_server: 192.168.186.128
#cobbler服务器地址
server: 192.168.186.128
#将DHCP设置为cobbler管理
manage_dhcp: 1
#将rsync设置为cobbler管理
manage_rsync: 1
#将tftpd设置为cobbler管理
manage_tftpd: 1
#更该端口号(也可以使用默认的80号端口),更改端口号后,httpd配置文件的端口号也得更改为相同的
http_port: 8090
3、修改装机的默认密码(该密码 password 是新装机器root用户的登录密码)
[[email protected] ~]#openssl passwd -1 -salt ‘random-phrase‘ ‘password‘
$1$random-p$sFftrCTxKKsDZ.Sdr8mDG0
将生产的密码替换settings配置文件里的默认密码
default_password_crypted: "$1$random-p$sFftrCTxKKsDZ.Sdr8mDG0"
4、修改tftp和rsync服务配置文件开启tftp和rsync服务,将disable由“yes”改成“no”
[[email protected] ~]# cat /etc/xinetd.d/tftp
service tftp
{
disable = no
...........................
[[email protected] ~]# cat /etc/xinetd.d/rsync
service rsync
{
disable = no
............................
5、修改cobbler提供的DHCP模板/etc/cobbler/dhcp.template,并替换dhcp的配置文件/etc/dhcp/dhcpd.conf
subnet 192.168.186.0 netmask 255.255.255.0 { #修改为自己需求的网段
option routers 192.168.186.2; #该网段的router地址,网关
option domain-name-servers 192.168.1.12; #DNS服务器地址
option subnet-mask 255.255.255.0; #掩码
range dynamic-bootp 192.168.186.100 192.168.186.254; #允许分配的IP段
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";
}
}
}
6、修改httpd配置
httpd.conf监听端口修改与settings相同端口
Listen 8090
#修改认证文件/etc/cobbler/modules.conf(最新的Cobbler版本貌似不用修改)
[authentication]
module = authn_configfile
[authorization]
module = authz_allowall
[dns]
module = manage_bind
[dhcp]
module = manage_isc
[tftpd]
module = manage_in_tftpd
修改/etc/httpd/conf.d/ssl.conf的ssl配置(增加以下行,如果不是用Cobbler提供的WEB端也可以不用配)
<VirtualHost *:8090>
<LocationMatch "^/cobbler_web/*">
RewriteEngine on
RewriteRule ^(.*) https://%{SERVER_NAME}/%{REQUEST_URI} [R,L]
</LocationMatch>
</VirtualHost>
修改cobbler的WEB页面管理密码【WEB管理地址https://ip/cobbler_web 用户名cobbler 密码Cobbler】
[[email protected] ~]# htdigest /etc/cobbler/users.digest "Cobbler" cobbler
7、校验cobbler安装条件并启动相关服务
需要启动的服务有httpd、DHCP、xinetd、cobbler,需要关闭SELinux、IPtables。其它的报错按cobbler check提示解决
[[email protected] ~]# cobbler get-loaders
[[email protected] ~]# cobbler check //如果检查有报错,请根据提示把报错都解决
No configuration problems found. All systems go.
[[email protected] ~]# cobbler sync
[[email protected] ~]#chkconfig --level 35 httpd on
[[email protected] ~]#chkconfig --level 35 xinetd on
[[email protected] ~]#chkconfig --level 35 dhcpd on
[[email protected] ~]#chkconfig --level 35 cobblerd on
8、导入系统镜像(先挂载后导入)
[[email protected] ~]# mount /dev/cdrom /media/
[[email protected] ~]# cobbler import --path=/media/ --name=CentOS64 --arch=x86_64
查看导入结果
[[email protected] ~]#cobbler distro list
完成后同步所有配置(同步数据到dhcp/pxe和数据目录)
[[email protected] ~]#cobbler sync
9、安装配置完成,新装机器开启pxe启动,重装机器设置第一引导项为pxe启动即可完成自动安装。