我下载的NSF13安装没有选择路径但是打印机每次重启都脱机电脑之…

??眔耕ㄎ聅凝挡狦?叫稲ノ
聅凝セ呼?
程??穝ら戳?
??13.1.1
??13.1.2
??13.1.3
??13.1.4
??13.2.1
??13.2.2
??13.2.3
??13.2.4 ?
??13.2.5 ? ,
??13.2.6 ? ,
??13.3.1
??13.3.2 ?
??13.3.3
??13.3.4
13.1 NFS ?パㄓ籔ㄤ??
NFS 硂?虑パ呼隔だㄉ郎?╰参?狝叭?琜砞???琌?虏虫??ぃ筁?ウ程??拜肈???舦??よ??阀├?
???ノめ狠籔?狝竟狠??ゲ斗璶ㄣ称???眀腹??镑??琘ㄇヘ魁┪郎??
???NFS ?币笆惠璶硓筁┮孔?环狠祘?㊣? (RPC)??碞琌弧?и??ぃ琌?璶币笆 NFS 碞???
临惠璶币笆 RPC 硂?狝叭?︽摆?
????秨﹍秈︽ NFS ?砞﹚ぇ玡?и?眔?ㄓ罙秆???ぐ或琌 NFS ㎡?ぃ礛量??帮?⊿Τノ?癸?? ^_^?
┏?碞ㄓ酵?酵ぐ或琌 NFS ?? NFS ?币笆临惠璶ぐ或妓??﹚摆?
13.1.1 ぐ或琌
NFS (Network FileSystem)
NFS 碞琌 Network FileSystem ?罽糶?程Νぇ玡琌パ
硂產そ?┮祇甶?ㄓ? ()?
ウ程????碞琌??硓筁呼隔?琵ぃ??诀竟?ぃ???穨╰参???┘?だㄉ???郎?
(share files)?┮??????虏虫?盢??暗琌??郎??狝竟 (file server) ㎡?硂? NFS
?狝竟??琵?? PC ㄓ盢呼隔环狠? NFS ?狝竟だㄉ?ヘ魁?本更?セ?狠?诀竟讽い?
?セ?狠?诀竟?癬ㄓ?ê?环狠?诀?ヘ魁碞?钩琌?????合盒だ澄佳?妓
(partition)?ㄏノ???讽?獽??
瓜 13.1-1?NFS ?狝竟だㄉヘ魁籔 Client 本更ボ種瓜
碞?????瓜ボ???讽и?? NFS ?狝竟砞﹚??だㄉ?ㄓ? /home/sharefile 硂?ヘ魁??ㄤ??
NFS ノめ狠碞??盢硂?ヘ魁本更???╰参???琘?本更翴 (本更翴???璹)?ㄒ?玡?瓜ボい?
NFS client 1 籔 NFS client 2 本更?ヘ魁碞ぃ???и?璶? NFS client 1 ╰参い秈?
/home/data/sharefile ず?碞???? NFS ?狝竟╰参ず? /home/sharefile ヘ魁??┮Τ戈??
(讽礛?舦?璶ì镑摆?^_^)?硂? /home/data/sharefile 碞?钩 NFS client 1 ??诀竟柑????
partition 翅??璶舦?癸??ê或???ㄏノ cp, cd, mv, rm...
单单合盒┪郎??闽????痷琌? X ?よ獽??
???琂礛 NFS 琌硓筁呼隔ㄓ秈︽戈??肚块?ê或竒パ ?阀├?穦?笵
NFS 莱赣穦ㄏノ?ㄇ梆???ê或 NFS ㄏノ??梆?ㄓ秈︽肚块㎡?膀セ? NFS 硂?狝叭?梆?秨?
2049 ??琌パ?郎?╰参獶盽狡馒??? NFS 临Τㄤ??祘??币笆肂??梆???硂ㄇ肂??梆?币笆?腹絏琌?
氮?琌....ぃ?笵? @_@ ???箇砞 NFS ノㄓ肚块?梆?琌繦诀匡拒?? 1024
???梆?ㄓㄏノ??玿?êノめ狠?或?笵??狝竟狠ㄏノê?梆?摆???碞眔璶
环狠祘?㊣?
(Remote Procedure Call, RPC) ??﹚ㄓ徊?罢?┏?и?碞ㄓ酵酵ぐ或琌 RPC?
13.1.2 ぐ或琌
RPC (Remote Procedure Call)
?? NFS や穿????讽???τぃ????常穦ㄏノぃ??祘Αㄓ币笆?
–币笆????碞穦币ノ?ㄇ梆?ㄓ肚块戈????? NFS ???┮癸莱?梆??⊿Τ㏕﹚??
τ琌繦诀?ノ?ㄇゼ砆ㄏノ??? 1024 ?梆?ㄓ??肚块ぇノ?????ㄓ?硑Θノめ狠稱璶硈??狝竟???耑?
??ノめ狠眔璶?笵?狝竟狠??闽梆???镑硈絬??
??и?碞眔惠璶环狠祘?㊣? (RPC) ?狝叭罢?RPC 程?璶???碞琌??﹚–?
NFS ??┮癸莱? port number ????厨倒ノめ狠?琵ノめ狠??硈挡?タ絋?梆????
ê RPC ?琌???笵–? NFS ?梆?㎡?硂琌??讽?狝竟?币笆
NFS ?穦繦诀?ノ计?梆????笆?? RPC 爹???? RPC ???笵–?梆?癸莱? NFS
???礛? RPC ?琌㏕﹚ㄏノ port 111 ㄓ菏钮ノめ狠?惠―??厨ノめ狠タ絋?梆??
┮?讽礛??琵 NFS ?币笆??淮肞磖е??
┮??璶猔種?璶币笆 NFS ぇ玡?RPC 碞璶?币笆???玥 NFS 穦礚猭? RPC 爹??
???RPC 璝?穝币笆???セ爹??戈?穦ぃǎ??? RPC
?穝币笆??ウ恨瞶?┮Τ狝叭常惠璶?穝币笆ㄓ?穝? RPC 爹??
瓜 13.1-2?NFS 籔 RPC 狝叭の郎?╰参巨???闽┦
??瓜┮ボ?讽ノめ狠Τ NFS 郎???惠―???穦????狝竟狠璶―戈?㎡?
ノめ狠穦??狝竟狠? RPC (port 111) 祇? NFS 郎??????高拜璶―?
?狝竟狠т?癸莱??爹?? NFS daemon 梆???穦?厨倒ノめ狠?
ノめ狠罙秆タ絋?梆???碞???钡籔 NFS daemon ㄓ硈絬?
パ? NFS ??兜??常ゲ斗璶? RPC ㄓ爹?????ㄓ RPC ??罙秆 NFS 硂?狝叭??兜??ぇ
port number, PID, NFS ??狝竟┮菏钮? IP 单单?τノめ狠??镑硓筁 RPC ?高拜т?タ絋癸莱?梆??
?碞琌弧?NFS ゲ斗璶Τ RPC ?????Θ??矗ㄑ狝叭???и?嘿 NFS ? RPC server
??贺?ㄆ龟??Τ??硂妓??狝竟常琌? RPC 爹???羭ㄒㄓ弧?NIS (Network Information Service) ?琌
RPC server ??贺㎡????パ瓜 13.1-2 ??穦?笵?ぃ阶琌ノめ狠临琌?狝竟狠?璶ㄏノ NFS
??ㄢ?常惠璶币笆 RPC ?︽翅?
??? NFS ?闽?﹚戈癟???把σ┏?呼??
RFC 1094, NFS ?﹚秆睦
Linux NFS-HOWTO?
13.1.3 NFS
币笆? RPC daemons
и?瞷??笵 NFS ?狝竟?币笆???碞眔璶? RPC 爹??┮? NFS ?狝竟?砆嘿? RPC server ぇ??
ê或 NFS ?狝竟?璶?ヴ叭琌秈︽郎?╰参?だㄉ?郎?╰参?だㄉ玥籔舦?Τ闽?
┮? NFS ?狝竟币笆??ぶ惠璶ㄢ? daemons ???恨瞶ノめ狠琌??镑祅??拜肈?
??恨瞶ノめ狠?镑?眔?舦???狦?临稱璶恨瞶 quota ?杠?ê或 NFS
临眔璶?更?ㄤ?? RPC 祘Α碞琌??и??耕虫?? NFS ?狝竟ㄓ弧?
rpc.nfsd?
程?璶? NFS ?狝竟狝叭矗ㄑ??硂? daemon ?璶???碞琌?恨瞶ノめ狠琌??镑ㄏノ?狝竟郎?╰参本更戈癟单?
ㄤい临??硂?祅??? ID ???翅?
rpc.mountd
硂? daemon ?璶????玥琌?恨瞶 NFS ?郎?╰参??讽ノめ狠抖??硄筁 rpc.nfsd
τ祅??狝竟ぇ??????ㄏノ NFS ?狝竟矗ㄑ?郎?ぇ玡?临穦竒筁郎?ㄏノ舦?
(碞琌ê? -rwxrwxrwx 籔 owner, group ê碭?舦?罢) ?粄靡祘???穦?弄 NFS ?砞﹚郎
/etc/exports ㄓゑ癸ノめ狠?舦??讽硄筁硂?闽ぇ?ノめ狠碞???眔ㄏノ NFS
郎??舦?罢?(爹?硂??琌и?ノㄓ恨瞶 NFS だㄉぇヘ魁?ㄏノ舦?籔??砞﹚??よ??)
rpc.lockd (獶ゲ璶)
硂??種ㄠ??ノ?恨瞶郎??玛﹚ (lock) ノ硚???郎?惠璶?玛﹚?㎡?
??琂礛だㄉ? NFS 郎???琵ノめ狠ㄏノ?ê或讽??ノめ狠??沽刚糶?琘?郎???
碞??癸?赣郎?硑Θ?ㄇ拜肈罢?硂? rpc.lockd 玥??ノㄓ?狝硂?拜肈?
? rpc.lockd ゲ斗璶???ノめ狠籔?狝竟狠常秨币?︽翅???? rpc.lockd ?盽籔 rpc.statd ??币ノ?
rpc.statd (獶ゲ璶)
??ノㄓ浪琩郎???璓┦?籔 rpc.lockd Τ闽?璝祇ネ??ノめ狠??ㄏノ??郎?硑Θ郎???Τ┮穕反??
rpc.statd ??ノㄓ浪代?沽刚?確赣郎??籔 rpc.lockd
?妓??硂???ゲ斗璶??狝竟狠籔ノめ狠常币笆?穦ネ??
?瓃硂碭? RPC ┮惠璶?祘??ㄤ龟常?竒糶??ㄢ?膀セ?狝叭币笆竲セい??ê碞琌 nfs ?の nfslock 舘?
ョ?琌? /etc/init.d/nfs, /etc/init.d/nfslock?籔?狝竟耕Τ闽?糶?? nfs 狝叭い?τ籔ノめ狠? rpc.lockd
ぇ摸??碞砞﹚? nfslock 狝叭い?
13.1.4 NFS ?郎???舦?
ぃ?笵?Τ⊿Τ稱筁硂?拜肈?? ?吏挂??安?и? NFS client 1 ???
dmtsai 硂?ㄏノ?ō?稱璶??? /home/data/sharefile/ 硂?ㄓ? NFS server ┮矗ㄑ?郎?╰参??
叫拜 NFS server ┮矗ㄑ?郎?╰参穦琵и?ぐ或ō?????琌 dmtsai 临琌?
?ぐ或穦硂或拜㎡?硂琌?? NFS セō?狝叭?⊿Τ秈︽ō?祅??醚??
┮?弧?讽??ノめ狠? dmtsai ?ō?稱璶???狝竟狠?郎?╰参??
?狝竟狠穦?ノめ狠?ㄏノ?
UID 籔 GID 单ō?ㄓ沽刚弄??狝竟狠?郎?╰参?硂?Τ?Τ届?拜肈碞玻ネ罢?
ê碞琌?狦ノめ狠籔?狝竟狠?ㄏノ?ō??ぃ?璓?或快?
и??┏?硂?瓜ボㄓ弧??????
瓜 13.1-3?NFS ??狝竟狠籔ノめ狠?ㄏノ?ō?絋粄诀?
讽и? dmtsai 硂???ō?ㄏノ?璶???ㄓ??狝竟狠?郎????璶?猔種??琌?
郎?╰参? inode ┮癘魁?妮┦? UID, GID τ獶眀腹籔竤舱??
ê?? Linux ?诀穦?笆????? /etc/passwd, /etc/group ㄓ琩高癸莱?ㄏノ??竤舱?嘿?
┮?讽 dmtsai 秈??赣ヘ魁??穦把酚 NFS client 1 ?ㄏノ?籔竤舱?嘿?
?琌パ?赣ヘ魁?郎??璶ㄓ? NFS server ?┮???碞穦祇瞷碭?薄猵?
NFS server/NFS client ??Τ???眀腹籔竤舱
玥??ㄏノ????钡? dmtsai ?ō?秈︽?狝竟┮矗ㄑ?郎?╰参ぇ???
NFS server ? 501 硂? UID 眀腹癸莱? vbird
璝 NFS ?狝竟?? /etc/passwd 柑? UID 501 ?ㄏノ??嘿? vbird ??
玥ノめ狠? dmtsai ?????狝竟狠? vbird 硂?ㄏノ??郎?翅????ㄢ?ㄣΤ???
UID τ??硂碞硑Θ???拜肈????⊿Τ???玂靡ノめ狠? UID ┮癸莱?眀腹穦籔?狝竟狠???
ê?狝竟┮矗ㄑ?戈?ぃ碞??穦砆岿粇?ㄏノ?睹э?
NFS server ?⊿Τ 501 硂? UID
???伐狠?薄猵琌???狝竟狠?⊿Τ 501 硂? UID ????玥?? dmtsai ?ō??赣ヘ魁?穦砆溃罽Θ拔???
?? NFS ?拔??穦? UID ? 65534 ?ㄤㄏノ??Ν戳? Linux distributions 硂? 65534 ?眀腹?嘿硄盽琌
nobody ?и?? CentOS 玥??? nfsnobody ??Τ??穦Τ疭??薄猵?ㄒ???狝竟狠だㄉ /tmp ?薄猵?? dmtsain
?ō?临琌穦玂? 501 ??ミ??兜戈???狝竟狠ㄓ??碞穦妮?礚局Τ??戈??
?狦ㄏノ?ō?琌 root ?
Τ?ゑ耕疭??ㄏノ??ê碞琌–? Linux ?诀常Τ? UID ? 0 ? root ?
稱?稱??狦ノめ狠??ノ root ?ō?????狝竟狠?郎?╰参??ê?狝竟狠?戈??Τぐ或玂臔┦?
┮??箇砞?薄猵?? root ?ō?穦砆?笆?溃罽Θ?拔???
羆ぇ?ノめ狠ㄏノ??暗?ㄆ薄琌籔 UID のㄤ GID Τ闽??ê讽ノめ狠籔?狝竟狠? UID の眀腹?癸莱ぃ?璓??
??碞穦硑Θ郎?╰参ㄏノ???耑?硂?碞琌 NFS 郎?╰参?ㄏノ???????璶??よ?
τ?罙秆ㄏノ?眀腹籔 UID の郎?╰参?闽玒ぇ??璶龟悔?ノめ狠? NFS ?ノ?狝竟狠?郎?╰参??
?临眔惠璶ㄣΤ?
NFS ?狝竟Τ秨??糶??舦? (籔 /etc/exports 砞﹚Τ闽)?
龟悔?郎?舦?ㄣΤ?糶? (w) ?舦??
讽?骸ì? (1)ㄏノ?眀腹?ョ? UID ??闽ō?? (2)NFS ?狝竟す砛Τ糶??舦??
(3)郎?╰参絋龟ㄣΤ w ?舦?????ㄣΤ赣郎???糶?舦?翅?
ぷㄤ琌ō? (UID) 絋粄?吏竊场だ?程甧?穌岿罢???????
┮? NFS 硄盽惠璶籔
硂????絋粄ノめ狠籔?狝竟狠ō??璓?狝叭穎皌ㄏノ??磷?ō??岿睹摆? ^_^
ρ龟弧?硂??竊?戈?ゑ耕螟来°ぷㄤ琌??钡牟? NFS server ?狟ね????????菠筁 13.1.4 硂??竊?
?琌???弄Ч籔暗Чセ彻?尿┮Τ?龟?ぇ??癘眔??硂??竊ㄓ?琩綷?Ωゅ彻ず甧??獺穦Τ秈?˙?粄醚??
13.2 NFS Server 狠?砞﹚
琂礛璶ㄏノ NFS ?杠?碞眔璶?杆 NFS ┮惠璶?硁砰??┏?琵и?琩高??╰参Τ礚?杆┮惠璶?硁砰?
NFS 硁砰?琜篶?の??砞﹚ NFS ?狝竟?? ^_^
13.2.1 ┮惠璶?硁砰
? CentOS 6.x ?ㄒ?杠?璶砞﹚? NFS ?狝竟и?ゲ斗璶Τㄢ?硁砰?︽?だ?琌?
RPC ?祘Α?rpcbind
碞????矗???и?? NFS ㄤ龟??砆跌??? RPC 狝叭?τ璶币笆ヴ??? RPC 狝叭ぇ玡?и?常惠璶暗?
port ?癸莱 (mapping) ????︽?硂???ㄤ龟碞琌? rpcbind ?硂?狝叭┮璽砫???碞琌弧?
?币笆ヴ??? RPC 狝叭ぇ玡?и?常惠璶币笆 rpcbind ?︽?
(? CentOS 5.x ?玡硂?硁砰嘿? portmap?? CentOS 6.x ぇ??嘿? rpcbind ??)
NFS ?祘Α?nfs-utils
碞琌矗ㄑ rpc.nfsd の rpc.mountd 硂ㄢ? NFS daemons 籔ㄤ??闽 documents 籔弧?ゅン?磅︽郎单?硁砰?硂?碞琌
NFS 狝叭┮惠璶??璶硁砰罢??﹚璶Τ翅?
????笵и?惠璶硂ㄢ?硁砰ぇ??瞷?稦估?话е???╰参?ノ RPM ???Τ⊿Τ硂ㄢ?硁砰罢?
⊿Τ?杠话еノ RPM ┪ yum ??杆翅?ぃ礛碞?ぃ????
叫拜и??诀琌? RPM ?甅ン恨瞶? Linux distribution ?ㄒ? Red Hat, CentOS 籔
SuSE 单?セ?ê或и璶???笵и??诀柑?琌??竒?杆? rpcbind 籔 nfs ?闽?硁砰㎡?
虏虫?ㄏノ? rpm -qa | grep nfs ?籔? rpm -qa | grep rpcbind ????笵罢??狦⊿Τ?杆?杠?
? CentOS ず??ㄏノ?
install nfs-utils ?ㄓ?杆?
13.2.2 NFS ?硁砰挡篶
NFS 硂?㎞㎞痷?琌?虏虫???и?矗?? NFS 硁砰い?砞﹚郎?Τ???磅︽郎?ぃ??
癘魁郎???ㄢㄢτ???话候?ㄓ????? ^_^
?璶砞﹚郎?/etc/exports
硂?郎?碞琌 NFS ??璶砞﹚郎??ぃ筁?╰参?⊿Τ箇砞??┮?硂?郎??
ぃ?﹚穦???????ゲ斗璶ㄏノ vim
?笆??ミ癬硂?郎?翅?и?单??璶酵?砞﹚?度?琌硂?郎?τ???
NFS 郎?╰参蝴臔???/usr/sbin/exportfs
硂?琌蝴臔 NFS だㄉ戈方????и????ノ硂????穝だㄉ /etc/exports
跑??ヘ魁戈方?盢 NFS Server だㄉ?ヘ魁?更┪?穝だㄉ单单?硂???琌 NFS
╰参柑??讽?璶???翅??????ノ猭и??┏?穦ざ残?
だㄉ戈方?祅魁郎?/var/lib/nfs/*tab
? NFS ?狝竟?祅魁郎常?竚? /var/lib/nfs/ ヘ魁柑???赣ヘ魁?Τㄢ?ゑ耕?璶?祅魁郎?
??琌 etab ??璶癘魁? NFS ┮だㄉ?ㄓ?ヘ魁?Ч俱舦?砞﹚????? xtab
玥癘魁纯竒硈挡?? NFS ?狝竟??闽ノめ狠戈??
ノめ狠琩高?狝竟だㄉ戈方????/usr/sbin/showmount
硂琌????璶? NFS ???exportfs 琌ノ? NFS Server 狠?τ showmount
玥?璶ノ? Client 狠?硂? showmount ??ノㄓ诡? NFS だㄉ?ㄓ?ヘ魁戈方翅?
碞弧ぃ螟???璶碞琌硂碭?舘?
13.2.3 /etc/exports
砞﹚郎?粂猭籔把计
?秨﹍ NFS ?狝竟?砞﹚ぇ玡??ゲ斗璶罙秆?琌?NFS
穦?钡ㄏノ??み???┮????みゲ斗璶Τや穿 NFS ?︽?窾??狦???み?セ?? 2.2
??┪??穝?︽絪亩筁?み?杠?ê或碞眔璶?猔種罢??????穦а癘匡拒 NFS ??みや穿摆?
临??и? CentOS ┪?琌ㄤ??セ? Linux ?箇砞?み硄盽琌や穿 NFS ????┮???璶絋粄???み?セ琌ヘ玡穝?
2.6.x ????ㄏノ?? distribution ┮矗ㄑ??み?ê莱赣碞ぃ穦Τ拜肈罢?
??穦矗眶眤硂?拜肈???琌??玡尘?常?尺舧?︽絪亩??疭???み??琌琘Ω絪亩?み??玱а癘??? NFS
??み???挡狦 NFS server 礚阶???穌ぃ癬ㄓ°程??稱??ㄓ???み琌獶タ砏?...
?? NFS ?狝竟?琜砞龟??虏虫???璶絪胯??璶砞﹚郎 /etc/exports
ぇ???币笆 rpcbind (璝?竒币笆??碞ぃ璶?穝币笆)?礛??币笆 nfs ??? NFS 碞Θ???
ぃ筁硂妓?砞﹚??癸ノめ狠ネ??ê碞眔璶σ納?舦?よ??砞﹚????紀杠ぶ弧?и?碞?钡ㄓ??ê? /etc/exports
莱赣??砞﹚??琘ㄇ distributions ?ぃ穦?笆矗ㄑ /etc/exports 郎??┮?叫??︽も笆?ミウ??
[root@www ~]# vim /etc/exports
192.168.100.0/24(ro)
localhost(rw)
*.ev.ncku.edu.tw(ro,sync)
[だㄉヘ魁]
[材?场?诀(舦?)]
[?ノ?诀?]
[?ノ窾ノ?じ]
????硂?砞﹚郎Τ镑虏虫??–?︽程玡?琌璶だㄉ?ㄓ?ヘ魁?猔種翅?琌?ヘ魁?虫?摆?
礛?硂?ヘ魁??ㄌ酚ぃ??舦?だㄉ倒ぃ???诀?钩尘????ㄒ?弧?琌?
璶盢 /tmp だ?だㄉ倒??ぃ???诀┪呼办?種??癘眔?诀????珹腹 () 砞璸舦?把计?
璝舦?把计ぃゎ????玥?硆腹 (,) だ秨???诀?籔?珹腹琌硈??癬?翅??硂?郎?ず????ノ # ㄓ爹秆㎡?
???诀?嘿?砞﹚?璶Τ碭?よΑ?
??ㄏノЧ俱? IP ┪?琌呼办?ㄒ? 192.168.100.10 ┪ 192.168.100.0/24 ?┪
192.168.100.0/255.255.255.0 常??钡??
???ㄏノ?诀?嘿??硂??诀?嘿ゲ斗璶? /etc/hosts ず?┪?ㄏノ DNS т?赣?嘿?︽摆?はタ?翴琌?т? IP
碞琌???狦琌?诀?嘿?杠?ê或???や穿窾ノ?じ?ㄒ? * ┪ ? А?钡??
??舦?よ? (碞琌?珹腹ず?把计) 盽ǎ?把计玥Τ?
把计?ず甧弧?
rwro赣ヘ魁だㄉ?舦?琌?弄糶 (read-write) ┪斑弄 (read-only)??程沧?ぃ?弄糶?临琌籔郎?╰参? rwx
のō?Τ闽?
syncasyncsync ??戈?穦?˙糶??癘拘砰籔祑盒い?async
玥??戈?穦?既??癘拘砰讽い?τ獶?钡糶?祑盒?
no_root_squashroot_squashノめ狠ㄏノ NFS 郎?╰参?眀腹璝?
root ??╰参赣???耞硂?眀腹?ō??箇砞?薄猵??ノめ狠 root ?ō?穦パ root_squash ?砞﹚溃罽Θ nfsnobody?
??癸?狝竟?╰参穦耕Τ玂毁???狦?稱璶秨?ノめ狠ㄏノ root ō?ㄓ巨??狝竟?郎?╰参?ê或硂柑碞眔璶秨
no_root_squash ?︽?
all_squashぃ阶祅? NFS ?ㄏノ?ō???? ??ō?常穦砆溃罽Θ?拔?ㄏノ??硄盽?碞琌
nobody(nfsnobody) 罢?
anonuidanongidanon 種? anonymous (拔??) 玡?闽? *_squash 矗??拔?ㄏノ?? UID
砞﹚??硄盽? nobody(nfsnobody)??琌????︽砞﹚硂? UID ???讽礛?硂? UID ゲ惠璶????? /etc/passwd 讽い?
anonuid ??琌 UID τ anongid 玥琌竤舱? GID 舘?
硂琌碭?ゑ耕盽ǎ?舦?把计??狦?Τ砍届?ㄤ??把计??叫?︽ man exports ??祇瞷??Τ届?戈??
钡?ㄓи??ノ?瓃?碭?把计ㄓ龟悔?σ??碭?Τ届??策肈?
ㄒ肈??琵 root 玂Τ root ?舦?
и稱盢 /tmp だㄉ??倒?產ㄏノ?パ?硂?ヘ魁セㄓ碞琌?產常??弄糶????稱琵┮Τ??常????????и璶琵 root
糶??郎?临琌ㄣΤ root ?舦??ê??砞璸砞﹚郎?
[root@www ~]# vim /etc/exports
# ヴ??常??ノи? /tmp ?ノ窾ノ?じㄓ矪瞶?诀?嘿??翴? no_root_squash
*(rw,no_root_squash)
?诀?嘿??ㄏノ窾ノ?じ??繷?ボ礚阶ㄓ??柑常??ㄏノи? /tmp 硂?ヘ魁?
?Ω矗眶?? *(rw,no_root_squash) ?硂?﹃砞﹚?い丁琌⊿Τ?フ?じ?翅?τ
/tmp 籔 *(rw,no_root_squash) 玥琌Τ?フ?じㄓ筳秨??疭?猔種?ê?
no_root_squash ?????硂?ㄒ?い??狦?琌ノめ狠?τ??琌? root ?ō?祅??? Linux
?诀?ê或讽? mount ?и硂场?诀? /tmp ぇ????赣 mount ?ヘ魁讽い?盢ㄣΤ?root ?舦???
ㄒ肈????ヘ魁皐癸ぃ?絛瞅秨?ぃ?舦?
и璶盢??そ??ヘ魁 /home/public そ秨????琌?Τ?﹚и?跋办呼隔 192.168.100.0/24 硂?呼办???
vbirdgroup (材?彻?ㄒ肈?ミ?竤舱) ?ノめ??镑弄糶?ㄤ?ㄓ方玥??弄??
[root@www ~]# mkdir /home/public
[root@www ~]# setfacl -m g:vbirdgroup:rwx /home/public
[root@www ~]# vim /etc/exports
*(rw,no_root_squash)
/home/public
192.168.100.0/24(rw)
# 膥尿仓?????猔種?иΤ盢?诀籔呼办だ?ㄢ琿 (ノ?フ筳秨) 翅?
???ㄒ?弧?琌?讽и? IP 琌? 192.168.100.0/24 硂?呼琿????ê或讽и? Client 狠本更?
Server 狠? /home/public ??皐癸硂?砆и本更?ヘ魁и碞ㄣΤ??弄糶?舦?°
???狦иぃ琌?硂?呼琿ぇず?ê或硂?ヘ魁?戈?и碞度?弄?τ??ョ??斑弄?妮┦罢?
惠璶猔種?琌?窾ノ?じ度?ノ??诀?嘿?だ侩???IP ┪呼琿碞??ノ 192.168.100.0/24 ??猵?
ぃ??ㄏノ 192.168.100.* 翅?
ㄒ肈??度倒琘?虫??诀ㄏノ?ヘ魁砞﹚
и璶盢??╬??ヘ魁 /home/test 秨?倒 192.168.100.10 硂? Client 狠?诀竟ㄓㄏノ??赣??砞﹚?
安砞ㄏノ??ō?琌 dmtsai ?ㄣΤЧ俱?舦???
[root@www ~]# mkdir /home/test
[root@www ~]# setfacl -m u:dmtsai:rwx /home/test
[root@www ~]# vim /etc/exports
*(rw,no_root_squash)
/home/public
192.168.100.0/24(rw)
/home/test
192.168.100.10(rw)
# ?璶砞﹚ IP タ絋???
硂妓碞砞﹚ЧΘ??τ???Τ 192.168.100.10 硂场诀竟??癸 /home/test 硂?ヘ魁秈︽??翅?
ㄒ肈??秨?拔?祅??薄猵
и璶琵 *.centos.vbird 呼办??诀?祅?и? NFS ?诀?????? /home/linux ??琌???戈?????и?辨???
UID 籔 GID 常跑Θ 45 硂?ō??ㄏノ??安砞и NFS ?狝竟?? UID 45 籔 GID 45 ?ノめ/竤舱?嘿? nfsanon?
[root@www ~]# groupadd -g 45 nfsanon
[root@www ~]# useradd -u 45 -g nfsanon nfsanon
[root@www ~]# mkdir /home/linux
[root@www ~]# setfacl -m u:nfsanon:rwx /home/linux
[root@www ~]# vim /etc/exports
*(rw,no_root_squash)
/home/public
192.168.100.0/24(rw)
/home/test
192.168.100.10(rw)
/home/linux
*.centos.vbird(rw,all_squash,anonuid=45,anongid=45)
# ?狦璶秨?拔??ê或?翴琌 all_squash???璶皌? anonuid 翅?
疭?猔種?ê? all_squash 籔 anonuid, anongid ???????ㄓ?讽 clientlinux.centos.vbird 祅?硂场 NFS ?诀???? /home/linux
糶?郎???赣郎??┮Τ?籔┮Τ竤舱?碞穦跑Θ /etc/passwd 柑?癸莱? UID ? 45 ?ê?ō??ㄏノ???
?????ㄒ?舦??狦ㄌ酚ㄓ?σ?杠?
ê或舦?穦琌ぐ或薄猵㎡?琵и?ㄓ浪琩???
ノめ狠籔?狝竟狠ㄣΤ??? UID 籔眀腹?
安砞и? 192.168.100.10 祅?硂场 NFS (IP 安砞? 192.168.100.254) ?狝竟???и?
192.168.100.10 ?眀腹? dmtsai 硂?ō??????硂场 NFS ???Τ dmtsai 硂?眀腹?
?ㄣΤ??? UID ?狦痷???杠?ê或?
パ? 192.168.100.254 硂场 NFS ?狝竟? /tmp 舦?? -rwxrwxrwt ?┮?и (dmtsai ? 192.168.100.10 ??)
? /tmp ┏?ㄣΤ???舦????糶??郎?┮Τ?? dmtsai ?
? /home/public 讽い?パ?иΤ弄糶?舦??┮??狦? /home/public 硂?ヘ魁?舦?癸? dmtsai
Τ秨?糶??杠?ê或и碞??弄糶???и糶??郎?┮Τ?琌 dmtsai ??琌窾?
/home/public 癸? dmtsai 硂?ㄏノ??⊿Τ秨???糶??舦???
ê或и临琌⊿Τ快猭糶?郎?翅?硂翴叫疭?痙種?
? /home/test 讽い?и?舦?籔 /home/public ????篈?临惠璶 NFS ?狝竟? /home/test 癸?
dmtsai Τ秨?舦??
? /home/linux 讽い碞ゑ耕陈沸???ぃ阶?琌?贺 user ???ō??﹚穦砆跑Θ UID=45
硂?眀腹?┮??硂?ヘ魁碞ゲ惠璶皐癸 UID = 45 ?ê?眀腹?嘿??э??舦??︽?
ノめ狠籔?狝竟狠?眀腹?ゼ????
安?и? 192.168.100.10 ?ō?? vbird (uid ? 600)??琌 192.168.100.254 硂场 NFS ?诀玱⊿Τ uid=600
?眀腹??薄猵穦跑Θ?妓㎡?
и? /tmp ┏?临琌??糶???琌赣郎??舦?穦玂?? UID=600 ????狝竟狠?癬ㄓ碞穦┣┣??
??тぃ? UID=600 硂?眀腹?陪ボ?珿郎?局Τ?穦恶? 600 绥?
и? /home/public 柑?琌???糶??临惠璶跌 /home/public ?舦?τ﹚?ぃ筁?パ?⊿Τ?? all_squash ?把计?
???赣ヘ魁?穦玂痙ノめ狠?ㄏノ? UID????翴┮ボ?
/home/test ?芠翴籔 /home/public ???
/home/linux ┏??и?ō?碞砆跑Θ UID = 45 ê?ㄏノ?碞琌??
讽ノめ狠?ō?? root ??
安?и? 192.168.100.10 ?ō?? root ㎡? root 硂?眀腹–?╰参常穦Τ??舦?跑Θ?妓㎡?
и? /tmp 柑???糶????パ? no_root_squash ?把计?э跑?箇砞?
root_squash 砞﹚??┮?? /tmp 糶??郎?┮Τ?? root 翅?
и? /home/public ┏??ō?临琌砆溃罽Θ? nobody ????箇砞妮┦柑?常ㄣΤ
root_squash ㎡?┮???狦 /home/public Τ皐癸 nobody
秨?糶?舦???ê或и碞??糶???琌郎?┮Τ?跑Θ nobody 碞琌??
/home/test 籔 /home/public ???
/home/linux ?薄猵い?и root ?ō??砆溃罽Θ? UID = 45 ?ê?ㄏノ???
硂妓?舦?量秆ぇ?????罙秆?盾?硂柑琌程?璶??よ??狦硂?闽硄筁??┏??㎞㎞碞⊿Τ拜肈罢? ^_^?
??盢セゅ弄Ч??程?临琌?????罖?罖?
??秆∕ NFS ?拜肈翅?
13.2.4 币笆 NFS
砞﹚郎穌﹚??讽礛璶秨﹍ㄓ币笆?︽摆?τ玡?и??矗?筁?NFS ?币笆临惠璶 rpcbind ????︽摆?
┮?话候ㄓ币笆??
[root@www ~]# /etc/init.d/rpcbind start
# ?狦 rpcbind セㄓ碞?竒?磅︽??ê碞ぃ惠璶币笆摆?
[root@www ~]# /etc/init.d/nfs start
# Τ??琘ㄇ distributions ??穦?瞷???牡?癟??
exportfs: /etc/exports [3]: No 'sync' or 'async' option specified
for export "192.168.100.10:/home/test".
Assuming default behaviour ('sync').
# ???牡?癟?度琌?????и?⊿Τ?﹚ sync ┪ async ?把计?
# 玥 NFS 盢箇砞穦ㄏノ sync ?戈癟τ?????ぃ瞶??????? /etc/exports?
[root@www ~]# /etc/init.d/nfslock start
[root@www ~]# chkconfig rpcbind on
[root@www ~]# chkconfig nfs on
[root@www ~]# chkconfig nfslock on
ê? rpcbind ?セ碞ぃ惠璶砞﹚??璶?钡币笆ウ碞??罢?币笆ぇ??穦?瞷??
port 111 ? sunrpc ?狝叭?ê碞琌 rpcbind 罢??? nfs 玥穦币笆?ぶㄢ???? daemon
?瞷?礛?碞秨﹍?菏钮 Client 狠?惠―罢??ゲ斗璶?猔種棵辊???块?戈癟?
???狦砞﹚郎糶岿?杠?棵辊?穦陪ボ?岿粇??よ翅?
????狦?稱璶糤??ㄇ NFS ?狝竟?戈??璓┦??????惠璶ノ? rpc.lockd の rpc.statd 单 RPC 狝叭?
ê或┪砛???糤???狝叭?ê碞琌 nfslock 舘?币笆ぇ??叫话е? /var/log/messages 柑???Τ⊿Τ砆タ絋?币笆㎡?
[root@www ~]# tail /var/log/messages
Jul 27 17:10:39 www kernel: Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
Jul 27 17:10:54 www kernel: NFSD: Using /var/lib/nfs/v4recovery as the NFSv4 state
recovery directory
Jul 27 17:10:54 www kernel: NFSD: starting 90-second grace period
Jul 27 17:11:32 www rpc.statd[3689]: Version 1.2.2 starting
?絋粄币笆⊿Τ拜肈ぇ??钡?ㄓи?ㄓ罖?罖ê或 NFS ?┏秨??ㄇ梆??
[root@www ~]# netstat -tulnp| grep -E '(rpc|nfs)'
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address
Foreign Address
PID/Program name
0 0.0.0.0:875
3631/rpc.rquotad
0 0.0.0.0:111
3601/rpcbind
0 0.0.0.0:4.0.0:*
3647/rpc.mountd
0 0.0.0.0:5.0.0:*
3689/rpc.statd
0 0.0.0.0:2049
0 0.0.0.0:875
3631/rpc.rquotad
0 0.0.0.0:111
3601/rpcbind
0 0.0.0.0:897
3689/rpc.statd
0 0.0.0.0:4.0.0:*
3647/rpc.mountd
0 0.0.0.0:808
3601/rpcbind
0 0.0.0.0:4.0.0:*
3689/rpc.statd
猔種????翅?羆?玻ネ???? port 翅?痷琌?┤?ぃ筁?璶?梆?琌?
rpcbind 币笆? port ? 111 ???币笆? UDP 籔 TCP?
nfs セō?狝叭币笆? port 2049 ?繷?
ㄤ? rpc.* 狝叭币笆? port 玥琌繦诀玻ネ????惠? port 111 爹??
???êи?或?笵–? RPC 狝叭?爹??猵?⊿闽玒????ㄏノ rpcinfo ㄓ芠诡??
[root@www ~]# rpcinfo -p [IP|hostname]
[root@www ~]# rpcinfo -t|-u
IP|hostname 祘Α?嘿
匡兜籔把计?
-p ?皐癸琘 IP (ゼ糶玥箇砞?セ诀) 陪ボ?┮Τ? port 籔 porgram ?戈癟?
-t ?皐癸琘?诀?琘や祘Α浪琩ㄤ TCP ??┮??硁砰?セ?
-u ?皐癸琘?诀?琘や祘Α浪琩ㄤ UDP ??┮??硁砰?セ?
# 1. 陪ボ?ヘ玡硂场?诀? RPC ?篈
[root@www ~]# rpcinfo -p localhost
program vers proto
portmapper
portmapper
portmapper
portmapper
portmapper
portmapper
....(┏??菠)....
# 祘Α?腹 NFS?セ ??摸? 梆?
# 2. 皐癸 nfs 硂?祘Α浪琩ㄤ?闽?硁砰?セ戈癟 (度诡? TCP ??)
[root@www ~]# rpcinfo -t localhost nfs
program 100003 version 2 ready and waiting
program 100003 version 3 ready and waiting
program 100003 version 4 ready and waiting
# ?祇瞷矗ㄑ nfs ??セ?Τ?贺?だ?琌 2, 3, 4 ?绥?
?灿罖罖????瞷?戈癟讽い埃?祘Α?嘿籔梆??癸莱??籔 netstat -tlunp 块??挡狦?ゑ癸ぇ??临惠璶猔種?
NFS ??セや穿?穝? NFS ?セ肚块硉?耕е?パ???癬ㄓ?и?? NFS ?ぶや穿?材 4 ??莱赣临衡?瞶罢? ^_^?
?狦?? rpcinfo 礚猭块??ê碞?ボ爹??戈?Τ拜肈罢???惠璶?穝币笆
rpcbind 籔 nfs 翅?
13.2.5 NFS ?硈絬芠诡
??? NFS ?狝竟砞﹚Т讽ぇ??и???? server 狠??и代刚??琌???硈絬翅?碞琌?ノ showmount
硂???ㄓ琩綷?
[root@www ~]# showmount [-ae] [hostname|IP]
匡兜籔把计?
-a ?陪ボヘ玡?诀籔ノめ狠? NFS 硈絬だㄉ??篈?
-e ?陪ボ琘场?诀? /etc/exports ┮だㄉ?ヘ魁戈??
# 1. 叫陪ボ???и?┮砞﹚???闽 exports だㄉヘ魁戈癟
[root@www ~]# showmount -e localhost
Export list for localhost:
/home/linux
*.centos.vbird
/home/test
192.168.100.10
/home/public (everyone)
?虏虫??┮??讽?璶苯核琘?场?诀?矗ㄑ? NFS だㄉ?ヘ魁??碞ㄏノ showmount -e
IP (┪hostname) ???獶盽?よ獽??硂?琌 NFS client 狠程盽ノ???翅?
??? NFS 闽?ヘ魁舦?砞﹚?戈?獶盽ぇ??? /etc/exports
?琌ゑ耕疭??舦?把计τ??临Τ??箇砞把计㎡?
硂ㄇ箇砞把计???и???浪琩?? /var/lib/nfs/etab 碞?笵??
[root@www ~]# tail /var/lib/nfs/etab
/home/public
192.168.100.0/24(rw,sync,wdelay,hide,nocrossmnt,secure,root_squash,
no_all_squash,no_subtree_check,secure_locks,acl,anonuid=65534,anongid=65534)
# ??琌??︽?????埃? rw, sync, root_squash 单单?
# ㄤ龟临Τ anonuid の anongid 单单?砞﹚?
??度度琌???絛ㄒ?硓筁だ猂 anonuid=65534 癸ゑ /etc/passwd ??穦祇瞷 CentOS ?瞷?琌
nfsnobody 罢?硂?眀腹?ぃ???セ常??穦ぃ?妓??????狦Τㄤ?ノめ狠本更???
NFS 郎?╰参??ê或赣ノめ狠籔郎?╰参戈癟碞穦砆癘魁? /var/lib/nfs/xtab 柑繷???
????狦?稱璶?穝矪瞶 /etc/exports 郎??讽?穝砞﹚Ч /etc/exports ?惠ぃ惠璶?穝币笆 nfs ?
ぃ惠璶罢??狦?穝币笆 nfs ?杠?璶眔?? RPC 爹???陈沸°硂???и???硓筁 exportfs 硂???ㄓ腊Γ翅?
[root@www ~]# exportfs [-aruv]
匡兜籔把计?
-a ??场本更(┪?更) /etc/exports 郎?ず?砞﹚
-r ??穝本更 /etc/exports 柑??砞﹚????ョ?˙?穝 /etc/exports
の /var/lib/nfs/xtab ?ず甧?
-u ??更琘?ヘ魁
-v ?? export ????盢だㄉ?ヘ魁陪ボ?棵辊??
# 1. ?穝本更?Ω /etc/exports ?砞﹚
[root@www ~]# exportfs -arv
exporting 192.168.100.10:/home/test
exporting 192.168.100.0/24:/home/public
exporting *.centos.vbird:/home/linux
exporting *:/home/public
exporting *:/tmp
# 2. 盢?竒だㄉ? NFS ヘ魁戈方?硄硄常?更
[root@www ~]# exportfs -auv
# 硂??狦??ㄏノ showmount -e localhost 碞穦?ぃ?ヴ?戈方??
璶剪眡??硂????ノ猭翅?硂妓?ㄓ?碞???钡?穝 exportfs и??癘魁? /etc/exports
?ヘ魁戈?舘??琌璶疭?痙種??狦?度Τ矪瞶砞﹚郎???⊿Τ?癸莱?ヘ魁 (/home/public 单ヘ魁) ??矗ㄑㄏノ摆?
ê??穦?瞷?ㄇ牡?癟?翅?┮?癘眔璶?ミだㄉ?ヘ魁?癸?
13.2.6 NFS ???┦
? NFS ???┦???Τㄇ?よ琌?ゲ斗璶?笵?翅?┏?и?だ?ㄓ酵?酵?
ň?鲤?砞﹚拜肈籔秆∕よ??
??ㄓ弧? NFS ?狝叭度穦癸ず场呼办秨??ぃ穦癸呼悔呼隔秨???礛τ??狦?Τ疭?惠―?杠?
ê或???穦阁ぃ?呼办碞琌???琌?NFS ?ň?鲤疭?螟穌??ぐ或㎡???埃?㏕﹚? port 111, 2049 ぇ??
临Τ??ぃ㏕﹚?梆?琌パ rpc.mountd, rpc.rquotad 单狝叭┮秨币??┮???? iptables 碞?螟砞﹚砏玥?
ê?快?螟笵俱?ň?鲤诀?常璶??????
??秆∕硂?拜肈? CentOS 6.x Τ矗ㄑ??㏕﹚疭﹚ NFS 狝叭?梆?砞﹚郎?ê碞琌 /etc/sysconfig/nfs 罢?
??硂?郎?柑?碞?镑?﹚疭﹚?梆??硂妓–Ω币笆 nfs ???闽狝叭币笆?梆?碞穦㏕﹚????ㄓ?
и?碞?镑砞﹚タ絋?ň?鲤舘?硂?砞﹚郎ず甧???荡?场だ?戈??常ぃ璶??э??璶э蛤 PORT 硂?闽龄?Τ闽?戈????
ê或惠璶?э? rpc 狝叭Τ?ㄇ㎡??璶Τ mountd, rquotad, nlockmgr 硂???┮??莱赣璶硂妓э?
[root@www ~]# vim /etc/sysconfig/nfs
RQUOTAD_PORT=1001
&==?? 13 ︽オ?
LOCKD_TCPPORT=30001 &==?? 21 ︽オ?
LOCKD_UDPPORT=30001 &==?? 23 ︽オ?
MOUNTD_PORT=1002
&==?? 41 ︽オ?
# 癘眔砞﹚?程オ娩?爹秆狝叭璶?奔ぇ??梆????????︽∕﹚?
[root@www ~]# /etc/init.d/nfs restart
[root@www ~]# rpcinfo -p | grep -E '(rquota|mount|nlock)'
# ?瓃?块?戈??竒砆尘?稪俱筁??⊿ノ??梆???奔?罢?
??┤???狦稱璶秨? NFS 倒??呼办?狟ねㄏノ??ぃ稱璶琵癸よ局Τㄤ?狝叭?祅????
ê??ň?鲤碞眔璶秨??瓃???梆?罢?Τ镑陈沸?°安砞?稱璶秨? 120.114.140.0/24 硂?呼办???镑ㄏノ?硂场?狝竟?
NFS ?戈方??安砞??竒ㄏノ?
ê或?临眔璶硂妓暗??镑皐癸赣呼办?︽翅?
[root@www ~]# vim /usr/local/virus/iptables/iptables.allow
iptables -A INPUT -i $EXTIF -p tcp -s 120.114.140.0/24 -m multiport \
--dport 111,02,30001 -j ACCEPT
iptables -A INPUT -i $EXTIF -p udp -s 120.114.140.0/24 -m multiport \
--dport 111,02,30001 -j ACCEPT
[root@www ~]# /usr/local/virus/iptables/iptables.rule
# 羆琌璶?穝磅︽硂妓ň?鲤砏玥?穦抖??ネ?摆??а癘??а癘?
ㄏノ /etc/exports 砞﹚????舦??
硂碞瞣疉???呸胯?σ???或砞﹚常⊿Τ闽玒??琌??獽??籔????ぇ丁?璶т???キ颗翴??到ノ
root_squash の all_squash 单?????ノ anonuid
单单?砞﹚ㄓ砏絛祅???诀?ㄏノ?ō??莱赣临琌Τ快猭矗ㄑ??耕???? NFS ?狝竟??
???讽礛罢??? NFS ?狝竟?郎?╰参ぇ舦?砞﹚?惠璶?痙種?
ぃ璶繦獽砞﹚Θ? -rwxrwxrwx ?硂妓穦硑Θ??╰参?????耑??摆?
???? partition 砏购?
?狦????吏挂い?ㄣΤ?场? Linux ?诀???箇璸┘?だㄉ?ヘ魁??ê或??杆 Linux
????程?碞??砏购??遏 partition ??箇痙ぇノ????
NFS ??皐癸ヘ魁ㄓだㄉ????????盢箇痙?
partition 本更?ヴ???本更翴??盢赣本更翴 (碞琌ヘ魁罢?)パ /etc/exports
?砞﹚いだㄉ???ê或俱???吏挂い?ㄤ? Linux ?诀碞??ㄏノ赣 NFS ?狝竟?ê遏箇痙?
partition ??┮????诀?砏购????璶惠璶痙種??Τ partition τ?????パ?だㄉ?
partition ??耕甧?砆?獻?程???皐癸赣 partition 砞﹚ゑ耕腨??把计? /etc/fstab 讽い翅?
????狦??だ澄暗?ぃ镑??羭ㄒㄓ弧????常尺舧ㄏノ胕?だ澄猭?ョ?俱?╰参い?Τ???ヘ魁? partition
τ??硂妓暗穦Τぐ或拜肈㎡?安砞?だㄉ?琌 /home 硂?倒??ノめ?ヘ魁???Τㄇㄏノ?谋眔硂? NFS ?合盒び?ノ??
挡狦ㄏノ?碞盢????帮既?戈?硄硄峨秈硂? NFS 合盒い?稱?稱??狦俱??ヘ魁碞??硂? /home 砆峨脄??
ê或??╰参盢穦硑Θ礚猭弄糶??耑??????▆??だ澄砏购?┪?琌?ノ合盒皌肂ㄓ??临琌??璶????
NFS ?狝竟闽诀玡?猔種ㄆ兜?
惠璶猔種?琌?パ? NFS ㄏノ?硂? RPC 狝叭?讽ノめ狠硈??狝竟??ê或???狝竟稱璶闽诀?
ê?碞穦Θ??ぃ???ヴ叭???狦???狝竟??临Τノめ狠?硈絬?ê或?璶闽诀?
??眔璶单?计?牧繷??镑タ盽?闽诀Θ??苡?痷?安??ぃ?獺盾?ぃ礛???ㄠ刚刚??^_^?
┮?舘??某?? NFS Server 稱璶闽诀ぇ玡????闽奔 rpcbind 籔 nfs ?硂ㄢ?狥﹁?
?狦礚猭タ絋?盢硂ㄢ? daemons 闽奔?ê或?? netstat -utlp т? PID ?礛?? kill
盢?闽奔??硂妓?Τ快猭タ盽?闽诀Θ?翅?硂?叫疭?疭??猔種㎡?
讽礛罢??????ノ
-a localhost ㄓ琩?ㄓê?ノめ狠临?硈絬?
┪?琌琩綷 /var/lib/nfs/rmtab ┪ xtab 单郎?ㄓ浪琩ョ??т?硂ㄇノめ狠??
???钡 call ??摆?琵???镑腊腊Γ?? ^_^
ㄆ龟??ノめ狠? NFS 硈絬??狝竟狠???狦?????笷?ㄇゑ耕ぃê或?祑??本更把计??
碞?镑搭ぶ硂よ??拜肈翅??闽???┦??把σ???竊?
13.3 NFS ノめ狠?砞﹚
琂礛 NFS ?狝竟程?璶???碞琌だㄉ郎?╰参倒呼隔?ㄤ??ノめ狠?┮?ノめ狠讽礛眔璶本更硂??種ㄠ舘?
????狝竟狠???砞ň?鲤ㄓ玂臔???郎?╰参?ê或ノめ狠本更赣郎?╰参??螟笵ぃ惠璶玂臔???
???┮?┏?и?璶ㄓ酵?酵碭? NFS ノめ狠?揭肈?
13.3.1 も笆本更 NFS
?狝竟だㄉ?戈方
?璶??本更 NFS ?狝竟┮矗ㄑ?郎?╰参㎡?膀セ????硂妓暗?
絋粄セ?狠?竒币笆? rpcbind 狝叭?
苯核 NFS ?狝竟だㄉ?ヘ魁Τ?ㄇ??罙秆и?琌???ㄏノ ()?
?セ?狠?ミ箇璸璶本更?本更翴ヘ魁 (mkdir)?
?ノ mount 盢环狠?诀?钡本更??闽ヘ魁?
??瞷?安砞ノめ狠? 192.168.100.10 硂场诀竟??τ?狝竟琌 192.168.100.254 ?
ê或话候ㄓ浪琩??и?琌??竒Τ rpcbind ?币笆???环狠?诀Τぐ或?ノ?ヘ魁㎡?
# 1. 币笆ゲ称?狝叭?璝⊿Τ币笆?币笆?Τ币笆玥玂??妓ぃ笆?
[root@clientlinux ~]# /etc/init.d/rpcbind start
[root@clientlinux ~]# /etc/init.d/nfslock start
# ??ㄓ弧?╰参箇砞穦币笆 rpcbind ?ぃ筁尘?ぇ玡闽超筁?┮?璶币笆?
# ????狦?狝竟狠Τ币笆 nfslock ?杠?ノめ狠?璶币笆??ネ??
# 2. 琩高?狝竟矗ㄑ?ㄇ戈方倒и?ㄏノ㎡?
[root@clientlinux ~]# showmount -e 192.168.100.254
Export list for 192.168.100.254:
/home/linux
*.centos.vbird
/home/test
192.168.100.10
/home/public (everyone)
&==硂琌单??и?璶本更?ヘ魁
钡?ㄓи稱璶盢环狠?诀? /home/public 本更?セ?狠?诀? /home/nfs/public ?
┮?и碞眔璶?セ?狠?诀??ミ癬硂?本更翴ヘ魁?︽摆?礛?碞??ノ mount
硂????钡本更 NFS ?郎?╰参舘?
# 3. ?ミ本更翴???龟悔本更??舘?
[root@clientlinux ~]# mkdir -p /home/nfs/public
[root@clientlinux ~]# mount -t nfs 192.168.100.254:/home/public \
& /home/nfs/public
# 猔種??本更?粂猭?? -t nfs ??﹚郎?╰参摸??
# IP:/dir 玥琌?﹚琘?场?诀?琘?矗ㄑ?ヘ魁?????狦?瞷??岿粇?
mount: 192.168.100.254:/home/public failed, reason given by server: No such file
or directory
# 硂???? Server ???⊿Τ?ミ /home/public 罢?????狝竟狠?ミ???
# 4. 羆琌眔璶??本更ぇ??薄猵?????ㄏノ df ┪ mount 罢?
[root@clientlinux ~]# df
?ノ ?ノ% 本更翴
....(い丁?菠)....
192.168.100.254:/home/public
3% /home/nfs/public
?猔種??本更 NFS 郎???Α絛ㄒ翅????硂妓碞??盢戈?本更秈ㄓ罢?叫猔種翅?
????璶?秈???ヘ魁 /home/nfs/public 碞单??? 192.168.100.254 ê场环狠?诀?
/home/public ê?ヘ魁い舘??ぃ岿??????赣ヘ魁?Τぐ或舦??
ê碞叫???玡??竊琩?琩舦???σ?? ^_^ ?ê或??盢本更? NFS ヘ魁?更㎡?碞ㄏノ umount 摆?
[root@clientlinux ~]# umount /home/nfs/public
ノめ狠?矪瞶?本更把计籔秨诀本更
罖?ノめ狠?本更???虏虫??ぃ筁ぃ惧眔?Τ⊿Τ稱筁??狦???本更?セ诀 /home/nfs/public
?郎?╰参讽い??Τ?や script ??硂や script ?ず甧?? rm -rf / ??赣郎?舦?? 555 ?
ぴ关°?狦?????倒?磅︽????Τ?????°??俱?╰参常穦砆炳???痷?鸡?
┮?弧?埃? NFS ?狝竟惠璶玂臔ぇ??и??ノ?產? NFS 郎?╰参?惠璶?и玂臔?︽摆?
ê璶???и玂臔摆???硓筁 mount ???把计翅??珹┏?硂ㄇ?璶?把计??沽刚???
把计把计??種竡╰参箇砞?
suidnosuid惧眔裕琌 SUID ???狦本更? partition ??Τヴ? SUID ? binary 祘Α??
??璶ㄏノ nosuid 碞?镑?? SUID ?????苡?ぃ?笵ぐ或琌 SUID ?ê碞ぃ璶厩?產琜?估?@_@?
话候??膀娄厩策絞材??狡策??罢?
rwro????﹚赣郎?╰参琌斑弄 (ro) ┪?弄糶翅??狝竟??矗ㄑ倒??弄糶?
?琌ノめ狠??度す砛斑弄?把计砞﹚??
devnodev琌???玂痙杆竚郎??疭??????ㄓ弧?Τ /dev
硂?ヘ魁?穦Τ疭??杆竚??????匡拒 nodev 翅?dev
execnoexec琌?ㄣΤ磅︽ binary file ?舦??
?狦?稱璶本更?度琌戈?跋 (ㄒ? /home)?ê或??匡拒 noexec
usernouser琌?す砛ㄏノ?秈︽郎??本更籔?更???
?狦璶玂臔郎?╰参?程?ぃ璶矗ㄑㄏノ?秈︽本更籔?更??nouser
autonoauto硂? auto ??琌?mount -a???穦ぃ穦砆本更?兜ヘ?
?狦?ぃ惠璶硂? partition 繦?砆本更???砞﹚? noauto?auto
??ㄓ弧??狦?? NFS ?狝竟┮矗ㄑ??琌摸? /home ┏????戈??
莱赣ぃ惠璶?磅︽?SUID 籔杆竚郎????讽??本更??????硂妓?笷??翅?
[root@clientlinux ~]# umount /home/nfs/public
[root@clientlinux ~]# mount -t nfs -o nosuid,noexec,nodev,rw \
& 192.168.100.254:/home/public /home/nfs/public
[root@clientlinux ~]# mount | grep addr
192.168.100.254:/home/public on /home/nfs/public type nfs (rw,noexec,nosuid,
nodev,vers=4,addr=192.168.100.254,clientaddr=192.168.100.10)
硂妓?ㄓ?┮本更?硂?郎?╰参碞????戈???ぇノ??癸ㄓ弧?癸?ノめ狠琌ゑ耕???ㄇ??
┮?弧?硂? nosuid, noexec, nodev 单单?把计?眔癘眔摆?
闽? NFS 疭??本更把计
埃??瓃? mount 把计ぇ??ㄤ龟皐癸 NFS ?狝竟???? Linux 临矗ㄑぃぶΤノ?肂?把计翅?硂ㄇ疭?把计临獶盽Τノ㎡?
?ぐ或㎡?羭ㄒㄓ弧?パ?郎?╰参癸 Linux 琌獶盽?璶?狥﹁???и?秈︽ヴ?笆????璶Τノ?郎?╰参?
ê或俱?ヘ魁攫╰参碞穦?笆??琩高?场?本更翴??狦?? NFS ?狝竟籔ノめ狠ぇ丁?硈絬??呼隔拜肈?
┪?琌?狝竟狠?闽诀??玱⊿Τ硄?ノめ狠?ê或ノめ狠?璶笆?郎?╰参??? (ㄒ? df, ls, cp 单单)
?俱?╰参碞穦篊?脄????ゲ斗璶单?郎?╰参穓碝单?筄???╰参?穦那???(尘?单筁 df ?? 30 だ牧筁...)
??磷?硂ㄇ?耑?и?临Τ?ㄇ肂?? NFS 本更把计?ノ?ㄒ??
把计把计??箇砞把计
fgbg讽磅︽本更??赣本更?︽?穦?玡春 (fg) 临琌?璉春 (bg) 磅︽?
璝?玡春磅︽??玥 mount 穦?尿沽刚本更???Θ?┪ time out ?ゎ?璝?璉春磅︽?
玥 mount 穦?璉春?尿?Ω秈︽ mount ?τぃ穦紇臫?玡春?祘?巨??
?狦??呼隔硈絬Τ翴ぃ铆﹚?┪琌?狝竟盽盽惠璶秨闽诀?ê?某ㄏノ bg ゑ耕Т讽?fg
softhard?狦琌 hard ?薄猵?玥讽ㄢ?ぇ丁Τヴ??场?诀瞒絬?玥 RPC
穦?尿?㊣????癸よ?確硈絬?ゎ??狦琌 soft ?杠?ê RPC 穦? time out ???狡?㊣??τ獶??尿?㊣??
??╰参?┑筐穦ゑ耕ぃ硂或?陪?????狦???狝竟??秨秨闽闽??某ノ soft 翅?
intr讽?ㄏノ?繷矗?? hard よΑ本更??璝?? intr 硂?把计?
玥讽 RPC ?尿㊣?い?赣Ω?㊣?琌??砆い耞? (interrupted)?⊿Τ
rsizewsize弄?(rsize)籔糶?(wsize)?跋遏?? (block size)?
硂?砞﹚???紇臫ノめ狠籔?狝竟狠肚块戈??絯侥癘拘甧秖???ㄓ弧?
?狦?跋办呼隔ず (LAN) ???ノめ狠籔?狝竟狠常ㄣΤì镑?癘拘砰?ê硂????砞﹚??翴?
ゑ?弧 32768 (bytes) 单?矗ど絯侥癘拘跋遏盢?矗ど NFS 郎?╰参?肚块???
?璶猔種砞﹚???ぃ璶び??程?琌笷?呼隔?镑肚块?程?????
rsize=1024wsize=1024
???把计??把σ man nfs ?块?戈?翅?
硄盽?狦?? NFS 琌ノ?蔼硉笲??吏挂讽い?杠?ê或???某??硂ㄇ把计?弧?
[root@clientlinux ~]# umount /home/nfs/public
[root@clientlinux ~]# mount -t nfs -o nosuid,noexec,nodev,rw \
& -o bg,soft,rsize=32768,wsize=32768 \
& 192.168.100.254:/home/public /home/nfs/public
玥讽?? 192.168.100.254 硂场?狝竟??琘ㄇ??τ瞒絬???? NFS ??膥尿?璉春讽い?狡?㊣??
?? NFS ?狝竟???絬?ゎ?硂癸?╰参??尿巨?临琌Τ腊??罢?
讽礛罢?ê? rsize 籔 wsize ???玥惠璶ㄌ沮??龟悔呼隔吏挂τ﹚翅?
?尘??龟悔?ㄒい?琘ㄇ???家Α笲衡?ぃす砛 soft 硂?把计翅?羭ㄒㄓ弧?尘?篋ノ? CMAQ ??珇借家Α?
硂?家Α?翺栋琜篶だㄉ郎?╰参い?碞ぃす砛ㄏノ soft 把计?硂翴惠璶疭?痙種翅?
盢 NFS 秨诀?本更
и??笵秨诀碞本更?本更翴籔?闽把计琌糶? /etc/fstab い??ê NFS ?ぃ?糶? /etc/fstab 讽い㎡?獶盽?堡?琌?
ぃ??㎡??裕㎡?だ猂??秨诀?瑈祘?и???祇瞷呼隔?币笆琌?セ诀本更ぇ????讽??ノ /etc/fstab
NFS ??╰参パ?﹟ゼ币笆呼隔?┮??﹚琌礚猭本更Θ??罢?ê?快?虏虫?碞糶? /etc/rc.d/rc.local ???
[root@clientlinux ~]# vim /etc/rc.d/rc.local
mount -t nfs -o nosuid,noexec,nodev,rw,bg,soft,rsize=32768,wsize=32768 \
192.168.100.254:/home/public /home/nfs/public
13.3.3 礚猭本更???だ猂
?狦ノめ狠碞琌礚猭本更?狝竟狠┮だㄉ?ヘ魁???┏琌祇ネぐ或拜肈????硂妓だ猂???
ノめ狠??诀?嘿┪ IP 呼琿ぃ砆す砛ㄏノ?
????ㄒ?ㄓ弧??и? /home/test ??矗ㄑ 192.168.100.0/24 硂?呼办?┮??狦и? 192.168.100.254
硂场?狝竟い?? localhost (127.0.0.1) ㄓ本更??碞穦礚猭本更??硂?舦?阀├⊿拜肈??ぃ礛?????狝竟?刚刚??
[root@www ~]# mount -t nfs localhost:/home/test /mnt
mount.nfs: access denied by server while mounting localhost:/home/test
?? access denied ???⊿岿罢°舦?ぃ才罢??狦絋﹚?? IP ⊿Τ岿粇?ê或叫硄??狝竟狠?叫恨瞶?盢?? IP ??
/etc/exports 硂?郎?い?
?狝竟┪ノめ狠琘ㄇ狝叭ゼ币笆?
硂?程甧?砆а癘??碞琌а癘?币笆 rpcbind 硂?狝叭罢??狦??ノめ狠祇瞷 mount ?癟?琌硂妓?
[root@clientlinux ~]# mount -t nfs 192.168.100.254:/home/test /mnt
mount: mount to NFS server '192.168.100.254' failed: System Error: Connection refused.
# ?狦?ㄏノ ping 玱祇瞷呼隔籔?狝竟常琌???ê或硂?拜肈碞琌 rpcbind ⊿Τ秨罢?
[root@clientlinux ~]# mount -t nfs 192.168.100.254:/home/test /home/nfs
mount: mount to NFS server '192.168.100.254' failed: RPC Error: Program not registered.
# 猔種?程???戈??絋龟Τ硈? RPC ??琌?狝竟? RPC ??и??赣祘Α礚爹?
璶估碞琌 rpcbind а癘秨 (材??岿粇)?璶估碞琌?狝竟狠? nfs а癘秨?程陈沸?琌?
?穝币笆? rpcbind ?琌玱а癘?穝币笆ㄤ?狝叭 (?瓃材??岿粇)?秆∕?よ猭碞琌??穝币笆 rpcbind
恨瞶?ㄤ?┮Τ狝叭碞琌??
砆ň?鲤郎奔??
パ? NFS 碭?ぃ癸?秨??τず场呼办?硄盽琌?场?戈方常?︽???筁?? NFS ?狟ね (?珹尘?セ?罢?)
常⊿Τ猔種筁 NFS ?ň?鲤拜肈?程?硂碭?尘??恨瞶筿福毙???Τ磝恨?场筿福毙??北ň?鲤?
??踞みび糉甡?厩ネ倒尘?睹穌???赣 Linux ň?鲤箇砞琌度?︽场だ戈方τ???パ?筿福毙??跋呼ず惠璶ノ?
Linux ? NFS 戈方?挡狦㎡?澈礛⊿快猭?︽摆??ㄓ碞琌 iptables ⊿Τ?︽ NFS ┮ㄏノ??梆?°
┮??讽???礚猭抖??硈钡 NFS ?狝竟?叫???狝竟狠?盢ノめ狠? IP Ч??︽?璝絋﹚硂妓碞硈???
ê??碞琌ň?鲤Τ拜肈罢??或秆∕㎡????竊ざ残筁??把σ盢 NFS ?狝竟梆?㏕﹚?よΑ??
13.3.4 ?笆本更 autofs ?ㄏノ
??? NFS 郎?╰参?ㄏノ薄猵い??狦ノめ狠璶ㄏノ?狝竟狠┮矗ㄑ? NFS 郎?╰参??璶估碞琌眔?
/etc/rc.d/rc.local 讽い砞﹚秨诀?本更?璶估碞眔璶祅?╰参?も笆?ノ mount ㄓ本更?
???ノめ狠眔璶箇?も笆??ミ?本更翴ヘ魁?礛?本更?ㄓ??琌硂妓?ㄏノ薄猵?┤Τ翴?拜肈?
NFS 郎?╰参籔呼隔硈絬??耑?
и??笵 NFS ?狝竟籔ノめ狠?硈絬┪砛ぃ穦ッ环???τ RPC 硂?狝叭??癚菇???狦本更? NFS
?狝竟??ヴ??よ瞒絬常??硑Θ???よρ琌?单?筄?°τ??本更? NFS
郎?╰参???ぃ琌盽盽砆ㄏノ??璝ぃ本更?杠?Τ??候?璶ㄏノ??眔硄?╰参恨瞶??
硂??ぃよ獽...摆??癚菇?稰谋摆°@_@
┮??琵и?传??σ?à?ㄓ癚阶??ㄏノ NFS ?薄挂?
?ぃ??琵ノめ狠?Τㄏノ? NFS 郎?╰参?惠―??琵╰参?笆本更?
讽 NFS 郎?╰参ㄏノЧ拨???ぃ??琵 NFS ?笆?更??磷???? RPC 岿粇?
?狦?笷??瓃????ê碞びЧ?罢?Τ⊿Τ硂狥﹁㎡?Τ???瞷?? Linux 吏挂?硂琌??笷Θ?瞶稱?ノ?碞琌
autofs 硂?狝叭罢?
autofs ?砞﹚阀├?
autofs 硂?狝叭?ノめ狠筿福???穦?尿?盎代琘??﹚?ヘ魁?
?箇?砞﹚讽ㄏノ?赣ヘ魁??琘?Ωヘ魁??盢穦?眔ㄓ??狝竟狠? NFS 郎?╰参戈方??秈︽?笆本更?笆??
量硂妓┪砛?Τ翴家絢?琵и??┏?硂?瓜ボㄓ???
瓜 13.3-1?autofs ?笆本更?砞﹚郎ず甧ボ種瓜
??瓜┮ボ?и?? autofs ?璶砞﹚郎? /etc/auto.master?硂?郎??ず甧?虏虫?
??┮ボ?и?璶﹚竡?程?糷ヘ魁 (/home/nfsfile) ???硂?ヘ魁碞琌 autofs 穦???尿盎代?ヘ魁罢?
???尿?郎?玥琌赣ヘ魁┏??Ωヘ魁?癸莱?? /etc/auto.nfs (硂?郎??郎???璹)
柑?玥??﹚竡?–?Ωヘ魁┮饼本更?环狠?狝竟? NFS ヘ魁戈方?
羭ㄒㄓ弧??讽и??ノめ狠璶ㄏノ /home/nfsfile/public ?戈????? autofs ?穦?
192.168.100.254 ?狝竟?本更 /home/public ????讽筳? 5 だ牧⊿Τㄏノ赣ヘ魁??戈???玥ノめ狠╰参盢穦?笆??更
/home/nfsfile/public ??
?ぃ岿ノ????ㄣ????Τノ??狝竟?戈????笆本更?⊿Τㄏノ?碞穦?笆?更?
τぃ琌肚参?薄猵??琌本更??琂礛硂或?ノ?ê碞琵и?龟悔ㄓ巨簍???
?ミ?砞﹚郎 /etc/auto.master ???﹚盎代?疭﹚ヘ魁
硂??璶砞﹚郎?ず甧?虏虫??璶Τ璶砆?尿盎代?ヘ魁の?戈?癸莱郎????
ê?戈?癸莱郎?郎?琌???︽砞﹚???尘?硂?ㄒ?讽いиㄏノ /etc/auto.nfs ㄓ㏑??
[root@clientlinux ~]# vim /etc/auto.master
/home/nfsfile
/etc/auto.nfs
?瓃戈?いゑ耕惠璶猔種?琌?ê? /home/nfsfile ヘ魁ぃ惠璶????? autofs 穦?笆??ミ赣ヘ魁?
?狦??ミ????はτ穦?拜肈°????絋﹚??⊿Τ赣ヘ魁??
?ミ戈?癸莱郎ず (/etc/auto.nfs) ?本更戈癟籔?狝竟癸莱戈方
??и?┮?﹚? /etc/auto.nfs 琌?︽砞﹚??┮?硂?郎?琌ぃ????ê或硂?郎???Α琌??㎡????硂妓??
[セ?狠Ωヘ魁]
[-本更把计]
[?狝竟┮矗ㄑ?ヘ魁]
匡兜籔把计?
[セ?狠Ωヘ魁] ???碞琌? /etc/auto.master ず?﹚?ヘ魁ぇΩヘ魁
[-本更把计]
?碞琌玡??竊矗?? rw,bg,soft 单单?把计罢??Τ?礚?
[?狝竟┮矗ㄑ?ヘ魁] ?ㄒ? 192.168.100.254:/home/public 单
[root@clientlinux ~]# vim /etc/auto.nfs
-rw,bg,soft,rsize=32768,wsize=38.100.254:/home/public
-rw,bg,soft,rsize=32768,wsize=38.100.254:/home/test
-rw,bg,soft,rsize=32768,wsize=38.100.254:/tmp
# 把计场だ??璶程玡??? - 才腹???
硂妓碞???ミ癸莱??璶猔種?琌?êㄇ /home/nfsfile/public 琌ぃ惠璶ㄆ??ミ??
??? autofs 穦ㄆ薄猵ㄓ矪瞶翅????钡?ㄓ琵и?????龟悔笲???
龟悔笲?籔芠诡
砞﹚郎砞﹚Т讽??讽礛碞琌璶币笆 autofs 罢?
[root@clientlinux ~]# /etc/init.d/autofs stop
[root@clientlinux ~]# /etc/init.d/autofs start
# ??┣?獶盽┣?CentOS 6.x ? autofs ㄏノ restart 穦ア??┮?尘??秈︽ㄢΩ
安砞?ヘ玡?⊿Τ本更ヴ?ㄓ? 192.168.100.254 硂场 NFS ?狝竟?戈方ヘ魁????
ê琵и?龟悔ㄓ芠诡??碭??璶?戈?????? /home/nfsfile 穦ぃ穦?笆?砆?ミ?
礛???狦и璶秈? /home/nfsfile/public ??郎?╰参穦??跑て㎡?
[root@clientlinux ~]# ll -d /home/nfsfile
drwxr-xr-x. 2 root root 0
00:07 /home/nfsfile
# ?灿??﹑穦祇瞷 /home/nfsfile 甧秖琌 0 翅?ê琌タ盽????琌 autofs ?ミ?
[root@clientlinux ~]# cd /home/nfsfile/public
[root@clientlinux public]# mount | grep nfsfile
192.168.100.254:/home/public on /home/nfsfile/public type nfs (rw,soft,rsize=32768,
wsize=32768,sloppy,vers=4,addr=192.168.100.254,clientaddr=192.168.100.10)
# ???块?琌??︽?罖??礛?瞷硂??種ㄠ???琌?笆本更?估?
[root@clientlinux public]# df
/home/nfsfile/public
?ノ ?ノ% 本更翴
192.168.100.254:/home/public
3% /home/nfsfile/public
# 郎??本更??瞷⊿岿?
???痷琌?摆????ㄓ??狦痷?Τ惠璶ノ?赣ヘ魁??╰参?穦??癸??狝竟??本更?
璝琌?皚?⊿Τㄏノ?ê或赣ヘ魁碞穦砆?更㎡?硂妓碞搭ぶ???ぃゲ璶?ㄏノ?诀罢?临ぃ岿ノ?? ^_^
13.4 ?ㄒ簍絤
琵и?ㄓ暗?龟悔簍絤??絤策ぇ玡?叫盢?狝竟? NFS 砞﹚戈?常睲埃??琌玂痙 rpcbind ぃ?闽超???ノめ狠?吏挂??
?闽超 autofs ?の??ぇ玡? /etc/rc.d/rc.local 柑?糶??秨诀?笆本更兜ヘ????埃 /home/nfs ヘ魁绥?
钡?ㄓ叫??и?璶矪瞶?吏挂???
家览?吏挂?篈い??狝竟狠?稱猭???
安砞?狝竟? IP ? 192.168.100.254 硂?场?
/tmp だㄉ??弄糶???ぃ??ㄏノ?ō??よΑ?だㄉ倒┮Τ 192.168.100.0/24 硂?呼办い?┮Τ筿福?
/home/nfs だㄉ?妮┦?斑弄??矗ㄑ埃?呼办ず??????? Internet ョ矗ㄑ戈?ず甧?
/home/upload 暗? 192.168.100.0/24 硂?呼办?戈??肚ヘ魁?ㄤい?硂?
/home/upload ?ㄏノ?の┮妮竤舱? nfs-upload 硂?????? UID 籔 GID А? 210?
/home/andy 硂?ヘ魁度だㄉ倒 192.168.100.10 硂场?诀??矗ㄑ赣?诀??
andy 硂?ㄏノ?ㄓㄏノ??碞琌弧? andy ? 192.168.100.10 の 192.168.100.254 АΤ眀腹??眀腹А?
andy ?┮?箇璸秨? /home/andy 倒 andy ㄏノ??產ヘ魁罢?
?狝竟狠砞﹚?龟?簍絤?
???ê或叫??ぃ璶?┏??氮?????笆掸┪??钡????诀竟??笆も????单?眔??璶?氮?ぇ??
??┏??弧???
???碞琌璶?ミ /etc/exports 硂?郎??ず甧舘????硂妓糶??
[root@www ~]# vim /etc/exports
192.168.100.0/24(rw,no_root_squash)
192.168.100.0/24(ro)
*(ro,all_squash)
/home/upload 192.168.100.0/24(rw,all_squash,anonuid=210,anongid=210)
/home/andy
192.168.100.10(rw)
?ㄓ?碞琌璶?ミ–?癸莱?ヘ魁?龟悔 Linux 舦???и?????ㄓ??
[root@www ~]# ll -d /tmp
drwxrwxrwt. 12 root root -27 23:49 /tmp
# 2. /home/nfs
[root@www ~]# mkdir -p /home/nfs
[root@www ~]# chmod 755 -R /home/nfs
# ?э耕?腨??郎?舦?盢ヘ魁籔郎?砞﹚Θ斑弄?ぃ?糶???篈?穦?玂繧?翴?
# 3. /home/upload
[root@www ~]# groupadd -g 210 nfs-upload
[root@www ~]# useradd -g 210 -u 210 -M nfs-upload
# ??ミ癸莱?眀腹籔竤舱?嘿の UID 翅?
[root@www ~]# mkdir -p /home/upload
[root@www ~]# chown -R nfs-upload:nfs-upload /home/upload
# ?э局Τ?????玥ㄏノ?籔ヘ魁?舦?常砞﹚Т讽舘?
# 4. /home/andy
[root@www ~]# useradd andy
[root@www ~]# ll -d /home/andy
drwx------. 4 andy andy -28 00:15 /home/andy
硂妓??ㄓ?舦??拜肈?阀碞??秆∕舘?
?穝币笆 nfs 狝叭?
[root@www ~]# /etc/init.d/nfs restart
? 192.168.100.10 硂场诀竟??簍絤???
# 1. 絋粄环狠?狝竟??ノヘ魁?
[root@clientlinux ~]# showmount -e 192.168.100.254
Export list for 192.168.100.254:
/home/andy
192.168.100.10
/home/upload 192.168.100.0/24
(everyone)
192.168.100.0/24
# 2. ?ミ本更翴?
[root@clientlinux ~]# mkdir -p /mnt/{tmp,nfs,upload,andy}
# 3. 龟悔本更?
[root@clientlinux ~]# mount -t nfs 192.168.100.254:/tmp
[root@clientlinux ~]# mount -t nfs 192.168.100.254:/home/nfs
[root@clientlinux ~]# mount -t nfs 192.168.100.254:/home/upload /mnt/upload
[root@clientlinux ~]# mount -t nfs 192.168.100.254:/home/andy
俱?˙艼?璓?碞琌硂妓???猳翅?
13.5 ?翴?臮
Network FileSystem (NFS) ??琵?诀ぇ丁硓筁呼隔だㄉ┘??郎?籔ヘ魁?
NFS ?璶琌硓筁 RPC ㄓ秈︽ file share ?ヘ??┮? Server 籔 Client ? RPC ?﹚璶币笆?︽?
NFS ?砞﹚郎碞琌 /etc/exports 硂?郎??
NFS ?舦???芠诡 /var/lib/nfs/etab?????璶祅魁郎??把σ /var/lib/nfs/xtab
硂?郎??临???讽?Τノ?戈癟?ㄤい?
NFS ?狝竟籔ノめ狠?ㄏノ?眀腹?嘿?UID 程?璶?璓???磷?舦?岿睹?
NFS ?狝竟箇砞癸ノめ狠? root 秈︽舦?溃罽?硄盽溃罽ㄤΘ? nfsnobody ┪ nobody?
NFS ?狝竟??笆 /etc/exports 硂?郎?ぇ????硓筁 exportfs 硂???ㄓ?穝本更だㄉ?ヘ魁?
??ㄏノ rpcinfo ㄓ芠诡 RPC program ぇ丁?闽玒???
NFS ?狝竟?砞﹚ぇ??碞ゲ斗璶σ納? client 狠祅??舦?拜肈?????礚猭糶?┪?礚猭秈︽だㄉ??璶琌
Linux 龟砰郎??舦?砞﹚拜肈┮璓?
NFS ノめ狠??硓筁ㄏノ showmount, mount 籔 umount ㄓㄏノ NFS ?诀矗ㄑ?だㄉ?ヘ魁?
NFS ョ??ㄏノ本更把计?? bg, soft, rsize, wsize, nosuid, noexec, nodev 单把计?
ㄓ笷?玂臔??郎?╰参?ヘ夹?
?笆本更? autofs 狝叭???ノめ狠惠璶 NFS ?狝竟矗ㄑ?戈方??本更?
13.6 セ彻策肈
NFS ??璶砞﹚郎???τ?赣郎?ず?璶砞﹚兜ヘ???
?璶?砞﹚郎? /etc/exports τ??ㄤ砞﹚?ず甧兜ヘ?–?︽讽い玥??
だㄉ?ヘ魁皐癸?だㄉヘ魁秨???诀┪ IP┪呼办皐癸硂场?诀┮秨??舦?把计?
? NFS ?璶?砞﹚郎讽い度Τぶ砛?把计弧????箇砞?把计弧?玥⊿Τ?赣郎?讽い?瞷?
叫拜??狦璶琩綷?冈灿?だㄉ?ㄓ?郎??妮┦?璶?ê?郎??
/var/lib/nfs/etab
? client 狠?狦璶本更 NFS ┮矗ㄑだㄉ?郎????ㄏノê????
ê?礛碞琌 mount 罢?临Τ?更琌 umount 翅?
? NFS ?璶砞﹚郎讽い???硓筁ê?把计ㄓ北?ぃ琵
client 狠? root ?ō?ㄏノ?┮だㄉ?ㄓ?ヘ魁籔郎??
??? /etc/exports 讽い?把计兜ヘ?砞﹚? root_squash ?ㄓ北?溃罽 root ?ō?翅?
и? client 狠本更? NFS Server ?琘?ヘ魁?и? /home/data
┏??讽и磅︽ㄤい琘?祘Α??玱祇瞷и?╰参砆瘆胊???粄?????????
赣???狝硂妓?拜肈?ぷㄤ琌讽и? Client 狠?诀ㄤ龟琌???ノ?吏挂?
┤ㄤ??ㄏノ???妓祇ネ摸??拜肈㎡??
??パ??本更秈ㄓ? NFS Server ? partition 讽いㄣΤ SUID
?郎?妮┦?τ?ぃ?みㄏノ?赣磅︽郎???碞??穦祇ネ╰参砆瘆胊?拜肈??
??盢本更秈ㄓ? NFS ヘ魁? SUID ?????ㄒ??
??パ??本更秈ㄓ? NFS Server ? partition 讽いㄣΤ SUID
?郎?妮┦?τ?ぃ?みㄏノ?赣磅︽郎???碞??穦祇ネ╰参砆瘆胊?拜肈??
??盢本更秈ㄓ? NFS ヘ魁? SUID ?????ㄒ??
mount -t nfs -o nosuid,ro server:/directory /your/directory
13.7 把σ戈?籔┑?綷弄
爹1?Sun (狜锭) そ??竒砆ヒ癌ゅ (Oracle) そ??ㄖ????そ?呼?э??
尘?硂柑?称??
man exports
man autofs
?材?ΩЧΘ
??э场だず甧???穝糤 LPI ?闽┦籔?翴俱瞶场だ?
???穝?э????の穝糤?诀?砏购单场だ?
?盢侣?ゅ彻簿笆?
???? autofs 单单?戈?翅?
??セ rsize ﹚竡? 8192??程???ㄇゅ膍?莱赣э? 32768 ゑ耕Т讽?
??程???ㄒ簍絤场だ? ?稰谅?
?盢侣?膀? CentOS 4.x ?ゅ彻簿笆?
??璹ЧΘ??ゑ耕??拜肈?? nfsnobody ??Τ??ぃ穦溃罽翅?
?盢膀? CentOS 5.x ?ゅ彻簿笆?
セ呼??璶?
皌?秆猂?
??砞璸ㄌ沮
is designed by

参考资料

 

随机推荐