Linux_NFS

一、NFS服务

  NFS:网络文件系统,是Unix系统和网络附加存储文件管理常用的文件系统,允许多个客户端通过网络共享文件访问;

二、NFS管理

 实验环境:

在server(server)服务端:172.25.254.216

在desktop(client)客户端:172.25.254.166

<1>以只读权限数据同步的方式共享文件系统

在server

[root@server ~]# systemctl start nfs

[root@server ~]# systemctl status nfs

[root@server ~]# vim /etc/exports##配置nfs主配置文件

/mnt  *(sync,ro)##共享给所有人并有只读权限

[root@server ~]# exportfs -rv##使其生效

在desktop

[root@client ~]# mount 172.25.254.216:/mnt/ /mnt##挂载/mnt 至/mnt

[root@client ~]# df

[root@client ~]# cd /mnt

[root@client mnt]# rm -fr *

<2>以读写权限数据同步的方式共享文件系统

 在server

[root@server ~]# vim /etc/exports

/mnt  *(sync,rw)

[root@server ~]# exportfs -rv

exporting *:/mnt

[root@server ~]# chmod 777 /mnt##给满权限为了实验方便

在desktop

[root@client ~]# mount 172.25.254.216:/mnt/ /mnt/

[root@client ~]# cd /mnt/

<3>以root身份登陆

在server
[root@server ~]# vim /etc/exports

/mnt  *(sync,rw,no_root_squash)##匿名用户以root身份读写同步

[root@server ~]# exportfs -rv

在desktop

<4>以uid,gid的身份同步数据

在server
[root@server ~]# vim /etc/exports

/mnt  *(sync,rw,anonuid=1000,anongid=1000)##所有用户以uid=1000,gid=1000的身份读写同步。

[root@server ~]# exportfs -rv

在desktop

<5>对不同ip设定不同权力

在server

[root@server ~]# vim /etc/exports

/westos 172.25.254.0/24(sync) 172.25.254.250(sync,rw)##172.25.254.0/24##只能同步,172.25.254.250读写同步。

[root@server ~]# exportfs -rv

在desktop

在主机

三.自动挂载和取消挂载

在server

在dekstop

[root@client ~]# yum install autofs -y##安装自动挂载软件

[root@client ~]# cd /net

-bash: cd: /net: No such file or directory

[root@client ~]# systemctl start autofs##启动服务后,根目录下生成net目录,进入根目录,

[root@client ~]# cd /net

[root@client net]# cd 172.25.254.216##可直接进入到挂载目录

root@client ~]# vim /etc/sysconfig/autofs

TIMEOUT=5##修改退出目录后自动挂载的等待时间

[root@client ~]# systemctl  restart autofs.service ##重启服务

[root@client ~]# cd /net/

[root@client net]# ls

[root@client net]# cd 172.25.254.216

[root@client 172.25.254.216]# cd westos/

[root@client westos]# df


[root@client ~]# df##等5秒自动卸载

四.改变自动挂载点

[root@client ~]# cd /net

[root@client net]# cd 172.25.254.216

[root@client 172.25.254.216]# ls

westos

[root@client 172.25.254.216]# cd westos/

[root@client westos]# vim /etc/auto.master##写入上层目录/nfs/etc/auto.westos

[root@client westos]# vim /etc/auto.westos##写入挂载点,挂载方式和指定挂载目录

westos  -rw,vers=3  172.25.254.216:/westos

[root@client westos]# mount##可以看到自己设定的参数

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值