NFS file systems are a type of network protocol that we are familiar. With the support of this network protocol, you can complete file sharing and network storage. The following describes the basic monitoring program and configuration.
Basic monitoring program
To run NFS smoothly, at least five Linux services are required. They have different functions, some are responsible for loading services, and some ensure that remote commands are directed to the correct location. these services use/etc/rc. d/init. the nfs, nfslock, and portmap scripts in the d directory are started. the following describes each monitoring program:
(1) Basic NFS
Rpc. nfsd is the NFS server Monitoring Program, which uses/etc/rc. d/init. run the nfs script in the d directory. the NFS Monitor also starts rpc. mountd loads the monitoring program and exports the shared directory.
(2) RPC Loading
You can use the mount command to connect to the local directory or network directory, but you also need a special monitoring program rpc. mountd that loads the NFS directory.
(3) Port er
The portmap monitor only directs the RPC communication data stream, but it is very important for the NFS service. If portmap is not run, the NFS client cannot find the directory shared from the NFS server.
(4) restart and statd
When the NFS service needs to be interrupted or restarted, the rpc. statd monitoring program and rpc. lockd resume the NFS connection of the client after the server is restarted.
(5) Lock
When a file is opened through the shared NFS directory, the user cannot overwrite the same file by locking the file through the nfslock script and starts running using the rpc. lockd monitoring program.
Procedure
Server Configuration and operations:
1. daemon to be run
Portmap
Nfsd
Rpc. mountd
Rpc. rquotad
Rpc. statd
Lockd
To start an NFS server, you must start portmap and nfs services. portmap must take precedence over nfs.
Stop the NFS server. You need to stop the NFS service before stopping the portmap service!
Stop: #/etc/rc. d/init. d/nfs stop
#/Etc/rc. d/init. d/portmap stop
Start: #/etc/rc. d/init. d/portmap start
#/Etc/rc. d/init. d/nfs start
2. configuration file of the NFS File System
Export Directory: when the server enables a directory to be used by other computers, it is usually said that this server "exports (export)" A directory
/Etc/exports is a list of exported directories.
The writing rules are as follows:
One row of each sharing rule. You can use a backslash to continue the row.
A client that can access a given file system is represented by a list separated by spaces. Each client is followed by a series of choices separated by commas.
As follows:
Export Directory Client (option 1, option 2 ,......) Client (option 1, option 2 ,......)
For example:
/Mnt/cdrom * .abc.com (ro, sync) master.abc.com (rw, sync)
The above rule means to share the/mnt/cdrom directory to the * .abc.com domain in read-only synchronization mode and share it with the master.abc.com host in read/write synchronization mode.
/Tmp * (rw, no_root_squash)
/Home/public 192.168.0. * (rw) * (ro)
/Home/test192.168.0.100 (rw)
/Home/linux * .the9.com (rw, all_squash, anonuid = 40, anongid = 40)
Description of the client in the/etc/exports file
Type syntax meaning
Host Name hostname
Network Group @ groupname NIS Network Group
Wildcard * and? FQDN with wildcard characters (* mismatch .)
Description of the ipaddr/mask CIDR style of the IP network (for example, 128.138.92.128/25)
Common export options in the/etc/exports file