NFS(Network File System)讓主機間能共享檔案。服務端需安裝 nfs-utils 與 rpcbind 兩個套件,其中 rpcbind 負責支援客戶端與服務端的通訊(在 CentOS5 上稱為 portmap),客戶端則安裝 nfs-utils 即可。
從客戶端訪問伺服器時出現:
clnt_create: RPC: Program not registered
在伺服器上依序停止再啟動服務,順序一定要正確:先停 rpcbind,再停 nfs,然後依序啟動 rpcbind 與 nfs。
/etc/init.d/rpcbind stop /etc/init.d/nfs stop /etc/init.d/rpcbind start /etc/init.d/nfs start
完成後即可正常訪問。可用 showmount 查看共享清單:
[root@Localhuang ~]# showmount -e 192.168.1.118 Export list for 192.168.1.118: /usr/local/src 192.168.1.119
接著掛載共享目錄並用 df 驗證:
[root@Localhuang ~]# mount -t nfs -o nolock,nfsvers=3 192.168.1.118:/usr/local/src/ /mnt [root@Localhuang ~]# df Filesystem 1K-blocks Used Available Use% Mounted on 192.168.1.118:/usr/local/src/ 18344832 6753792 10652544 39% /mnt
可見掛載成功,NFS 共享已可正常使用。