免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 914 | 回复: 0
打印 上一主题 下一主题

Pxe+dhcp+nfs+tftp 网络安装centos [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-12-01 11:44 |只看该作者 |倒序浏览
注:来自网络

一、介绍
简单原理介绍:无光软驱服务器通过PXE网卡启动,从dhcp服务器获取IP 通过tftp 取到pxelinux配置文件,按配置文件进行启动centos 文件进行引导系统安装。

二、环境说明
本文测试环境及用到的软件
Server: centos 5.2  dhcp nfs tftp  ip:192.168.1.251 (此IP只需要与服务器网卡相连,不管是什么都可以)

三、安装配置过程及基本讲解:
安装相应的软件:yum –y install dhcp* nfs* tftp*
1、  配置tftp
  1. more /etc/xinetd.d/tftp
  2. # default: off
  3. # de.ion: The tftp server serves files using the trivial file transfer \
  4. #       protocol.  The tftp protocol is often used to boot diskless \
  5. #       workstations, download configuration files to network-aware printers, \
  6. #       and to start the installation process for some operating systems.
  7. # trad: liuyu
  8. # blog: liuyu.blog.51cto.com
  9. # bbs: [url]www.linuxtone.org[/url]
  10. service tftp
  11. {
  12.         disable = no   #默认是yes 改为no
  13.         socket_type             = dgram
  14.         protocol                = udp
  15.         wait                    = yes
  16.         user                    = root
  17.         server                  = /usr/sbin/in.tftpd
  18.         server_args             = -u nobody -s /tftpboot  #添加nobody可以访问//-s 表示用/tftpboot作为tftp目录的根目录
  19.         per_source              = 11
  20.         cps                     = 100 2
  21.         flags                   = IPv4
  22. }
复制代码
   重启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我的配置
  1. # more /etc/dhcpd.conf
  2. #
  3. # DHCP Server Configuration file.
  4. #   see /usr/share/doc/dhcp*/dhcpd.conf.sample
  5. #
  6. # trad: liuyu
  7. # blog: liuyu.blog.51cto.com
  8. # bbs: [url]www.linuxtone.org[/url]
  9. ddns-update-style interim;
  10. ignore client-updates;
  11. allow booting;
  12. allow bootp;
  13. subnet 192.168.1.0 netmask 255.255.255.0 {
  14. option routers 192.168.1.251;
  15. option subnet-mask 255.255.255.0;
  16. option domain-name-servers 192.168.1.251;   #本地IP
  17. option time-offset -18000; # Eastern Standard Time
  18. range dynamic-bootp 192.168.1.12 192.168.1.254;  #要分区的IP
  19. default-lease-time 21600;
  20. max-lease-time 43200;
  21. # Group the PXE bootable hosts together
  22. # PXE-specific configuration directives...
  23. next-server 192.168.1.251;
  24. filename "/pxelinux.0";   #方便查找配置文件
  25. }
复制代码

/etc/init.d/dhcpd start  启动服务

4、  配置pxe所需要的文件
  1. Mkdir /tftpboot/pxelinux.cfg
  2. cp /usr/lib/syslinux/pxelinux.0 /tftpboot/
  3. cp /mnt/isolinux/vmlinuz /tftpboot/
  4. cp /mnt/isolinux/initrd.img /tftpboot/
  5. 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 为客户端设定和格林威治时间的偏移时间,单位是秒。
一、介绍
简单原理介绍:无光软驱服务器通过PXE网卡启动,从dhcp服务器获取IP 通过tftp 取到pxelinux配置文件,按配置文件进行启动centos 文件进行引导系统安装。

二、环境说明
本文测试环境及用到的软件
Server: centos 5.2  dhcp nfs tftp  ip:192.168.1.251 (此IP只需要与服务器网卡相连,不管是什么都可以)

三、安装配置过程及基本讲解:
安装相应的软件:yum –y install dhcp* nfs* tftp*
1、  配置tftp
  1. more /etc/xinetd.d/tftp
  2. # default: off
  3. # de.ion: The tftp server serves files using the trivial file transfer \
  4. #       protocol.  The tftp protocol is often used to boot diskless \
  5. #       workstations, download configuration files to network-aware printers, \
  6. #       and to start the installation process for some operating systems.
  7. # trad: liuyu
  8. # blog: liuyu.blog.51cto.com
  9. # bbs: [url]www.linuxtone.org[/url]
  10. service tftp
  11. {
  12.         disable = no   #默认是yes 改为no
  13.         socket_type             = dgram
  14.         protocol                = udp
  15.         wait                    = yes
  16.         user                    = root
  17.         server                  = /usr/sbin/in.tftpd
  18.         server_args             = -u nobody -s /tftpboot  #添加nobody可以访问//-s 表示用/tftpboot作为tftp目录的根目录
  19.         per_source              = 11
  20.         cps                     = 100 2
  21.         flags                   = IPv4
  22. }
复制代码
   重启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我的配置
  1. # more /etc/dhcpd.conf
  2. #
  3. # DHCP Server Configuration file.
  4. #   see /usr/share/doc/dhcp*/dhcpd.conf.sample
  5. #
  6. # trad: liuyu
  7. # blog: liuyu.blog.51cto.com
  8. # bbs: [url]www.linuxtone.org[/url]
  9. ddns-update-style interim;
  10. ignore client-updates;
  11. allow booting;
  12. allow bootp;
  13. subnet 192.168.1.0 netmask 255.255.255.0 {
  14. option routers 192.168.1.251;
  15. option subnet-mask 255.255.255.0;
  16. option domain-name-servers 192.168.1.251;   #本地IP
  17. option time-offset -18000; # Eastern Standard Time
  18. range dynamic-bootp 192.168.1.12 192.168.1.254;  #要分区的IP
  19. default-lease-time 21600;
  20. max-lease-time 43200;
  21. # Group the PXE bootable hosts together
  22. # PXE-specific configuration directives...
  23. next-server 192.168.1.251;
  24. filename "/pxelinux.0";   #方便查找配置文件
  25. }
复制代码

/etc/init.d/dhcpd start  启动服务

4、  配置pxe所需要的文件
  1. Mkdir /tftpboot/pxelinux.cfg
  2. cp /usr/lib/syslinux/pxelinux.0 /tftpboot/
  3. cp /mnt/isolinux/vmlinuz /tftpboot/
  4. cp /mnt/isolinux/initrd.img /tftpboot/
  5. 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 为客户端设定和格林威治时间的偏移时间,单位是秒。
http://blog.chinaunix.net/u2/63038/showart_2107082.html


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/41660/showart_2108132.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP