A服务器做服务端:
1、安装nfs相关软件,实际上是基于rpc协议的
yum install -y nfs-utils rpcbind
2、设置共享目录
mkdir -p /data/vi /etc/exports/data 192.168.139.71(rw,async,no_root_squash)
#rw(来访者的权限,rw表示可读写,ro表示只能读取不能修改)
#async(表示异同步,同步用sync,推荐使用async)
#root_squash 当登录NFS主机使用共享目录的使用者是root时,其权限将被转换成为匿名使用者,通常它的UID与GID都会变成nobody身份。
#no_root_squash 如果登录NFS主机使用共享目录的使用者是root,那么对于这个共享的目录来说,它具有root的权限\
3、启动服务
chkconfig nfs on
systemctl enable nfs.servicechkconfig rpcbind on
systemctl enable rpcbind.servicesystemctl start nfs
systemctl start rpcbind
4、如果有防火墙或者安全策略,需要打开2049端口
B客户端:
1、安装nfs工具
yum install -y nfs-utils
2、设置挂载目录点,可以新建一个目录即可
mkdir /data
3、执行挂载
mkdir -p /data/
mount -t nfs 192.168.139.0/24:/data /data
成功后即可通过df查看了
4、随系统启动自动挂载
编辑/etc/fstab,追加:
192.168.139.72:/data /data nfs rw,tcp,intr 0 1