nfs文件共享

nfs

1.nfs
net file system

2.nfs

yum install nfs-utils -y
systemctl start nfs.server
systemctl stop firewalld

測試:
在客戶端

showmount -e 172.25.254.117

3.配置

mkdir /nfsdir
vim /etc/exports
本集目錄    共享客戶端(共享方式)
/nfsdir  *(sync)
exportfs -rv
測試:在![這裏寫圖片描述](https://img-blog.csdn.net/20180228131227676?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2p3Xzk2MDEyMA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70)
mount 172.25.254.117:/nfsdir /mnt

權限

chmod 777 /nfsdir
vim /etc/exports
/nfsdir  172.25.254.0/24(sync)
/nfsdir  172.25.254.217(rw,anonuid=1001,anongid=1001,no_root_squash)
exportfs -rv        ##刷新

@@@@@@@@@@@@@@@@@
rw:開啓讀寫權限
anonuid=1001:指定用戶
anongid=1001:指定組
no_root_squash:之前的指定用戶和組無效,都以root身份掛載
@@@@@@@@@@@@@@@@@
測試:
在客戶端

mount 172.25.254.117:/nfsdir /mnt   ##掛載(只有在root身份下才能掛載)
touch /mnt/file
ll /mnt

這裏寫圖片描述
這裏寫圖片描述
這裏寫圖片描述
4自動掛載和卸載
在客戶端:

yum install autofs.x86_64 -y
systemctl start autofs
systemctl enable autofs
vim /etc/sysconfig/autofs
TIMEOUT=3       ##爲了方便看到效果設置爲3s
systemctl restart autofs

測試:

cd /net/
cd 172.25.254.117
cd nfsdir/
df
cd /        ##等待3秒
df

這裏寫圖片描述
這裏寫圖片描述
5.自行設置掛載點

vim /etc/auto.master
/mnt /etc/auto.nfs
vim /etc/auto.nfs
westos -ro,vers=3.0 172.25.254.117/nfsdir
systemctl restart autofs.service

測試:

cd /mnt/
cd westos
df
mount
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章