1. 安装:

    # 服务端
    yum -y install nfs-utils rpcbind
    # 客户端
    yum -y install nfs-utils
  2. 服务端:

    1. 配置共享目录:
      vim /etc/exports
      /path/to/dir xx.xx.xx.*(rw,async,no_root_squash)
    2. 更改目录权限:
      chmod -R +w /path/to/dir
    3. 启动服务:
      systemctl start rpcbind && systemctl enable rpcbind
      systemctl start nfs && systemctl enable nfs
    4. 开放防火墙端口:
      # rpcbind的端口
      iptables  -I  INPUT  -p  udp  --dport  111  -j  ACCEPT
      iptables  -I  INPUT  -p  tcp  --dport  111  -j  ACCEPT
      # nfs的端口
      iptables  -I  INPUT  -p  udp  --dport  2049  -j  ACCEPT
      iptables  -I  INPUT  -p  tcp  --dport  2049  -j  ACCEPT
  3. 客户端:

    1. 查看服务端挂载状态:
      showmount -e xx.xx.xx.xx
    2. 挂载:
      mount xx.xx.xx.xx:/path/to/dir /path/to/dir
    3. 开机自动挂载:
      echo "xx.xx.xx.xx:/path/to/dir /path/to/dir nfs defaults 0 0" >> /etc/fstab
文档更新时间: 2024-04-19 15:11   作者:lee