Installing NFS Rpcbind
first, the service-side configuration
packages required to install Server for NFS: NFS and Rpcbind
# yum Install Nfs-utils
# Yum Install rpcbind (default system installed)
Set Startup
# Chkconfig NFS On
# Chkconfig Rpcbind on
Start the NFS service
1) first start Rpcbind service Rpcbind start
2) Restart NFS Service NFS Start
Configuring server-Side Shared directories
1) Edit the configuration file
Suppose the server-side directory is/home/data
# Vi/etc/exports
Format:
Directory to be shared (using absolute path) client host IP ... (multiple IPs can be separated by spaces)
/home/data 10.1.0.2 (rw,sync,all_squash,anonuid=0,anongid=1000) 10.1.0.3 (rw,sync,all_squash,anonuid=0,anongid= 1000)
The parameters in parentheses:
Rw:read-write, can read and write;
Ro:read-only, read-only;
Sync: The file is written to both the hard disk and memory;
Async: The file is temporarily stored in memory, not directly to the hard disk;
No_root_squash:nfs the client connects to the server, if root is used, it also has root access to the directory shared by the server. Obviously it's not safe to turn it on.
Root_squash:nfs the client connects to the server, if root is used, then the directory shared by the server, with anonymous user rights, usually he will use nobody or nfsnobody identity;
All_squash: Regardless of which user is used by the NFS client to connect to the server, the directory shared by the server has anonymous user rights;
Anonuid: The UID value of the anonymous user, usually nobody or nfsnobody, can be set at this point;
Anongid: The GID value of the anonymous user.
Other options
Secure restricts clients from connecting to Server for NFS (the default setting) only from TCP/IP ports less than 1024;
Insecure allows clients to connect to servers from TCP/IP ports greater than 1024;
Sync writes data synchronously to the memory buffer and disk, but it is inefficient, but it can guarantee the consistency of data;
Async saves the data in the memory buffer and writes the disk if necessary;
Wdelay Check if there is a related write operation, if any, then perform these writes together, which can improve the efficiency (default setting);
No_wdelay If a write operation is performed immediately, should be used in conjunction with sync;
Subtree If the output directory is a subdirectory, the NFS server will check the permissions of its parent directory (default setting);
No_subtree the NFS server does not check the permissions of its parent directory even if the output directory is a subdirectory, which can improve efficiency;
2) Load configuration file
Exportfs parameters
Parameters:
-A all mount settings in the/etc/exports file
-R: Re-mount the settings in/etc/exports, and also update the contents of/etc/exports and Var/lib/nfs/xtab synchronously.
-U: Uninstalling a directory
-V: The shared directory is displayed on the screen when you export.
3) Configuring the server-side firewall
Turn on server firewall port 2049
# Vi/etc/sysconfig/iptables
Add A Row-A input-m State--state new-m tcp-p TCP--dport 2049-j ACCEPT Save exit
#/etc/init.d/iptables Restart Restart effective
Second, the client configuration
Install NFS and Rpcbind services as the server and start Port 2049
Mount using the Monut command
Assume that the directory to be mounted by the client is/home/client server IP is 10.1.0.1
Mount-t NFS 10.0.1.1:/home/server/home/client
Umount-a Cancel All Mounts