13-3 14 NFS
生活随笔
收集整理的這篇文章主要介紹了
13-3 14 NFS
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
2019獨角獸企業重金招聘Python工程師標準>>>
14.1 NFS介紹
NFS用于在網絡上共享存儲
- NFS是Network File System的縮寫
- NFS最早由Sun公司開發,分2,3,4三個版本,2和3由Sun起草開發,4.0開始Netapp公司參與并主導開發,最新為4.1版本
- NFS數據傳輸基于RPC協議,RPC為Remote Procedure Call的簡寫。
- NFS應用場景是:A,B,C三臺機器上需要保證被訪問到的文件是一樣的,A共享數據出來,B和C分別去掛載A共享的數據目錄,從而B和C訪問到的數據和A上的一致
NFS原理圖
14.2 NFS服務端安裝配置
服務端與客戶端都需要安裝nfs-util包
[root@axiang-02 ~]# yum install -y nfs-utils [root@axiang-03 ~]# yum install -y nfs-utils新增配置文件(原來沒有)
vim /etc/exports 加入一行: /home/nfstestdir 192.168.133.0/24(rw,sync,all_squash,anonuid=1000,anongid=1000)- 第一段為定義共享的目錄
- 第二段為允許訪問的IP或IP段
- 第三段即括號內容為權限選項
服務端啟動
[root@axiang-02 ~]# mkdir /home/nfstestdir [root@axiang-02 ~]# chmod 777 !$ //方便實驗 chmod 777 /home/nfstestdir[root@axiang-02 ~]# systemctl start rpcbind [root@axiang-02 ~]# systemctl start nfs [root@axiang-02 ~]# systemctl enable rpcbind //開機啟動 [root@axiang-02 ~]# systemctl enable nfs //開機啟動 [root@axiang-02 ~]# netstat -lntp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1/systemd //111端口即rpc監聽端口14.3 NFS配置選項
- rw 讀寫
- ro 只讀
- sync 同步模式,內存數據實時寫入磁盤
- async 非同步模式
- no_root_squash 客戶端掛載NFS共享目錄后,root用戶不受約束,權限很大
- root_squash 與上面選項相對,客戶端上的root用戶收到約束,被限定成某個普通用戶
- all_squash 客戶端上所有用戶在使用NFS共享目錄時都被限定為一個普通用戶
- anonuid/anongid 和上面幾個選項搭配使用,定義被限定用戶的uid和gid
客戶端掛載
安裝完不用設置,需要關閉防火墻。即使放行111端口。所以建議先把兩邊防火墻關掉。即可使用
[root@axiang-02 ~]# iptables -F 或者 systemctl stop firewalld [root@axiang-03 ~]# iptables -F 或者 systemctl stop firewalld [root@axiang-03 ~]# showmount -e 10.1.1.8 Export list for 10.1.1.8: /home/nfstestdir 10.1.1.0/24 [root@axiang-03 ~]# mount -t nfs 10.1.1.8:/home/nfstestdir /mnt [root@axiang-03 ~]# df -h 10.1.1.8:/home/nfstestdir 18G 7.1G 11G 40% /mnt [root@axiang-03 ~]# cd /mnt [root@axiang-03 mnt]# touch 111.txt [root@axiang-03 mnt]# ll 總用量 0 -rw-r--r-- 1 mysql mysql 0 8月 23 15:49 111.txt成功共享存儲。且限定用戶id為1000
[root@axiang-02 ~]# ll /home/nfstestdir/ 總用量 0 -rw-r--r-- 1 mysql mysql 0 8月 23 15:49 111.txt [root@axiang-02 ~]# id mysql uid=1000(mysql) gid=1000(mysql) 組=1000(mysql)轉載于:https://my.oschina.net/u/3579690/blog/1560233
總結
以上是生活随笔為你收集整理的13-3 14 NFS的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Java Web 分页实现
- 下一篇: 你是如何保护用户的密码的?