一 NFS介紹
屬于網絡檔案系統,它是unix,linux标準協定,開源的标準擴充協定,支援nfsv4。NFS傳輸使用的是遠端過程調用RPC機制
二 NFS安裝和配置
yum -y install nfs-utils
yum -y install rpc.mountd portmap
systemctl enable nfs-secure
mkdir /mountpoint
mount serverX:/ /mountpoint
2.檢視
showmount -e serverX
3.nfsmount setup
4.自動挂載autofs
yum -y install autofs
/etc/auto.master.d
vi /etc/auto.master.d/demo.autofs
vi /etc/auto.direct
/mnt/docs -rw,sync,krb2p serverX:/shares/docs
vi /etc/auto.master.d/shares.autofs
/shares /etc/auto.shares
* -rw,sync,sec=krb5p serverX:/shares/&
systemctl enable autofs
systemctl start autofs
5.配置
vi /etc/exports
/myshare server0.example.com
/myshare disk(rw,no_root_squash)
systemctl start nfs-server
exportfs -r
firewall-cmd --permanent --add-service=nfs
firewall-cmd --reload
5.2 參考指令
ro 隻讀
rw 讀寫
sync 所有資料在請求時寫入共享
async NFS在寫入資料前可以相應請求
secure NFS通過1024以下的安全TCP/IP端口發送
insecure 1024以上
wdelay 如果多個使用者要寫入NFS目錄,則規組寫入預設
no_wdelay
hide 在NFS共享目錄中不共享子目錄
no_hide 共享NFS目錄的子目錄
subtree_check 如果共享/usr/bin之類的子目錄時,強制檢查權限
all_squash 共享檔案的UID和GID映射到匿名使用者,适合公共目錄
no_all_squash 保留共享檔案的UID和GID
root_squash root所有請求映射成如 anonymouns
anonuid=xxx 指定NFS伺服器passwd檔案的匿名ID
三 NFS案例
案例:nfs伺服器共享了3個目錄,一個是 share,一個是data,一個是public,需要按照下面要求實作相應功能:
a 釋出share目錄,所有都可以讀寫
b 釋出data目錄,隻允許oracle使用者可以讀寫
c 釋出public,所有人隻可以讀,無法寫
四 NFS 性能
4.1 使用測試工具做性能測試
iozone
fio
五 NFS 高可用
六 問題
6.1 nfs自啟動是否可以放入到fstab裡面
本文轉自 woshiwei201 51CTO部落格,原文連結:http://blog.51cto.com/chenwei/1841963