先言:人们对于安装操作系统往往的理解是在电脑光驱里安一张光驱 然后狂按下一步 直到提示电脑重启安装完成,或是通过高级一点的U盘安装,但是有没有想过在一个教室 或者是当一个公司开业购买电脑,光驱安装和U盘这种普通的安装方式已经不再适合,管理员们耗不起这时间,这时就需要一种批量安装操作系统的方式来解放管理员的时间,批量部署操作系统的好处在于省时省力,可以多台机器同时安装操作系统
环境:RHEL5.5 vmware9.0
安装前准备:关闭SElinux 配置IP地址 配置yum源
实验注意事项:网卡必须支持PXE启动(vmware默认支持)服务器能上网 从网上下载cobbler等软件
实验拓扑图:
IP地址配置
在这里我用了两块网卡 eth0用于从网上下载安装软件为NAT模式
eth1用于部署操作系统 为单独的局域网VMnet2
1 #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
mount /dev/cdrom /mnt/
2 yum install cobbler httpd rsync tftp-server xinetd dhcp
手动开启wsgi模块
vim /etc/httpd/conf.d/wsgi.conf
#LoadModule wsgi_module modules/mod_wsgi.so 前面#去掉即可
service cobblerd restart
service httpd restart
cobbler import –path=/mnt/ –name=RedHat-5-i386
cobbler list
4 xinet.d配置文件修改
#vi /etc/xinetd.d/rsync
disable = yes 改成no
#vi /etc/xinetd.d/tftp
disable = yes 改成no
vi /etc/cobbler/settings
next_server: ‘127.0.0.1’ //改成本机IP:192.168.1.1
server: ‘127.0.0.1’ //改成本机IP:192.168.1.1
manage_dhcp: 0 // 改成1 //开启管理DHCP服务
5 dhcp的配置
#vi /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.1;
#option domain-name-server 192.168.0.100;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.1.2 192.168.1.200;
filename “/pxelinux.0”;
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
6 编辑ks文件 模板文件位置位于/var/lib/cobbler/kickstarts/目录下
vi /etc/cobbler/default.ks
#platform=x86, AMD64, or Intel EM64T
# System authorization information
auth –useshadow –enablemd5
# System bootloader configuration
bootloader –location=mbr
# Partition clearing information
clearpart –all –initlabel
# Use text mode install
text
# Firewall configuration
firewall –disabled
# 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
# Network information
network –bootproto=dhcp –device=eth0 –onboot=on
# Reboot after installation
reboot
#Root password
rootpw 123456
# SELinux configuration
selinux –disabled
#disabled serverces
services –disabled acpid,anacron,apmd,atd,auditd,autofs,avahi-daemon,bluetooth,cups,firstboot,hidd,ip6tables,lvm2-monitor,mcstrans,mdmonitor,microcode_ctl,netfs,nfslock,pcscd,portmap,rawdevices,readahead_early,restorecond,rpcgssd,rpcidmapd,sendmail,setroubleshoot,xfs,xinetd,yum-updatesd
#enabled services
services –enabled cpuspeed,crond,gpm,haldaemon,irqbalance,kudzu,messagebus,network,smartd,sshd,syslog
# Do not configure the X Window System
skipx
# System timezone
timezone –utc Asia/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
clearpart –all –drives=sda –initlabel
part / –fstype ext3 –size=20000
part /usr/local –fstype ext3 –size=50000
part swap –size=1024
part /home –fstype ext3 –size=1000 –grow
#EOF
##
%packages
@admin-tools
@base
@development-libs
@development-tools
@editors
@emacs
@system-tools
%post
$yum_config_stanza
$kickstart_done
6 同步cobbler配置使之生效
service cobblerd restart
service httpd restart
service xinetd restart
cobbler sync
service dhcpd restart
7 至此服务器的配置工作完成 客户端开机
开机选择第二项
到这一步就是选择红帽的key了 由于在ks文件里面没有设置好需要选择跳过才能一路安装
可以看到安装进度 OK 实验成功!
更多RedHat相关信息见RedHat 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=10