Long long ago
,我们一直在做装机民工这份很有前途的职业。自打若干年前
Red Hat
推出了
Kickstart
,此后我们顿觉身价倍增。不再需要刻了光盘一台一台地安装
Linux
,只要搞定
PXE
、
DHCP
、
TFTP
,还有那满屏眼花缭乱不知所云的
Kickstart
脚本,我们就可以像哈里波特一样,轻点魔棒,瞬间安装上百台服务器。这一堆花里胡哨的东西可不是一般人都能整明白的,没有大专以上学历,通不过英语四级,
根本别想玩转。总而言之,这是一份多么有前途,多么有技术含量的工作啊。很不幸,
Red Hat
最新(
Cobbler
项目最初在
2008
年左右发布)发布了网络安装服务器套件
Cobbler
,它已将
Linux
网络安装的技术门槛,从大专以上文化水平,成功降低到初中以下,连补鞋匠都能学会。对于我们这些在装机领域浸淫多年,经验丰富,老骥伏枥,志在千里的民工兄弟们来说,不啻为一个晴天霹雳。
废话完了,下面就来感受一下
Cobbler
是如何快速建立网络环境的。
1.
安装相关软件
CentOS 5.6
默认的
Repository
里找不到
Cobbler
,先安装
rpmforge
这个
Repository
。很全很强大,近
10000
个软件包。
#32
位:
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.1-1.el5.rf.i386.rpm
rpm -ivh rpmforge-release-0.5.1-1.el5.rf.i386.rpm
#64
位:
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.1-1.el5.rf.x86_64.rpm
rpm -ivh rpmforge-release-0.5.1-1.el5.rf.x86_64.rpm
yum -y install cobbler dhcp httpd xinetd tftp-server
完成后提示
Complete!
2.
检查cobbler
配置
#
按提示解决相关问题,把
/var/lib/cobbler/settings
中的
server
和
next_server
设为本服务器的
IP
地址,
manage_dhcp
设为
1
,以便管理
DHCP
;
/etc/xinetd.d/tftp
中
disable = yes
改为
disable = no
3.
导入 CentOS 5
安装 DVD
中的文件
cobbler import --mirror=/media/CentOS_5.6_Final --name= CentOS_5.6
#
从
/media/CentOS_5.6_Final
目录导入所有安装文件,命名为
CentOS_5.6
#
查看导入结果,应包含一个
xen
的
4.
修改 DHCP
和 Kickstart
配置模板
#
参照
/etc/cobbler/dhcp.template
DHCP
配置模板,注意你本服务器的
IP
地址要和
dhcp
配置的
subnet
一个网段,否则会启动失败。
vi /etc/cobbler/default.ks
# Kickstart
配置模板,可以用
system-config-kickstart
(建议)生成,也可以安装系统后在
/root/anaconda-ks.cfg
得到你所安装系统的配置。
vi /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)
# MENU DEFAULT
# LOCALBOOT 0
LABEL local
kernel /images/CentOS_5.6-i386/vmlinuz
MENU LABEL CentOS_5.6-i386
……
#
启动菜单,将
local
有关信息注释
v
i /var/www/cobbler/kickstarts/CentOS_5.6-i386
#platform=x86, AMD64, or Intel EM64T
# System authorization information
auth --useshadow --enablemd5
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all
# 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=
http://
192.168.1.97
/cblr/links/CentOS_5.6-i386
# If any cobbler repo definitions were referenced in the kickstart profile, include them here.
# Network information
network --bootproto=dhcp --device=eth0 --onboot=on
# Reboot after installation
reboot
#Root password
rootpw
123456
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# System timezone
timezone
America/Shanghai
# Install OS instead of upgrade
install
# Clear the Master Boot Record
zerombr
# Magically figure out how to partition this thing
%include /tmp/partinfo
%pre
# Determine how many drives we have
set $(list-harddrives)
let numd=$#/2
d1=$1
d2 = $3
cat << EOF >> /tmp/partinfo
part /boot --fstype ext3 --size=100 --ondisk=$d1 --asprimary
part / --fstype ext3 --size=102400 --grow --ondisk=$d1 --asprimary
part swap --size=2048 --ondisk=$d1 --asprimary
#EOF
%packages
@base
@core
@development-tools
@dialup
@editors
@gnome-desktop
@graphical-internet
@graphics
@printing
@sound-and-video
@text-internet
@base-x
keyutils
iscsi-initiator-utils
trousers
fipscheck
device-mapper-multipath
imake
libsane-hpaio
xorg-x11-server-Xnest
xorg-x11-server-Xvfb
%post
$yum_config_stanza
$kickstart_done
wget http://
192.168.1.97
/cblr/watcher.py?profile_done=CentOS_5.6-i386 -b
5.
生成并同步所有配置
#
继续刷屏
6.
启动相关服务
service xinetd start
service httpd start
service dhcpd start
service cobblerd start
7.
安装服务器
#
启动新的服务器,通过
PXE
启动进入。安装过程完全不需要人工干预!
接下来是见证奇迹的时刻,泡杯茶,悠闲地欣赏
Cobbler
带来的魔法秀
……
8.
重装系统
rpm �C
ivh
koan-1.2.5-1.el5.noarch.rpm
koan -server=192.168.1.
97
-list-profiles
koan -replace-self -server=192.168.1.
97
-profile=CentOS_5.
6
-i386
reboot