Chinaunix首页 | 论坛 | 博客
  • 博客访问: 423667
  • 博文数量: 81
  • 博客积分: 2830
  • 博客等级: 少校
  • 技术积分: 1445
  • 用 户 组: 普通用户
  • 注册时间: 2006-11-24 09:19
文章分类

全部博文(81)

文章存档

2011年(1)

2010年(34)

2009年(16)

2008年(30)

我的朋友

分类: LINUX

2010-05-03 11:43:24

说明:通过 pxe+tftp+dhcp+http+Kicksstart 可以同时安装数百台服务器,不需要人工干预,对与大规模部署安装服务器是相当有用,并且能减轻SA工作负担,提高工作效率

一、DHCP 配置

cat /etc/dhcpd.conf
# ******************************************************************
# Cobbler managed dhcpd.conf file
# generated from cobbler dhcp.conf template (Mon Jun  1 04:20:03 2009)
# ******************************************************************

ddns-update-style interim;

allow booting;
allow bootp;

ignore client-updates;
set vendorclass = option vendor-class-identifier;

subnet 192.88.50.0 netmask 255.255.255.0 {
     option routers          192.88.50.1;
     option subnet-mask      255.255.255.0;
     range dynamic-bootp     192.88.50.180 192.88.50.254;
     filename                "pxelinux.0"; //
     default-lease-time      21600;
     max-lease-time          43200;
     next-server             192.88.50.35;
}

说明:

    在 '''/etc/dhcpd.conf''' 中增加 tftp-server 需要推送给客户端的启动文件:

filename "pxelinux.0";

因为 tftp 的默认目录是 /tftpboot,所以文件的绝对路径就是:

/tftpboot/pxelinux.0"

也可以指定为别的路径。

另外需要指定 next-server 参数,告诉客户端在获取到 pxelinux.0 文件之后去哪里获取其余的启动文件:

next-server 192.88.50.35;

二、tftp 配置

安装以下两个包:

    * tftp-server
    * tftp

一个服务器端,一个客户端程序。

tftp 服务由 xinetd 服务管理。编辑 '''/etc/xinetd.d/tftp''' 文件,将 '''disable = yes''' 改为:

disable = no

重启 xinetd:

# /etc/init.d/xinetd restart
# chkconfig --level 35 xinetd on

三、PXE

安装 syslinux

使用 syslinux 提供 PXE 安装(RedHat Enterprise Linux默认已安装)。

    * syslinux 主页:
    * syslinux 下载:

可以直接下载 RPM 包。

配置
/tftpboot/pxelinux.0

安装好 syslinux 以后,将 pxelinux.0 这个文件复制到 '''/tftpboot''' 目录:

# rpm -ql syslinux | grep 'pxelinux.0'
/usr/lib/syslinux/pxelinux.0
cp /usr/lib/syslinux/pxelinux.0   /tftpboot/

四、其他配置

    将系统安装盘中或者是ISO文件中的下面文件复制到指定的位置:
   
    mount -o loop server.iso /media
    cp /media/isolinux/*.msg /tftpboot/
    mkdir /tftpboot/pxelinux.cfg
    cp /media/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default
   
    vi /tftpboot/pxelinux.cfg/default
# 默认启动的是 'label linux' 中标记的内核
default autoinstall
prompt 1
timeout 30
display boot.msg
F1 boot.msg
F2 options.msg
F3 general.msg
F4 param.msg
F5 rescue.msg
label linux
  kernel vmlinuz
  append initrd=initrd.img
label text
  kernel vmlinuz
  append initrd=initrd.img text
label ks
  kernel vmlinuz
  append ks initrd=initrd.img
label local
  localboot 1
label autoinstall
  kernel vmlinuz
  append ks= initrd=initrd.img

vi /tftpboot/boot.msg
^L
^Xsplash.lss

 -  To install or upgrade in graphical mode, press the ^O01^O07 key.

 -  To install or upgrade in text mode, type: ^O01linux text ^O07.

 -  To Auto Install AS5.3_X86_64 Linux, type: linux autoinstall .

 -  Use the function keys listed below for more information.

^O0f[F1-Main] [F2-Options] [F3-General] [F4-Kernel] [F5-Rescue]^O07

mount -o loop server.iso /var/www/html/rhel/5/5.3/server/x86_64

然后启动  http 服务

/etc/init.d/httpd start

 ks.cfg 配置文件说明:

* command 区段—此部份包含了必要安装选项
    * packages 区段—列出欲安装套件
    * %pre and %post 区段
    * command 区段

      ■lang(必要):安装时所使用的语言
      例如:安装过程中选用中文语言,lang zh_TW.Big5
      ■langsupport (必要):指定系统使用的语言。假如你安装一至多国语系,你必需使用默认选项去指定默认语言。语法为:
      例如:langsupport --default en_US.UTF-8 zh_TW.Big5 en_US.UTF-8
      ■键盘(必要):设置系统键盘的种类。语法为:keyboard us
      ■鼠标(必要):设置鼠标。语法为:
      mouse- -device=ttvS0(鼠标识别装置位置)- - emulthree(仿真三个按键)generics/2(定义鼠标种类)
      ■timezone(必要) 设置系统时区。
      timezone Asia/Taipei (指定你的时区位置)
      ■设置系统键盘的种类。语法为:keyboard us
      ■鼠标(必要):设置鼠标。语法为:
      mouse- -device=ttvS0(鼠标识别装置位置)- - emulthree(仿真三个按键)generics/2(定义鼠标种类)
      ■xconfig(非必要):在安装过程中手动设置X,假如你不想安装X,你不应该使用此选项。命令的格式为:
      ■xconfig - - card(显示卡类别)- - videoram(指定显示卡记忆容量)- - hsync(指定屏幕水平扫描频率)- - vsync(指定屏幕垂直扫描频率)- - resolution(指定屏幕分辨率) - - depth(指定X 窗口系统彩度)- - startxonboot (假如你想在系统开机时激活X 时使用)- - defaultdesktop gnome(或kde)(指定默认桌面)。
      ■install (非必要):告知系统安装一个新的安装。这是默认模式,因此一个新的安装不需再选用这个命令。接着您必需指定安装方式,可以是cdrom、harddrive、nfs 或url。
      ■cdrom
      ■harddrive—partition=your partition –dir=/your directory path
      -- partition = 来源分区
      -- dir = Red Hat 子目录
      (请确定你所键入来源分区和子目录信息的正确性)。
      ■nfs – server—your server –dir=/your directory path
      -- server = 指定安装来源服务器
      -- dir = Red Hat 子目录
      (请确定你所键入来源分区和子目录信息的正确性)。
      ■url – url server/dir
      使用HTTP 进行安装
      ■url – url ftp://your username:password@your server/dir
      使用FTP 进行安装
      ■rootpw (必要) 设置一组系统root 密码。
      rootpw - - iscrypted (表示密码已被加密) password
      ■firewall(非必要) 提供安全性等级来保护系统。
      ■authconfig (必要) 设置系统认证选项。命令格式:
      - -enablemd5 (使用md5 编码使用者密码)
      - -enableshadow (使用shadow 密码)
      ■bootloader (必要) 指定开机管理程序的位置和传递任何kernel 选项。默认开机管理程序为GRUB,但是你也能选择LILO 开机管理程序来取代GRUB。命令格式为:
      - - location=mbr (指定开机管理程序的位置)
      - -append=(指定要传递的核心参数)。
      - -useLilo (使用LILO 为开机管理程序)。
      ■clearpart (非必要)告知系统移除系统上的分区。你可以使用clearpart 移除Linux 分区以及移除所有的分区,或者你也能指定你想要移除分区的磁碟机。命令格式为:
      -- linux (移除所有Linux 分区)
      - - all (移除系统上所有的分区)
      -- drives = (指定要移除分区的磁盘驱动器)
      ■Part (必要) 安装时是必要的,升级时请忽略。使用这个命令你能为系统建立分区。
    * package 区段

      安装一个新的系统,你必需选择你想安装的套件。选择欲安装的套件是使用%packages 命令。套件可分为单一套件或者是套件组。你能在第一片Red Hat安装光盘下的/base/comps.xml 寻找群组套件清单。

      通常,只需列出套件组不需要列出单一套件。注意!默认之下core 和base 群组是被选取的,所以也不需要在 %packages 这个区段下去指定它们。

      如同利用ksconfig 所产生出来的ks.cfg %packages 区段中套件组是一行指定一个,以@节号开头,后面加上一格空白接下来是完整群组名称就如同comps.xml 文件所指定。如果个别单一套件并列出该单一套件名,不加上额外的字符。

      套件组是一行指定一个,以@节号开头,后面加上一格空白接下来是完整群组名称就如同comps.xml 文件所指定。如果是个别单一套件则列出该单一套件名,前面不需加上额外的字符。
      %package 有三个选项可以设置:

      ◆- -resolvedeps
      决解自动相依性问题及安装套件。建意选项,在安装中由于没使用自动决解相依性,若有相依性问题可能会造成中止安装并且做提示响应。
      ◆- -ignoredeps
      你选择安装套某套件但乎略它的相依性,可能造成此套件无法运作,尤其是此套件需要其它相依的套件。
      ◆—ignoremissing
      标示忽视安装遗失套件及群组并且也不做提示响应。
    * %pre and %post 区段

      %pre 区段内可填入在开始安装操作系统需要先执行的工作。%post 命令传递到系统上执行必须在Kickstart 安装完成后。能有效的执行命令去安装其它的软件或者设置系统信息。

我的ks.cfg 配置文件:

# Kickstart file automatically generated by anaconda.

# System bootloader configuration
bootloader --location=mbr --driveorder=sda --append="rhgb quiet"

clearpart --all --drives=sda
#clearpart --linux
part /boot --fstype ext3 --size=200 --asprimary
part /usr --fstype ext3 --size=40960
part /home --fstype ext3 --size=20480
part swap --size=4096 --asprimary
part /var --fstype ext3 --size=10240
part / --fstype ext3 --size=10480 --asprimary
part /www --fstype ext3 --size=100 --grow

# Partition clearing information
clearpart --all --initlabel
# Use graphical install
#graphical
# Use text mode install
text
# Run the Setup Agent on first boot
firstboot --disable
# Use interactive kickstart installation method
###interactive  允许修改值
# System keyboard
keyboard us
# System language
lang en_US
#language support
langsupport  zh_CN.UTF-8 zh_CN.GB2312 en_US.UTF-8
# Installation logging level
#logging --level=info
# Use network installation
url --url=

key 49af89414d147589

network --device eth0 --bootproto dhcp
#network --bootproto=dhcp --device=eth0 --onboot=on

reboot
#Root password
rootpw --iscrypted $1$iN4LwkGf$uHo9pYaefUu6uwd16adLT.

# SELinux configuration
selinux --enforcing
# System timezone
timezone  Asia/Shanghai

firewall --enabled --port=22:tcp

#bootloader --location=mbr --driveorder=sda --append="rhgb quiet"

install
# X Window System configuration information
xconfig  --defaultdesktop=GNOME --depth=32 --resolution=1024x768 --startxonboot

%packages
@cluster-storage
@admin-tools
@editors
@system-tools
@development-tools
@gnome-software-development
@text-internet
@x-software-development
@virtualization
@gnome-desktop
@dialup
@core
@base
@legacy-software-development
@clustering
@legacy-software-support
@base-x
@chinese-support
@graphics
@ruby
@kde-software-development
@sound-and-video
@development-libs
@graphical-internet
emacs
arpwatch
adjtimex
avahi-tools
rdesktop
watchdog
wireshark-gnome
tog-pegasus
lsscsi
uucp
dtach
tsclient
x3270
gnutls-utils
lslk
arptables_jf
am-utils
hwbrowser
uuidd
createrepo
mtx
nmap-frontend
tn5250
audit
net-snmp-utils
mc
sblim-gather
amanda-client
sblim-wbemcli
sysstat
gnome-nettool
iptraf
mt-st
vlock
dstat
imake
mesa-libGLU-devel
kexec-tools
bridge-utils
dstat
imake
mesa-libGLU-devel
kexec-tools
bridge-utils
device-mapper-multipath
xorg-x11-utils
xorg-x11-server-Xnest
xorg-x11-server-Xvfb
libsane-hpaio
perl-XML-SAX
python-imaging
perl-XML-NamespaceSupport
-sysreport
%post --interpreter=/bin/bash
chkconfig --level 35 rawdevices     off
chkconfig --level 35 rhnsd     off
chkconfig --level 35 rhnsd     off
chkconfig --level 35 ricci    off
chkconfig --level 35 ricci    off
chkconfig --level 35 rpcgssd    off
chkconfig --level 35 rpcidmapd    off
chkconfig --level 35 smartd    off
chkconfig --level 35 uuidd  off
chkconfig --level 35 yum-updatesd off
chkconfig --level 35 arptables_jf    off
chkconfig --level 35 avahi-daemon    off
chkconfig --level 35 bluetooth    off
chkconfig --level 35 cmirror    off
chkconfig --level 35 firstboot     off
chkconfig --level 35 cups     off
chkconfig --level 35 ip6tables     off
chkconfig --level 35 isdn     off
chkconfig --level 35 libvirtd     off
chkconfig --level 35 mcstrans     off
chkconfig --level 35 modclusterd      off
chkconfig --level 35 netfs      off
chkconfig --level 35 nfslock      off
chkconfig --level 35 pcscd       off
chkconfig --level 35 portmap       off
chkconfig --level 35 xendomains off
chkconfig --level 35 xend  off
chkconfig --level 35 lvm2-monitor  off
chkconfig --level 35 lm_sensors  off
chkconfig --level 35 iscsid  off
chkconfig --level 35 iscsi  off
chkconfig --level 35 hidd  off
echo "LANG="zh_CN.GB2312"">/etc/sysconfig/i18n
echo "SYSFONT="latarcyrheb-sun16"">>/etc/sysconfig/i18n
echo "alias vi='vim'">>/etc/bashrc
echo "nobody          soft    nofile          819200" >>/etc/security/limits.conf
echo "root            soft    nofile          819200" >>/etc/security/limits.conf
echo "nobody          hard    nofile          819200" >>/etc/security/limits.conf
echo "root            hard    nofile          819200" >>/etc/security/limits.conf

echo "nobody          soft    stack          4096" >>/etc/security/limits.conf
echo "root            soft    stack          4096" >>/etc/security/limits.conf
echo "nobody          hard    stack          4096" >>/etc/security/limits.conf
echo "root            hard    stack          4096" >>/etc/security/limits.conf

echo "nobody          soft    nproc          778240" >>/etc/security/limits.conf
echo "root            soft    nproc          778240" >>/etc/security/limits.conf
echo "nobody          hard    nproc          778240" >>/etc/security/limits.conf
echo "root            hard    nproc          778240" >>/etc/security/limits.conf

当然可以再加一些你想要加的东西


阅读(1806) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~