环境:
System:Sentos7.4
Server1:172.16.74.1
Server2:172.16.74.2
Server3:172.16.74.3
一、安装
Server1,Server2,Server3都安装rpcbind,nfs-utils
~]# yum install -y rpcbind nfs-utils
---开启rpcbind服务
~]# /etc/init.d/rpcbind status #查询rpcbind服务状态并启动
~]# lsof -i :111 #查询rpcbind监听状态 (111是rpcbind的主端口)
~]# netstat -lntup |grep rpcbind #查询rpcbind服务启动状态 (同lsof查询端口效果一样)
~]# chkconfig --list rpcbind #检查rpcbind自启动情况
~]# rpcinfo -p localhost #查看NFS服务项rpc服务器注册的端口信
---启动NFS服务
~]# service nfs status #查看NFS服务并启动
~]# netstat -lntup|grep nfs #查看NFS端口启动(FNS默认端口为2049)
~]# lsof -i :2049 #查看NFS端口启动(FNS默认端口为2049)
~]# netstat -lntup|grep 2049 #查看NFS端口启动(FNS默认端口为2049)
~]# rpcinfo -p localhost #启动NFS过后rpcbind服务已经启用了对FNS的端口映射
~]# chkconfig --list nfs #查看nfs的开机自启动情况
~]# chkconfig nfs on #让FNS开机自启动
~]# less /etc/init.d/rpcbind #查看rpcbind服务启动详情
~]# less /etc/init.d/nfs
~]# vi /etc/rc.local
~]# ps -ef |egrep "rpc|nfs" #查看nfs相进程
二、挂载
/etc/exports 是NFS程序的配置文件。并且默认为空
/etc/exports文件的配置格式为:
NFS共享目录 NFS客户端地址1(参数1,参数2,参数3......) 客户端地址2(参数1,参数2,参数3......)
NFS共享目录 NFS客户端地址(参数1,参数2,参数3......)
配置完成exports后平滑重启NFS服务 ,下面两条命令等同
~]# /etc/init.d/nfs reload
~]# exportfs -r
客户端也需要安装rpcbind和nfs-utils软件,并且设置开机自启动。(只需要启动rpcbind即可)
~]# showmount -e 127.0.0.1 #查看本机挂载情况
~]# mount -t nfs 192.168.1.5:/data /mnt #在本机测试挂载
参考例子:
https://www.cnblogs.com/alonones/p/6105586.html