前提条件,确保两个ip可以正常通信
确认服务端是否安装nfs-utils和rpcbind
[root@localhost /]# rpm -qa|grep "nfs"
nfs4-acl-tools-0.3.3-17.el7.x86_64
libnfsidmap-0.25-19.el7.x86_64
nfs-utils-1.3.0-0.61.el7.x86_64
[root@localhost /]# rpm -qa|grep "rpc"
xmlrpc-c-client-1.32.5-1905.svn2451.el7.x86_64
libtirpc-0.2.4-0.10.el7.x86_64
rpcbind-0.2.0-47.el7.x86_64
xmlrpc-c-1.32.5-1905.svn2451.el7.x86_64
mkdir /data/sharestore 创建共享目录
chmod -Rf 777 /data/sharestore 确保其他用户对该目录具备读写权限(该步骤可以不执行)
服务端配置
cat /etc/exports
/data/sharestore *(insecure,rw,no_root_squash,no_all_squash,async)
exports参数相关可以参考:https://blog.csdn.net/qq_36357820/article/details/78488077
cat /etc/sysconfig/nfs|grep -v '#'
LOCKD_TCPPORT=32803
LOCKD_UDPPORT=32769
RPCNFSDARGS="-N 4"
MOUNTD_PORT=10892
STATD_PORT=10662
STATD_OUTGOING_PORT=12020
GSS_USE_PROXY="yes"
systemctl restart rpcbind
systemctl restart nfs-server
systemctl enable rpcbind
systemctl enable nfs-server
exportfs -r 使配置文件立即生效
客户端配置:
确认是否安装:nfs-common 该包提供showmount等功能
执行:dpkg-query -l nfs-common
出现以下信息说明已安装
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==================================================-==============================-==============================-=========================================================================================================
ii nfs-common 1:1.2.8-6ubuntu1.2 amd64 NFS support files common to client and server
mkdir /nfsfile 创建挂载目录
chmod -Rf 777 /nfsfile(具备读写权限即可,可以不给777)
showmount -e 服务端ip(如果出现服务端共享的目录信息说明目录共享成功)
rpcinfo -p 服务端ip地址 ---查看服务端rpc进程(该命令不指定ip地址可以用于获取本地rpc进程)
program vers proto port service
100000 4 tcp 111 portmapper
100000 3 tcp 111 portmapper
100000 2 tcp 111 portmapper
100000 4 udp 111 portmapper
100000 3 udp 111 portmapper
100000 2 udp 111 portmapper
100005 1 udp 20048 mountd
100005 1 tcp 20048 mountd
100005 2 udp 20048 mountd
100005 2 tcp 20048 mountd
100005 3 udp 20048 mountd
100005 3 tcp 20048 mountd
100003 3 tcp 2049 nfs
100003 4 tcp 2049 nfs