当前位置:网站首页>NFS协议(练习题)

NFS协议(练习题)

2022-11-24 21:38:51Jeff657

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

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

服务端:

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

客户端:

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

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

服务端:

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

[[email protected] upload]# chmod o=rwx /nfs/upload/
[[email protected] 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

客户端:

[[email protected] ~]# mkdir  -pv /nfs/upload
[[email protected] nfs]# mount 192.168.76.132:/nfs/upload   /nfs/upload/
[[email protected] upload]# cat test1
my name is jeff
[[email protected] upload]# touch file
[[email protected] 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
原网站

版权声明
本文为[Jeff657]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_56105279/article/details/127889136

随机推荐