標籤:exports 硬碟 rest 防火牆設定 設定檔 伺服器端 相關 exp pkg
1、系統內容
查詢當前系統,安裝對應得版本得 nfs相關軟體;本文系統內容為 Ubuntu 16.04 amd64
# lsb_release -a
?
2、NFS 伺服器端2.1 軟體安裝2.1.1 deb安裝
直接 deb安裝
# dpkg -i *.deb
?
2.1.2 連網安裝
# apt-get install nfs-kernel-server
?
3.2 服務配置3.2.1 防火牆設定
若不需要 防火牆,可直接關閉防火牆
# ufw disable
?
3.2.2 NFS 配置3.2.2.1 設定檔
修改配置,重啟服務
# vim /etc/exports# /etc/init.d/nfs-kernel-server restart## 或者不需要重啟服務,讓配置生效( exportfs -r),用戶端最好重新掛載
?
3.2.2.2 設定檔參數
/opt *(rw,async,fsid=0,no_root_squash,no_subtree_check)
| 參數 |
說明 |
| /opt |
共用目錄 |
| rw |
可擦寫 (read-write) |
| async |
資料會先暫存於記憶體當中,而非直接寫入硬碟 |
| no_root_squash |
用戶端使用 NFS 檔案系統的帳號若為 root 時,系統該如何判斷這個帳號的身份?預設的情況下,用戶端 root 的身份會由 root_squash 的設定壓縮成 nfsnobody, 如此對伺服器的系統會較有保障開放用戶端使用 root 身份來動作伺服器的檔案系統 |
| no_subtree_check |
預設參數 |
| 備忘 |
詳細參見 "man exports" |
?
3.2.3 服務基本操作
查看當前服務共用的目錄
# showmount -e
4、NFS 用戶端4.1 軟體安裝4.1.1 deb安裝
直接 deb安裝
# dpkg -i *.deb
?
4.1.2 連網安裝
# apt-get install nfs-common
?
4.2 NFS用戶端掛載
# mount -t nfs {nfs_server_ip}:{share_path} {mount_path}
| 參數 |
說明 |
| nfs_server_ip |
NFS 伺服器IP |
| share_path |
NFS 伺服器共用目錄 |
| moun_path |
NFS用戶端本地掛載目錄 |
?
4.3 NFS用戶端卸載
# umount {mount_path}
NFS 服務搭建