Linux 之 nfs 文件系统

一、nfs文件系统的安装和启用

nfs服务:(network file system)linux或unix系统之间实现资源的共享

本是思想:linuxA下/share文件夹,linuxB可以利用挂载(mount)机制将linuxA系统中的/share文件夹挂在到linuxB中,从而实现资源的共享。

[root@server ~]# yum install nfs-utils -y
[root@server ~]# systemctl start nfs
[root@server ~]# systemctl stop firewalld

这里写图片描述

[root@client ~]# yum install nfs-utils -y
[root@client ~]# showmount -e 172.25.254.229    ##查看nfs共享状态
Export list for 172.25.254.229:

这里写图片描述

二、配置共享

1.只读权限

[root@server ~]# vim /etc/exports
写入:
  1 /mnt   *(sync,ro)    ##只读
[root@server ~]# exportfs -rv   ##刷新
exporting *:/mnt

这里写图片描述
这里写图片描述

[root@client ~]# umount /mnt/
[root@client ~]# mount 172.25.254.229:/mnt/ /mnt/
[root@client ~]# df
Filesystem          1K-blocks    Used Available Use% Mounted on
/dev/vda1            10473900 3182752   7291148  31% /
devtmpfs               469344       0    469344   0% /dev
tmpfs                  484932      80    484852   1% /dev/shm
tmpfs                  484932   12776    472156   3% /run
tmpfs                  484932       0    484932   0% /sys/fs/cgroup
/dev/mapper/vg0-vo     483670    2357    451822   1% /home
172.25.254.229:/mnt  10473984 3158400   7315584  31% /mnt
[root@client ~]# cd /mnt/
[root@client mnt]# ls
fiel1
[root@client mnt]# ll
total 0
-rw-r--r-- 1 root root 0 Jun  2 02:52 fiel1    ##只读
[root@client mnt]# 

这里写图片描述

2.读写权限

[root@server ~]# vim /etc/exports
写入:
  1 /mnt   *(sync,rw)    ##读写

[root@server ~]# exportfs -rv
exporting *:/mnt

这里写图片描述
这里写图片描述

[root@client ~]# mount 172.25.254.229:/mnt/ /mnt/
[root@client ~]# cd /mnt/
[root@client mnt]# ls
fiel1
[root@client mnt]# touch file2
touch: cannot touch ‘file2’: Permission denied     

这里写图片描述
在server: chmod 777 /mnt/
这里写图片描述

[root@client mnt]# touch file2
[root@client mnt]# ll
total 0
-rw-r-
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值