Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1117140
  • 博文数量: 309
  • 博客积分: 6093
  • 博客等级: 准将
  • 技术积分: 3038
  • 用 户 组: 普通用户
  • 注册时间: 2008-02-03 17:14
个人简介

linux学习记录

文章分类

全部博文(309)

文章存档

2014年(2)

2012年(37)

2011年(41)

2010年(87)

2009年(54)

2008年(88)

分类:

2010-08-25 15:24:23

                   RHCE学习笔记

 

linux下面实现PXE网络引导的讨论,

 

在安装RedHat Linux企业版的过程中,我们一般情况使用一个安装引导介质(引导光盘,引导软盘,U盘等),有没有一种方法可以不通过引导光盘的方式来安装呢,而直接通过网络来进行安装呢,我们通过PXE技术就可以实现。

 

下面就开始进行PXE网络引导的配置

PXE安装,需要如下步骤:

1.      配置DHCP服务器,用于给客户端提供IP地址和其他信息

2.      配置TFTP服务器,用于提供客户端PXE引导所必须的文件

3.      配置NFS服务器 ,用于存放安装源

4.      配置kickstart,用于无人职守的安装(可选)

5.      使用PXE功能引导客户端

 

第一步,配置DHCP服务器

有关DHCP服务器的具体配置可以参考:

http://blog.chinaunix.net/u3/111899/showart_2197859.html

 

下面是DHCP服务器的配置文件,

Vim   /etc/dhcpd.conf

ddns-update-style interim;

ignore client-updates;

next-server  192.168.0.254;

filename  "pxelinux.0";

 

subnet 192.168.0.0 netmask 255.255.255.0 {

 

# --- default gateway

        option routers                           192.168.0.254;

        option subnet-mask                  255.255.255.0;

 

        option nis-domain                     "domain.org";

        option domain-name                 "example.com";

        option domain-name-servers     192.168.0.254;

 

        option time-offset                      -18000; # Eastern Standard Time

#       option ntp-servers                     192.168.1.1;

#       option netbios-name-servers     192.168.1.1;

# --- Selects point-to-point node (default is hybrid). Don't change this unless

# -- you understand Netbios very well

#       option netbios-node-type 2;

 

        range dynamic-bootp    192.168.0.10   192.168.0.250;

        default-lease-time   21600;

        max-lease-time    43200;

 

 

        # we want the nameserver to appear at a fixed address

        host ns {

                next-server marvin.redhat.com;

                hardware ethernet 12:34:56:78:AB:CD;

                fixed-address 207.175.42.254;

        }

DHCP的配置文件/etc/dhcpd.conf文件里面中加上,

next-server   192.168.0.254;

指定tftp-serverIP地址是多少

filename   "pxelinux.0";

指定pxelinux启动文件的位置

关于DHCP服务器的配置如上就OK了。

 

第二步,配置TFTP服务器

我们知道TFTP是由xinetd管理的服务,所以TFTP的配置文件是/etc/xinetd.d/tftp

1. 配置TFTP的配置文件,

[root@localhost ~]#

[root@localhost ~]# cd /etc/xinetd.d/

[root@localhost xinetd.d]#

[root@localhost xinetd.d]# cat 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.

service tftp

 

        socket_type         = dgram

        protocol               = udp

        wait                     = yes

        user                     = root

        server                  = /usr/sbin/in.tftpd

        server_args          = -s /tftpboot

        disable                 = yes

        per_source          = 11

        cps                      = 100 2

        flags                    = IPv4

}

[root@localhost xinetd.d]#

tftp服务的配置文件中的disable=yes设置成disable=no

现在我们重启下xinetd服务,

[root@localhost ~]#

[root@localhost ~]# service xinetd restart

Stopping xinetd:                                          [  OK  ]

Starting xinetd:                                            [  OK  ]

[root@localhost ~]#

[root@localhost ~]# chkconfig tftp on

[root@localhost ~]#

OK,服务启动没有问题,并且设置下次启动生效。

 

2. 配置PXE引导配置,

当我们装完tftp-server以后,系统默认会生成一个/tftpboot的目录。

现在我们将光盘里面的isolinux这个目录下的所有东西复制到/tftpboot这个目录下面去。

[root@localhost ~]#

[root@localhost ~]# cd /media/RHEL_5.4\ i386\ DVD/isolinux/

[root@localhost isolinux]#

[root@localhost isolinux]# cp * /tftpboot/

[root@localhost isolinux]#

[root@localhost isolinux]# cd   /tftpboot/

[root@localhost tftpboot]# ls

boot.cat        initrd.img      memtest         rescue.msg  vmlinuz

boot.msg      isolinux.bin   options.msg   splash.lss

general.msg  isolinux.cfg    param.msg    TRANS.TBL

[root@localhost tftpboot]#

这里面的每个文件都是有意义的。

因为PXE读取到的是pxelinux.cfg这个文件夹,所有必须创建这个文件夹。

[root@localhost ~]#

[root@localhost ~]# cd /tftpboot/

[root@localhost tftpboot]#

[root@localhost tftpboot]# mkdir pxelinux.cfg

[root@localhost tftpboot]#

然后我们需要将pxe的引导文件pexlinux.0给复制过来,

[root@localhost ~]#

[root@localhost ~]# cp /usr/lib/syslinux/pxelinux.0 /tftpboot/

[root@localhost ~]#

[root@localhost ~]# cd /tftpboot/

[root@localhost tftpboot]#

[root@localhost tftpboot]# ls pxelinux.0

pxelinux.0

[root@localhost tftpboot]#

最后我们需要将isolinux.cfg这个模板文件复制成pxelinux.cfg这个目录下的default这个文件

[root@localhost ~]#

[root@localhost ~]# cd /tftpboot/

[root@localhost tftpboot]#

[root@localhost tftpboot]# mv isolinux.cfg pxelinux.cfg/default

[root@localhost tftpboot]#

[root@localhost tftpboot]# cd pxelinux.cfg/

[root@localhost pxelinux.cfg]# ls

default

[root@localhost pxelinux.cfg]#

这个是/tftpboot目录的树状结构:

[root@server1 ~]# tree /tftpboot/
/tftpboot/
|-- TRANS.TBL
|-- boot.cat
|-- boot.msg
|-- general.msg
|-- initrd.img
|-- isolinux.bin
|-- isolinux.cfg
|-- memtest
|-- options.msg
|-- param.msg
|-- pxelinux.0
|-- pxelinux.cfg
|   `-- default
|-- rescue.msg
|-- splash.lss
`-- vmlinuz

1 directory, 15 files


 关于TFTP服务器的配置和PXE的配置就OK了。

 

 第三步,配置NFS服务器

有关NFS服务器的具体配置可以参考:

http://blog.chinaunix.net/u3/111899/showart_2197860.html

 

现在我们将光盘里面的所有文件全部复制到/var/ftp/pub这个目录下面去,

[root@localhost ~]#

[root@localhost ~]# cd /media/RHEL_5.4\ i386\ DVD/

[root@localhost RHEL_5.4 i386 DVD]#

[root@localhost RHEL_5.4 i386 DVD]# cp -r * /var/ftp/pub/

[root@localhost RHEL_5.4 i386 DVD]#

然后将/var/ftp/pub这个目录给共享出来,

首先编辑NFS的配置文件,

vim     /etc/exports

/var/ftp/pub         192.168.0.0/24(ro,sync)

然后重启下NFS服务,(先启portmap,在启nfs)

[root@localhost ~]#

[root@localhost ~]# service portmap restart

Stopping portmap:                                            [  OK  ]

Starting portmap:                                              [  OK  ]

[root@localhost ~]# service nfs restart

Shutting down NFS mountd:                              [  OK  ]

Shutting down NFS daemon:                             [  OK  ]

Shutting down NFS quotas:                               [  OK  ]

Shutting down NFS services:                             [  OK  ]

Starting NFS services:                                       [  OK  ]

Starting NFS quotas:                                         [  OK  ]

Starting NFS daemon:                                       [  OK  ]

Starting NFS mountd:                                        [  OK  ]

[root@localhost ~]

我们可以使用showmount –e来查看一下共享是否成功,

[root@server1 ~]#

[root@server1 ~]# showmount -e 192.168.0.254

Export list for 192.168.0.254:

/var/ftp/pub 192.168.0.0/24

[root@server1 ~]#

OK,没有问题,NFS共享成功了。

 

关于NFS服务器的配置就OK了。

 

第四步,配置kickstart的安装

通常我们在安装系统的时候需要大量的人机交互界面,而kickstart的安装可以实现无人职守的自动化安装,我们只需要将kickstart的脚本放在服务器上面,就可以避免繁琐的人机交互界面。

linux下面,可以通过system-config-kickstart这个图形工具来生成这个kickstart的脚本。我们知道在系统安装完成后会自动的创建一个kickstart的文件,这个文件就记录了系统的真实安装配置。该文件在/root/ anaconda-ks.cfg

现在我就使用这个文件,将它复制重命名到/var/ftp/pub/ksfile/ksinstall,并改变一下权限。

[root@localhost ~]#

[root@localhost ~]# cp /root/anaconda-ks.cfg /var/ftp/pub/ksfile/ksinstall.cfg

[root@localhost ~]#

[root@localhost ~]#

[root@localhost ~]# cd /var/ftp/pub/

[root@localhost pub]# cd ksfile/

[root@localhost ksfile]# ls

ksinstall.cfg

[root@localhost ksfile]# chmod 644 ksinstall.cfg

[root@localhost ksfile]# ll

total 8

-rw-r--r-- 1 root root 1085 Mar 19 16:30 ksinstall.cfg

[root@localhost ksfile]#

复制完成后,需要改变权限为644,让每个用户都有读取的权限。

现在只需要稍微修改一下ksinstall.cfg这个文件,

在这个文件中定义安装源的路径,

# Kickstart file automatically generated by anaconda.

 

install

nfs --server=192.168.0.254 --dir=/var/ftp/pub/

这个参数告诉系统到服务器192.168.0.254NFS共享目录/var/ftp/pub/ksfile下去寻找安装介质。

接下来还要在/tftpboot/pxelinux.cfg/default这个文件中定义ks的路径就OK了,

label linux

  kernel vmlinuz

  append ks=nfs:192.168.0.254: var/ftp/pub/ksfile/ksinstall.cfg  initrd=initrd.img

OK,现在kickstart安装配置就完成了。

 

第五步,配置客户端的PXE引导

首先,重启客户端,将启动方式设置成网络引导,

 

OK,看到这个界面就行了,这个时候直接回车,系统就会通过我们刚才定义的ksinstall.cfg脚本进行无人职守的安装系统了。

 

 

linux下面实现PXE网络引导的讨论就到这里了。


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