NFS协议(练习题)

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

#客户端和服务端都需要安装相应的软件包:
[root@localhost ~]# yum  install -y nfs-utils		
[root@localhost ~]# yum  install -y rpcbind

服务端:

#服务端:
[root@localhost ~]# systemctl stop firewalld.service				#关闭防火墙
[root@localhost ~]# setenforce 0									#关闭SELinux
[root@localhost ~]# mkdir -pv 
[root@localhost ~]# mkdir -pv /nfs/shared							#创建共享目录
[root@localhost shared]# touch test1								#创建共享文件
[root@localhost shared]# echo "this is a test" > /nfs/shared/test1
[root@localhost shared]# vim /etc/exports							#编辑配置文件
						/nfs/shared     *(ro)
						
[root@localhost shared]# systemctl restart nfs-server.service		#重新启动服务	
[root@localhost shared]# showmount  -e  192.168.76.132				#查看共享内容
Export list for 192.168.76.132:
/nfs/shared *

客户端:

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

2、开放/nfs/upload目录,该目录为192.168.76.0/24网段的主机的数据上传目录,并将所有该网段主机上
传文件的所属者和所属组映射为nfs-upload,其UID和GID为2001;

服务端:

[root@localhost ~]# mkdir -pv /nfs/upload
[root@localhost upload]# touch test1
[root@localhost upload]# ll
总用量 0
-rw-r--r--. 1 root root 0 1116 18:21 test1
[root@localhost upload]# echo "my name is jeff" > test1
[root@localhost upload]# vim /etc/exports
/nfs/upload     192.168.76.0/24(rw,all_squash,anonuid=2001,anongid=2001)
[root@localhost upload]# useradd -u 2001 nfs-upload
[root@localhost upload]# systemctl restart nfs-server.service
[root@localhost upload]# showmount -e localhost
Export list for localhost:
/nfs/upload 192.168.76.0/24

[root@localhost upload]# chmod o=rwx /nfs/upload/
[root@localhost upload]# ll
总用量 4
-rw-r--r--. 1 nfs-upload nfs-upload  0 1116 18:26 file
-rw-r--r--. 1 root       root       16 1116 18:21 test1

客户端:

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值