NFS installation and configuration under Ubuntu 14.04

NFS installation and configuration under Ubuntu 14.04

Reference: http://www.linuxidc.com/Linux/2013-08/89154.htm

 

[Work to be done on the server side]

 

1. Execute the command: sudo apt-get install nfs-kernel-server ;

2. Execute the command: mkdir /home/jacobxu/nfs-jacoxu to create a dedicated folder for the nfs service;

3. After creating the folder, execute the command: sudo vi /etc/exports to configure nfs;

4. Add to the last line of the article: /home/jacobxu/nfs-jacoxu *(rw,sync,no_root_squash,no_subtree_check)
/home/jacobxu/nfs-jacoxu *(rw,sync,no_root_squash,no_subtree_check) The meaning of this line is :
/home/jacobxu/nfs-jacoxu: The directory shared with the nfs service client, this path must be the same as the path of the file you set earlier!
*: All network segment access is allowed, or specific IP can be used
rw: The client that mounts this directory has read and write permissions to the shared directory
sync: Data is written to memory and hard disk synchronously
no_root_squash: The root user has access to the root directory Full administrative access.
no_subtree_check: Do not check parent directory permissions.

 

You can specify the client ip address as follows (allow 10.10.86.22, 10.10.11.3 these two clients to access):

/data/share 10.10.86.22(rw,sync,no_root_squash,no_subtree_check) 10.10.11.3(rw,sync,no_root_squash,no_subtree_check)

 

5. After modifying the above configuration file, save and exit.

6. Execute the command: sudo /etc/init.d/rpcbind restart to restart the rpcbind service. nfs is an RPC program. Before using it, you need to map the port and set it through rpcbind.

7. Execute the command: sudo /etc/init.d/nfs-kernel-server restart to restart the nfs service.

 

Use the showmount -e command to check whether the configuration is normal

root@10-10-228-163:/etc# showmount -e
Export list for 10-10-228-163:
/data/share 10.10.11.3,10.10.86.22

 

[The work to be done by the client]

8. Mount command:
sudo mount -t nfs 192.168.111.128:/home/jacobxu/nfs-jacoxu /nfs-jacoxu-node001/
to any server to execute the mount command, you can specify the share on the ip server Path, mount to local.

Note: nfs is just a file directory sharing mode that is accessed locally. HDFS is a distributed file system that can load balance data among servers.

 

The following error is reported when the mount command is executed:

root@10-10-228-163:/# mount -t nfs 10.10.86.22:/data/images /data/mnt
mount: wrong fs type, bad option, bad superblock on 10.10.86.22:/data/images,
       missing codepage or helper program, or other error
       (for several filesystems (e.g. nfs, cifs) you might
       need a /sbin/mount.<type> helper program)
       In some cases useful info is found in syslog - try
       dmesg | tail  or so

That's because the client does not have mount.nfs installed. Check it with ls -l /sbin. Sure enough, there is no mount.nfs file in the /sbin directory.

Therefore, under the client mount mount.nfs execute the command:

apt-get install nfs-common

After the installation is successful, execute the mount command and it will be ok.

 

 

9. Automatic mount at boot:
write the above command sudo mount -t nfs 192.168.111.128:/home/jacobxu/nfs-jacoxu /nfs-jacoxu-node001/ to the /etc/rc.local file

 

10. Cancel the mount

sudo umount /nfs-jacoxu-node001/

================================

Appendix: Common parameters of NFS are as follows:
ro read-only access
rw read-write access sync all data is written to the share when requested
async nfs can respond to requests before writing data secure nfs sends insecure nfs through 1024 through
a secure TCP/IP port below 1024
The above port sends
wdelay If multiple users want to write to the nfs directory, grouped writes (default)
no_wdelay If multiple users want to write to the nfs directory, write immediately, when using async, this setting is not required.
hide Do not share its subdirectories in the nfs shared directory
no_hide Share the subdirectories of the nfs directory
subtree_check If a subdirectory such as /usr/bin is shared, force nfs to check the permissions of the parent directory (default)
no_subtree_check Relative to the above, do not check the parent Directory permissions
all_squash Shared file UID and GID mapping anonymous user anonymous, suitable for public directories.
no_all_squash keep UID and GID of shared files (default)
root_squash All requests of root user are mapped to the same permissions as anonymous user (default)
no_root_squas root user has full administrative access to the root directory
annuid=xxx Specifies the nfs server /etc/passwd file The UID of the anonymous user in the
anongid=xxx specifies the GID of the anonymous user in the /etc/passwd file of the nfs server

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326676724&siteId=291194637