Article Title: How to build an NFS service in a Linux operating system. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
This document only describes the simplest process of building NFS. It aims to help you quickly build and get started;
This build process is based on FC5 and uses the built-in SAMBA package;
I. Concepts
NFS (Network File System/Network File System ):
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, all_squash, anonuid = 65534, anongid = 65534)
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.
3. Check the shared directory
Then you can use showmount? E. 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;
3. 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 do not need to restart the nfs service to directly use exports? Rv can re-export the shared directory;
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. The showmout command is helpful for NFS operations and troubleshooting. 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.65.16
Export list for 172.20.65.16:
/Var/nfs 172. 20 .*.*
[Root @ ns var] # showmount-
All mount points on ns. osserver:
172. 20. *. *:/var/nfs
5. FAQs
1. Tip: mount to NFS server '2017. ipv67.203 'failed: server is down.
Solution: the NFS server firewall may be faulty;
2. Tip: 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.