架设一台NFS服务器

 1、开放/nfs/shared目录,供所有用户查询资料
2、开放/nfs/upload目录,为192.168.xxx.0/24网段主机可以上传目录,
并将所有用户及所属的组映射为nfs-upload,其UID和GID均为210
3、将/home/tom目录仅共享给192.168.xxx.xxx这台主机,并只有用户tom对该目录有读写权限
 

服务器:192.168.137.130 

配置文件 

[root@10 ~]# rpm -qa | grep nfs-utils
nfs-utils-2.5.4-15.el9.x86_64
[root@10 ~]# vim /etc/exports
[root@10 ~]# cat /etc/exports
/nfs/shared  *(ro)
/nfs/upload  192.168.137.0/24(rw,anonuid=210,anongid=210)
/home/tom  192.168.137.132(rw)

创建共享目录以及用户tom

[root@10 ~]# mkdir  /nfs/upload -pv
mkdir: created directory '/nfs/upload'
[root@10 ~]# mkdir  /nfs/shared -pv
[root@10 ~]# useradd tom

组映射为nfs-upload,其UID和GID均为210

[root@10 ~]# useradd -r -u 210 nfs-upload

配置生效

[root@10 ~]# exportfs -ra

  设备:192.168.137.132

创建文件,挂载共享文件

[root@localhost ~]# mkdir /test{1..3}
[root@localhost ~]# mount 192.168.137.130:/nfs/shared   /test1
[root@localhost ~]# mount | grep /test1
192.168.137.130:/nfs/shared on /test1 type nfs4 (rw,relatime,vers=4.2,rsize=262144,wsize=262144,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=192.168.137.132,local_lock=none,addr=192.168.137.130)

挂载,测试创建文件设备端没权限 

[root@localhost ~]# mount 192.168.137.130:/nfs/upload   /test2
[root@localhost ~]# cd /test2
[root@localhost test2]# touch  1
touch: cannot touch '1': Permission denied

在服务端开启权限

[root@10 ~]# chmod  o+w /nfs/upload/

在设备上测试权限创建文件

[root@localhost test2]# touch 1

挂载test3

[root@localhost test2]# mount 192.168.137.130:/home/tom   /test3
[root@localhost test2]# mount | grep /test3
192.168.137.130:/home/tom on /test3 type nfs4 (rw,relatime,vers=4.2,rsize=262144,wsize=262144,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=192.168.137.132,local_lock=none,addr=192.168.137.130)

设备上创建tom用户测试权限

[root@localhost test2]# useradd tom
[root@localhost test2]# id tom
uid=1001(tom) gid=1001(tom) groups=1001(tom)
[root@localhost test2]# su - tom
[tom@localhost ~]$ ll /test3
total 0
[tom@localhost ~]$ touch /test3/1

光盘的挂载

[root@localhost test2]# vim /etc/fstab

192.168.137.130:/home/tom      /test3    nfs4           defaults,sync   0 0    
/dev/sr0                       /mnt      iso9660        defaults        0 0 
~

预挂载

[root@localhost test2]# vim /etc/fstab
[root@localhost test2]# mount -a
mount: /mnt: WARNING: source write-protected, mounted read-only.
[root@localhost test2]# reboot
[root@localhost test2]# Connection closing...Socket close.

挂载信息

/dev/nvme0n1p1 on /boot type xfs (rw,relatime,seclabel,attr2,inode64,logbufs=8,logbsize=32k,noquota)
/dev/sr0 on /mnt type iso9660 (ro,relatime,nojoliet,check=s,map=n,blocksize=2048)


192.168.137.130:/home/tom on /test3 type nfs4 (rw,relatime,sync,vers=4.2,rsize=262144,wsize=262144,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=192.168.137.132,local_lock=none,addr=192.168.137.130)

挂载成功

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

光!!

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值