NFS Cmds

mount -t nfs -o [options] remote:/nfs /mount

1. 检测挂载参数

# nfsstat -m
/home/admin/qbli from 10.25.54.164:/
 Flags: rw,relatime,vers=3,rsize=1048576,wsize=1048576,namlen=255,hard,nolock,proto=tcp,port=2049,timeo=600,retrans=2,sec=sys,local_lock=all,addr=10.25.54.164

2. 通用挂载参数

hard VS soft

  • Hard: 当服务端宕机或不可达时,客户端会一直尝试重连。当服务端正常后,连接会继续传输数据,所以硬挂载不会丢失数据,但是用户的连接会hang,默认是hard
  • Soft: 当服务端宕机或不可达时,客户端会断链接会等待kernal设置的timeout返回I/O ERROR,会造成数据丢失和破坏。

timeo and retrans

RPC请求重传相关的两个参数。timeo表示RPC消息等待时间,如果客户端在这个时间内没有接收到应答消息,则认为RPC消息失败了。retrans表示RPC请求重试次数,当达到这个次数时客户端根据soft/hard选项进行不同处理。

rsize and wsize

rsize指定了每个RPC应答消息中最多可以传输的数据量。wsize表示写操作中每个RPC消息最多可以传输的数据量。如果客户端在挂载NFS文件系统时没有指定rsize/wsize的值,则客户端和服务器会自行协商出一个合适的数值。

async/sync

同步、异步挂载,客户端默认异步(async)。对于异步挂载,客户端下发的写数据会先缓存在内存中,达到一定大小或者其他条件(与客户端设置,状态有关),再一起发往服务端。而同步挂载,每次下发的写数据马上发到服务端。

acregmin/acregmax

设置NFS客户端缓存普通文件属性的最短时间和最长时间,单位为秒。超过此时间后对其进行更新。默认最短时间是3s,最长时间是60s。

acdirmin/acdirmax

设置NFS客户端缓存目录属性的最短时间和最长时间,单位为秒。超过此时间后对其进行更新。默认最短时间是3s,最长时间是60s。

resvport/noresvport

设置连接服务器是否使用保密源端口。默认的resvport设置保密端口,noresvport设置为非保密端口。内核2.6.28及以后版本支持。

ac and noac

为了提高系统性能,NFS客户端可以缓存文件属性信息,在一定的时间范围内这些属性缓存是有效的。这就存在文件同步的问题,因为NFS文件系统可以供多个客户端挂载,不同客户端上的用户可以同时访问同一个文件,如何保持文件同步是一个非常麻烦的问题。如果客户端挂载文件系统时使用了ac选项,则表示启用文件属性缓存机制。在文件属性缓存的有效期内,如果其他客户端已经修改了文件属性(比如撤销了文件写权限),这个客户端无法及时感知这种变化。当客户端写服务器发起WRITE请求时,首先检查本地文件属性缓存,发现自己具有写权限,于是就将数据发送给服务器。但是由于其他客户端已经撤销了写权限,因此这些数据是不能写到服务器的磁盘中的,WRITE请求失败,这就会降低系统性能。如果客户端在挂载文件系统时使用了noac选项,则客户端不会缓存文件属性信息。当客户端向服务器发起WRITE请求时,首先会发起一个GETATTR请求获取文件属性,如果发现没有写权限,就不会向服务器传输数据了。但是相比于ac选项,客户端在发起WRITE请求前需要先发起GETATTR请求,这同样会降低系统性能。因此,当客户端数量比较少,客户端与服务器的交互不频繁时可以使用ac选项。而保持文件同步更好的办法是在NFS文件系统中使用文件锁。

nocto

提高open/access的性能,使用nocto可以阻止打开文件后执行GetAttr,默认该参数是关闭的。

timeo=n

客户端重传请求前等待时间。对于基于TCP的NFS服务,默认等待重传时间为60s。使用TCP协议时,NFS Client不执行任何超时backoff。对于UDP协议,client使用一个合适的算法,为常用的请求类型estimate合适的超时时间。但对不常用的请求类型使用timeo设置。如果timeo没有设置,不常用的请求类型1.1秒以后重试。在每次重发后,NFS Client会将timeout时间加倍,直到最大的60秒。

retrans=n客户端返回错误前的重传次数。默认为重传3次。retrans与soft参数一起使用时才有效。

 

3. NFS客户端命令

nfsstat

The nfsstat displays statistics kept about NFS client and server activity.

[Fri Dec 13 10:28 root@:~]$ nfsstat -c
Client rpc stats:
calls      retrans    authrefrsh
967360     13577      967716

Client nfs v3:
null         getattr      setattr      lookup       access       readlink
0         0% 6047      0% 46        0% 79        0% 273       0% 0         0%
read         write        create       mkdir        symlink      mknod
960728   99% 107       0% 32        0% 8         0% 0         0% 0         0%
remove       rmdir        rename       link         readdir      readdirplus
21        0% 3         0% 1         0% 0         0% 0         0% 54        0%
fsstat       fsinfo       pathconf     commit
32        0% 22        0% 11        0% 0         0%

nfsiostat [[<interval>] [<count>]] [<options>][<mount_point>]

The meaning of each column of nfsiostat's output is the following:
- op/s:This is the number of operations per second.
- rpc bklog:This is the length of the backlog queue.
- kB/s:This is the number of kB written/read per second.
- kB/op:This is the number of kB written/read per each operation.
- retrans:This is the number of retransmissions.
- avg RTT (ms):This is the duration from the time that client's kernel sends the RPC request until the time it receives the reply.
- avg exe (ms):This is the duration from the time that NFS client does the RPC request to its kernel until the RPC request is completed, this includes the RTT time above.
[zhemi@~]$ nfsiostat 2 3 /mnt

*.com:/ mounted on /mnt:

   op/s		rpc bklog
 292.94	   0.00
read:            ops/s		   kB/s		  kB/op		retrans		avg RTT (ms)	avg exe (ms)
		  0.012	  0.424	 36.154       0 (0.0%)	  1.993	  2.006
write:           ops/s		   kB/s		  kB/op		retrans		avg RTT (ms)	avg exe (ms)
		 26.650	854.486	 32.063 6448912 (3.2%)	  2.889	  4.638
......

mountstats - Displays various NFS client per-mount statistics

  • mountstats iostat [-h|--help] [-v|--version] [-f|--file infile] [-S|--since sincefile] [interval] [count] [mountpoint]...
  • mounstats nfsstat [-h|--help] [-v|--version] [-f|--file infile] [-S|--since sincefile] [-3] [-4] [mountpoint]...
[zhemi@~]$ mountstats iostat  2 3 /mnt

*com:/ mounted on /mnt:

           ops/s       rpc bklog
         292.949           0.000

read:              ops/s            kB/s           kB/op         retrans    avg RTT (ms)    avg exe (ms)
                   0.012           0.423          36.154        0 (0.0%)           1.993           2.006
write:             ops/s            kB/s           kB/op         retrans    avg RTT (ms)    avg exe (ms)
                  26.652         854.447          32.059  6448912 (3.2%)           2.889           4.638

[zhemi@~]$ mountstats nfsstat  2 3 /mnt
Client rpc stats:
calls      retrans    authrefrsh
2202133683 2220344613 2202133683

Client nfs v3
null         getattr      setattr      lookup       access       readlink
0         0% 202524017  9% 938283731 42% 313077573 14% 231553281 10% 2828      0%
read         write        create       mkdir        symlink      mknod
88056     0% 200350640  9% 198483410  9% 12641373  0% 24258     0% 0         0%
remove       rmdir        rename       link         readdir      readdirplus
5350      0% 38        0% 105096514  4% 0         0% 380       0% 2152      0%
fsstat       fsinfo       pathconf     commit
79        0% 2         0% 1         0% 0         0%

[zhemi@~]$ mountstats /mnt
Stats for *v.com:/ mounted on /mnt:

  NFS mount options: rw,vers=3,rsize=1048576,wsize=1048576,namlen=255,acregmin=3,acregmax=60,acdirmin=30,acdirmax=60,hard,nolock,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=10.73.241.35,mountvers=3,mountport=2049,mountproto=tcp,local_lock=all
  NFS server capabilities: caps=0x3fc7,wtmult=4096,dtsize=32768,bsize=0,namlen=255
  NFS security flavor: 1  pseudoflavor: 0

NFS byte counts:
  applications read 3237730772 bytes via read(2)
  applications wrote 6518358058225 bytes via write(2)
  applications read 0 bytes via O_DIRECT read(2)
  applications wrote 0 bytes via O_DIRECT write(2)
  client read 3237625412 bytes via NFS READ
  client wrote 6518358067455 bytes via NFS WRITE
RPC statistics:
  2202170058 RPC requests sent, 2202170029 RPC replies received (1 XIDs not found)
  average backlog queue length: 0

SETATTR:
	938283450 ops (42%) 	1 retrans (0%) 	0 major timeouts
	avg bytes sent per op: 146	avg bytes received per op: 143
	backlog wait: 0.008542 	RTT: 1.161280 	total execute time: 1.189072 (milliseconds)
LOOKUP:
	313077454 ops (14%) 	814 retrans (0%) 	0 major timeouts
	avg bytes sent per op: 137	avg bytes received per op: 94
	backlog wait: 0.011776 	RTT: 1.816527 	total execute time: 1.845988 (milliseconds)
ACCESS:
	231553278 ops (10%) 	11754404 retrans (5%) 	0 major timeouts
	avg bytes sent per op: 116	avg bytes received per op: 119
	backlog wait: 0.017155 	RTT: 0.390765 	total execute time: 0.423057 (milliseconds)
GETATTR:
	202524016 ops (9%) 	6769 retrans (0%) 	0 major timeouts
	avg bytes sent per op: 112	avg bytes received per op: 111
	backlog wait: 0.019829 	RTT: 0.403930 	total execute time: 0.438445 (milliseconds)
WRITE:
	200350570 ops (9%) 	6448912 retrans (3%) 	0 major timeouts
	avg bytes sent per op: 32668	avg bytes received per op: 159
	backlog wait: 1.743008 	RTT: 2.888951 	total execute time: 4.638136 (milliseconds)
CREATE:
	198483340 ops (9%)
	avg bytes sent per op: 164	avg bytes received per op: 256
	backlog wait: 0.009367 	RTT: 3.430582 	total execute time: 3.460205 (milliseconds)
RENAME:
	105096445 ops (4%)
	avg bytes sent per op: 194	avg bytes received per op: 259
	backlog wait: 0.005719 	RTT: 2.006402 	total execute time: 2.016675 (milliseconds)
MKDIR:
	12641373 ops (0%) 	30 retrans (0%) 	0 major timeouts
	avg bytes sent per op: 152	avg bytes received per op: 255
	backlog wait: 0.007189 	RTT: 2.471870 	total execute time: 2.498604 (milliseconds)
READ:
	88056 ops (0%)
	avg bytes sent per op: 124	avg bytes re
......

4. 查看某一个磁盘对应的文件系统的日志方式

dmesg | grep -B 1 "mounted filesystem"

5. 查看当前linux内核的引导参数

$cat /proc/cmdline
BOOT_IMAGE=/vmlinuz-3.10.0-327.*.*.x86_64 root=UUID=bd42316d-97d5-4a6c-bcd0-7c18d3df3c58 ro crashkernel=auto vconsole.font=latarcyrheb-sun16 vconsole.keymap=us biosdevname=0 console=tty0 console=ttyS0,115200 scsi_mod.scan=sync intel_idle.max_cstate=0 pci=pcie_bus_perf ipv6.disable=1 rd.driver.pre=ahci

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值