Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2447117
  • 博文数量: 540
  • 博客积分: 11289
  • 博客等级: 上将
  • 技术积分: 6160
  • 用 户 组: 普通用户
  • 注册时间: 2008-02-11 20:27
个人简介

潜龙勿用,见龙在田

文章分类

全部博文(540)

文章存档

2018年(2)

2013年(5)

2012年(24)

2011年(104)

2010年(60)

2009年(217)

2008年(128)

分类: LINUX

2009-03-18 15:26:28

参考了许多文档,有官方的,也有他人的安装文档,同时也有自己的安装心得。本文没有太多的理论介绍,所以想了解其中各种原理可以Google相关资料。
介绍了http和NFS两种网络安装方式,配置文件中的区别主要有两处,下文都有提到。本人实验时为HTTP方式。
本人测试环境:RHEL5U2
步骤:
1. 安装http服务:
我安装的是RHEL5U2自带apache rpm安装包。httpd服务安装后,假设web根目录为WEB_HOME=/var/www/html,我的RHEL5U2放在/databackup/rhel5u2,可以创建一个链接文件到web根目录里:

ln -s /databackup/rhel5u2 $WEB_HOME/

如果能在浏览器里浏览到rhel5u2的目录,即在浏览器里输入能列出安装文件树,接着:
如果你的系统安装文件为iso文件的话,需要装载后里面的文件方能被浏览。装载命令:
mount /path/to/your/xxx.iso -o loop /your/mount/path/
注意:下面是安装时碰到的一个错误,虽然是错误现象一样,但我的问题的是ISO文件有问题,另外下载一个好的iso文件便解决了。跟下面情况并不相同,但需要引起我们注意。
----------------------------------------------------------------------------
当从包含 红帽企业 Linux ISO 映像的 NFS 服务器目录里安装红帽企业 Linux 5 时,Anaconda 可能会显示下面的错误信息:

Unable to read package metadata. This may be due to a missing repodata directory.

Please ensure that your install tree has been correctly generated. Cannot

open/read repomd.xml file for repository:

如果存放 ISO 镜像的目录也包含了部分解开的安装树(例如,第一个 ISO 里的 /images 目录)时,就会出现这个问题。这些目录的存在会导致上面的错误。
要避免这个错误,你需要把安装树解开到不包含 ISO 安装映像的其他目录下。
-----------------------------------------------------------------------------------------

2. 创建kickstart配置文件:

可以使用system-config-kickstart创建一个配置文件,另外可以使用/root/anaconda-ks.cfg作为原始文件,再根据你的需求加以修改。

# vi $WEB_HOME/ks5u2.cfg

以下为一个ks文件的范本,可根据自己需求定制。关键是要弄清楚每个命令的作用。对于每个命令的作用可参考redhat官方文档:



# Kickstart file automatically generated by anaconda.
install
url --url
#nfs --server=192.168.3.252 --dir=/databackup/rhel5u2
key --skip
#key
lang en_US
langsupport --default=en_US.UTF-8 zh_CN.UTF-8 en_US.UTF-8
keyboard us
rootpw --iscrypted $1$BzRT3/$L/MCsPnX3Tt0LxJETFsb50
firewall --disabled
authconfig --enableshadow --enablemd5
selinux --disabled
timezone Asia/Shanghai
reboot
text
network --bootproto=dhcp --device=eth0 --onboot=on --noipv6
network --bootproto=dhcp --device=eth1 --onboot=on --noipv6
#network --device=eth0 --bootproto=static --ip=192.168.3.29 --netmask=255.255.255.0 --gateway=192.168.3.1
--nameserver=202.96.209.5 --hostname=test06
bootloader --location=mbr --initlabel
#clearpart --linux
#clearpart --drives=sda,sdb,sdc --all
part /boot --fstype ext3 --size=100 --ondisk=sda
part / --fstype ext3 --size=15000 --ondisk=sda
part swap --size=1024 --ondisk=sda
part /databackup --fstype ext3 --size=10240 --ondisk=sda --grow
%packages
@mysql
@development-libs
@development-tools
@editors
@system-tools
@text-internet
@core
@base
@legacy-software-support
@base-x
@chinese-support
@web-server
@server-cfg
@admin-tools
@graphical-internet
emacs
sysstat
iptraf
lynx
mesa-libGLU-devel
device-mapper-multipath
gtk+
xorg-x11-utils
xorg-x11-server-Xvfb
system-config-kickstart
imake
-bluez-hcidump
-zsh
-ksh
-words
-apmd
-fbset
-finger
-mlocate
-dhcpv6-client
-mozldap
-rsh
-zsh
-sysreport
-rp-pppoe
-unix2dos
-svrcore
-amtu
-nc
-bluez-utils
-bluez-gnome
-nss_ldap
-krb5-workstation
-stunnel
-dosfstools
-pcmciautils
-pam_ccreds
-pam_smb
-mtools
-microcode_ctl
-mlocate
-mdadm
-talk
-system-config-httpd
-sabayon
-system-config-lvm
-setroubleshoot
-system-config-netboot
-system-config-kdump
-system-config-rootpassword
-sendmail
-symlinks
-xdelta
-openldap-clients
-ypbind
-eject
-setarch
-nc
-irda-utils
-tux
-webalize
-squid
%post
useradd test01
echo 12345678 | passwd test01 --stdin
chkconfig --level 345 sshd on
for i in autofs bluetooth cups firstboot ip6tables iptables rhnsd xfs yum-updatesd sendmail atd portmap pcmcia irqbalance ip6tables ; do chkconfig  $i off ; done
##To see more info about kickstart option:
#
#上面这个配置可以实现双系统安装,即如果你的硬盘原有一个系统如Windows2003,并且有足够的未分配空间,
#这个例子可以自动将Linux系统安装在未分配空间里;如果是新硬盘或者你不想硬盘保留有其他系统,启用
#clearpart --all命令即可。两种安装方式我都测试通过。
#zerombr: 如果没有此选项,在虚拟机测试时发现第一次会提示你删除分区数据。
#rootpw 后面可以是明文,也可以是密文。
--iscrypted MD5加密算法,密文可以通过grub-md5-crypt或者openssl passwd -1 -salt "shaker" 来获得
#本人在实验时通过前者来加密。用法是输入该命令直接回车,会提示你输入两次密码,然后打印出加密后的密文。即使相同的密码,生成的密文也不会相同的。
到这里如果没什么意外的话,则可以实现半自动安装了。你可以使用一张RHEL5安装光盘进入引导画面后,输入:
linux ks=
如果你安装的发行版自带的驱动能够找到你的网卡,接下来就能自动安装系统了,如果认不到你的网卡,那这种方式就行不通了,呵呵。所以谓之曰
半自动,因为前提是要能够支持你的网卡驱动。要想实现全自动安装,还得继续配置DHCP,PEX,TFTP.

3. DHCP:
# rpm -qa|grep dhcp
dhcp-3.0.5-13.el5
#To enable dhcp daemon after system start.
# chkconfig --level 345 dhcpd on

把客户端机器的MAC地址写入下列配置文件里,我的是vmware虚拟机作为客户端,开机可以按F12从
网络启动:

Here is my dhcpd.conf:


# cat /etc/dhcpd.conf
#---------------------------------/etc/dhcpd.conf-------------------------------#
ddns-update-style interim;
ignore client-updates;
deny unknown-clients;
allow booting;allow bootp;
#not authoritative;
authoritative; ##如果局域网中有了dhcp server,为避免分配与之相同的ip段中的ip,可以
加上此选项。

subnet 192.168.3.0 netmask 255.255.255.0 {
# 作用:定义作用域,指定子网
# 注意:网络号必须与DHCP服务器的网络号相同


# --- default gateway
option routers 192.168.3.1;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.3.255;
option ip-forwarding false; # No IP forwarding
# -- option mask-supplier false; # Don't respond to ICMP Mask req
option domain-name-servers 192.168.3.1;
option time-offset -18000; # Eastern Standard Time
range dynamic-bootp 192.168.3.24 192.168.3.26;
default-lease-time 21600;
max-lease-time 43200;
group {
next-server 192.168.3.252; # name of your TFTP server
filename "pxelinux.0"; # name of the bootloader program

host node1 {
hardware ethernet 00:0C:29:54:89:79;
fixed-address 192.168.3.25;
}
host node2 {
hardware ethernet
00:0C:29:54:89:80;
fixed-address 192.168.3.26;
}
}
}

#---------------------------------/etc/dhcpd.conf-------------------------------#

典型故障:

1.DHCP服务器配置完成,没有语法错误。但是网络中的客户机却没办法取得IP地址。 

通常是Linux DHCP服务器沒有办法接收來自255.255.255.255 DHCP 客户机的Request 封包造成的。一般是Linux DHCP服务器的网卡没有设置具有MULTICAST功能。为了让dhcpd(dhcp程序的守护进程)能够正常的和DHCP客户机沟通,dhcpd必须传送封包到255.255.255.255这个IP地址,但是有些Linux系统里255.255.255.255这个IP地址被用来做为监听区域子网域(local subnet)广播的 IP地址,所以需要在路由表(routing table)里加入255.255.255.255以激活MULTICAST功能; 

使用命令:

route add -host 255.255.255.255 dev eth0



4. TFTP:
[root@localhost ~]# rpm -qa|grep tftp
tftp-server-0.42-3.1

# chkconfig --level 345 tftp on
# cp /usr/lib/syslinux/pxelinux.0 /tftpboot/
# cp /databackup/rhel5u2/images/pxeboot/initrd.img /tftpboot/initrd-as5u2.img
# cp /databackup/rhel5u2/images/pxeboot/vmlinuz /tftpboot/vmlinuz-as5u2
# mkdir /tftpboot/pxelinux.cfg
# cp /databackup/rhel5u2/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default
# cp /databackup/rhel5u2/isolinux/*.msg /tftpboot/



The TFTP server directory /tftpboot should look like this:

[root@localhost tftpboot]# ls -p
boot.msg initrd-as5u2.img param.msg pxelinux.cfg/ snake.msg
general.msg options.msg pxelinux.0 rescue.msg vmlinuz-as5u2

[root@localhost tftpboot]# ls -p pxelinux.cfg/
default




5. PEXlinux:
PXE can load a program into the client's memory and start it. I found it the easiest to manage,
if I first load a bootloader into the clients. The bootloader then loads its configuration file
via TFTP from the next-server(tftpsrv in the dhcpd.conf file example above).
The bootloader configuration file determines whether a client boots from its local hard disk
or over the network.


Here are example configuration files for my case: (/tftpboot/pxelinux.cfg/default)

default local
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 0
label memtest86
kernel memtest
append -
label netinstall
kernel vmlinuz-as5u2
append ks= initrd=initrd-as5u2.img
当有多个网卡时,在安装时会提示选择使用哪个网卡,为避免交互,使用ksdevice参数指定网卡名称:append ks= initrd=initrd-as5u2.img ksdevice=eth0

NFS方式安装则为:
ks=nfs:192.168.3.252:/var/www/html/ks5u2.cfg

修改/tftp/boot.msg:
注意cat和vi的显示是不一样的,vi编辑的时候不要去修改那些特殊的字符,添加行时复制即可。

##---------------/tftpboot/boot.msg-------------------------------------------------#

splash.lss

- To boot from local, press the 0107 key.

- To install or upgrade in graphical mode, press the 01linux 07 key.

- To install or upgrade in text mode, type: 01linux text 07.

- To install RHEL AS5U2 automaticaly from network , type: 01netinstall 07.

- Use the function keys listed below for more information.

0f[F1-Main] [F2-Options] [F3-General] [F4-Kernel] [F5-Rescue]07


##---------------/tftpboot/boot.msg--------------------------------------------------#
关于boot.msg里符号:ctrl +v +o

注释:1)display显示的是pxelinux.cfg目录下的list文档,可自己编辑
#cat pxelinux.cfg/list
======================================================================
choose one of the following Linux distributions for your installation:
Default 1
======================================================================
chosen         Distribution
  1            RHEL3-U8
  2            RHEL4-U4
=================补充=================
/tftpboot目录中新建pxelinux.cfg文件夹,客户端MAC地址为88:99:aa:bb:cc:dd,
新建01-88-99-aa-bb-cc-dd文件在/data/tftpboot/pxelinux.cfg文件夹下,内容如下:
prompt 1 
default linux 
timeout 100    
label linux 
kernel vmlinuz 
append initrd=initrd.img ramdisk_size=9216 noapic acpi=off 
ks=
 注:配置文必须01开头,01+MAC地址,如01-88-99-aa-bb-cc-dd
ks= 就是kickstart自动安装脚本文件
有些内核关机会出现 system halted,不关闭电源,修改/etc/grub.conf文件,需取消内核启动参数 
noapic acpi=off
pxelinx.0(NBP)程序配置文件搜索顺序

由于多个客户端可以从一个PXE服务器引导,PXE引导映像使用了一个复杂的配置文件搜索方式来查找针对客户机的配置文件.
假设 客户端服务器的网卡的MAC地址为 88:99:AA:BB:CC:DD ,对应的IP地址为192.168.1.195,那么客户端的pxelinux.0 程序 搜索顺序如下:

  1. 首先以MAC地址为文件名匹配的配置文件,如果不存在,继续查找.
  2. 其次以IP地址来查找.根据IP地址16进制命名的配置文件查找,从小范围到打大分为查找(子网掩码由小到大),如果不存在,继续查找.
  3. 最后尝试default文件

总体来说,pxelinux.0 搜索的文件的顺序是(可以通过tcpdum得到结果):
 /tftpboot/pxelinux.cfg/01-88-99-aa-bb-cc-dd
  /tftpboot/pxelinux.cfg/C0A801C3
  /tftpboot/pxelinux.cfg/C0A801C
  /tftpboot/pxelinux.cfg/C0A801
  /tftpboot/pxelinux.cfg/C0A80
  /tftpboot/pxelinux.cfg/C0A8
  /tftpboot/pxelinux.cfg/C0A
  /tftpboot/pxelinux.cfg/C0
  /tftpboot/pxelinux.cfg/C
  /tftpboot/pxelinux.cfg/default


---------------------------------------------------------
  pxelinux.0在执行过程中,要读取pexlinux.cfg目录下的配置文件,该配置文件名为客户机IP的十六进制表示,如上面提到的客户机其ip转换为十六进制后是COA8BB82。当然也可以写成默认的default文件。

     vim   COA8BB82 <==   DEFAULT   install

                                            PROMPT 1

             LABEL         rhel-5.2-i386

                                            KERNEL      vmlinuz

                                                                ramdisk_size=16384

                                            "DISPLAY    pxelinux.cfg/list" 


如果有多个系统可选择的话,可编辑list文件, 每一行如下所示:

rhel-5.2-i386   RHEL 5 AS V2 i386 192.168.187.130:/home/instsrv/i386/rhel5u2

其中第一字段必须与配置文件中的LABEL字段相同。


-------------------------------------------

/tftpboot/pxelinux.cfg/default
DEFAULT menu.c32
# You can also load a background image if you use
# DEFAULT vesamenu.c32
# MENU BACKGROUND Logo.jpg

PROMPT 0

# Wait 5 seconds unless the user presses a button, but always boot after 900 seconds.
TIMEOUT 50
TOTALTIMEOUT 9000

MENU TITLE PXE menu from TFTP server

label harddisk
        menu label Boot from local harddisk
        kernel chain.c32
        append hd0

# Remember: Config files (such as centos.conf) are relative to /tftpboot/

label CentosMenu
        menu label CentOS-5.0 Linux installation menu
        kernel menu.c32
        append CentOS-5.0/centos.conf

label SystemImagerMenu
        menu label SystemImager Linux cloning menu
        kernel menu.c32
        append SI/si.conf

label hdt
        menu label HDT - Hardware Detection Tool
        COM32 hdt.c32

label ToolsMenu
        menu label Test tools menu
        kernel menu.c32
        append Tools/tools.conf

label x3455menu
        menu label IBM x3455 menu
        kernel menu.c32
        append x3455/x3455.conf

label mysystemmenu
        menu label mysystem menu
        kernel menu.c32
        append mysystem/mysystem.conf









参考文档:

系统里面的文档:
/usr/share/doc/syslinux-3.11/
How to Install Red Hat Linux via PXE and Kickstart:~alfw/PXE-Kickstart/PXE-Kickstart.html#toc6

kickstart命令参考文档:


阅读(3062) | 评论(0) | 转发(0) |
0

上一篇:Windows内存问题

下一篇:mysql myisam表修复

给主人留下些什么吧!~~