刚进公司,听同事提到cobbler,之前只知道有个PXE,后来在网上查找了一些资料,自己找了台服务器测试了一下
Cobbler
部署环境 :
cobbler-server dell PowerEdge C6220
cobbler-server OS Centos6.4
cobbler_server ip : 192.168.1.100
cobbler安装环境:
1、安装epel
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
sudo rpm -Uvh epel-release-6*.rpm
2、服务安装
yum -y install cobbler httpd rsync tftp xinetd dhcp cman pykickstart
3、修改cobbler配置文件 /etc/cobbler/settings
sed -i 's/manage_dhcp: 0/manage_dhcp: 1/' /etc/cobbler/settings #开启dhcp功能
sed -i 's/manage_rsync: 0/manage_rsync: 1/' /etc/cobbler/settings #开启rsync功能
sed -i 's/next_server: 127.0.0.1/next_server: 192.168.1.100/' /etc/cobbler/settings #设置你的 tftp server 地址
sed -i 's/server: 127.0.0.1/server: 192.168.1.100/' /etc/cobbler/settings #cobbler_server 地址
4、开启cobbler服务前需要做
service iptables stop #关闭防火墙
setenforce 0 #关闭selinux
/etc/xinetd.d/tftp
disable = no #开启tftp服务
/etc/xinetd.d/rsync
disable = no #开启 rsync 服务
openssl passwd -1 -salt 'cocosoa' '00001234' 生成系统安装后的 root 密码,cocosoa是干扰密码,00001234是系统登录密码
vim /etc/cobbler/settings 编辑配置文件,将默认的密码替换为新生成的
default_password_crypted: "$1$cocosoa$oAeSzE7VLKwhMPiBEOJD81"
cobbler get-loaders #下载引导操作系统文件
yum install debmirror -y
vim /etc/debmirror.conf
#@dists="sid"; // 注销
#@arches="i386"; // 注销
配置dhcp服务,只需要修改cobbler的dhcp模板文件即可
vim /etc/cobbler/dhcp.template
subnet 192.168.1.0 netmask 255.255.255.0 {
option routers 192.168.1.5;
option domain-name-servers 192.168.1.1;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.1.100 192.168.1.254;
default-lease-time 21600;
max-lease-time 43200;
next-server 192.168.1.122;
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 sync 同步下配置文件,不然dhcp无法启动,会报错
service httpd start 在配置文件中加入ServerName localhost:80
service cobbler start
chkconfig httpd on
chkconfig cobblerd on
chkconfig dhcpd on
chkconfig xinetd on
chkconfig tftp on
chkconfig iptables off
6、导入镜像
cobbler import --path=/media --name=CentOS6.4 --arch=x86_64
touch /var/lib/cobbler/kickstarts/CentOS6.4.ks
cobbler profile add --name=centos6.4 --distro=CentOS6.4-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS6.4.ks
添加一个profile文件,并使用CentOS6.4-x86_64这个distro,并指定相应的ks文件,ks文件是事先准备好的
vim /etc/cobbler/pxe/pxedefault.template #编辑pxe模板
ONTIMEOUT centos6.4 #修改默认安装的profile为centos6.4,也就是说当你没有选择,超时操作后自动安装此profile
7、编辑kickstarts文件 #可以自己写
vim /var/lib/cobbler/kickstarts/CentOS6.4.ks
install
auth --useshadow --enablemd5
key --skip
bootloader --location=mbr
clearpart --all --initlabel
text
firewall --disabled
keyboard us
lang en_US
url --url=$tree
reboot
rootpw --iscrypted $1$cocosoa$oAeSzE7VLKwhMPiBEOJD81
selinux --disabled
timezone --isUtc Asia/Shanghai
zerombr
autopart
%packages
$SNIPPET('package')
cat /var/lib/cobbler/snippets/package
此文件里写入需要安装的包
下面是扩展目录,可以自己添加单独的配置文件,方便管理
/var/lib/cobbler/snippets
$SNIPPET (文件名) 该文件要到/var/lib/cobbler/snippets下创建编辑。
# System authorization information
auth --useshadow --enablemd #用户登录认证
# System bootloader configuration
bootloader --location=mbr #mbr引导
# Partition clearing information
clearpart --all --initlabel #默认清除所以分区
# Use text mode install
text #默认以文本模式安装
# Firewall configuration
firewall --enabled #防火墙默认开启
# Run the Setup Agent on first boot
firstboot --disable #禁用启动代理
# System keyboard
keyboard us #默认英文键盘
# System language
lang en_US #默认语言英文
# Use network installation
url --url=$tree #网络安装路径
# If any cobbler repo definitions were referenced in the kickstart profile, include them here
$yum_repo_stanza #默认的yum仓库
# Network information
$SNIPPET('network_config')
# Reboot after installation
reboot #安装完成后重启
#Root password
rootpw --iscrypted $default_password_crypted #密码是我们/etc/cobbler/settings设置密码
# SELinux configuration
selinux --disabled #默认关闭selinux
# Do not configure the X Window System
skipx #默认没有安装图形界面
# System timezone
timezone America/New_York #默认时区是美国/纽约
# Install OS instead of upgrade
install #定义的是安装系统而不是升级系统
# Clear the Master Boot Record
zerombr #默认清空所有的mbr
# Allow anaconda to partition the system as needed
autopart #默认自动分区