解决NFS client配置rszie和wsize不生效的问题

基础环境信息:

[[email protected] /]# cat /etc/redhat-release 
CentOS release 6.7 (Final)
[[email protected] /]# uname -r
2.6.32-573.el6.x86_64
[[email protected] /]#

默认挂载属性为:

[[email protected] /]# showmount -e nfs01
Export list for nfs01:
/data 172.16.1.0/24
[[email protected] /]# mount -t nfs nfs01:/data /mnt
[[email protected] /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 6.9G 1.8G 4.7G 28% /
tmpfs 238M 4.0K 238M 1% /dev/shm
/dev/sda1 190M 36M 145M 20% /boot
nfs01:/data 6.9G 1.7G 4.8G 27% /mnt
[[email protected] /]# grep mnt /proc/mounts
nfs01:/data/ /mnt nfs4 rw,sync,relatime,vers=4,rsize=65536,wsize=65536,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=172.16.1.61,minorversion=0,local_lock=none,addr=172.16.1.31 0 0
[[email protected] /]# ##tcp协议默认的rszie和wsize为65536

修改rsize和wsize:

[[email protected] nfsd]# umount /mnt
[[email protected] nfsd]# mount -t nfs -o rsize=131072,wsize=131072 nfs01:/data /mnt 
[[email protected] nfsd]# grep mnt /proc/mounts
nfs01:/data/ /mnt nfs4 rw,relatime,vers=4,rsize=65536,wsize=65536,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=172.16.1.61,minorversion=0,local_lock=none,addr=172.16.1.31 0 0
[[email protected] nfsd]# ##可以看到修改后并没有生效

使用tcpdump命令抓包查看过程:

[[email protected] ~]# tcpdump -nn -i eth1 -w wireshark.cap -s 0

使用wireshark对包进行分析
解决NFS client配置rszie和wsize不生效的问题
发现rsize和wsize是和服务端协商,并由服务端答复而来的(NFS V4 compound reply包)。

查阅相关资料得知:NFS 服务器在决定默认的最大读写块大小时考虑到内存占用情况,每个 NFS 内核线程最多只使用 1/4096 的物理内存大小,对于 UDP 来说,由于一个 UDP 包最大才 64KB,因此使用 UDP 协议的 NFS 读写块大小最大不超过 48KB,而 kernel 中则直接限制为 32KB 了;而使用 TCP 协议的 NFS 由于没有这个限制允许更大的读写块大小,但 Linux kernel 还是将其限制为 1MB 了。对于物理内存超过 4GB 的机器才使用最大的 1MB 读写块大小。记录这个大小的文件为/proc/fs/nfsd/max_block_size.

查看服务端该文件的大小:

[[email protected] ~]# cat /proc/fs/nfsd/max_block_size 
65536
[[email protected] ~]#

 

找到问题的所在了!然后我做了如下的修改
1、停止nfs服务

[[email protected] ~]# /etc/init.d/nfs stop
Shutting down NFS daemon: [ OK ]
Shutting down NFS mountd: [ OK ]
Shutting down NFS quotas: [ OK ]
Shutting down NFS services: [ OK ]
Shutting down RPC idmapd: [ OK ]
[[email protected] ~]#

2、修改max_block_size

[[email protected] ~]# echo 1048576 > /proc/fs/nfsd/max_block_size 
[[email protected] ~]# cat /proc/fs/nfsd/max_block_size
1048576
[[email protected] ~]# ##直接改为最大1M。

3、启动nfs服务

[[email protected] ~]# /etc/init.d/nfs start
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS mountd: [ OK ]
Starting NFS daemon: [ OK ]
Starting RPC idmapd: [ OK ]
[[email protected] ~]#

4、客户端进行挂载

[[email protected] nfsd]# mount -t nfs -o rsize=131072,wsize=131072 nfs01:/data /mnt
[[email protected] nfsd]# grep mnt /proc/mounts
nfs01:/data/ /mnt nfs4 rw,relatime,vers=4,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=172.16.1.61,minorversion=0,local_lock=none,addr=172.16.1.31 0 0
[[email protected] nfsd]# ##修改成功!

问题解决!

posted @ 2016-11-18 16:48 Dahlhin 阅读(...) 评论(...)  编辑 收藏

相关文章:

  • 2021-11-16
  • 2021-06-02
  • 2021-12-19
  • 2022-12-23
  • 2023-02-13
  • 2021-11-25
  • 2021-06-13
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-13
  • 2022-12-23
  • 2021-08-02
  • 2022-01-08
  • 2022-12-23
相关资源
相似解决方案