A server-side:
1.1 Installation Services for NFS:
# Execute the following command to install the NFS server, #apt will automatically install nfs - the Common, the rpcbind other 13 packages sudo APT install nfs-Kernel-Server
1.2 write configuration file:
# Edit / etc / exports file: sudo vim / etc / exports # / etc / content exports file is as follows: / the Data / use * (rw, Sync , no_subtree_check, no_root_squash)
Resolution:
/ Data / use - NFS server directory, and for sharing client nfs
* - allows all network access, you can also use specific IP
rw-- mount this directory client has read and write permissions to the shared directory
sync-- written to memory and hard drive data synchronization
no_root_squash - root user has full administrative access to the root directory
no_subtree_check-- not check the permissions of the parent directory
1.3 Create a shared directory
# Create / data / server-side use shared directory sudo mkdir -p / data / use
1.4 Restart nfs service:
sudo service nfs-kernel-server restart
1.5 tool commonly used commands:
# When you install the NFS server already contains commonly used command-line tool, without additional installation. # Display client machine to mount the machine nfs directory. sudo showmount - E localhost # the directory configuration file to re-export all the time! Without having to restart the service. the sudo the exportfs - RV # view the operating state of NFS the sudo the nfsstat # view rpc execution information may be used to detect the operation rpc the sudo the rpcinfo # view the network port, the default is to use the NFS port 111. sudo netstat -tu - 4
Second, the client:
2.1 Installing client tools:
# On the need to connect to the server NFS client machine, # need to execute the following command to install nfs - the Common package. #apt will automatically install nfs - the Common, the rpcbind in 12 packages sudo APT install nfs-the Common
2.2 view shared directory on the NFS server
# Displays the specified (HCG-BG-AS- 01 ) Export out on the NFS server #hcg -bg-AS- 01 to the server host name or IP address of the sudo showmount -e HCG-BG-AS- 01
2.3 Create a local mount directory
sudo mkdir -p /data/use
2.4 mount the shared directory
# The NFS server 192. 168.3 directory on the .167, mount to the local / data / use / directory Mount -t nfs HCG-BG-AS- 01 : / data / use / the Data / use Mount -t nfs - O Sync , HCG-NFS-safe locking noac 01 : / Data / FreeSWITCH / Data / FreeSWITCH
2.4 automatically mount
vim /etc/fstab hcg-nfs-01:/data/freeswitch /data/freeswitch nfs defaults 0 0 hcg-nfs-01:/data/freeswitch /data/freeswitch nfs sync,noac 0 0
# Note: nfs-common is not installed or nfs-kernel- machine server package, # perform showmount, exportfs, nfsstat, rpcinfo commands directly, the # system will give prompt and friendly, # such as direct showmount will prompt APT need to do sudo install NFS-safe locking the Common command, # such as direct rpcinfo will prompt you need to perform APT sudo install the rpcbind command.
appendix
NFS common parameters ro-- read-only access rw-- write access Sync - all data written to the shared When requested async - nfs in response to the request before the write data can be secure - nfs 1024 through the secure the TCP / the IP port to send insecure - nfs sent through the port above 1024 if more than one user to be written nfs directory, the grouping write wdelay-- (default) no_wdelay-- If multiple users want to write nfs directory, write immediately when using the async, without this setting hide-- does not share its subdirectories nfs shared directory no_hide-- nfs shared subdirectory of subtree_check-- If the shared / usr / bin upon such subdirectory, check forced nfs permissions of the parent directory (the default) no_subtree_check-- above relative, do not check the parent directory permissions all_squash-- UID and GID mapping file sharing anonymous user anonymous, for the public directory. no_all_squash-- reserved share files UID and GID (default) root_squash - All root user requests mapped to the same privileges as anonymous users (default) no_root_squash - root user has full administrative access to the root directory anonuid = xxx-- specify nfs server / etc /passwd file in the anonymous user's UID anongid = xxx-- specify nfs server / etc / passwd file in the anonymous user's GID