系统管理指南:网络服务

如何显示 NFS 服务器和客户机统计信息

NFS 分布式文件服务使用远程过程调用 (remote procedure call, RPC) 工具来将本地命令转换为对远程主机的请求。远程过程调用是同步的。在服务器完成调用并返回结果之前,客户机应用程序将被阻塞或暂停。影响 NFS 性能的一个主要因素是重新传输率。

如果文件服务器不能对客户机的请求做出响应,则客户机在退出之前将重新传输该请求,重新传输的次数是指定次数。每次重新传输都会产生系统开销并增加网络通信流量。过多的重新传输会引起网络性能问题。如果重新传输率很高,可检查是否存在以下问题:

表 30–3 中介绍了用于显示客户机和服务器统计信息的 nfsstat 选项。

表 30–3 用于显示客户机/服务器统计信息的命令

命令 

显示 

nfsstat -c

客户机统计信息 

nfsstat -s

服务器统计信息 

netstat -m

每个文件系统的网络统计信息 

使用 nfsstat -c 可以显示客户机统计信息,使用 nfsstat -s 可以显示服务器统计信息。使用 netstat -m 可以显示每个文件系统的网络统计信息。有关更多信息,请参见 nfsstat(1M)

示例-显示 NFS 服务器和客户机统计信息

以下示例显示客户机 pluto 的 RPC 和 NFS 数据。


$ nfsstat -c



Client rpc:

Connection oriented:

calls    badcalls  badxids  timeouts newcreds  badverfs   timers     

1595799  1511      59       297      0         0          0          

cantconn nomem     interrupts 

1198      0         7          

Connectionless:

calls    badcalls  retrans  badxids  timeouts  newcreds   badverfs   

80785    3135      25029    193      9543      0          0          

timers   nomem     cantsend   

17399    0         0          



Client nfs:

calls    badcalls  clgets   cltoomany  

1640097  3112      1640097  0          

Version 2: (46366 calls)

null     getattr   setattr  root     lookup     readlink  read       

0 0%     6589 14%  2202 4%  0 0%     11506 24%  0 0%      7654 16%   

wrcache  write     create   remove   rename     link      symlink    

0 0%     13297 28% 1081 2%  0 0%     0 0%       0 0%      0 0%       

mkdir    rmdir     readdir  statfs     

24 0%    0 0%      906 1%   3107 6%    

Version 3: (1585571 calls)

null    getattr    setattr  lookup     access     readlink  read     

0 0%    508406 32% 10209 0% 263441 16% 400845 25% 3065 0%  117959 7%

write    create     mkdir    symlink    mknod    remove   rmdir 

69201 4% 7615 0%    42 0%    16 0%      0 0%     7875 0%  51 0%      

rename   link       readdir  readdir+   fsstat   fsinfo   pathconf   

929 0%   597 0%     3986 0%  185145 11% 942 0%   300 0%   583 0%     

commit     

4364 0%    

 

Client nfs_acl:

Version 2: (3105 calls)

null       getacl     setacl     getattr    access     

0 0%       0 0%       0 0%       3105 100%  0 0%       

Version 3: (5055 calls)

null       getacl     setacl     

0 0%       5055 100%  0 0%    

表 30–4 中介绍了 nfsstat -c 命令的输出。

表 30–4 nfsstat -c 命令的输出

字段 

说明 

calls

发送的调用总数。 

badcalls

RPC 拒绝的调用总数。 

retrans

重新传输的总数。对于此客户机,重新传输率小于 1%,或者 6888 次调用中有 10 次超时。这些重新传输可能是由临时故障引起的。更高的比率表明可能存在问题。 

badxid

对一个 NFS 请求收到重复确认的次数。 

timeout

超时的调用数。 

wait

因没有可用的客户机句柄,调用必须等待的次数。 

newcred

必须刷新验证信息的次数。 

timers

超时值大于或等于为调用指定的超时值的次数。 

readlink

使 read 成为符号链接的次数。如果此值很高(超过 10 %)则可能存在过多符号链接。

以下示例显示 nfsstat -m 命令的输出。


pluto$ nfsstat -m

/usr/man from pluto:/export/svr4/man

Flags: vers=2,proto=udp,auth=unix,hard,intr,dynamic,

        rsize=8192, wsize=8192,retrans=5

 Lookups: srtt=13 (32ms), dev=10 (50ms), cur=6 (120ms)

 All:     srtt=13 (32ms), dev=10 (50ms), cur=6 (120ms)

nfsstat -m 命令的输出以毫秒显示,表 30–5 中对其进行了介绍。

表 30–5 nfsstat -m 命令的输出

字段 

说明 

srtt

往返时间的平滑平均值 

dev

平均偏差 

cur

当前的“预期”响应时间 

如果怀疑网络的硬件组件存在问题,则需要仔细检查电缆和连接器。