常見問題:
Linux伺服器上,在192.168.0.2上挂載192.168.0.3中的某一目錄,若挂載不成功,可在192.168.0.2上使用service nfs restart 或 /etc/rc.d/init.d/nfs restart指令,重新開機nft服務,便可挂載成功。
有時,192.168.0.3伺服器關機重新開機,但192.168.0.2伺服器仍在運作,導緻挂載在192.168.0.2上的目錄強行丢失,需對192.168.0.2的目錄重新挂載,此時直接使用umount指令,會出現“not found / mounted or server not reachable”錯誤,應使用umount -f /nfs指令,若仍不成功,可使用umount -l /nfs指令。其中/nfs為你在192.168.0.2上挂載的目錄,如我的是/mnt/examWord。
詳見以下網絡收集内容:
【聲明以下内容已經驗證,可以使用】
1.配置nfs
1.1#rpm -qa |grep nfs (查詢系統中是否安裝有nfs包)
2.2 # vi /etc/exports (編譯nfs服務的配置檔案,我要把我的/data目錄共享出來,允許所有網段的使用者可以通路)
/rhome/nfs1 *(rw,async)
2.3.#exportfs –rv(這個指令可以驗證我們設定的配置檔案是 否正确,如果是下面的輸出,就說明是正确的)
[[email protected] ~]# exportfs -rv
exporting *:/rhome/nfs1
或showmount -e localhost
[[email protected] ~]# showmount -e localhost
Export list for localhost:
/rhome/nfs1 *
2.4 # chkconfig --list |grep nfs (這個指令是檢視nfs服務在哪幾種啟動級别會自動啟動)
nfs 0:off 1:off 2:off 3:off 4:off 5:off 6:off
nfslock 0:off 1:off 2:off 3:on 4:on 5:on 6:off
[[email protected] ~]# chkconfig nfs on (為了讓nfs服務在2345這幾個啟動級别都啟動,我執行了這個指令)
[[email protected] ~]# chkconfig --list |grep nfs (現在去檢視一下)
nfs 0:off 1:off 2:on 3:on 4:on 5:on 6:off
2.5 [[email protected] ~]# service nfs restart (現在我們就可以啟動這個服務的,讓我們的配置檔案生效)
安全:配合/etc/hosts.allow與hosts.deny 固定IP通路
2.6 用戶端測試
[[email protected] other]# showmount -e 192.168.0.83
Export list for 192.168.0.83:
/rhome/nfs1 *
3.配置autofs
用autofs實作挂載192.168.0.83:/rhome/nfs1 到本機。
3.1 vim /etc/auto.master
#
/misc /etc/auto.misc
/nfs /etc/auto.home
/rhome /etc/auto.misc
/home /etc/auto.misc
#
# vi /etc/auto.misc
cd -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom下增加這行
nfs1 192.168.0.83:/rhome/nfs1
3.2 #service autofs restart 重新啟動autofs服務
3.3 以nfs1在用戶端登入
ssh [email protected]
成功後[[email protected] ~]$
---------------------------------------------------------------------------
1.服務端和用戶端都需要開啟portmap服務。RCP是nfs mount和umount時通信的方式。
2.假如用戶端portmap沒有啟動,mount時,會非常慢,最終會失敗。umount時,即使本地的portmap是關閉的,也能umount成功。
3.挂載完成後,服務端的portmap停止後,nfs仍然工作正常,但是umout财會提示: not found / mounted or server not reachable。重新開機伺服器的portmap也無濟于事。
4.假如服務端的portmap重新開機了,那麼nfs也要跟着重新開機,否則nfs工作仍然是不正常的。
5.假如服務端nfs關閉(IP是通的),這時用戶端會無法umount,這時使用umount -f /nfs一般能成功,當服務端當機時,umount -f /nfs 有可能會失敗,這時可以使用 umount -l /nfs .
最終建議:
1.使用NFS,就要使用portmap,NFS嚴重依賴于portmap,是以不要試圖去停止它(portmap)。
2.當不能umount /nfs 分區時,試着使用umount -f /nfs,一般都能成功。
3.當umount -f /nfs不能umount時,可以試試umount -l /nfs. umount -l是最終級的umount。
源文檔 <http://blog.chinaunix.net/uid-12115233-id-3260209.html>