NFS 服务器处于活动状态(已退出)

NFS 服务器处于活动状态(已退出)

为什么我的 NFS 服务器卡在活动(退出)状态?状态如下:

    $ sudo systemctl status nfs-server.service
● nfs-server.service - NFS server and services
     Loaded: loaded (/lib/systemd/system/nfs-server.service; enabled; vendor preset: enabled)
    Drop-In: /run/systemd/generator/nfs-server.service.d
             └─order-with-mounts.conf
     Active: active (exited) since Fri 2021-02-19 12:48:48 CET; 7s ago
    Process: 6257 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS)
    Process: 6258 ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS (code=exited, status=0/SUCCESS)
   Main PID: 6258 (code=exited, status=0/SUCCESS)

Feb 19 12:48:47 xxx_name_xxx systemd[1]: Starting NFS server and services...
Feb 19 12:48:48 xxx_name_xxx systemd[1]: Finished NFS server and services.

这是 /var/log/syslog 中的日志

Feb 19 12:50:30 xxx_name_xxx systemd-resolved[681]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.
Feb 19 12:50:30 xxx_name_xxx systemd-resolved[681]: message repeated 3 times: [ Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.]
Feb 19 12:50:30 xxx_name_xxx systemd[1]: Condition check resulted in Kernel Module supporting RPCSEC_GSS being skipped.
Feb 19 12:50:30 xxx_name_xxx systemd[1]: Starting Preprocess NFS configuration...
Feb 19 12:50:30 xxx_name_xxx systemd[1]: nfs-config.service: Succeeded.
Feb 19 12:50:30 xxx_name_xxx systemd[1]: Finished Preprocess NFS configuration.
Feb 19 12:50:30 xxx_name_xxx systemd[1]: Starting NFSv4 ID-name mapping service...
Feb 19 12:50:30 xxx_name_xxx systemd[1]: Starting NFS Mount Daemon...
Feb 19 12:50:30 xxx_name_xxx systemd[1]: Condition check resulted in RPC security service for NFS client and server being skipped.
Feb 19 12:50:30 xxx_name_xxx systemd[1]: Condition check resulted in RPC security service for NFS server being skipped.
Feb 19 12:50:30 xxx_name_xxx systemd-resolved[681]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.
Feb 19 12:50:30 xxx_name_xxx systemd-resolved[681]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.
Feb 19 12:50:30 xxx_name_xxx rpc.mountd[6304]: Version 1.3.3 starting
Feb 19 12:50:30 xxx_name_xxx systemd[1]: Started NFSv4 ID-name mapping service.
Feb 19 12:50:30 xxx_name_xxx systemd[1]: Started NFS Mount Daemon.
Feb 19 12:50:30 xxx_name_xxx systemd[1]: Starting NFS server and services...
Feb 19 12:50:31 xxx_name_xxx kernel: [ 6663.675764] NFSD: Using UMH upcall client tracking operations.
Feb 19 12:50:31 xxx_name_xxx kernel: [ 6663.675771] NFSD: starting 90-second grace period (net f0000098)
Feb 19 12:50:31 xxx_name_xxx systemd[1]: Finished NFS server and services.

这是 uname -a 的结果:

Linux xxx_name_xxx 5.8.0-7642-generic #47~1612288990~20.04~b8113e7-Ubuntu SMP Wed Feb 3 02:25:36 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

我试过了并尝试停止 nfs-server.service 和 nfs-client.target 并仅启动服务器,但到目前为止没有任何效果。我看到客户端和服务器之间存在冲突,但我不敢相信您的机器不能同时用作 NFS 服务器和客户端。

答案1

为什么我的 NFS 服务器卡在活动(退出)状态

因为 NFS 服务器位于内核中并且没有用户空间进程。

该程序的唯一工作rpc.nfsd是要求内核启动 NFS 服务器 kthreads - 但这些线程与原始 rpc.nfsd 进程没有任何关联,并且即使在进程退出后仍将继续运行。

因此 systemd .service 的行为是正确的(嗯,这是它能做的最好的事情)。它类似于“启动” iptables 或 nftables,这两者都没有用户空间守护进程。

要检查内核 NFS 服务器是否正在运行,请运行ps axf或 htop 并搜索名为“[nfsd]”的 kthreads。您还可以检查在以下位置找到的信息/proc/fs/nfsd

# cat /proc/fs/nfsd/threads
8

# cat /proc/fs/nfsd/versions
-2 +3 +4 +4.1 +4.2

$ ps axf
    PID TTY      STAT   TIME COMMAND
      2 ?        S      0:00 [kthreadd]
    917 ?        S      0:00  \_ [lockd]
   1310 ?        S      0:01  \_ [nfsd]
   1311 ?        S      0:01  \_ [nfsd]
   1312 ?        S      0:02  \_ [nfsd]

相关内容