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
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值