◆ 1. Concepts
NFS is short for Network File System. It is an integral part of a distributed computer system. It can share and assemble remote file systems on Heterogeneous Networks.
Developed by Sun, NFS has become a standard for file services (rfc1904, rfc1813 ). Its biggest function is to allow computers of different operating systems to share data through the network, so it can also be seen as a file server. NFS is a method for communication between windows, Linux, and UNIX and Linux except Samba.
|
Ideal NFS Network Topology |
1. Set file sharing between Linux systems (SAMBA service is used for file sharing between Linux and Windows );
2. NFS is only a file system. It has no transmission function and is implemented based on the RPC protocol to share the file directories between two Linux systems;
3. NFS is a C/S architecture;
◆ II. Server Configuration
1. Configuration File
The main configuration file is/etc/exports.
Format: mount the Host IP address in the shared directory (parameter 1, parameter 2 ,......)
For example:/var/nfs 172. 20. *. * (RW, sync, no_rootl_squash)
Note: The NFS/directory access permission must be set to 777. The parent directory/var permission is not required. The normal 755 permission is required;
2. Start Related Services
Start related services in sequence: Portmap, nfslock, and NFS.
Service Portmap start
Service nfslock start
Service NFS start
The close order is the opposite.
3. Check the shared directory
Then you can use showmount-e to check the shared directory:
[Root @ NS var] # showmount-e
Export list for NS. osserver:
/Var/nfs 172. 20 .*.*
OK. So far, the NFS server has been set up;
◆ Client Configuration
1. Ensure Portmap operation
The client must ensure that the corresponding Portmap of the RPC protocol runs normally; otherwise, the Mount fails;
2. Mount the/var/NFS Directory (the local mount point is/mnt/NFS)
Mount-t nfs 172.20.65.16:/var/nfs/mnt/nfs
After the Mount operation is successful, you can perform the same operations as the local directory;
◆ 4. Other related commands
1. After the/etc/exports file is modified,You can use exports-RV to re-export the shared directory without restarting the NFS service;
The command format is as follows:
Exportfs [-aruv]
-A: All content in Mount or unmount/etc/exports
-R: Re-mount the directory shared in/etc/exports
-U: umount directory
-V: when the export is used, the detailed information is output to the screen.
Example:
[Root @ NS var] # showmount-e
Export list for NS. osserver:
/Var/nfs 172. 20 .*.*
[Root @ NS var] # exportfs-Au # Uninstall all
[Root @ NS var] # showmount-e
Export list for NS. osserver:
[Root @ NS var] # exportfs-RV # Re-export all once
Exporting 172. 20. *. *:/var/nfs
[Root @ NS var] #
2. Run the showmout command to check NFS operations and errors.It is very helpful, so let's take a look at the usage of showmount.
Showmout
-A: this parameter is generally used on the NFS server and is used to display the Cline machine that has mounted the local NFS directory.
-E: displays the export directory on the specified NFS server.
For example:
[Root @ localhost ~] # Showmount-e 172.20.16.139
Export list for 172.20.16.139:
/Root/share 172.20.16.20.
[Root @ NS var] # showmount-
All mount points on localhost. localdomain:
*:/Root/share
, 172. 20. *. *:/root/share
, 172.20.16. *:/root/share
, 172.20.16.139:/nfsshare
, 172.20.16.139:/root/share
172.20.16.20 :*
172.20.16.20.:, 172. 20 .*.*
172.20.16.20.:, 172.20.16 .*
172.20.16.20.:/root/share
172.20.16.139 :*
172.20.16.139:, 172. 20 .*.*
172.20.16.139:, 172.20.16 .*
172.20.16.139:, 172.20.16.139
172.20.16.139: Default
◆ 5. FAQs
1. tips:Mount to NFS server '2017. ipv67.203 'failed: Server is down.
Solution: the NFS server firewall may be faulty;
2. tips:Mount: RPC: timed out
Solution: Because the RPC protocol is not running, start the Portmap service;
It may also be a firewall problem; server/client may also be.
Reprinted from: http://blog.csdn.net/symgdwyh/article/details/5936265