★ Noted : 當client mount 到一個路徑,絕對不是說copy server上的這一個路徑 到local的機器上,我們可以用 cd 進入這一個mount到的路徑,就如同是使用 local directory一樣
□ Setting Up a NFS Server 1. 定義機器為 NFS file server 2. 劃分server's disk ,定義哪一些partitions 是要提供出來作為 client 所共享的file system 3. 在 Client Form 上定義每一臺client 的參數(shù) 4. 寫出 /etc/exports (一般系統(tǒng)都有一個default exports) 5. 重新boot NFS server or 用指令 exportfs -a 輸出所有的 directories 并且用 nfsd 8 & 啟動 nfsd守護程式,常駐在背景
For example : exportfs -a 把exports中的路徑全部export出去 exportfs -o access=engineering:other /usr /usr 這路徑export後只有engineering and other 這兩個 group 能夠 read & write exportfs -o access=oak,ro=dancer /usr 設(shè)定dancer 這臺client 對 /usr 為read only ,且只有 oak這一個 group 能做read
● syntax : mount -t type [-rv] -o [option] server:pathname /mount_point MOUNT : mount -a 把/etc/fstab 中所列的路徑全部掛上 mount -o ro,soft,bg dancer:/usr/local /usr/local/dancer 把dancer server 的/usr/local mount 到 client的 /usr/local/dancer 并且是read only
-t type : 你所要mount的型別, 如 nfs or 4.2 -r : 所mount的路徑定為read only -v : mount過程的每一個動作,都有messages 傳回到螢幕上 hard : 重復要求,直到server回應為止,但如server一直不回應 the server may be down ! soft : 當client的請求得不到回應,retry one time 後 傳回 error message bg : 當?shù)谝淮握埱蟛怀晒?第二次的mount將放到背景執(zhí)行 fg : retries mount 都一直在提示符號下進行 intr : 當正在進行 NFS 請求時,允許用鍵盤中斷
mount 成功時的message NFS server hostname ok mount fail NFS server hostname not responding, still trying . . .hostname server not reponding: RPC: Timed out
§ UNMOUNT :
umount mount_point umount -a 卸下所有已經(jīng)mount上的路徑
1. 用 rpcinfo -p server_name 去查看此server是否存在 2. 用 rpcinfo -u server_name mount 查看mountd daemon 是否有 在server上執(zhí)行 3. 假如server 都沒問題,檢查 server 和 client 之間的 Ethernet connetions 4. 在client 上 用 ps ax 看portmap and several biod daemons running or not ! (rpcinfo : 用來對 RPC server 做 RPC 呼叫,回傳遠端程序呼叫 過程中的訊息)
一些mount 失敗的錯誤訊息
1. /etc/mtab : No such file or directory mtab 這一個路徑或是檔案必須存在,在mount之前 2. mount : ... Block device required 遠端的機器名稱可能打錯了 3. mount: ... not found in /etc/fstab fstab 一定要存在,client 上 /etc下 4. ... not in hosts database /etc/hosts 沒有這一個 hosts database , 或是 NIS 的daemon, ypbind 沒有在執(zhí)行 5. Must be root to use mount 一般都只有 root 才能mount ,所以mount之前先成 為superuser 6. Stale NFS file handle 當我們已經(jīng)mount 上的file or directory ,在server 上突然被remove or unexport ,就會出現(xiàn)此訊息