2009年4月9日星期四

实战:Pxe+dhcp+nfs+tftp网络安装Centos

实战:Pxe+dhcp+nfs+tftp网络安装Centos

[2009-04-09] 来源:IT168  作者:守住每一天

http://www.linuxidc.com/Linux/2009-04/19332.htm

一、 介绍

简单原理介绍:无光软驱服务器通过PXE网卡启动,从dhcp服务器获取IP 通过tftp 下载pxelinux.0文件找到pxelinux.cfg里的配置文件,按配置文件找着vmlinuz引导centos进入安装界面,之后选择NFS方式安装系统。

另: 如需要实现全自动安装 要安装 Kickstart  软件包并配置。本文并不讨论


二、环境说明

本文测试环境及用到的软件

Server: centos 5.2  dhcp nfs tftp  ip:192.168.1.251 (此IP只需要与服务器网卡相连,不管是什么都可以)

三、安装配置过程及基本讲解:

安装相应的软件:yum –y install dhcp* nfs* tftp*

1、 配置tftp more /etc/xinetd.d/tftp

# default: off
# description: The tftp server serves files using the trivial file transfer \
#       protocol.  The tftp protocol is often used to boot diskless \
#       workstations, download configuration files to network-aware printers, \
#       and to start the installation process for some operating systems.
# trad: liuyu
# blog: liuyu.blog.51cto.com
# bbs: www.britepic.org
service tftp
{
disable = no   #默认是yes 改为no
socket_type             = dgram
protocol                = udp
wait                    = yes
user                    = root
server                  = /usr/sbin/in.tftpd
server_args             = -u nobody -s /tftpboot  #添加nobody可以访问
per_source              = 11
cps                     = 100 2
flags                   = IPv4
}

复制代码重启xinetd服务: /etc/init.d/xinetd restart

查看tftp 是否启动:# chkconfig --list |grep tftp

tftp:           on

2、 配置nfs

mount /iso/CentOS-5.2-i386-bin-1of6.iso /mnt -o loop  #我是挂载的镜像文件,你们可以挂载光驱

echo "/tftpboot *(ro,sync)" > /etc/exports

echo "/mnt *(ro,sync)" > /etc/exports   #此二步设置共享的目录

exportfs –a   #使配置生效

/etc/init.d/portmap start  &&/etc/init.d/nfs start    #重启服务

Showmount –e localhost  #看查共享的目录

Export list for localhost:

/mnt      *

/tftpboot *

3、配置dhcp

直接copy我的配置

# more /etc/dhcpd.conf
#
# DHCP Server Configuration file.
#   see /usr/share/doc/dhcp*/dhcpd.conf.sample
#
# trad: liuyu
# blog: liuyu.blog.51cto.com
# bbs: www.britepic.org
ddns-update-style interim;
ignore client-updates;
allow booting;
allow bootp;
subnet 192.168.1.0 netmask 255.255.255.0 {
option routers 192.168.1.251;
option subnet-mask 255.255.255.0;
option domain-name-servers 192.168.1.251;   #本地IP
option time-offset -18000; # Eastern Standard Time
range dynamic-bootp 192.168.1.12 192.168.1.254;  #要分区的IP
default-lease-time 21600;
max-lease-time 43200;
# Group the PXE bootable hosts together
# PXE-specific configuration directives...
next-server 192.168.1.251;
filename "/pxelinux.0";   #方便查找配置文件
}

复制代码/etc/init.d/dhcpd start  启动服务

4、 配置pxe所需要的文件 Mkdir /tftpboot/pxelinux.cfg

cp /usr/lib/syslinux/pxelinux.0 /tftpboot/

cp /mnt/isolinux/vmlinuz /tftpboot/

cp /mnt/isolinux/initrd.img /tftpboot/

cp /mnt/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default

复制代码四、测试

启动服务器,一般是按F12选择进入PXE网络启动。这时就会自动获取IP并进入

Boot: 界面。按linux text 进入。之后选择NFS安装系统。

五、配置文件详解

dhcpd.conf配置的有关说明:

parameters(参数):

ddns-update-style 配置DHCP-DNS互动更新模式

default-lease-time 指定缺省租赁时间的长度,单位是秒

max-lease-time 指定最大租赁时间长度,单位是秒

hardware 指定网卡接口类型和MAC地址

server-name 通知DHCP客户服务器名称

get-lease-hostnames flag 检查客户端使用的IP地址

fixed-address ip 分配给客户端一个固定的地址

authritative 拒绝不正确的IP地址的要求

declarations(声明):

shared-network 用来告知是否一些子网络分享相同网络

subnet 描述一个IP地址是否属于该子网

range 起始IP 终止IP 提供动态分配IP 的范围

host 主机名称 参考特别的主机

group 为一组参数提供声明

allow unknown-clients或deny unknown-client 是否动态分配IP给未知的使用者

allow bootp或deny bootp 是否响应激活查询

allow booting或deny booting 是否响应使用者查询

filename 开始启动文件的名称,应用于无盘工作站

next-server 设置服务器从引导文件中装如主机名,应用于无盘工作站

option(选项):

subnet-mask 为客户端设定子网掩码

domain-name 为客户端指明DNS名字

domain-name-servers 为客户端指明DNS服务器IP地址

host-name 为客户端指定主机名称

routers 为客户端设定默认网关

broadcast-address 为客户端设定广播地址

ntp-server 为客户端设定网络时间服务器IP地址

time-offset 为客户端设定和格林威治时间的偏移时间,单位是秒。



7 条评论:

匿名 说...

There are so many ways to use brick, block, slabs, rocks, gravel and
other stone formations. It also happens sometimes that your
character will say something silly. Also onsite is a physics lab, which is in The underground psychic lab is in use today, by the University of Minnesota.


Here is my web site; mining

匿名 说...

things hard to build, difficult to replace, and costly to substitute.
We had no problem finding a space, though, despite the fact that there was a performance that night.
Subway is the largest sandwich franchise in the world, with 30,476 franchises in 87 countries.



Also visit my weblog: check this out

匿名 说...

Repairing Small Cracks in concrete Floors: Determine the Damage.

The estimate you receive will be based on the number of skips you need,
what size skip you want, and how long you plan to keep it.
Repairing larger cracks or holes in driveways takes a little more time and
preparation.

匿名 说...

The Regional Animal Hospital in Yorba Linda is well equipped to handle the emergencies.
Predominantly the computer software will endeavor
to lure you into paying for non-existent software program to
clear away the viruses that are infecting your Computer. At the end of the
meeting it was announced that he was to enroll in a dental college.

If you have a personal injury legal matter, a dog bite or if you’ve
lost a loved one in a wrongful death accident, call
the Law Offices of R. The doctor will ask about symptoms of metabolic disorders such as fatigue, headaches, cramping, mood changes,
shortness of breath, and chronic diarrhea.

Feel free to visit my weblog ... Imperial bushel

匿名 说...

There was a point when I was single that I used to
judge people I dated by whether they liked cats or not.

Include the locality Most realtors, property brokers
and owners miss out on this when placing ads in newspapers
for selling or leasing their properties. This is where the
online websites play quite a vital role. Approximate 46% of the daily newspapers are vernacular, 45% of them publish in Hindi and only 10% in English. Lap books are another tool a teacher can use to help students create booklets that they will want to keep and review.

Visit my weblog; egyptian newspapers

匿名 说...

Mira Hair Oil is a simple item to make use of, all you have to do is to try using 1 / 2 a teaspoon or even a full teaspoon at the most plus
massage the oil directly on your scalp and hair. It can also be left
in the hair as a conditioner but it may be hard to explain the tomatoes.
Quality Omega 3 fish oils are generally derived from
cold-water fishes like mackerel, sardines, salmon, and tuna.
All-natural oils such as olive, coconut, and avocado oil can be used
as wonderful hot oil treatments for hair.
The herbal solution is said to be a natural one, but, this does not necessarily indicate that it is more effective than
other available procedures.

Visit my blog post bridal hairstyles

匿名 说...

This blog was... how do I say it? Relevant!! Finally I have found something that helped me.
Cheers!

My site; home cellulite treatment