NFS
Net File System
NFS基本信息
- 安裝包:nfs-utils
- 服務腳本:
nfs-server
- 共享配置文件:
/etc/exports
NFS的啓用
systemctl start nfs-server
開啓服務firewall-cmd --permanent --add-service=rpc-bind
firewall-cmd --permanent --add-service=mountd
firewall-cmd --permanent --add-service=nfs
firewall-cmd --reload
設置火牆
- rpc-bind----->mountd----->nfs-server(流程)
- rpc-bind:分配端口
- nfs:驗證你的客戶端是由有資格共享文件
測試: showmount -e 192.168.1.20
192.168.1.20是本主機的ip
NFS配置
vim /etc/exports
此文件更改後生效exportfs -rv
這裏不使用restart的方式- 共享目錄 共享給誰(共享參數)
- /westosdir *(ro)
- 測試:
mount 192.168.1.20:/westosdir /mnt/
NFS配置參數
anonuid=1000,anongid=1000
指定用戶身份(uid和gid可通過id 用戶名 查看)sync
更改生成後同步數據到服務器async
時時同步數據到服務器rw
讀寫ro
只讀no_root_squash
root用戶掛載不轉換身份
nfs+autofs
- 參看autofs章節內容
vim /etc/auto.master
(在客戶端)
vim /etc/auto.nfs
nfs 192.168.0.30:/westosdir
- 注意:nfs格式與samba不同
- nfs:
nfs 192.168.1.20:/westosdir
- samba -fstype=cifs,username=westos,password=westos://192.168.1.30/
westosdir