NFS
NFS,網絡檔案系統。一個系統在網絡上與他人共享目錄和檔案。通過使用NFS,使用者和程式可以像通路本地
檔案一樣通路系統上的檔案。
用途:共享檔案
優點:節省磁盤空間
組成:一台伺服器和一台或多台客戶機
1.安裝、開啟
[root@server ~]# systemctl start nfs
[root@server ~]# systemctl start nfs 開啟服務
添加防火牆政策
列出防火牆狀态
2.共享目錄
[root@server ~]# mkdir /public/nfs -p ##建立共享目錄
[root@server ~]# mkdir /public/nfs/file ##建立共享檔案
[root@server ~]# vim /etc/exports
[root@server ~]# exportfs -rv
exporting *:/public/nfs
exports内容
測試
(用戶端)
挂載
3.autofs(自動挂載工具)
當有需求的時候直接進入/net 就自動挂載成功
安裝、開啟(用戶端)
[root@client ~]# yum install autofs.x86_64 -y
[root@client ~]# systemctl start autofs
檢視autofs的根目錄
自動挂載到/net下
[root@client nfs]# vim /etc/auto.master
永久性挂載
[root@client nfs]# vim /etc/auto.nfs
[root@client nfs]# systemctl restart autofs.service
4.共享目錄的一些配置
給共享目錄權限
服務端(117主機)中exports /public/nfs *(sync,rw) ##共享給所有人可讀可寫
[root@server ~]# vim /etc/exports
[root@server ~]# exportfs -rv ##将剛編輯内容重新整理并加載
測試(測試主機中)
服務端(117主機)中exports /public/nfs 172.25.254.0/24(sync) ##共享給172.25.254.0/24網段隻讀
服務端(117主機)中exports /public/nfs *(sync,no_root_squash,rw) ##共享給所有人,當客戶段使用root挂載不轉換使用者身份
服務端(117主機)中exports /public/nfs *(sync,rw,anonuid=1001,anongid=1001) ##共享給uid=1001,gid=1001的使用者可讀寫
本文轉自 無緣 51CTO部落格,原文連結:http://blog.51cto.com/13352594/2050474