Collection of my translations：http://www.cnblogs.com/f-ck-need-u/p/7048359.html
rpc.statd Main program implementationNFS Lock related content, Such as ordinary file lock(NLM,NSM), Document delegation, Lease, etc. But pay attention to, Its sumsm-notify Combined to achieve the wholeNFS Locking mechanism, For details, please refer to the following translation documents.
RPC.STATD(8) System Manager's Manual RPC.STATD(8) NAME rpc.statd - NSM Service Daemon
SYNOPSIS rpc.statd [-dh?FLNvV] [-H prog] [-n my-name] [-o outgoing-port] [-p
listener-port] [-P path] [--nlm-port port] [--nlm-udp-port port] DESCRIPTION
File lock is not part of persistent file system state. Therefore, the lock status will be lost when the host restarts.
When the remote host restarts, The network file system must be able to detect the loss of lock state. WhenNFS On client restart,NFS service
The client must release all file locks requested by the client. After the server is restarted, The client must be able to remind the server of its application All file locks requested for.
aboutNFSv2 andNFSv3, Using the network status monitorNetwork Status Monitor(NSM) Agreement to informNFS Opposite end about weight
Kai's business. stayLinux upper,NSM The service process consists of two independent user space programs： ● rpc.statd
The daemons are used to listen for restart messages from other hosts, And manage the list of hosts that need to be notified when the local host restarts. ● sm-notify An assistant program, Used to notify when the local system restartsNFS Opposite end.
( translator's note： In other wordsrpc.statd Is the recipient of the restart message, andsm-notify Is the informer of information) localNFS Lock manager(NFS lock
manager,NLM) It will be localrpc.statd Warn each remote peer in the list Status needs to be monitored. When the local system restarts,sm-
notify The command will notify the peerNSM Service about restarting matter. When the remote host restarts, Remote to endsm-
notify Notify localrcp.statd, Then tell the localNFS Lock manager, The local lock manager will maintain the lock of the file corresponding to the restart end. NSM OPERATION IN
DETAIL NFS The first file lock interaction between the client and the server will cause theNLM All contact their localNSM Service to
Store their end-to-end information. stayLinux upper, That is, let the local manager contactrpc.statd Daemon.
rpc.statd WillNFS Peer information is recorded on persistent storage. This information describes how to contact the remote if the local system restarts
Opposite end, How to identify the information that the peer reports it is restarting, And how to notify when the peer says it has restartedNLM.
Each client will send a file lock request called clientcaller_name Hostname.NFS The server can
Send async to client with this hostnameGRANT call, Or notify the client that it has restarted. Linux
NFS The server cancaller_name Or the client's network address is provided torpc.statd. In order to observeNSM
Agreement, The name or address is called peermon_name. in addition, The local lock manager will tellrpc.statd Its own hostname, In order to observeNSM Agreement, This hostname is calledmy_name.
stayNFS in,NFS The server does not inform the client of the interaction behavior of its host name. thereforeNFS The client does not actually know the server
Ofmon_name, Though inSM_NOTIFY It will be used in the request.Linux NFS The client is obtained from the mount command by using the
To identify the startingNFS Server side. Reboot notification When the local system restarts, Localsm-
notify Command to read monitoring peer list from persistent storage, And sendSM_NOTIFY request
For each remote peer in the listNSM Service process, Its usemon_name String to specify the send destination. To identify which owner Machine has been restarted, After reboot, the host will usesm-
notify Command sendmy_name Character string. Long-rangerpc.statd Will use The string matches the counterpart in its monitor list to find the sendSM_NOTIFY Requested host.
Ifrpc.statd No matching received in its monitoring listSM_NOTIFY Opposite end of request, The notification will not be forwarded
To local lock manager. in addition, Each peer has a unique32 Bit integerNSM Status code, After every reboot,sm-notify life
Make it collide and repeat.rpc.statd Use this number to distinguish between restart or notification replay. NFS Part of lock recovery is to rediscover which peer needs to be monitored again. After every reboot,sm-
notify Orders will be clear Monitoring list on empty persistent storage. OPTIONS-d, --no-syslog If specified at the same time"-F"
option, It means lettingrpc.statd No longersyslog Log in, It's outputstderr in.-F, --foreground
bringrpc.statd Attached to the control terminal forNSM Operation can be directly monitored, Mainly for debugging. If not Set the option. berpc.statd Enter background operation immediately after startup.-h,
-? --help outputrpc.statd Instructions for using the command and exit. -H, --ha-callout prog
Specify a high availabilitycallout program. If this option is not specified, Nocallout program. For details, see Underneath"High-availability callouts"
paragraph.-L, --no-notify preventrpc.statd Run when it startssm-notify command, And prevent retention of existingNSM Status number and monitoring column surface. Be careful：sm-
notify The command contains a check to ensure that it only runs once after each system restart. ifrpc.statd Take no"-L" On option restart, This prevents false restart notifications. -n,
--name ipaddr |hostname AppointRPC Listen for socket binding address. If this option is not specified,rpc.statd Use generic address( Namely0.0.0.0).
The string is also passed tosm-notify command, Used as the source address when sending restart notification request. For details, see sm-notify(8) Ofman File. -N
Give Wayrpc.statd implementsm-notify Command and exit. Becausesm-notify Command can be run directly, This option is obsolete. -o, --outgoing-port port
Designated assm-notify Source port number used when command sends restart notification. For details, seesm-notify(8) Ofman File. -p, --port port
Appointrpc Port number of listening socket. If this option is not specified, berpc.statd Will try to/etc/services in
Obtain, If successful, This port number is set for all listening sockets, Otherwise, it will be selected for each listening socket A random port number.
The option isSM_NOTIFY It can be used to adjust the port number when passing through the firewall, Prevent being blocked by firewall.-T, --nlm-port port Designated monitoringNLM Requested port number. Unless used"
-U" Specified separatelyUDP Port number, Otherwise, it will monitor at the same timeTCP andUDP Of Port number. -U, --nlm-udp-port port Designated monitoringNLM RequestedUDP Port number.
-P, --state-directory-path pathname AppointNSM Parent directory of state information saving path. If this option is not specified, The default is/var/lib/nfs/
statd. After program start,rpc.statd Will attempt to use for this directoryUID andGID Set its owner and group.-v, -V, --version
outputrpc.statd Version number of and exit. SECURITY The rpc.statd daemon must be started as root to
acquire privileges needed to create sockets with privileged source ports, and
to access the state information database. Because rpc.statd mai- ntains a long-
running network service, however, it drops root privileges as soon as it starts
up to reduce the risk of a privilege escalation attack. During normal
operation, the effective user ID it chooses is the owner of the state
directory. This allows it to continue to access filesin that directory after it
has dropped its root privileges. To controlwhich user ID rpc.statd chooses,
simply usechown(1) to set the owner of the state directory. You can also
protect your rpc.statd listeners using the tcp_wrapper library or iptables(8).
To use the tcp_wrapper library, add the hostnames of peers that should be
allowed access to/etc/hosts.allow. Use the daemon name statd even if the
rpc.statd binary has a different filename. For further information see the tcpd(
8) and hosts_access(5) man pages. ADDITIONAL NOTES
Lock recovery after a host reboot is critical to maintaining data consistency and preventing unnecessary application hangs. In order to make
rpc.statd Match more efficientlySM_NOTIFY request, Some best practices should be followed, Include： SystematicUTS Name needs andNFS Used to make connectionsDNS Name matches.
( notes： If you don't know what to doUTS name, We can simply think thatUTS Name is the host name) SystematicUTS Name should always befqdn Name of the format.
SystematicUTS Forward and reverse of namesDNS It is better to keep the mapping consistent. The host name of the server that the client uses to mount should match the one it sendsSM_NOTIFY In requestmon_name.
uninstallNFS There is no need to stop the state monitoring of the client or any end of the server when the file system is running. Both ends may continue to monitor for a while
time, In case of new mounts and additional file locks between the two endsNFS Traffic appears.
stayLinux upper, If not installed in the kernel lock module, All remoteNFS The opposite end will not be monitored. This could happen inNFS Of
Client side, for example, Auto mount tool removed allNFS Mount point, Because they are idle and inactive. High-availability callouts
stayrpc.statd Successful treatmentSM_MON, SM_UNMOU andSM_UNMON_ALL Requested or receivedSM_NOTIFY Time,rpc.statd Sure
Execute a specific callback(callout) program. This program is highly availableNFS(HA-NFS) Can be used to track lock status in the environment, Especially When resources need to be migrated after a node host restarts.
callout The name of the program is given byrpc.statd Of"-H" Option specified. The program runs with4 A parameter： The first parameter isadd-client ordel-client orsm-
notify, It depends on why you callcallout Reasons for. The second parameter is to monitor the end-to-endmon_name. The third parameter is that the lock manager needs toadd-client ordel-
client Hourcaller_name, Otherwise, it will be sentSM_NOTIFY RequestedIP address. The fourth parameter isSM_NOTIFY In requeststate_value.
IPv6 and TI-RPC support TI-RPC is a pre-requisite for supporting NFS on IPv6.
If TI-RPC support is built into rpc.statd, it attempts to start listeners on
network transports marked'visible' in /etc/netconfig. As long as at least one
network transport listener starts successfully, rpc.statd will operate. FILES
/var/lib/nfs/statd/sm directory containing monitor list /var/lib/nfs/statd/
sm.bak directory containing notify list/var/lib/nfs/statd/state NSM state number
for this host /var/run/run.statd.pid pid file /etc/netconfig network transport
capability database SEE ALSO sm-notify(8),nfs(5),rpc.nfsd(8),rpcbind(8),tcpd(8
),hosts_access(5),iptables(8),netconfig(5) RFC 1094 - "NFS: Network File System
Protocol Specification" RFC 1813 - "NFS Version 3 Protocol Specification"
OpenGroup Protocolsfor Interworking: XNFS, Version 3W - Chapter 11 AUTHORS Jeff
Uphoff<[email protected]> Olaf Kirch <[email protected]> H.J. Lu
<[email protected]> Lon Hohberger <[email protected]> Paul Clements
<[email protected]> Chuck Lever <[email protected]> 1 November
Below isNFS Related translation：
translate：man rpcbind(rpcbind Chinese Manual) <http://www.cnblogs.com/f-ck-need-u/p/7302577.html>
translate：man nfsd(rpc.nfsd Chinese Manual) <http://www.cnblogs.com/f-ck-need-u/p/7302580.html>
translate：man mountd(rpc.mountd Chinese Manual)
translate：man statd(rpc.statd Chinese Manual) <http://www.cnblogs.com/f-ck-need-u/p/7302593.html>
translate：man sm-notify(sm-notify Command manual in Chinese)
translate：man exportfs(exportfs Command manual in Chinese)
Partial translation：man nfs <http://www.cnblogs.com/f-ck-need-u/p/7305755.html#blogmannfs>