跳转至

nfs

以下教程使用的 linux 环境为 Linux rocky 5.14.0-70.13.1.el9_0.x86_64

1 安装

- 服务端、客户端均安装 `nfs-utils` 和 `rpcbind` 工具
- 服务端先启动 rpc 服务,再启动 nfs 服务
- 客户端启动 rpc 服务
  1. 安装 nfs 服务: dnf install nfs-utils ,会装一些依赖,包括 rpcbind 服务:
  2. 启动 nfs 服务:systemctl start nfs-server,同时会将 rpcbind 服务启动(其它内核可能是 nfs)
  3. 检测 nfs 服务运行情况:rpcinfo -p

2 挂载

https://www.cnblogs.com/yanling-coder/p/13028552.html 1. -t nfs :指定 nfs,或者直接 -t nfs4, -o 指定参数,vers=n 指定 nfs 版本号。

mount -t nfs -o vers=3 127.0.0.1:/tmp/nfs1 /tmp/cli1

2.1 使用 ipv6

  • 指令:mount -t nfs 可选参数 [ipv6地址]:server_path client_path
  • 示例
$ mount -t nfs -o vers=4 [fe80::f6e9:d4ff:fee6:79e4]:/fs1 /nfs_fs1

2.2 NFS 客户端挂载参数

挂载时最好选择 hard +intr :为了防止整个系统被 NFS 锁死,因为 hard 连接的时候,即使服务端 NFS 没起来,客户端也是一直在尝试进行连接,导致 df -h 无输出,如果添加了 intr, 可以按 ctrl+c 中断
  • rsizewsize :性能优化参数,这个设置可以影响客户端和服务端传输数据的缓冲存储量,一般来说在局域网内,并且客户端和服务端都足够大内存可以设置大一点,比如 65535 或者 131072,提升缓冲区可提升 NFS 文件系统传输能力,但是也不要太大了,最好是在网络能传输的最大值,一般默认是:32768。NFS 服务端和客户端之间传输的数据块大小。也就是文件 io block 的大小。
  • async :异步
  • sync :同步
  • ro :只读
  • rw :读写
  • auto :可以通过 mount -a 自动挂载,但是前提要写入/etc/fstab 文件
  • defaults :fstab 的缺省值包括:rw,suid,dev,exec,auto,nouser,async
  • exec :允许文件系统执行二进制文件,取消这个参数可以提升安全,因为即使被上传也不能被执行,适用于那种仓库存储
  • noatime :不更新文件系统上的 inode 访问时间,高并发环境推荐,可以显著提高性能
  • nodiratime :不更新文件系统上的目录节点访问时间,高并发环境推荐,可以显著提高性能
  • nosuid :不允许权限位生效,可以提高安全
  • noexec : 不允许文件系统执行二进制文件
  • remount :mount -o remount,rw (当系统出错进入救援模式时无法写系统,可利用 remount 参数)
  • clientaddr=<ip> :指定客户端用哪一个 ip 与 nfs 服务端通信。

rsize 参数只是定义了服务器在一次传输中可以发送的最大数据量,即 1MB。然而,实际上,客户端每次读取的数据块大小是由客户端应用程序决定的,而不是由 rsize 参数决定的。客户端应用程序在每次读取时可以选择读取 4KB 的数据块,也可以选择读取更大或更小的数据块,只要不超过服务器和客户端之间网络传输的最大数据包大小。wsize 同理。

一些挂载示例: - 客户端挂载加参数命令格式为:mount -t nfs -o bg,hard,intr,rsize=131072,wsize=131072 10.0.0.7:/data /mnt - 客户端的安全挂载命令:mount -t nfs -o nosuid,noexec,nodev,rw 192.168.50.1:/data /mnt - 客户端的性能挂载命令:mount -t nfs -o noatime,nodiratime,rw 192.168.50.1:/data /mnt - 客户端的安全加性能参数为:mount -t nfs -o noatime,nodiratime,nosuid,noexec,nodev,rw,hard,intr,rsize=131072,wsize=131072 192.168.50.1:/data /mnt - 本地文件系统挂载:mount /dev/sdb1 /mnt -o defaults,async,noatime,data=writeback,barrier=0 - 如果卸载文件系统时,有用户或者进程在访问,导致卸载的时候提示设备忙,则可以使用 umount -lf /mnt

2.2.1 选择客户端 ip

在多网卡机器上,有的网卡带宽较高,而有些带宽较低。如果数据包通过较低带宽的网卡传输数据,会严重影响读写操作的速度。此时我们可以通过 clientaddr=<ip> 选项指定用于连接服务端的客户端 ip。

$ mount  -t nfs -o vers=4,clientaddr=10.20.28.38 10.20.28.27:/fs1 /tmp/nfs 
$ nfsstat -m 
/tmp/nfs from 10.20.28.27:/fs1
 Flags: rw,relatime,vers=4.1,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=10.20.28.38,local_lock=none,addr=10.20.28.27

2.2.2 指定 nfs 端口

有些 nfs 使用自定义端口,这时可以通过 port=number 来指定 nfs 端口。

$ sudo mount -t nfs -o port=2049,vers=4.1 10.20.29.17:/fs2 /tmp/nfs

3 /etc/exports 配置

1. 可以在linux上通过`man exports`查看有哪些配置项。
2. 建议导出的共享目录是**整个文件系统**,而不是某个文件系统的子目录。因为导出子目录会产生一些其它问题。

/etc/exports 文件包含 NFS 服务器上可供 NFS 客户端访问的本地物理文件系统的列表。每一行表示一个导出点。每一行在路径名之后可能有一个或多个默认选项。以 # 开始的行作为注释行,不会被解析。 要对此文件应用更改,请运行 exportfs -rav 或重新启动 NFS 服务器。

3.1 语法格式

directory    Machine(option)[ Machine(option)[ Machine(option)[ ...]]]

/mnt 192.0.2.0/24(rw) trusty(rw,no_root_squash),每一行一个挂载点,且可以设置多个主机匹配规则,通过空格分隔。 - 示例

/  *(rw,fsid=0,insecure,no_root_squash)
/nfs1  *(rw,fsid=1,insecure,no_root_squash)

3.2 客户端主机名称格式

  1. ipv4 (192.0.2.0/24)和 ipv6(2001:db8:9:e54::/64):ip 后面的掩码部分可选,如 192.0.2.0
  2. 主机名(hostname ):hostname 是在 /etc/hosts 配置的
  3. 域名(cs.foo.edu):域名可由 DNS 域名服务器设置
  4. 网络组(@group):
  5. 匿名网络(*):表示所有网络客户端均可访问
  6. 通配符:通配符 *? 可以用在域名中,如 *.cs.foo.edu 会匹配所有在域名 cs.foo.edu 下的主机

3.3 选项

3.3.1 用户映射

默认情况下客户端以任何用户访问 nfs 服务端,用户会映射到 nfs 的匿名用户(nobody 用户),这个匿名用户可以通过 anonuid、anongid 设置。

选项 功能
root_squash 将客户端的 uid/gid 为 0(即 root 用户/组) 的映射到 anonymous 用户/组的 uid/gid
no_root_squash 不进行 uid/gid 为 0 (即 root)的映射,相当于 nfs 服务端还是使用 uid/gid 为 0 (root)的身份访问
all_squash 将客户端所有 uid/gid 映射到 anonymous 的 uid/gid(默认选项
no_all_squash 所有用户不进行 uid/gid 映射
anonuid 指定 anonymous 用户的 uid(默认是 nobody 用户)
anongid 指定 anonymous 组的 gid(默认是 nobody 组)
  • no_root_squash :如果对于访问 NFS server 共享目录用户是 root 的话,那这个客户端对这个共享目录具有 root 权限
  • root_squash :如果对于访问 NFS server 共享目录用户是 root 的话, 那被写入的数据的权限会被压缩成匿名用户,UID 和 GID 通常会变成 nfsnobody, 这个用户是可以改的,只是通常默认是这个。
  • all_squash :不管访问 NFS server 共享目录用户是 root 还是普通用户都会被压缩成匿名用户,UID 和 GID 通常会变成 nfsnobody, 这个用户是可以改的,只是通常默认是这个。

3.3.2 其它选项

选项 功能
rw 读写权限
ro 只读权限
secure 限制客户端只能从 0~1024 tcp/ip 端口访问(默认选项)
insecure 取消端口号限制
fsid=num/root/uuid 用于标识每一个文件系统,可以是 32 位数字、root 或者 uuid
async 数据异步写入,性能高,但有风险
sync 数据同步写入,性能较低,但数据不会丢失
no_wdelay 取消延迟提交功能;如果设置了 async 则失效。
wdelay 延迟提交写请求,以便于多个写请求合并提交,以提升性能;如果主要是不相关的小请求,性能反而会下降。
no_hide 不隐藏子目录,从而可以同时 export 目录和它的子目录。nfs4 默认开启,nfs2、nfs3 默认 hide 选项
hide 隐藏子目录,即不能共享了父目录后还共享它的子目录
no_subtree_check 不检查共享目录的父级目录是否有权限
subtree_check 检查共享目录的父级目录是否有权限,比如共享目录 /mnt/fs1, 当客户端请求到来时,还要检查父级目录 /mnt 是否也有权限
  • sync :同步客户端往服务端写数据,写成功后才返回 OK,安全不会丢数据,但是性能没 async 那么好。
  • async : 异步请求写入数据时,先返回请求,再将数据写入到内存,如果服务器中途断电,可能内存内的数据来不及向硬中写入,所以可能会丢数据,但是效率高,因为是往对方内中写数据,电商秒杀是异步,短时间内数据会稍微延迟。

3.4 配置示例

/               master(rw) trusty(rw,no_root_squash)
/projects       proj*.local.domain(rw)
/usr            *.local.domain(ro) @trusted(rw)
/home/joe       pc001(rw,all_squash,anonuid=150,anongid=100)
/pub            *(ro,insecure,all_squash)
/srv/www        -sync,rw server @trusted @external(ro)
/foo            2001:db8:9:e54::/64(rw) 192.0.2.0/24(rw)
/build          buildhost[0-9].local.domain(rw)
  1. The first line exports the entire filesystem to machines master and trusty. In addition to write access, all uid squashing is turned off for host trusty.
  2. The second and third entry show examples for wildcard hostnames and netgroups (this is the entry @trusted).
  3. The fourth line shows the entry for the PC/NFS client discussed above.
  4. Line 5 exports the public FTP directory to every host in the world, executing all requests under the nobody account. The insecure option in this entry also allows clients with NFS implementations that don't use a reserved port for NFS.
  5. The sixth line exports a directory read-write to the machine 'server' as well as the @trusted netgroup, and read-only to netgroup @external, all three mounts with the sync option enabled.
  6. The seventh line exports a directory to both an IPv6 and an IPv4 subnet. The eighth line demonstrates a character class wildcard match.

4 /etc/nfsmount.conf 配置

/etc/nfsmount.conf文件是 NFS 挂载的配置文件,用于指定挂载 NFS 文件系统时的一些参数和选项。

#
# /etc/nfsmount.conf - see nfsmount.conf(5) for details
#
# This is an NFS mount configuration file. This file can be broken
# up into three different sections: Mount, Server and Global
# 
# [ MountPoint "Mount_point" ] 
# This section defines all the mount options that
# should be used on a particular mount point. The '<Mount_Point>'
# string need to be an exact match of the path in the mount 
# command. Example:
#     [ MountPoint "/export/home" ]
#       background=True
# Would cause all mount to /export/home would be done in
# the background
#
# [ Server "Server_Name" ]
# This section defines all the mount options that
# should be used on mounts to a particular NFS server. 
# Example:
#     [ Server "nfsserver.foo.com" ]
#       rsize=32k
#       wsize=32k
# All reads and writes to the 'nfsserver.foo.com' server 
# will be done with 32k (32768 bytes) block sizes.
#
[ NFSMount_Global_Options ]
# This statically named section defines global mount 
# options that can be applied on all NFS mount.
#
# Protocol Version [2,3,4]
# This defines the default protocol version which will
# be used to start the negotiation with the server.
# Defaultvers=4
#
# Setting this option makes it mandatory the server supports the
# given version. The mount will fail if the given version is 
# not support by the server. 
# Nfsvers=4
#
# Network Protocol [udp,tcp,rdma] (Note: values are case sensitive)
# This defines the default network protocol which will
# be used to start the negotiation with the server.
# Defaultproto=tcp
#
# Setting this option makes it mandatory the server supports the
# given network protocol. The mount will fail if the given network
# protocol is not supported by the server.
# Proto=tcp
#
# The number of times a request will be retired before 
# generating a timeout 
# Retrans=2
#
# The number of minutes that will retry mount
# Retry=2
#
# The minimum time (in seconds) file attributes are cached
# acregmin=30
#
# The Maximum time (in seconds) file attributes are cached
# acregmin=60
#
# The minimum time (in seconds) directory attributes are cached
# acregmin=30
#
# The Maximum time (in seconds) directory attributes are cached
# acregmin=60
#
# Enable Access  Control  Lists
# Acl=False
#
# Enable Attribute Caching
# Ac=True
#
# Do mounts in background (i.e. asynchronously)
# Background=False
#
# Close-To-Open cache coherence
# Cto=True
#
# Do mounts in foreground (i.e. synchronously)
# Foreground=True
#
# How to handle times out from servers (Hard is STRONGLY suggested)
# Hard=True
# Soft=False
#
# Enable File Locking
# Lock=True
#
# Enable READDIRPLUS on NFS version 3 mounts
# Rdirplus=True
#
# Maximum Read Size (in Bytes)
# Rsize=8k
#
# Maximum Write Size (in Bytes)
# Wsize=8k
#
# Maximum Server Block Size (in Bytes)
# Bsize=8k
#
# Ignore unknown mount options
# Sloppy=False
#
# Share Data and Attribute Caches
# Sharecache=True
#
# The amount of time, in tenths of a seconds, the client
# will wait for a response from the server before retransmitting
# the request.
# Timeo=600
#
# Sets all attributes times to the same time (in seconds)
# actimeo=30
#
# Server Mountd port mountport
# mountport=4001
#
# Server Mountd Protocol
# mountproto=tcp
#
# Server Mountd Version
# mountvers=3
#
# Server Mountd Host
# mounthost=hostname
#
# Server Port
# Port=2049
#
# RPCGSS security flavors 
# [none, sys, krb5, krb5i, krb5p ]
# Sec=sys

5 /etc/sysconfig/nfs 配置

#
# Note: For new values to take effect the nfs-config service
# has to be restarted with the following command:
#    systemctl restart nfs-config
#
# Optional arguments passed to in-kernel lockd
#LOCKDARG=
# TCP port rpc.lockd should listen on.
#LOCKD_TCPPORT=32803
# UDP port rpc.lockd should listen on.
#LOCKD_UDPPORT=32769
#
# Optional arguments passed to rpc.nfsd. See rpc.nfsd(8)
#RPCNFSDARGS="-N 4"
#RPCNFSDARGS="-N 2 -N 3"
#RPCNFSDARGS="-V 4.2"
# Number of nfs server processes to be started.
# The default is 8. 
RPCNFSDCOUNT=8
#RPCNFSDCOUNT=1
#
# Set V4 grace period in seconds
#NFSD_V4_GRACE=90
#
# Set V4 lease period in seconds
#NFSD_V4_LEASE=90
#
# Optional arguments passed to rpc.mountd. See rpc.mountd(8)
RPCMOUNTDOPTS=""
# Port rpc.mountd should listen on.
#MOUNTD_PORT=892
#
# Optional arguments passed to rpc.statd. See rpc.statd(8)
STATDARG=""
# Port rpc.statd should listen on.
#STATD_PORT=662
# Outgoing port statd should used. The default is port
# is random
#STATD_OUTGOING_PORT=2020
# Specify callout program
#STATD_HA_CALLOUT="/usr/local/bin/foo"
#
#
# Optional arguments passed to sm-notify. See sm-notify(8)
SMNOTIFYARGS=""
#
# Optional arguments passed to rpc.idmapd. See rpc.idmapd(8)
RPCIDMAPDARGS=""
#
# Optional arguments passed to rpc.gssd. See rpc.gssd(8)
# Note: The rpc-gssd service will not start unless the 
#       file /etc/krb5.keytab exists. If an alternate
#       keytab is needed, that separate keytab file
#       location may be defined in the rpc-gssd.service's
#       systemd unit file under the ConditionPathExists
#       parameter
RPCGSSDARGS=""
#
# Enable usage of gssproxy. See gssproxy-mech(8).
GSS_USE_PROXY="yes"
#
# Optional arguments passed to blkmapd. See blkmapd(8)
BLKMAPDARGS=""
USE_KERNEL_NFSD_NUMBER=1

6 exportfs

-a 和 -v 不太清楚具体区别在哪。
  • 功能:维护导出的 NFS 文件系统表,主要使用 /etc/exports 文件
       /usr/sbin/exportfs [-avi] [-o options,..] [client:/path ..]
       /usr/sbin/exportfs -r [-v]
       /usr/sbin/exportfs [-av] -u [client:/path ..]
       /usr/sbin/exportfs [-v]
       /usr/sbin/exportfs -f
       /usr/sbin/exportfs -s

6.1 -d kind

6.2 -i

  • 功能:忽略/etc/exports 文件和/etc/exports.d 目录下的文件。仅使用默认选项和命令行上给定的选项。
  • 示例:
## exportfs -i
/tmp/nfs1       <world>

6.3 -a

  • 功能:导出或取消导出所有目录。
## exportfs -av
exporting 127.0.0.1:/tmp/nfs1

6.4 -r

  • 功能:重新导出所有目录
  • 示例
## exportfs -rv
exporting 127.0.0.1:/tmp/nfs1

6.5 -u

  • 功能:卸载一个或多个导出目录(客户端挂载点也会被卸载,如果又被导出,客户端又会被挂载,详见示例)
  • 示例:
## mount -t nfs 127.0.0.1:/tmp/nfs1 /tmp/cli1
## df -h|grep /tmp/cli1
127.0.0.1:/tmp/nfs1         17G  3.8G   14G  23% /tmp/cli1
## exportfs -vu 127.0.0.1:/tmp/nfs1
unexporting 127.0.0.1:/tmp/nfs1
## df -h|grep /tmp/cli1
## exportfs -av
exporting 127.0.0.1:/tmp/nfs1
## df -h|grep /tmp/cli1
127.0.0.1:/tmp/nfs1         17G  3.8G   14G  23% /tmp/cli1

6.6 -s

这个选项在显示导出列表信息时很像
  • 功能:显示/etc/exports 当前导出列表。
  • 示例:
## exportfs -s
/tmp/nfs1  *(sync,wdelay,hide,no_subtree_check,fsid=1,sec=sys,rw,secure,root_squash,no_all_squash)

6.7 -v

  • 功能:显示详细信息。导出或取消导出时,显示正在进行的操作;显示当前导出列表时,还显示导出选项列表。
  • 示例:
## 5 exportfs -v
/tmp/nfs1       <world>(sync,wdelay,hide,no_subtree_check,fsid=1,sec=sys,rw,secure,root_squash,no_all_squash)

7 showmount

  • 功能:显示 NFS 服务器的挂载信息

7.1 -e

  • 功能:显示 nfs 服务端的 exports 导出列表
  • 示例
## showmount -e 192.168.211.3
Export list for 192.168.211.3:
/tmp/nfs1 127.0.0.1

7.2 -a、-d

  • 功能:
    • -a 以 HostName:Directory 格式显示所有远程客户机挂载,其中 HostName 是客户机的名称,Directory 是远程挂载的目录路径名
    • -d :仅列出客户机挂载的目录
  • 示例
## showmount -a 192.168.211.3
All mount points on 192.168.211.3:
127.0.0.1:/tmp/nfs1
## showmount -d 192.168.211.3
Directories on 192.168.211.3:
/tmp/nfs1

8 nfsstat

8.1 -m

  • 功能:打印有关每个已挂载 NFS 文件系统的信息。
  • 示例
## nfsstat -m
/tmp/cli1 from 127.0.0.1:/tmp/nfs1
 Flags: rw,relatime,vers=3,rsize=524288,wsize=524288,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=127.0.0.1,mountvers=3,mountport=20048,mountproto=udp,local_lock=none,addr=127.0.0.1

8.2 -n

  • 功能:指定 nfs 版本,包括 2、3、4
  • 示例
## nfsstat -3 -c
Client rpc stats:
calls      retrans    authrefrsh
93         0          93      

Client nfs v3:
null             getattr          setattr          lookup           access           
2        12%     5        31%     0         0%     0         0%     0         0%     
readlink         read             write            create           mkdir            
0         0%     0         0%     0         0%     0         0%     0         0%     
symlink          mknod            remove           rmdir            rename           
0         0%     0         0%     0         0%     0         0%     0         0%     
link             readdir          readdirplus      fsstat           fsinfo           
0         0%     0         0%     0         0%     3        18%     4        25%     
pathconf         commit           
2        12%     0         0%    

8.3 -s、-c

默认服务端和客户端信息都会打印
  • 功能:
    • -s: 仅打印服务器端统计信息
    • -c : 仅打印客户端统计信息

8.4 -r

  • 功能:打印 rpc 统计信息
  • 示例
## nfsstat -r
Server rpc stats:
calls      badcalls   badfmt     badauth    badclnt
97         0          0          0          0       

Client rpc stats:
calls      retrans    authrefrsh
93         0          93     

8.5 -l

  • 功能:以列表形式打印信息
  • 示例
## nfsstat -l
nfs v3 server        total:       18 
------------- ------------- --------
nfs v3 server         null:        4 
nfs v3 server      getattr:        5 
nfs v3 server       fsstat:        3 
nfs v3 server       fsinfo:        4 
nfs v3 server     pathconf:        2 

9 rpcinfo

语法如下:

     rpcinfo [-m | -s] [host]
     rpcinfo -p [host]
     rpcinfo -T transport host prognum [versnum]
     rpcinfo -l [-T transport] host prognum versnum
     rpcinfo [-n portnum] -u host prognum [versnum]
     rpcinfo [-n portnum] [-t] host prognum [versnum]
     rpcinfo -a serv_address -T transport prognum [versnum]
     rpcinfo -b [-T transport] prognum versnum
     rpcinfo -d [-T transport] prognum versnum

以下是一些常见的 rpcinfo 命令用法和示例:

  1. 列出所有已注册的 RPC 服务

运行以下命令将显示本地主机上所有已注册的 RPC 服务及其相关信息:

rpcinfo -p

示例输出:

program version netid     address                service    owner
100000    4       tcp6      ::.0.111               portmapper superuser
100000    3       tcp6      ::.0.111               portmapper superuser
100000    2       tcp6      ::.0.111               portmapper superuser
100000    4       udp6      ::.0.111               portmapper superuser
100000    3       udp6      ::.0.111               portmapper superuser
100000    2       udp6      ::.0.111               portmapper superuser
  1. 查询特定主机上的 RPC 服务信息

使用以下命令可以查询特定主机上的 RPC 服务信息,将 hostname 替换为目标主机的名称或 IP 地址:

rpcinfo -p hostname

示例:

rpcinfo -p 192.168.1.100
  1. 列出服务器的地址和端口号

若要获取特定 RPC 程序的详细信息,包括地址和端口号,可以使用 -u 参数来列出 UDP 服务,使用 -t 参数来列出 TCP 服务。例如,要查看 portmapper 的 TCP 和 UDP 信息,可以运行:

rpcinfo -u 100000
rpcinfo -t 100000
  1. 让输出更简洁
rpcinfo -s klaxon

示例输出

     program   version (s)                          netid (s)   service      owner
     100000    2, 3, 4     local,tcp,udp,tcp6,udp6   rpcbind    super-user
     100008    1         udp,tcp,udp6,tcp6         walld      super-user
     100002    2, 1       udp,udp6                  rusersd    super-user
     100001    2, 3, 4     udp,udp6                  rstatd     super-user
     100012    1         udp,tcp                   sprayd     super-user
     100007    3         udp,tcp                   ypbind     super-user
  1. 注销某服务 rpc
rpcinfo -d 100008 1

或者

rpcinfo -d walld 1

9.1 rpcinfo -p

rpcinfo -p 命令用于列出已注册的 RPC(Remote Procedure Call)服务的信息,包括程序号、版本、网络标识、地址、服务名称以及所有者信息。以下是 rpcinfo -p 命令输出的解析示例:

program version netid     address                service    owner
100000    4       tcp6      ::.0.111               portmapper superuser
100000    3       tcp6      ::.0.111               portmapper superuser
100000    2       tcp6      ::.0.111               portmapper superuser
100000    4       udp6      ::.0.111               portmapper superuser
100000    3       udp6      ::.0.111               portmapper superuser
100000    2       udp6      ::.0.111               portmapper superuser

解析各列的含义:

  • program:RPC 程序的程序号(program number)。每个 RPC 程序都有一个唯一的程序号,用于标识该程序。
  • version:RPC 程序的版本号。每个 RPC 程序可以有不同的版本。
  • netid:网络标识(network identifier)或传输协议,表示 RPC 程序使用的网络类型。例如,"tcp6" 表示 TCP/IP 协议的 IPv6。
  • address:RPC 服务器的地址,包括 IP 地址和端口号。例如,::.0.111 表示服务器使用的 IPv6 地址和端口号 111。
  • service:RPC 服务的名称。在示例中,"portmapper" 是一个 RPC 服务的名称。
  • owner:RPC 服务的所有者信息。通常是超级用户(superuser)。

在示例输出中,可以看到不同的程序版本(version)在不同的网络标识(netid)下使用不同的地址(address)和端口号。这表示同一个 RPC 程序在不同网络上可能有多个实例,每个实例可能有不同的版本和地址。

10 NFS 实用命令

  • showmount -e 127.0.0.1 :显示可以挂载的文件系统
  • rpcinfo -p localhost 查看 nfs 注册的端口号
  • mount -t nfs 192.168.50.1:/data /mnt 挂载 nfs 文件系统
  • /etc/init.d/nfs reload 平滑重启服务
  • cat /proc/mounts |grep "root/nfs" 客户端查看挂载参数
  • cat /var/lib/nfs/etab 服务端查看 nfs 配置参数