Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

8.5. 启动和停止 NFS 服务器

先决条件

  • 对于支持 NFSv2 或 NFSv3 连接的服务器,rpcbind[1] 服务必须正在运行。要验证 rpcbind 是否处于活动状态,请使用以下命令:
    $ systemctl status rpcbind
    要配置只使用 NFSv4 的服务器,它不需要 rpcbind,请参阅 第 8.6.7 节 “配置只使用 NFSv4 的服务器”
  • 在 Red Hat Enterprise Linux 7.0 中,如果您的 NFS 服务器导出 NFSv3 并在引导时启用,则需要手动启动并启用 nfs-lock 服务:
    # systemctl start nfs-lock
    # systemctl enable nfs-lock
    在 Red Hat Enterprise Linux 7.1 及更高版本中,如果需要,nfs-lock 会自动启动,并尝试手动启用它。

流程

  • 要启动 NFS 服务器,请使用以下命令:
    # systemctl start nfs
  • 要使 NFS 在引导时启动,请使用以下命令:
    # systemctl enable nfs
  • 要停止服务器,请使用:
    # systemctl stop nfs
  • restart 选项是停止然后启动 NFS 的简写方式。这是编辑 NFS 配置文件后使配置更改生效的最有效方式。要重启服务器的类型:
    # systemctl restart nfs
  • 编辑 /etc/sysconfig/nfs 文件后,运行以下命令来重启 nfs-config 服务,使新值生效:
    # systemctl restart nfs-config
  • try-restart 命令仅在当前正在运行时启动 nfs。此命令等同于 Red Hat init 脚本中的 condrestart (有条件重启)非常有用,因为它不会在 NFS 未运行时启动守护进程。
    要有条件地重启服务器,请输入:
    # systemctl try-restart nfs
  • 要在不重启服务类型的情况下重新载入 NFS 服务器配置文件:
    # systemctl reload nfs