搭建 NFS 服务

1 NFS 服务器端安装与配置

1.1 环境信息

NFS 服务器信息如下:

  • IP 为 10.1.11.64

1.2 防火墙

为了避免 NFS 服务的通信问题,可以先将防火墙关闭,或者打开对应的端口。

  1. systemctl stop firewalld

1.3 安装 NFS 服务器所需的软件包

  1. yum install -y nfs-utils

1.4 创建 NFS 目录

  1. mkdir -p /opt/kettle /opt/plugins/thirdpart /opt/static-resource
  2. chmod 666 -R /opt/kettle /opt/plugins/thirdpart /opt/static-resource

1.5 编辑 exports 文件

以下命令中的 “10.1.11.0/24” 请替换为各自具体的网段。

  1. echo "/opt/kettle 10.1.11.0/24(rw,no_root_squash,no_all_squash,sync)" >> /etc/exports
  2. echo "/opt/static-resource 10.1.11.0/24(rw,no_root_squash,no_all_squash,sync)" >> /etc/exports
  3. echo "/opt/plugins/thirdpart 10.1.11.0/24(rw,no_root_squash,no_all_squash,sync)" >> /etc/exports

1.6 rpcbind 和 NFS 做开机启动

NFS 服务器使用 rpcbind 来实现端口映射工作,必须先启动 rpcbind 服务。

  1. systemctl enable rpcbind.service
  2. systemctl enable nfs-server.service

1.7 分别启动 rpcbind 和 NFS 服务

  1. systemctl start rpcbind.service
  2. systemctl start nfs-server.service

1.8 让 exports 配置生效

  1. exportfs -r

1.9 检查 exports 是否生效

  1. exportfs
  2. # 10.1.11.64 为 NFS 服务器地址,即当前机器地址
  3. showmount -e 10.1.11.64