NFS was first developed by Sun in 1984 to allow different computer operating systems to share files with each other. NFS is very convenient to use, so it was quickly widely supported by most Unix/Linux systems and developed by iete (International Internet Engineering Group) as rfc1904, rfc1813, and rfc3010 standards.
**************************************** ********
To use the NFS service, you must start at least three systems:
System daemon process.
(1) RPC. nfsd
(2) RPC. mountd
(3) Portmap
**************************************** ********
There are three methods to set file system sharing on NFS servers.
1. directly modify the/etc/exports file
2. Use the exports command to add and delete directories
3. Use graphical configuration methods
NFS client configuration method
1. Mount through the mount command
2. Add entries in/etc/fstab.
**************************************** *****************************
Each row in the exprots file provides a shared directory setting. The command format is:
<Output directory> [client 1 (option 1, option 2,…)] [Client 2 (option 1, option 2,…)]
Except that the output directory is a required parameter, other parameters are optional.
Note: The output directory and client in the format are separated by spaces between the client and the client, but there cannot be spaces between the client and the options.
**************************************** *****************************
A client is a computer on the network that can access the NFS output directory. The client can be an IP address or domain name of a single host, or a host in a subnet or domain.
Common Methods for specifying a client:
Client description
Host with the specified IP address 192.168.16.20
192.168.16.0/24 (or 192.168.16. *) specifies all hosts in the subnet
Host with the specified domain name pc1.gdvcp.net
* .Gdvcp.net all hosts in the specified domain
* (Or by default) All Hosts
**************************************** *****************************
Options are used to set access permissions for the output directory, user ing, etc. In the/etc/exports file, there are many options
Generally, it can be divided into three categories.
(1) access permission options
*************
Options used to control access to the output directory
Description of access permission options
RO sets the output directory to read-only
RW sets the output directory to read/write
(2) User ing options
*************
Description of user ing options
All_squash maps all common users and user groups remotely accessed to anonymous users or user groups (generally nfsnobody)
No_all_squash does not map all common users and user groups remotely accessed to anonymous users or user groups (set by default)
Root_squash maps root users and user groups to anonymous users or user groups (default)
No_root_squash does not map root users and user groups to anonymous users or user groups.
Anonuid = xxx maps all remotely accessed users to anonymous users, and specifies the anonymous user account as a local user account (uid = xxx)
Anongid = xxx maps all remotely accessed user groups to anonymous user group accounts, and specifies this anonymous user group account as a local user group account (gid = xxx)
(3) Other common options
**************
There are many other options for more comprehensive control over the output directory.
Other options
Secure limits the client to connect to the NFS server only from a TCP/IP port less than 1024 (default)
Insecure allows clients to connect to the NFS server from TCP/IP ports greater than 1024
Sync writes data to the memory buffer and disk synchronously. Although this method is inefficient, it ensures data consistency.
Async stores data in the memory buffer before writing data to the disk if necessary
Wdelay checks whether there are related write operations. If yes, execute these write operations together to improve efficiency (default setting)
No_wdelay is executed immediately if there is a write operation, and should be used with sync
Subtree_check if the output directory is a sub-directory, the NFS server checks the permissions of its parent directory (default setting)
No_subtree_check even if the output directory is a sub-directory, the NFS server does not check the permissions of its parent directory. This improves efficiency.
I. Installation
[Root @ localhost init. d] # cd/Media/Fedora/8/i386/DVD/packages/
[Root @ localhost packages] # Find.-Name "* NFS *"
/Nfs-utils-1.1.0-6.fc8.i386.rpm
/Nfs-utils-lib-1.1.0-3.fc8.i386.rpm
/System-config-nfs-1.3.32-1.fc8.noarch.rpm
[Root @ localhost packages] # Find.-Name "* Portmap *"
Installed by default
[Root @ localhost packages] # rpm-Q nfs-utils-lib-1.1.0-3.fc8.i386
Nfs-utils-lib-1.1.0-3.fc8
[Root @ localhost packages] # rpm-Q nfs-utils-1.1.0-6.fc8.i386
Nfs-utils-1.1.0-6.fc8
[Root @ localhost etc] #/etc/rc. d/init. d/nfs start
Start the NFS service: [OK]
Disable NFS quota: [OK]
Start the NFS daemon: [OK]
Start NFS mountd: [OK]
[Root @ localhost etc] #/etc/rc. d/init. d/nfs stop
Disable NFS mountd: [OK]
Disable the NFS daemon: [OK]
Disable NFS quotas: [OK]
Disable NFS: [failed]
Ii. configuration file/etc/exports
The file is empty by default and no shared directory is output. This is based on security considerations, so that no shared resources will be output even if the system starts the NFS service.
[Root @ localhost opt] # cd/
[Root @ localhost/] # mkdir NFS
[Root @ localhost/] # cd nfs/
[Root @ localhost NFS] # mkdir public root users Ji
[Root @ localhost NFS] # ls
Ji public root users
[Root @ localhost NFS] # pwd
/Nfs
[Root @ localhost etc] # vi exports
[Root @ localhost etc] # more exports
/Nfs/Public 192.168.1. * (RW, async) * (RO)
/Nfs/JI 192.168.1.6 (RW, sync)
/Nfs/root * .j1_com (RO, no_root_squash)
/Nfs/users * .jw.com (RW, insecure, all_squash, sync, no_wdelay)
3. start/stop
[Root @ localhost etc] #/etc/rc. d/init. d/nfs start
Start the NFS service: [OK]
Disable NFS quota: [OK]
Start the NFS daemon: [OK]
Start NFS mountd: [OK]
[Root @ localhost etc] #/etc/rc. d/init. d/nfs stop
Disable NFS mountd: [OK]
Disable the NFS daemon: [OK]
Disable NFS quotas: [OK]
Disable NFS: [OK]
Personal addition:
1. Install the xinetd service: Yum install xinetd
2. Disable the firewall: #/etc/init. d/iptables stop
Reprinted from: http://blog.chinaunix.net/u1/39714/showart_1004463.html