更多: zhilu jiaocheng

配置 /etc/sysconfig/nfs 的示例

要指定 rpc.mountd 使用 20048 以外的空闲静态端口,只需取消注释 MOUNTD_PORT 以设置新端口值,然后重新启动 nfs-mountd 服务或者 nfs-server 服务。

MOUNTD_PORT=892

要指定 rpc.nfsd 使用 2049 以外的空闲静态端口,我们只需取消注释 RPCNFSDARGS 以添加新端口值,然后重新启动 nfs-server 服务。

RPCNFSDARGS="-p 20499"

要指定 rpc.statd 使用空闲静态端口,我们只需取消注释 STATD_PORT 和 STATD_OUTGOING_PORT 以设置新端口值,然后重新启动 rpc-statd 服务。

STATD_PORT=662
STATD_OUTGOING_PORT=2020

NFS 服务

NFS 服务(服务器端)包括:

  • NLM(NFS 锁管理器或者内核内锁)
  • rpc.mountd
  • rpc文件
  • rpc.rquotad
  • rpc.statd

请注意 lockd 和 rpc.statd 也在 NFS 客户端上运行。
此外,rpc.rquotad 严格来说并不是 NFS 系列的一部分,而是用于检查由 NFS 服务器共享并由一个或者多个 NFS 客户端安装的文件系统上的配额。

使用 NFSv3,rpc.nfsd 与 LOCKD/NLM、rpc.mountd 和 rpc.statd 交互。
但是,在 NFSv4 中,所有这些交互现在都被合并/整合了。

对于 CentOS/RHEL 7,nfs-utils RPM 现在提供 /etc/modprobe.d/lockd.conf、/etc/sysconfig/nfs 和 /etc/sysconfig/rpc-rquotad 作为主要的 NFS(服务器端)配置文件。
此外,还有 /etc/nfs.conf,在不久的将来,它可能会弃用其他配置文件。

对于 CentOS/RHEL 7,rpc.mountd、rpc.nfsd 和 rpc.rquotad 的静态端口分别默认为 20048、2049 和 875,因为它们被认为是众所周知的端口。
其他 NFS 服务(server_side),例如 LOCKD/NLM 和 rpc.statd,通常只使用随机端口,但 /etc/modprobe.d/lockd.conf 和 /etc/sysconfig/nfs 确实提供了示例端口值以供参考。
示例端口值对于大多数场景来说已经足够了。

# cat /etc/services
mountd  20048/tcp            # NFS mount protocol
mountd  20048/udp            # NFS mount protocol
nfs     2049/tcp  nfsd shilp # Network File System
nfs     2049/udp  nfsd shilp # Network File System
rquotad 875/tcp              # rquota daemon
rquotad 875/udp              # rquota daemon
# cat /etc/modprobe.d/lockd.conf
# Set the TCP port that the NFS lock manager should use.
# port must be a valid TCP port value (1-65535).
#options lockd nlm_tcpport
#
# Set the UDP port that the NFS lock manager should use.
# port must be a valid UDP port value (1-65535).
#options lockd nlm_udpport
# cat /etc/sysconfig/nfs
# Port rpc.mountd should listen on.
#MOUNTD_PORT=892
# Port rpc.statd should listen on.
#STATD_PORT=662
# Outgoing port statd should used. The default is port
# is random
#STATD_OUTGOING_PORT=2020
# cat /etc/sysconfig/rpc-rquotad
# -I, --autofs Ignore autofs mount points
# -p port, --port port Listen on alternative port
# -s, --no-setquota Don't allow setting quotas with RPC (default)
# -S, --setquota Allow setting quotas with RPC
# -x path, --xtab path Use alternative NFSD export table
RPCRQUOTADOPTS=""
CentOS/RHEL 7如何配置 NFS 服务使用固定的静态端口

默认情况下,一些 NFS 服务(server_side)使用众所周知的端口,但有些通常只使用随机端口。
由于严格的防火墙规则会阻止随机但未知的端口,因此随机端口的使用效果不佳。
因此,有时最好手动更改或者指定静态端口供 NFS 服务 (server_side) 使用。

这篇文章描述了如何配置 NFS 服务(服务器端)作为替代方案在静态端口上运行。

配置/etc/modprobe.d/lockd.conf的例子

要指定 LOCKD/NLM 使用空闲静态端口,我们只需取消 nlm_tcpport 和 nlm_udpport 的注释以设置新端口值,然后重新加载 lockd 内核模块或者重新启动。

options lockd nlm_tcpport=32803
options lockd nlm_udpport=32769

配置/etc/sysconfig/rpc-rquotad的例子

要指定 rpc.rquotad 使用 875 以外的空闲静态端口,我们只需取消注释 RPCRQUOTADOPTS 以添加新端口值,然后重新启动 rpc-rquotad 服务。

RPCRQUOTADOPTS="-p 8755"

服务控制

重启 nfs-mountd 服务:

# systemctl restart nfs-mountd.service

重启 nfs-server 服务:

# systemctl restart nfs-server.service

重启 rpc-rquotad 服务:

# systemctl restart rpc-rquotad.service

重启 rpc-statd 服务:

# systemctl restart rpc-statd.service

确认:

# rpcinfo -p
日期:2020-09-17 00:12:28 来源:oir作者:oir