一、Server端配置

1.下载rpcbind和nfs

#yum install -y rpcbind nfs-utils

2.创建共享文件并授权

  • 创建共享文件夹
#mkdir /server-nfs
  • 创建测试文件
#touch /server-nfs/test.txt
#echo "Test file">/server-nfs/test.txt
  • 分配权限
#chown -R nfsnobody.nfsnobody /server-nfs/

3.配置文件并挂载

  • 写配置文件
#echo "/server-nfs 172.16.30.0/24(rw,sync)" >> /etc/exports
  • 重新加载
#exportfs -rv
  • 查看挂载情况
#showmount -e localhost
  • 查看NFS Server的配置文件参数
# cat /var/lib/nfs/etab
  • 挂载共享存储当本地
# mount -t nfs localhost:/server-nfs /mnt
  • 使用#df -h可以查看挂载情况
    4.启动nfs和rpcbind服务
#systemctl start nfs
#systemctl start rpcbind

二、Client端配置

1.下载rpcbind和nfs

#yum install -y rpcbind nfs-utils
  • 启动rpc服务,不需要启动nfs
#systemctl start rpcbind

2.查看Server端共享目录

#showmount -e {Server端ip}
  • 注:如果出现“clnt_create: RPC: Port mapper failure - Unable to receive: errno 113 (No route to host)”,请关闭Server端的防火墙,就可以查看了

3.将共享存储挂载到Client端上

#mount -t nfs {Server端ip}:/server-nfs /mnt/
  • 注:如果出现“mount: can't find /mnt/ in /etc/fstab”,在/etc/fstab下增加该行即可
{Server端ip}:/server-nfs      /mnt               nfs                defaults    0    0   

4.使用#df -h查看挂载是否成功

  • 此时就可以对挂载目下进行文件操作了

相关文章:

  • 2022-12-23
  • 2021-08-08
  • 2022-01-19
  • 2021-04-27
  • 2022-12-23
  • 2022-12-23
  • 2021-08-19
  • 2021-06-26
猜你喜欢
  • 2022-02-03
  • 2021-10-23
  • 2021-12-02
  • 2021-07-07
  • 2021-10-31
  • 2021-12-30
相关资源
相似解决方案