注意:本文直接展示操作命令以及在运用中出现的问题,有关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 --自启动