nfs服务

本文详细介绍如何手动搭建NFS服务器,包括开放共享目录供查阅资料,以及为特定网段提供数据上传目录,并设置用户权限映射。服务端与客户端的具体操作步骤也一并给出。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.手动搭建一个nfs服务器

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

服务端
[root@hanyuce ~]# vim /etc/exports
[root@hanyuce ~]# systemctl stop firewalld
[root@hanyuce ~]# systemctl disable firewalld
[root@hanyuce ~]# setenforce 0
setenforce: SELinux is disabled
[root@hanyuce ~]# vi /etc/selinux/config 
[root@hanyuce ~]# systemctl restart nfs-server
[root@hanyuce ~]# mkdir nfs
[root@hanyuce ~]# cd nfs
[root@hanyuce nfs]# mkdir shared



客户端
[root@hyc ~]# systemctl stop firewalld
[root@hyc ~]# systemctl disable firewalld
[root@hyc ~]# vi /etc/selinux/config 
[root@hyc ~]# showmount -e 192.168.30.131
Export list for 192.168.30.131:
/nfs/shared *

开放/nfs/upload目录为192.168.30.0/24网段的数据上传目录,并将所有用户及所属的用户组都映射为nfs-upload,其UID与GID均为300

服务端


[root@hanyuce ~]# useradd -r -u 300 nfs-upload
[root@hanyuce ~]# id nfs-upload
uid=300(nfs-upload) gid=300(nfs-upload) 组=300(nfs-upload)
[root@hanyuce ~]# cat /etc/exports
/nfs/shared *(rw)
/nfs/upload 192.168.30.0/24(rw,anonuid=300,anongid=300)
[root@hanyuce ~]# mkdir /nfs/upload
[root@hanyuce ~]# chmod 777 /nfs/upload


客户端
[root@hyc ~]# mount -t nfs 192.168.30.131:/nfs/upload /gege
[root@hyc ~]# cd /gege
[root@hyc gege]# touch 1
[root@hyc gege]# ll
总用量 0
-rw-r--r-- 1 300 300 0 7月   2 16:58 1


服务端
[root@hanyuce ~]# cd /nfs/upload/
[root@hanyuce upload]# ll
总用量 0
-rw-r--r-- 1 nfs-upload nfs-upload 0 7月   2 16:58 1
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值