[root@centos goldfive5]# rpm -qa | grep nfs =>檢查系統是否安裝NFSlibnfsidmap-0.25-19.el7.x86_64nfs-utils-1.3.0-0.54.el7.x86_64[root@centos goldfive5]# rpm -qa | grep rpcbind =>檢查系統是否安裝RPCrpcbind-0.2.0-44.el7.x86_64[root@centos goldfive5]# yum install nfs-utils -y =>若系統未安裝時vim /etc/exports/tmp 192.168.100.0/24(ro) localhost(rw) *.ev.ncku.edu.tw(ro,sync)[分享目錄] [第一部主機(權限)] [可用主機名] [可用萬用字元]Aug 28 08:15:36 centos systemd: Mounted NFSD configuration filesystem.Aug 28 08:15:36 centos systemd: Starting NFS Mount Daemon...Aug 28 08:15:36 centos systemd: Started NFS Mount Daemon.Aug 28 08:15:36 centos systemd: Starting NFS server and services...Aug 28 08:15:36 centos rpc.mountd[8894]: Version 1.3.0 startingAug 28 08:15:36 centos kernel: NFSD: starting 90-second grace period (net ffffffffa70fc9c0)Aug 28 08:15:36 centos systemd: Started NFS server and services.Aug 28 08:15:36 centos systemd: Starting Notify NFS peers of a restart...Aug 28 08:15:36 centos sm-notify[8917]: Version 1.3.0 startingAug 28 08:15:36 centos systemd: Started Notify NFS peers of a restart.tcp 0 0 0.0.0.0:51069 0.0.0.0:* LISTEN 8880/rpc.statd ***以下省略*****選項與參數:-p :針對某 IP (未寫則預設為本機) 顯示出所有的 port 與 porgram 的資訊;-t :針對某主機的某支程式檢查其 TCP 封包所在的軟體版本;-u :針對某主機的某支程式檢查其 UDP 封包所在的軟體版本; program vers proto port service 100000 4 tcp 111 portmapper 100000 3 tcp 111 portmapper***以下省略*****針對 nfs 這個程式檢查其相關的軟體版本資訊 (僅察看 TCP 封包)[root@www ~]# rpcinfo -t localhost nfs選項與參數:-a :顯示目前主機與用戶端的 NFS 連線分享的狀態;-e :顯示某部主機的 /etc/exports 所分享的目錄資料。Export list for localhost:/tmp (everyone)選項與參數:-a :全部掛載(或卸載) /etc/exports 檔案內的設定-r :重新掛載 /etc/exports 裡面的設定,此外,亦同步更新 /etc/exports 及 /var/lib/nfs/xtab 的內容!-u :卸載某一目錄-v :在 export 的時候,將分享的目錄顯示到螢幕上!exporting 192.168.100.10:/home/testexporting 192.168.100.0/24:/home/publicexporting *.centos.vbird:/home/linuxexporting *:/home/publicexporting *:/tmp# 這時如果你再使用 showmount -e localhost 就會看不到任何資源了!1.先『關掉 rpcbind 與 nfs 』這兩個東西!
[root@centos goldfive5]# systemctl stop nfs[root@centos goldfive5]# systemctl stop rpcbindWarning: Stopping rpcbind.service, but it can still be activated by: rpcbind.socket如果無法正確的將這兩個 daemons 關掉,那麼先以 netstat -utlp 找出 PID ,然後以 kill 將他關掉先!這樣才有辦法正常的關機成功喔!這個請特別特別的注意呢!
當然啦,你也可以利用 showmount -a localhost 來查出來那個用戶端還在連線? 或者是查閱 /var/lib/nfs/rmtab 或 xtab 等檔案來檢查亦可。
3. 建立掛載點,並且實際掛載看看囉!# 注意一下掛載的語法!『 -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檔案系統 1K-區段 已用 可用 已用% 掛載點....(中間省略)....192.168.100.254:/home/public 7104640 143104 6607104 3% /home/nfs/public[root@clientlinux ~]# umount /home/nfs/publicmount -t nfs -o nosuid,noexec,nodev,rw,bg,soft,rsize=32768,wsize=32768 \192.168.100.254:/home/public /home/nfs/public/home/nfsfile /etc/auto.nfs */home/nfsfile/public 是不需要事先建立的!
[本地端次目錄] [-掛載參數] [伺服器所提供的目錄]temp -rw,bg,soft,rsize=32768,wsize=32768 192.168.100.254:/tmp