Cobbler介绍
Cobbler是一个快速网络安装linux的服务,而且在经过调整也可以支持网络安装windows。该工具使用python开发,小巧轻便(才15k行代码),使用简单的命令即可完成PXE网络安装环境的配置,同时还可以管理DHCP,DNS,以及yum包镜像。
Cobbler支持命令行管理,web界面管理,还提供了API接口,可以方便二次开发使用。
和Kickstart不同的是,使用cobbler不会因为在局域网中启动了dhcp而导致有些机器因为默认从pxe启动在重启服务器后加载tftp内容导致启动终止。
cobbler的安装部署配置
cobbler安装环境准备
1, 安装epel (yum拓展源)
#Rpm-Uvh'http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm
2. 安装dhcp,xinetd,tftp,rsync,httpd,cobbler 并selinux 与iptables关闭
#yum -y install dhcp xinetd tftp rsync httpd
#setenforce 0
#iptables -F
#iptables -Z
#iptables -X
启动相关服务
#service cobblerd start
#service httpd start
将tftp 与rsync 的disable yes 修改为no并启动 xinetd服务
# service xinetd restart
检查cobbler配置.
# cobbler check (根据提示修改配置)
#0: The 'server' field in /var/lib/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.
#1: For PXE to be functional, the 'next_server' field in /var/lib/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.
0:编辑/var/lib/cobbler/settings文件,找到 server选项,修改为适当的ip地址,本实例配置ip为:192.168.1.2
1:编辑/var/lib/cobbler/settings文件,找到 next_server选项,修改为适当的ip地址,本实例配置ip为:192.168.1.2
再次 cobbler check
No setup problems found
Manual review and editing of /var/lib/cobbler/settings is recommended to tailor cobbler to your particular configuration.
Good luck.
重启 cobbler
#service cobbler restart
3. 配置DHCP模板文件
将 /var/lib/cobbler/settings manage_dhcp :0 改为 manage_dhcp:1 意为让cobbler管理dhcp.
#vim /etc/cobbler/dhcp.template
ddns-update-style interim;
allow booting;
allow bootp;
ignore client-updates;
set vendorclass = option vendor-class-identifier;
subnet 192.168.1.0 netmask 255.255.255.0 {
option routers 192.168.1.2;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.1.100 192.168.1.254;
filename "/pxelinux.0";
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
}
$insert_cobbler_system_definitions
4. 导入centos或redhat的安装DVD ISO的文件
#mount /dev/cdrom /media
# cobbler import --mirror=/media --name=centos-5-5-X86-64
会在 /var/www/cobbler/ks_mirror 下生成 centos的镜像文件.
5.安装并配置kickstart
#rpm -ivh pykickstart-0.43.5-1.el5.noarch.rpm
#rpm -vih system-config-kickstart-2.6.19.8-2.el5.noarch.rpm
#system-config-kickstart 生成kickstart文件.
#platform=x86, AMD64, or Intel EM64T
# System authorization information
auth --useshadow --enablemd5
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Use graphical install
graphical
# Firewall configuration
firewall --disabled
# Run the Setup Agent on first boot
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# Installation logging level
logging --level=info
# Use network installation
url --url=http://192.168.1.2/cobbler/ks_mirror/centos_media_5_5_x86_64
# Network information
network --bootproto=dhcp --device=eth0 --onboot=on
# Reboot after installation
reboot
#Root password
rootpw --iscrypted $1$y8UsMlQp$AWapn2nbeyMmUYJ.5J4VO0
# SELinux configuration
selinux --disabled
# System timezone
timezone America/New_York
# Install OS instead of upgrade
install
# X Window System configuration information
xconfig --defaultdesktop=GNOME --depth=8 --resolution=640x480 --startxonboot
# Disk partitioning information
part swap --bytes-per-inode=4096 --fstype="swap" --size=1000
part /boot --bytes-per-inode=4096 --fstype="ext3" --size=100
part /usr --bytes-per-inode=4096 --fstype="ext3" --size=7000
part /var --bytes-per-inode=4096 --fstype="ext3" --size=5000
part / --bytes-per-inode=4096 --fstype="ext3" --size=4000
%packages
@base
@gnome-desktop
@base-x
@x-software-development
@chinese-support
@admin-tools
@editors
6.配置tftp文件
#vim /tftpboot/pxelinux.cfg/default
DEFAULT local
PROMPT 1
MENU TITLE Cobbler | http://cobbler.et.redhat.com
TIMEOUT 200
TOTALTIMEOUT 6000
ONTIMEOUT local
LABEL local
MENU LABEL (local)
kernel /images/centos_media_5_5-x86_64/vmlinuz
MENU LABEL centos_media_5_5-x86_64
append ksdevice=eth0 lang= text syslog=192.168.1.2:25150 initrd=/images/centos_media_5_5-x86_64/initrd.img ks=http://192.168.1.2/cblr/kickstarts/centos_media_5_5-x86_64/ks.cfg
LABEL centos_media_5_5-xen-x86_64
kernel /images/centos_media_5_5-xen-x86_64/vmlinuz
MENU LABEL centos_media_5_5-xen-x86_64
append ksdevice=eth0 lang= text syslog=192.168.1.2:25150 initrd=/images/centos_media_5_5-xen-x86_64/initrd.img ks=http://192.168.1.2/cblr/kickstarts/centos_media_5_5-xen-x86_64/ks.cfg
7.同步cobbler配置
#cobbler sync
8.利用cobbler重装系统 (客户机)
# rpm -Uhv koan-1.2.5-1.el5.noarch.rpm
# koan -server=192.168.1.3 -list-profiles
# koan -replace-self -server=192.168.1.3 -profile=CentOS_5.2-i386
# reboot