Linux下通過NFS共享資料夾

chy710發表於2016-06-15

測試環境:CentOS 6.7

 

服務端

# yum -y install nfs-utils rpcbind


# 開啟服務
service nfs start
service rpcbind start

# 配置
nano /etc/exports
# 配置檔案內容
/home/filesrv 10.1.8.*(rw,sync)

# 配置生效
exportfs -r

# 檢查
showmount -e

# 共享資料夾的許可權
chmod 777 /home/filesrv

# 所用到的埠
rpcinfo -p

# 新增允許埠到iptables或關閉iptables
#
 重要 此伺服器不暴露在公網時或只能通過內網IP訪問時這樣做,否則不建議這樣做。
iptables -A INPUT -p tcp --dport 111 -j ACCEPT
iptables -A INPUT -p udp --dport 111 -j ACCEPT
........

客戶端

# 檢查服務端共享情況
showmount -e 10.1.8.25

# 掛載共享資料夾到本機

mount -t nfs 10.1.8.25:/home/filesrv /home/fileapp 

這樣就可以在本機操作/home/fileapp下的檔案,讀寫均可。

其實就是一個對映,對此資料夾下的操作對應的就是操作共享資料夾,像是windows上的對映網路驅動器一樣。

相關文章