NFS相关练习

题目
1、开放/nfs/shared目录,供所有用户查询资料
2、开放/nfs/upload目录,供所有用户上传下载资料

检查是否安装对应包

[root@server1 ~]# rpm -qa | grep nfs
[root@server1 ~]# rpm -qa | grep rpc

关闭防火墙和selinux

[root@server ~]# systemctl stop firewalld
[root@server ~]# setenforce 0

启动NFS服务

[root@server1 ~]# systemctl start nfs-server

开放/nfs/shared目录,供所有用户查询资料

服务端:

[root@server1~]# mkdir -pv /nfs/shared							#创建共享目录
[root@server1 ~]# cd /nfs/shared/
[root@server1 shared]# touch test1								#创建共享文件
[root@server1 shared]# echo "this is a test" > /nfs/shared/test1
[root@server1 shared]# vim /etc/exports							#编辑配置文件
						/nfs/shared     *(ro)
		
[root@server1 shared]# systemctl restart nfs-server.service		#重新启动服务	
[root@server1 shared]# showmount  -e  192.168.210.129				#查看共享内容
Export list for 192.168.210.129:
/nfs/shared *

客户端:

[root@localhost ~]# showmount -e 192.168.210.129
Export list for 192.168.210.129:
/nfs/shared *
[root@localhost ~]# mkdir -pv /nfs/shared							#创建存放共享文件的目录
[root@localhost ~]# mount 192.168.210.129:/nfs/shared  /nfs/shared/	#把共享文件挂载到指定的共享文件目录中
[root@localhost ~]# cd /nfs/shared/
[root@localhost shared]# ll
总用量 4
-rw-r--r--. 1 root root 15 1124 13:20 test1
[root@localhost shared]# cat test1
this is a test
[root@localhost shared]# touch file1
touch: 无法创建 'file1': 只读文件系统

开放/nfs/upload目录,供所有用户上传下载资料

服务端:

[root@server1 ~]# mkdir -pv /nfs/upload
[root@server1 ~]# cd /nfs/upload
[root@server1 upload]# touch test1
[root@server1 upload]# ll
总用量 0
-rw-r--r--. 1 root root 0 Nov 24 13:26 test1
[root@server1 upload]# echo "my name is czc" > test1
[root@server1 upload]# vim /etc/exports
/nfs/upload     192.168.210.0/24(rw,all_squash,anonuid=1001,anongid=1001)
[root@server1 upload]# useradd -u 1001 -g 1001 nfs-upload
[root@server1 upload]# systemctl restart nfs-server.service
[root@server1 upload]# showmount -e localhost
Export list for localhost:
/nfs/upload 192.168.210.0/24

[root@server1 upload]# chmod o=rwx /nfs/upload/
[root@server1 upload]# ll
总用量 4
-rw-r--r--. 1 nfs-upload nfs-upload  0 1124 13:30 file
-rw-r--r--. 1 root       root       16 1124 13:26 test1

客户端:

[root@localhost ~]# mkdir  -pv /nfs/upload
[root@localhost nfs]# mount 192.168.210.129:/nfs/upload   /nfs/upload/
[root@localhost upload]# cat test1
my name is czc
[root@localhost upload]# touch file
[root@localhost upload]# ll
总用量 4
-rw-r--r--. 1 1001 1001  0 1124 13:30 file
-rw-r--r--. 1 root root 16 1124 13:26 test1
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值