linux文件共享NFS详细操作(企业级)

版权声明:皆为本人原创,复制必究 https://blog.csdn.net/m493096871/article/details/84488276

服务端

yum install nfs-utils -y

systemctl start nfs-server

/westos     *(sync,ro)    表示共享/westos  后面分别是 实时同步和只读权限

exportfs -rv   刷新

客户端

yum install nfs-utils -y

上面进行完刷新操作后

showmount -e 172.25.254.113

也可以直接挂载

mount 172.25.254.113:/westos  /mnt

这时安装自动挂载

yum install autofs.x86_64  -y

systemctl start autofs

cd /net/172.25.254.113/westos 

只要进去一次  就会自动挂载  这时df就会出现

默认过300秒 不访问挂载的地址时自动umount

这里进入  /etc/sysconfig/autofs

修改  TIMEOUT=300   ->5  变成五秒无访问自动取消卸载

即可

设置自动挂载

vim /etc/auto.master

vim /etc/auto.pub

然后

systemctl restart autofs.service

这时候就可以进入     cd  /pub/westos  

就df  就可以显示自动挂载了

修改权限,限定指定用户等的操作


vim /etc/exports
  *(sync,rw,no_root_squash)     不指定root用户
 *(sync,rw,anonuid=1001,anongid=1000)     指定特定用户,组
  172.25.254.100(sync,rw,anonuid=1001,anongid=1000) *(ro)
  表示100是读写,其他人只读,空格表示分开写
  *.westos.com(sync,rw,anonuid=1001,anongid=1000)
  这时需要dns解析
 172.25.254.0/24(sync,rw,anonuid=1001,anongid=1000) *(ro)


  表示这个网段的有读写权限,其他人只读权限
改完之后  exportfs -rv  刷新以下配置
 showmount -e 172.25.254.113 查看状态
你还需要(如果不能写文件)
/etc/auto.master
vim /etc/auto.pub
改为读写权限才行

猜你喜欢

转载自blog.csdn.net/m493096871/article/details/84488276