NFS 文件共享

備註:NFS 文件共享需設置兩部分:服務端和客戶端

一、服務端設置

1.1、查看nfs包是否安裝,未安裝則重新安裝

NFS 文件共享

[root@localhost ~]# rpm -qa|grep rpcbindrpcbind-0.2.0-42.el7.x86_64[root@localhost ~]# rpm -qa|grep nfs-utilsnfs-utils-1.3.0-0.48.el7.x86_64

-------------------------------------------------

yum -y install nfs-utils rpcbind

NFS 文件共享

1.2、創建共享目錄並賦予權限

<code>[root@localhost home]# mkdir /home/{gong,xiang}
[root@localhost home]# chmod -R 755 /home/gong/ /home/xiang//<code>

1.3、修改共享配置文件

格式為:【 共享路徑 客戶端主機 (選項) 】 或 【共享路徑 客戶端主機1 (選項) 客戶端主機2 (選項) 】

<code>[root@localhost home]# vi /etc/exports
/home/gong 192.168.43.11(rw,no_root_squash)
/home/xiang *(ro,sync)/<code>

1.4、啟動NFS服務,若不成功則執行 service nfs restart

<code>[root@localhost home]# systemctl start rpcbind
[root@localhost home]# systemctl start nfs-utils/<code>

二、客戶端部分設置

2.1、通過showmount查看共享信息,若報錯則重啟nfs服務(centos7.4以後適用)

NFS 文件共享

<code>[root@localhost ~]# systemctl restart nfs-utils
[root@localhost ~]# showmount -e 192.168.43.12
clnt_create: RPC: Program not registered
[root@localhost ~]#
[root@localhost ~]# service nfs restart
Redirecting to /bin/systemctl restart nfs.service
[root@localhost ~]#
[root@localhost ~]# showmount -e 192.168.43.12
Export list for 192.168.43.12:
/home/xiang *
/home/gong 192.168.43.11/<code>
NFS 文件共享

2.2、在客戶端設置掛載目錄,最好是相同的,方便記憶。也可以是不同的

格式為:mount NFS服務器IP:共享目錄 本地掛載點目錄

<code>[root@localhost ~]# mount 192.168.43.12:/home/gong/  /home/gong/
[root@localhost ~]# mount 192.168.43.12:/home/xiang/ /home/xiang//<code>

2.3 查看共享信息

<code>[root@localhost home]# ls /home/gong/ /home/xiang/
/home/gong/:
ifcfg-ens33

/home/xiang/:
ifcfg-ens33/<code>


3、常見問題分析:

3.1、防火牆問題

系統會提示:xxxx:errno 113 (No route to host) 說明端口被防火牆屏蔽,需開放2049端口

<code>[root@localhost ~]# showmount -e 192.168.43.12
clnt_create: RPC: Port mapper failure - Unable to receive: errno 113 (No route to host)/<code>

3.2、掛載錯誤

系統提示No such file or directory,說明服務器上沒有相應的掛載點,檢查掛載點

----------結束


分享到:


相關文章: