最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】CentOS和Ubuntu中如何确认已安装的NFS的版本

CentOS crifan 10623浏览 0评论

【背景】

折腾:

【已解决】在远程Ubuntu服务器中开通NFS服务供别人访问服务器上的文件

期间,需要去搞懂:

作为NFS服务器端Ubuntu中的已安装的nfs的server的版本

作为NFS客户端的CentOS的已安装的nfs的client的版本

以便于去设置对应的fstab中的nfsvers的值。

【解决过程】

1.好像没有什么nfs -v之类,去查看版本信息。

2.参考:

14.04 – Can’t auto-mount NFS share using fstab – Ask Ubuntu

去试试:

man nfs

结果没有显示当前版本:

root@chantyou:~# man nfs
NFS(5)                                                 File Formats Manual                                                NFS(5)

NAME
       nfs - fstab format and options for the nfs file systems

SYNOPSIS
       /etc/fstab

DESCRIPTION
       NFS is an Internet Standard protocol created by Sun Microsystems in 1984. NFS was developed to allow file sharing between
       systems residing on a local area network.  The Linux NFS client supports three versions of the NFS protocol: NFS  version
       2 [RFC1094], NFS version 3 [RFC1813], and NFS version 4 [RFC3530].

       The  mount(8) command attaches a file system to the system's name space hierarchy at a given mount point.  The /etc/fstab
       file describes how mount(8) should assemble a system's file name hierarchy from various independent file systems (includ‐
       ing  file  systems  exported by NFS servers).  Each line in the /etc/fstab file describes a single file system, its mount
       point, and a set of default mount options for that mount point.

       For NFS file system mounts, a line in the /etc/fstab file specifies the server name, the path name of the exported server
       directory  to  mount,  the  local directory that is the mount point, the type of file system that is being mounted, and a
       list of mount options that control the way the filesystem is mounted and how the NFS client behaves when accessing  files
       on  this  mount point.  The fifth and sixth fields on each line are not used by NFS, thus conventionally each contain the
       digit zero. For example:

               server:path   /mountpoint   fstype   option,option,...   0 0

2.搜:

check nfs version

参考:

linux – How to determine if NFS mount is mounted as v3 or v4? – Unix & Linux Stack Exchange

去试试:

root@chantyou:~# nfsstat --help
Usage: nfsstat [OPTION]...

  -m, --mounts          Show statistics on mounted NFS filesystems
  -c, --client          Show NFS client statistics
  -s, --server          Show NFS server statistics
  -2                    Show NFS version 2 statistics
  -3                    Show NFS version 3 statistics
  -4                    Show NFS version 4 statistics
  -o [facility]         Show statistics on particular facilities.
     nfs                NFS protocol information
     rpc                General RPC information
     net                Network layer statistics
     fh                 Usage information on the server's file handle cache
     rc                 Usage information on the server's request reply cache
     all                Select all of the above
  -v, --verbose, --all  Same as '-o all'
  -r, --rpc             Show RPC statistics
  -n, --nfs             Show NFS statistics
  -Z[#], --sleep[=#]    Collects stats until interrupted.
                            Cumulative stats are then printed
                            If # is provided, stats will be output every
                            # seconds.
  -S, --since file      Shows difference between current stats and those in 'file'
  -l, --list            Prints stats in list format
  --version             Show program version
  --help                What you just did

root@chantyou:~# nfsstat -m
root@chantyou:~# mount -t nfs 121.41.120.185:/home/share/image /root/nfs_client_root/
root@chantyou:~# nfsstat -m
/root/nfs_client_root from 121.41.120.185:/home/share/image
 Flags: rw,relatime,vers=4.0,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=120.26.121.239,local_lock=none,addr=121.41.120.185

3.再去试试另外一种:

结果无输出:

root@chantyou:~# mount -v | grep /root/nfs_client_root/

4.所以现在确定了:

NFS的vers=4.0

5.NFS服务器中,去试试:

root@iZ23lqgttauZ:image# nfsstat -m

很明显,没输出,是因为NFS服务器中没有mount。所以没有结果输出。

所以再去搜:

NFS server check nfs version 

参考:

Example: Linux Command To Find NFS Version

root@iZ23lqgttauZ:image# nfsstat -s
Server rpc stats:
calls      badcalls   badclnt    badauth    xdrcall
324        0          0          0          0       

Server nfs v4:
null         compound     
3         0% 321      99% 

Server nfs v4 operations:
op0-unused   op1-unused   op2-future   access       close        commit       
0         0% 0         0% 0         0% 23        4% 3         0% 0         0% 
create       delegpurge   delegreturn  getattr      getfh        link         
0         0% 0         0% 0         0% 104      20% 18        3% 0         0% 
lock         lockt        locku        lookup       lookup_root  nverify      
0         0% 0         0% 0         0% 14        2% 0         0% 0         0% 
open         openattr     open_conf    open_dgrd    putfh        putpubfh     
19        3% 0         0% 3         0% 0         0% 127      24% 0         0% 
putrootfh    read         readdir      readlink     remove       rename       
3         0% 0         0% 3         0% 0         0% 0         0% 0         0% 
renew        restorefh    savefh       secinfo      setattr      setcltid     
181      35% 0         0% 0         0% 2         0% 3         0% 5         0% 
setcltidconf verify       write        rellockowner bc_ctl       bind_conn    
5         0% 0         0% 0         0% 0         0% 0         0% 0         0% 
exchange_id  create_ses   destroy_ses  free_stateid getdirdeleg  getdevinfo   
0         0% 0         0% 0         0% 0         0% 0         0% 0         0% 
getdevlist   layoutcommit layoutget    layoutreturn secinfononam sequence     
0         0% 0         0% 0         0% 0         0% 0         0% 0         0% 
set_ssv      test_stateid want_deleg   destroy_clid reclaim_comp 
0         0% 0         0% 0         0% 0         0% 0         0% 

可以看出:

Server nfs v4

的确,NFS服务器版本是4

【总结】

1.NFS的客户端中:

nfsstat -m

中的vers=4.0确定NFS版本是4。

2.NFS服务器中:

nfsstat -s

中的Server nfs v4确定NFS版本的确是4。

转载请注明:在路上 » 【已解决】CentOS和Ubuntu中如何确认已安装的NFS的版本

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
82 queries in 0.190 seconds, using 22.12MB memory