Linux NFS 服务器和客户端

注意:本文直接展示操作命令以及在运用中出现的问题,有关NFS基本概念请找度娘,建议先理解一下什么是NFS。

目的:有Server、Client两台主机,在Server及Client中执行如下命令:

创建用户及用户组,必须指定uid 及 gid 并且要保证每个主机中的uid和gid相同,无论是Server主机还是Client主机。

[root@localhost home]# groupadd -g 999 nfsgrp
[root@localhost home]# useradd -u 999 nfsuser -g 999 -d /home/nfs
设置密码略.....passwd nfsuser

如发现权限不对可执行如下命令:

[root@localhost home]# chown -R nfsuser:nfsgrp /home/nfs

创建共享的目录

[root@localhost /]# mkdir /data
[root@localhost /]# echo "/data *(rw,no_root_squash)" > /etc/exports
[root@localhost /]# chown -R nfsuser:nfsgrp /data

修改客户端访问的默认组,注意Nobody-User、Nobody-Group的值

[root@localhost /]# more /etc/idmapd.conf
[General]
#Verbosity = 0
# The following should be set to the local NFSv4 domain name
# The default is the host's DNS domain name.
#Domain = local.domain.edu

# The following is a comma-separated list of Kerberos realm
# names that should be considered to be equivalent to the
# local realm, such that <user>@REALM.A can be assumed to
# be the same user as <user>@REALM.B
# If not specified, the default local realm is the domain name,
# which defaults to the host's DNS domain name,
# translated to upper-case.
# Note that if this value is specified, the local realm name
# must be included in the list!
#Local-Realms =

[Mapping]

#Nobody-User = nobody
#Nobody-Group = nobody
Nobody-User = nfsuser
Nobody-Group = nfsgrp

重启服务

[root@hn-bilxxz02 ~]# service rpcidmapd restart
Shutting down RPC idmapd: [  OK  ]
Starting RPC idmapd: [  OK  ]
[root@hn-bilxxz02 ~]# 

--------------------------------------------------------------------------- 客户端 ----------------------------------------------------------------------------

[root@Client ]#mount -t nfs -o vers=3 192.168.168.168:/data /data 

NFS服务器与客户端用户同步
服务器创建用户为 nfsuser:999  用户组nfsgrp:999 
客户端的UID和GID也应是999

chkconfig --list nfs
chkconfig --level 35 nfs on   --自启动




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

钩子水手

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

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

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

打赏作者

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

抵扣说明:

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

余额充值