歡迎您光臨本站 註冊首頁

Pxe+dhcp+nfs+tftp 網路安裝centos

←手機掃碼閱讀     火星人 @ 2014-03-03 , reply:0

Pxe+dhcp+nfs+tftp 網路安裝centos

Pxe+dhcp+nfs+tftp 網路安裝centos





一、 介紹
簡單原理介紹:無光軟碟機伺服器通過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、 配置tftpmore /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.linuxtone.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:           on2、 配置nfsmount /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.linuxtone.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 為客戶端設定和格林威治時間的偏移時間,單位是秒。
《解決方案》

cobbler方便又好用

[火星人 ] Pxe+dhcp+nfs+tftp 網路安裝centos已經有829次圍觀

http://coctec.com/docs/service/show-post-1731.html