NFS服務(wù)多協(xié)議平臺建設(shè)
隨著嵌入式卡發(fā)的不斷發(fā)展,目前在平臺中加入NFS服務(wù),以及ftp協(xié)議等內(nèi)容是時常遇到的事情。那么如何構(gòu)架這樣一個平臺呢?下面我們就來詳細(xì)介紹一下具體的實(shí)現(xiàn)步驟。
一、 介紹
簡單原理介紹:無光軟驅(qū)服務(wù)器通過PXE網(wǎng)卡啟動,從dhcp服務(wù)器獲取IP 通過tftp 下載pxelinux.0文件找到pxelinux.cfg里的配置文件,按配置文件找著vmlinuz引導(dǎo)centos進(jìn)入安裝界面,之后選擇NFS服務(wù)方式安裝系統(tǒng).
另: 如需要實(shí)現(xiàn)全自動安裝 要安裝 Kickstart 軟件包并配置.本文并不討論
二、環(huán)境說明
本文測試環(huán)境及用到的軟件
Server: centos 5.2 dhcp nfs tftp ip:192.168.1.251 (此IP只需要與服務(wù)器網(wǎng)卡相連,不管是什么都可以)
三、安裝配置過程及基本講解:
安裝相應(yīng)的軟件: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.linuxtone.org
- service tftp
- {
- disable = no #默認(rèn)是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服務(wù): /etc/init.d/xinetd restart
查看tftp 是否啟動:# chkconfig --list |grep tftp
tftp: on
2、 配置nfs服務(wù)
- mount /iso/CentOS-5.2-i386-bin-1of6.iso /mnt -o loop #我是掛載的鏡像文件,你們可以掛載光驅(qū)
- echo "/tftpboot *(ro,sync)" > /etc/exports
- echo "/mnt *(ro,sync)" > /etc/exports #此二步設(shè)置共享的目錄
- exportfs –a #使配置生效
- /etc/init.d/portmap start &&/etc/init.d/nfs start #重啟服務(wù)
- 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; #要分區(qū)的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 啟動服務(wù)
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
四、測試
啟動服務(wù)器,一般是按F12選擇進(jìn)入PXE網(wǎng)絡(luò)啟動.這時就會自動獲取IP并進(jìn)入Boot: 界面.按linux text 進(jìn)入.之后選擇NFS服務(wù)安裝系統(tǒng).
五、配置文件詳解
dhcpd.conf配置的有關(guān)說明:
parameters(參數(shù)):
ddns-update-style 配置DHCP-DNS互動更新模式
default-lease-time 指定缺省租賃時間的長度,單位是秒
max-lease-time 指定最大租賃時間長度,單位是秒
hardware 指定網(wǎng)卡接口類型和MAC地址
server-name 通知DHCP客戶服務(wù)器名稱
get-lease-hostnames flag 檢查客戶端使用的IP地址
fixed-address ip 分配給客戶端一個固定的地址
authritative 拒絕不正確的IP地址的要求
declarations(聲明):
shared-network 用來告知是否一些子網(wǎng)絡(luò)分享相同網(wǎng)絡(luò)
subnet 描述一個IP地址是否屬于該子網(wǎng)
range 起始IP 終止IP 提供動態(tài)分配IP 的范圍
host 主機(jī)名稱 參考特別的主機(jī)
group 為一組參數(shù)提供聲明
allow unknown-clients或deny unknown-client 是否動態(tài)分配IP給未知的使用者
allow bootp或deny bootp 是否響應(yīng)激活查詢
allow booting或deny booting 是否響應(yīng)使用者查詢
filename 開始啟動文件的名稱,應(yīng)用于無盤工作站
next-server 設(shè)置服務(wù)器從引導(dǎo)文件中裝如主機(jī)名,應(yīng)用于無盤工作站
option(選項):
subnet-mask 為客戶端設(shè)定子網(wǎng)掩碼
domain-name 為客戶端指明DNS名字
domain-name-servers 為客戶端指明DNS服務(wù)器IP地址
host-name 為客戶端指定主機(jī)名稱
routers 為客戶端設(shè)定默認(rèn)網(wǎng)關(guān)
broadcast-address 為客戶端設(shè)定廣播地址
ntp-server 為客戶端設(shè)定網(wǎng)絡(luò)時間服務(wù)器IP地址
time-offset 為客戶端設(shè)定和格林威治時間的偏移時間,單位是秒.