http://cobbler.github.io/manuals/2.6.0/1/1_-_Release_Notes.html
http://www.osyunwei.com/archives/7606.html
http://tshare365.com/archives/439.html
Cobbler 是一个免费开源系统安装部署软件,用于自动化网络安装操作系统;基于Python开发,是对 PXE 的二次封装,提供了 CLI 和 Web 的管理形式,也提供了API接口,方便二次开发使用。
它不仅可以安装物理机,同时也支持虚拟化、GuestOS的安装。另外,Cobbler还能结合 Puppet 等集中化管理软件,实现自动化管理。
实验环境:
cobbler服务器:c6.5-minimal系统上安装cobbler相关包
裸机:在a机上安装c6.5,在b机上安装c7.2,
实现目的:
通过配置Cobbler服务器,全自动批量安装部署Linux系统
#http服务需要此端口 80
#tftp服务需要此端口 25251
#cobbler需要此端口 69
cobbler文件与包
安装cobbler
c6与c7的cobbler相关包是不一样的
[root@107-c6 ~]# yum install epel-release
[root@107-c6 ~]# yum install cobbler-web dhcp debmirror pykickstart Cobbler目录说明: 1、Cobbler配置文件目录:/etc/cobbler /etc/cobbler/settings #cobbler主配置文件 /etc/cobbler/dhcp.template #DHCP服务的配置模板 /etc/cobbler/tftpd.template #tftp服务的配置模板 /etc/cobbler/rsync.template #rsync服务的配置模板 /etc/cobbler/iso #iso模板配置文件 /etc/cobbler/pxe #pxe模板文件 /etc/cobbler/power #电源的配置文件 /etc/cobbler/users.conf #Web服务授权配置文件 /etc/cobbler/users.digest #用于web访问的用户名密码配置文件 /etc/cobbler/dnsmasq.template #DNS服务的配置模板 /etc/cobbler/modules.conf #Cobbler模块配置文件 2、Cobbler数据目录:/var/lib/cobbler /var/lib/cobbler/config #配置文件 /var/lib/cobbler/triggers #Cobbler命令 /var/lib/cobbler/kickstarts #默认存放kickstart文件 /var/lib/cobbler/loaders #存放的各种引导程序 3、系统安装镜像目录:/var/www/cobbler /var/www/cobbler/ks_mirror #导入的系统镜像列表 /var/www/cobbler/images #导入的系统镜像启动文件 /var/www/cobbler/repo_mirror #yum源存储目录 4、日志目录:/var/log/cobbler /var/log/cobbler/install.log #客户端系统安装日志 /var/log/cobbler/cobbler.log #cobbler日志
第一部分 分步安装配置,即dhcp,tftp,httpd,cobber
yum repolist
yum install epel-release
yum install cobbler dhcp pykickstart
sed -i -e 's/= yes/= no/g' /etc/xinetd.d/tftp
sed -i 's@next_server: 127.0.0.1@next_server: '192.168.10.101'@g' /etc/cobbler/settings
sed -i 's@server: 127.0.0.1@server: '192.168.10.101'@g' /etc/cobbler/settings
[root@localhost loaders]# sed -n '/default_password/p' /etc/cobbler/settings
default_password_crypted: "$1$mF86/UHC$WvcIcX2t6crBz2onWxyac."
[root@localhost loaders]# sed -i 's@default_password_crypted@#default_password_crypted@g' /etc/cobbler/settings
[root@localhost loaders]# sed -n '/default_password/p' /etc/cobbler/settings
#default_password_crypted: "$1$mF86/UHC$WvcIcX2t6crBz2onWxyac." openssl passwd -1 -salt '任意字母' '你的密码'
echo "default_password_crypted: "$1$ac756ac7$erF27Ljjp3rDItLVqHLOg/"" >> /etc/cobbler/settings
cp /usr/share/syslinux/meminfo.c32 /var/lib/cobbler/loaders/
cp /usr/share/syslinux/pxelinux.0 /var/lib/cobbler/loaders/
systemctl start httpd
systemctl start cobblerd
cobbler sync
cobbler check
systemctl start dhcpd
systemctl start tftp
systemctl start rsyncd
mount -o loop CentOS-6.5-x86_64-bin-DVD1.iso /mnt/
cobbler import --name=cs65 --path=/mnt
cobbler profile edit --name=cs65-x86_64 --distro=cs65-x86_64 --kickstart=/var/lib/cobbler/kickstarts/wo.cfg
第二部分 脚本安装
1.创建tshare365.sh脚本
#!/bin/sh
#coding=utf8
#Author tshare365.com
##################################################################
#将如下IP修改成你cobbler服务器的IP地址
ip=192.168.10.195
#将如下net修改成你Cobbler所在网段的NET
net=192.168.10.0
#修改成dhcp计划分配的IP段
begin=192.168.10.14
end=192.168.10.34
echo "$ip www.tshare365.com" >> /etc/hosts
yum install cobbler cobbler-web pykickstart dhcp debmirror syslinux cman fence-agents vim -y
/etc/init.d/iptables stop
/etc/init.d/httpd start
/etc/init.d/cobblerd start
service cobblerd restart
sed -i -e 's/= yes/= no/g' /etc/xinetd.d/rsync
sed -i -e 's/= yes/= no/g' /etc/xinetd.d/rsync
sed -i 's@next_server: 127.0.0.1@next_server: '$ip'@g' /etc/cobbler/settings
sed -i 's@server: 127.0.0.1@server: '$ip'@g' /etc/cobbler/settings
cp /usr/share/syslinux/pxelinux.0 /var/lib/cobbler/loaders/
cp /usr/share/syslinux/meminfo.c32 /var/lib/cobbler/loaders/
sed -i 's$@arches="i386"$#@arches="i386"$g' /etc/debmirror.conf
sed -i 's$@dists="sid"$#@dists="sid"$g' /etc/debmirror.conf
sed -i 's@default_password_crypted@#default_password_crypted@g' /etc/cobbler/settings
echo "default_password_crypted: "$1$ac756ac7$erF27Ljjp3rDItLVqHLOg/"" >> /etc/cobbler/settings
service cobblerd restart
cobbler sync
cobbler check
#dhcp
cat > /etc/dhcp/dhcpd.conf <<EOF
option domain-name "tshare365.com";
option domain-name-servers $ip;
default-lease-time 43200;
max-lease-time 86400;
log-facility local7;
subnet $net netmask 255.255.255.0 {
range $begin $end;
option routers $ip;
}
next-server $ip;
filename="pxelinux.0";
EOF
/etc/init.d/dhcpd restart
service xinetd restart
mkdir /opt/tshare365
mount /dev/cdrom /opt/tshare365
cobbler import --name=centos-6.5-x86_64-tshare365 --path=/opt/tshare365
cobbler profile add --name=centos-6.5-x86_64-tshare365 --distro=centos-6.5-x86_64-tshare365 --kickstart=/var/lib/cobbler/kickstarts/tshare365.cfg
2.创建tshare365.cfg文件
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Upgrade existing installation
upgrade
# Use network installation
#修改成自己的IP
url --url="http://192.168.10.195/cobbler/ks_mirror/centos-6.5-tshare365/"
# Root password
rootpw --iscrypted $1$CgIgFiPo$rqNvZR480Z5A2dnbxdd7C0
# System authorization information
auth --useshadow --passalgo=sha512
firewall --disabled
timezone Asia/Shanghai
# Use graphical install
graphical
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# Installation logging level
logging --level=info
# Reboot after installation
reboot
# System timezone
timezone Africa/Abidjan
# System bootloader configuration
bootloader --location=mbr
clearpart --all --drives=sda --initlabel
part /boot --fstype ext3 --size=100 --ondisk=sda
part swap --size=4096
part / --fstype ext3 --size=100 --grow --asprimary
%packages
@core
@server-policy
@workstation-policy
%end
将tshare365.cfg放到/var/lib/cobbler/kickstarts/目录下然后执行 sh tshare.sh
切记 一定要挂载光盘并关闭selinux
安装成功之后默认登录密码是redhat
遇到一个问题是menu.c32 is not a COM32B image.解决办法是
1.cp /usr/share/syslinux/vesamenu.c32 /var/lib/tftpboot/
2.修改cobbler服务器/var/lib/tftpboot/pxelinux.cfg/default文件,将DEFAULT menu行改为DEFAULT vesamenu就可以了
曾经在Dell R720服务器安装Centos 6.5 的过程中出现过如下问题
解决办法是修改cobbler服务器/var/lib/tftpboot/pxelinux.cfg/default 文件
在vmlinuz 后面加入 biosdevname=0,如图
重新安装系统: 在需要重装系统的服务器上安装koan wget http://dl.fedoraproject.org/pub/epel/5/x86_64/koan-2.4.0-1.el5.noarch.rpm #CentOS 5.X rpm -ivh koan-2.4.0-1.el5.noarch.rpm #安装koan http://dl.fedoraproject.org/pub/epel/6/x86_64/koan-2.4.0-1.el6.noarch.rpm #CentOS 6.X yum install cobbler debmirror pykickstart python-ctypes cman #安装koan运行依赖包(需要设置epel源) koan --list=profiles --server=192.168.21.128 #查看Cobbler服务器系统镜像列表 koan --replace-self --server=192.168.21.128 --profile=CentOS-5.10-x86_64 #选择要重装的系统 reboot #重新启动系统进行自动安装