论坛风格切换切换到宽版
  • 597阅读
  • 0回复

[问题求助]网络文件系统(NFS)使用指南 [复制链接]

上一主题 下一主题
离线tnka.
 
发帖
2076
C币
-60326
威望
404
贡献值
1
银元
-3
铜钱
4803
人人网人气币
0
只看楼主 倒序阅读 使用道具 楼主  发表于: 2009-05-01
What is NFS ?
就是Network F.ile System    健康

NFS 是由SU.N公司发展, 并.於1984年推出, NFS是一个RPC service ,.
它使我们能够达到档.案的共享, 它的设计是为.了在不同的系统间使用, 所.
以它的通讯协定设计与主机及作.业系统无关.当使用.者想用远端档案时只虚拟主机
要用"mount"就可把r.emote档案系统挂接在自己的档案系统之下,使得远.端.
的档案使用上和local机器的档案没两.样.[成人用品]

mac.hine A machine B            杀毒

/ /

bin. etc usr bin etc usr             电子

man man share lo.cal              乙肝

假如我们在机器A上, 要把机器.B上的 /usr/man 挂接到machin.e A 的外贸
/usr/home下,只要

mount machine_n.ame:/u.sr/man /usr/home.

就可mou.nt过来.而我们不只是可以mount目录,就是一个档也是可.以的.在.
挂接之後我.们.只能对档案做reading (or writing) 的动作,而不能在             电子
remote mach.ie上把此档或目录move,delete掉 , 但须注意的是如我.们健康
mount /usr 後 , 不能再mount /usr.底下的目录, 否则会发生错误.           建材

□ S.ervers & Clients学习

NFS就是促使Servers上的档案能被其他的机器mou.nt,而达.到资源共享,.
享用这些档案的机器就可称为Client,一.个client可以从server上mou.nt一    健康
个档或是一个层次的..目录(file hierarchies) . 然而事实上任何一台机器.
都可以做NFS server or N.FS client ,甚至同时为NFS se.rver and NFS--------------彩票
client 也可以.

□ Server's Expor.ting & Cli.ent's Mounting域名

NFS ser.ver 所expor.t 出来的档案或目录都记录在 /etc/exports 这           鲜花
一个档中,当我们.启动NFS .server 时 在 /etc/rc.local 的这一个script             电子
会自动的启动 exportfs 这一个程式 , 搜.寻 /etc./exports 这一个档是否域名
存在, 并且..赋予正确的权限给所有export出去的 file hierarchies .              乙肝

exports文件中记录了哪些目录可.以export给哪.些机器。例如:             电子
/u.sr/tmp -root=machine2    外汇
/usr/bak
说明启动nfs后,/usr/tmp目.录允许machine2的root用户mount,而/.usr/bak学习
目录则export给所有的机.器。投资

但须注意的是,只有server所ex.p.ort出去的路径,NFS client才能够mount服务器
, 同样的.当启动client时 , 系统会自动去mount所有s.erver export的路径,教育
而mount.到的所有路径都会记录在 /etc/fsta.b 下 , 类似如下的fstab档           女人


/dev/sd0a / 4.2 rw 1. 1    美容
/dev/sd0h /.tmp 4.2 rw 1 3.
/dev/sd0g ./usr 4.2 rw 1 2(        游戏          )
/dev/fd0 /pcf.s pcfs rw,noauto 0. 0.
sparc20:/s.wap /sw.ap nfs rw,intr,bg,soft 0 0外贸
spar.c17:/home /h.ome nfs rw,intr,bg,soft 0 0.
sparc17:/home3 /home3 nfs rw.,intr,bg,soft 0 .0虚拟主机
spa.rc14:/hom.e4 /home4 nfs rw,intr,bg,soft 0 0电影
sparc20:/home2 /home2 nfs rw,intr,bg,so.ft. 0 0(        游戏          )
sp.arc20:/var/spool/mail /var/spool/mail nf.s rw,intr,bg,soft 0 0电脑
rs9.7.0:/home1 /home1 nfs rw,intr,bg,soft 0 0.


★ Noted :

当c.lient mount 到.一个路径,绝对不是说copy server上的这一个路径学习
到loc.al的机器上,我们可以用 cd 进入这一个mount到的路径.,就如同是使用.
local .directory一样.




□ Setting Up a NFS Se.rver服务器

1. 定义机器为 NFS file serve.r.

2. 划分server.'s disk ,定义哪一些partitions. 是要提供出来作为    外汇
client 所共享.的file system.

3. 在 Clie.nt Form 上定义.每一台client 的参数学习

4. 写出 /etc/exports (一般系.统.都有一个default exports)    健康

5. 重新bo.ot NFS server or 用指令 exportfs. -a 输出所有的    美容
directories 并且用 nfsd 8 & 启动 n.fsd.守护程式,常驻在背景投资


※ ps. 一些细节

1. 检查 /etc/exports. 输出路.径的权限,确定只有root能修改,.
all user只能read
2. 用exportfs 去增加或删.除direct.ories.
export.fs -o .access=engineering,ro=dancer /usr服务器
exportfs -u. /usr--- 印刷
3. 假如你的机器没有NI.S(YP server).的服务,当更改资料时记得修改           鲜花
/etc/passwd
/etc/group
/etc/hosts
/etc/ethers
4. 为你自己的n.etwo.rk 设置security教育


exportfs的语法

/usr/etc/exportfs [ -avu ] [ -o option ] [ .direc.tory ]<性病>

-a : 把 /etc/export.s 中所有路径expo.rt出去           建材

-.u : 把 export出去的路径卸下 ., 如 exportfs -u /usr服务器

-o option : 如 export.fs -o ro /usr ,所有人对/u.sr 都为read only    美容

option 还有 root = hostname , access = clie.n.t.

acc.ess = netgroup.


For example :

expo.rtfs -a 把exports中的.路径全部export出去             电子

exportfs -o access=engineeringther /usrhttp://upload.bbs.csuboy.com/Mon_1004/126_7015_c83c7cca86332e4.gif[/img]--- 印刷

/usr 这.路径export後只.有engineering and other 这两个投资
group 能够 read & write..

expor.tfs -o access=oak,r.o=dancer /usr           女人

设定dancer 这台cl.ient 对 /usr .为read only ,且只有[成人用品]
oak这一个 grou.p 能做read            杀毒



/etc/exp.orts 档的□例.


● syntax : directory. -option[,opti.on]    美容

(设定两个group能rw)
/usr -acce.ss=engineering:accounti.ng(广告)
/home .-access=engineeri.ng:accounting.
/var/spool/mail -acces.s=engineering:ac.counting--- 印刷
/export/exec/sun3. -acces.s=engineering:accounting(        游戏          )
/export/exec/sun3.sunos.4.1 -access=en.gin.eering:accounting外贸
/export/exec/kvm/sun3.sunos.4.1 -access=e.ngine.ering:accounting学习
/export/.root/birch -access.=birch,root=birch    健康
/expor.t/swap/birch -acce.ss=birch,root=birch    美容
/ex.port/root/oak .-access=oak,root=oak            杀毒
/export/swap/oak -access=oak,root=.o.ak投资
/exp.ort/root/willow -access=willow,roo.t=willow健康
/export/swap/wi.llow -access=willow,root=wil.low外贸
/export/roo.t/pine -accsee=pine,root=.pine外贸
/.export./swap/pine -accsee=pine,root=pine虚拟主机

(access=c.lient , root=hostname 如此只有这一台client的superuser有权力rw.)--- 印刷


□ Setting U.p a NFS Client             电子


1. 宣告机.器为没有磁碟机或没有资料的Client,在使用S.unInstall之前.

2.. 编辑好 /etc/fstab 这一个档,确定要moun.t的路径都在fstab中.

3. 依照fstab所设的内容,在.Cli.ent上设定好Mount points.
(mou.nt_points 就是.用mkdir 设exports所输出的路径)            杀毒

4. 确定我们所要moun.t的路径,都有出现在 /etc/exp.orts 中.

5.. 可以启动mount去连结server上的directories ( mount. -a ).



/etc/fstab 档的.□例             电子

● syntax filesy.stem directory type opt.ions freq pass    健康

oak:/e.xport/ro.ot/boomer / nfs rw 0 0.
^^^
因为档案在se.rver上,not on. client.
所以client的设定为0
oak:/export/exec/sun3 /usr. n.fs ro 0 0学习
oak:/e.xport/exec/kvm/.sun3 /usr/kvm nfs ro 0 0.
oak:/us.r/share ./usr/share nfs ro 0 0服务器
oak:./home/oak /home/oak nfs rw,.bg 0 0.




§ mount 的语法


● syntax : mount -t type [-rv.] -o [option] server:.pathname /mount_point健康

MOUNT :
moun.t -a 把/.etc/fstab 中所列的路径全部挂上.

mount. -o ro,soft,bg da.ncer:/usr/local /usr/local/dancer    外汇

把d.ancer server 的/usr/local mount 到. client的    美容
/usr/local/dancer 并且是re.ad .only.


-t type : 你所要mount的型别, .如 nfs .or 4.2.
-r : 所mount的路径定为.read only            杀毒
-v : mou.nt过程的每一个动作,都有messages 传回到萤幕.上投资
hard : 重复要求,直到server回应为止,但如.server一直不回.应<性病>
the serv.er may be down !--- 印刷
soft : 当client的请求得不到回应,retry one tim.e. 後 传回.
error message
bg : 当第一次请求不成功,第二.次的mo.unt将放到背景执行.
fg. : retries mount 都一直在.提示符号下进行学习
int.r : 当正在进行 NFS 请求时,.允许用键盘中断健康


mount 成功时的mes.sage.

NFS serv.er hostname ok虚拟主机

<har.d>; mount fail外贸

NFS server hostna.me not r.esponding, still trying(广告)

<soft>; . . .host.name se.rver not reponding: RPC: Timed out            杀毒



§ UNMOUNT :


umount mo.unt_point.

umount -a 卸下所有已经m.ount上的路径域名



==========================.=====.===========================================电影



◎ How NFS W.ork ?           建材


当.我们启动 NFS file server 时,/etc/rc.local 会自动启动e.xportfs这投资
一个程式,指定可以.export的档案或目录,而我们所能mount的也只能.是其所指定健康
的目录.



□ NFS 架设在 XDR/.RPC的协定之上[成人用品]


XDR : (eXternal Dat.a Representation). 外部资料表示法             汽车

XDR.(eXternal Data Represent.ation) 提供一种方法把资料从一种格式转换           鲜花
成另一种标准.资料格式表示法,确保在不同.的电脑,作业系统及电脑语言中,所           女人
有资料代表的意义都是相同的


RPC :. (Remote Procedure Calls.) 远端程序呼叫.

RPC(Remote Procedure Ca.lls) 远端程序呼叫, 请求远端电脑给予.服务. 委--- 印刷
托器(cl.ient)就会透过网路传送RPC到远端电脑.,请求服务.           女人

(一.般 local machine : client remote machine : se.rver )           建材




□. NFS 如何运用 RPC 传送资料             汽车



客户端process 主.服务端process             电子
┌————┐ ┌—————┐
│ 客户端 │ │ 主服务.站 │           鲜花
│ro.utines│ │ routines │.
└—┬——┘ └┬————┘
本地程序呼叫 │ 《 │ 《
(1)│ │(10)(6)│ │. (5)            杀毒
》 │ 》 │
┌———┴┐ ┌————┴┐
│ 客户端. │ │ 主服务端 │.
│ stub │ │ stu.b │             汽车
└—┬——┘ └┬————┘
系统呼叫 │《 │ 《
(2)│ │(9) (7)│ │ (4).教育
》│ 》 │
┌———┴┐ ( ┌————┴┐http://upload.bbs.csuboy.com/Mon_1004/126_7015_31ffde71d54d97a.gif[/img]             汽车
│network │<.——┤ network │.
│.routines├——>;│ routi.nes │.
└—.———┘ (3) └—————┘.
本地系统核心 网路通讯 .远端系统核心             汽车


(1) client. 送出讯息,请求服务教育

(2) client stub (客户株) 把c.lient 送出的参数转换成XDR---标准资.料电脑
格式并用系统呼叫(sy.st.em call) 把讯息送到网路上           建材

(3) 讯息经过网路送.达远端主机系统健康

(4) 远端主机将接受到的.讯.息传给server stub (服务站株)虚拟主机

(5) 把XD.R形式的资料,转换成符合主机端.的格式,取出client发出的服务.
请求参数,送给server

(6) -- (1.0) 则是逆向而行 , server 送出服务给 c.lient--- 印刷




□ rc.local 启动守.护程式.


一个NFS server. 要 inet , portmap , nfs , m.ount 此四个守护程式,保.
持在背景执行的状态下才能运作. (if running NIS .must add. ypbind daemon)--------------彩票


◆ 当启动 NFS file server .时,(        游戏          )


the /etc/rc..local sc.ript 会做如下的动作健康

1. 执行exportfs. , 读取server's /etc./exports 告诉kernel[成人用品]
所要输出的file h.ierarch.ies 和 存取的权限健康
( export.fs -a )学习

2. 启动 .rpc.mountd daemon 和 nfsd daemon. (通常是 8 个).
( rpc.mountd -n.. nfsd 8 & echo -n 'nfsd' ).



◆ 当启动 NFS client 时.--- 印刷


rc.l.ocal 会做如下的动作.

1. 启动 boid da.emons 处理读写.的程序
(biod 8 echo. -n ' biod' ).

2. 执行 mount -.vat nfs .读取client's /etc/fstab 并且 mount 所.
有属於 NFS-type 的fi.les.



□ NFS daemons (守护程.式) 的功用(广告)


nfsd, biod, rpc.mount.d, inetd, portmap 都可在/usr/etc .下找到           女人


nfsd : .依.client 对档案系统的需求情况, 而启动.
" file system request. da.emon "[成人用品]
应付.client 的需求,而一般file s.ystem request daemon 的数目           鲜花
是 " 8 ", 这也就是我们在rc.loca.l 中写 " nfsd 8. & "的原因了          婚庆


biod : 此指令是在NFS client上用的 , 用来启..动域名
" asynchr.on.ous block I/O daemon"    美容
用来建立buf.fer cache , 处理.在client上的读写             汽车


mountd : mountd 是一.台 RPC server ,.启动rpc.mountd daemon後 它会读取投资
/etc/xtab 查看哪一台client正在.mount 哪一个fi.le system,并回.
应.client 所要mount 的路径.
(mo.untd处理的过.程可用 showmount 来看)域名


inetd : inetd (Internet .servic.es daemon) , 当系统启动时rc.local    美容
会启动inetd 读.取 inetd.conf 这一个. configuration-file ,外贸
读取网路上所有 se.rver's address , 连结启动in.etd.conf中所.
有的server , .当client 请求服务时, in.etd 就会为clinet 启动投资
相关的serve.r daemon 负责任务, 如user 用 telnet. 时 , 则.
inetd 启.动telnetd 迎合us.er telnet 的需求, 其馀像 ftp ,虚拟主机
fing.er , rlogin 之类的应用程式 , i.netd 也都会启动相对应的             汽车
da.emons, ftpd,. fingerd, rloingd    美容

po.rtmap : portmap 是一台server , 主要功能 转换 TCP/IP. 通讯协定的.
port number 变成 RPC program numbe.r , 因为这样cl.inet才能.
做RPC calls


一般 RPC server. 是被inetd 所启动的, 所以p.ortmap 必须            杀毒
在inetd之前启动, 否.则无法.做 RPC call    美容




□ NFS 的网路安全的


NFS 使server上的档案能被client所取用, 乍看之下好像.server 上.           女人
的档案任何人都可取用没什麽保护性, 其实不是如此的. 一.开始serv.er              乙肝
要 exportfs 之前在 /etc/exporrc .中就已经设定了档案的使用权限,. 像          婚庆

/usr/src -.access=engine.ering:accounting域名

就是限定只有 rcgineering 和 .accounting 这两台 client. 才能 mount--------------彩票
/usr/src

/usr/src .-access=oa.k,root=oak(        游戏          )

这是说只有 oak 这.台 .cilent 能 mount这一个路径 且只有 oak client's.
sup.eruser 才能行使 read & write. 的权力--------------彩票


另外管.理者为了维护 expo.rted 和 mounted 的安全, 一定要建[成人用品]
立公共(public)和私人(secret).的 key(.password), 然而这些安全性投资
问.题是要建立在 N.IS (network infomation system) 上的, 有一个.
/etc/publickey档 ,里面记录了public. and secre.t keys , 而这些key电影
是.依照 machine_name 和 user_name ,以16 进位码.表示出来的, 管理<性病>
者可在有NIS的机器上用

newkey -u. username 给.予user login 权力学习

newkey -h ho.stname 造出login 此机器时所需.的password             电子


在NFS刚安装时 u.ser 是. "nobody" 任何人都可以进入, 所以管理者域名
一定要.做修改, 以保护资料的安全.虚拟主机


当使用者为 .nobody 时 p.ublickey 的内容--- 印刷

netname use.r's public key .: user's secret key--------------彩票

nobody 3d91f44568fbbefada5a7:7675c.d9b8753b5db.09dabf12电影


在管理者给予user权力之後, user 就可.使用 chkey 修.改自己的.
secret. key 创造自己的帐号路口,教育


willow% chkey
Gen.erating new key for us.ername虚拟主机
password : <enter p.as.sword>;教育
S.ending ke.y change request to server ...    美容
Done.
willow%


所设定的password. 是使用者位於 NIS 中的加密键 , 当我们lo.gin 时             汽车
NIS 就会将此密码解开,(因为publickey.中是以16.进位码记录) , 存放到--- 印刷
keyserv 里加以保管, 再将加密键传给client , 当client .发出请求时 .,--------------彩票
此键会附在每个NFS 请求上一起送到 NFS server 上, 当加密.键和serve.r上.
所保存的keyserv核对无错後, 请求就会被接受.学习






□ When fail .to mo.unt server教育


1. 用 rpcinfo -p se.rver_name 去.查看此server是否存在.

2. 用 rpcinfo -u server_.name mount 查看mou.ntd daemon 是否有服务器
在server上执行

3. 假如server 都没问题,检查 server 和 clien..t 之间的    健康
Ethernet con.netions.

4. 在client. 上 用 ps ax 看portmap and several biod. daemons--- 印刷
run.ning or not !    健康

(rpcinfo : 用来对 .RPC server 做 RPC 呼叫,回传远端程序.呼叫.

过程中的讯息)


一些m.ount 失败的错误讯息--- 印刷


1. ./etc/mtab : No such file or d.irectory教育

mtab 这一个路径或是档案..必须存在,在mount之前投资

2. mount : ... .Block dev.ice required电脑

远端的机器名称可能打错了

3. m.ount:. ... not found in /etc/fstab.

fstab 一定要存在,.cl.ient 上 /etc下(广告)

4. ... .not in hos.ts database<性病>

/etc/hosts .没有这一个 hosts data.base , 或是健康
NIS 的daemon, ypbind .没有在执行.

5. Mus.t be root to use m.ount             电子

一般都只有. root 才能mount ,所以mount之前.先成.
为superuser

6. Stale .NFS file handle(        游戏          )

当我们已经mount 上的file or direct.ory ,在server..
上突然被remove or unexpor.t ,就会.出现此讯息域名
评价一下你浏览此帖子的感受

精彩

感动

搞笑

开心

愤怒

无聊

灌水
快速回复
限100 字节
批量上传需要先选择文件,再选择上传
 
上一个 下一个