How to set and use NFS in Linux

Source: Internet
Author: User
Install the NFS server and client. # Yuminstallnfs configure the main NFS configuration file of the nfs server is/etc/exports, where the directory opened by the NFS server and the client access permission are configured. # Vi/etc/exports add: #/nfsdata192.168.109.109 (rw, root_squash, no_all_squa

Install NFS

Both the server and client must be installed.
# Yum install nfs

Configure NFS server

The main nfs configuration file is/etc/exports. here, the directory opened by the NFS server and the client access permission are configured.

# Vi/etc/exports

Join:

#/Nfsdata 192.168.109.109 (rw, root_squash, no_all_squash, sync)

Save Settings

# Exportfs-r

Configuration explanation:
# The configuration file is segmented into segments in each line:
# The first section is the shared directory, using the absolute path
# Section 2 shows the client address and permissions:
You can use the complete IP address or CIDR block, or the host name and wildcard character.
Permissions:
Rw: read-write, which can be read and written;
Ro: read-only, read-only;
Sync: writes files to both the hard disk and memory;
Async: files are stored in memory instead of directly written into memory;
No_root_squash: If the NFS client uses root to connect to the server, it also has root permissions for the directory shared by the server. It is obviously not safe to enable this feature.
Root_squash: If the NFS client uses root to connect to the server, it has Anonymous user permissions for the directory shared by the server. generally, it uses nobody or nfsnobody;
All_squash: no matter which user the NFS client uses to connect to the server, the directory shared by the server is anonymous;
Anonuid: UID value of an anonymous user, usually nobody or nfsnobody, which can be set here;
Anongid: the GID value of an anonymous user.
Allows the specified client to connect to the NFS server
Note that NFS uses portmap, and the new version of portmap uses the hosts. deny and hosts. allow files to control the access Source. modify these two configuration files so that the NFS client can connect to the server normally:

# Vi/etc/hosts. deny

Portmap: ALL

 

# Vi/etc/hosts. allow

Portmap: 192.168.1.103

Start and test the NFS server

Start the postmap

# Service nfs start

Show the shared directory information:

# Showmount-e

Display the Mount Directory:

# Showmount-e 192.168.109.109

Mount the network directory/nfsdata to/root/nfsdata (ensure that the directory exists)

# Mount-t nfs 192.168.109.109:/nfsdata/root/nfsdata

Check whether the disk has been mounted:

# Mount

If you need to mount the device at startup, do not forget to add it to/etc/fstab.

#/Root/nfsdata 192.168.1.101:/nfsdata

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.