Setting up NFS services under Linux

Source: Internet
Author: User


Refer to "Simple NFS server Settings" in "Bird's Linux Private cuisine", stating the setup process only

1. About NFS (Network FileSystem) and RPC (Remote Procedure call)
NFS, the network file system, enables a local host to mount a directory shared by a remote NFS host over the network to a local host.
RPC, "Remote Procedure Call", NFS uses RPC protocol for data transfer. Therefore, both NFS server and client have to start RPC for data transfer.

2.Server Terminal settings
/etc/exports main configuration file for NFS
/usr/sbin/exprotfs Use this command to re-share/etc/exports changed directory resources, uninstall or re-share NFS shared directories, etc.
/usr/sbin/showmount clients use this command to view the directory resources shared by the server side
/var/lib/nfs/xtab NFS log files to see which client side has ever connected to an NFS host

2.1/etc/exports Settings
file format:
[shared directory] [hostname 1 or IP1 (parameters..)] [Host Name 2 or IP2 (parameter:)]
[Share directory]: is the directory to share to IP1 and IP2
Main parameters:
RW: Read-write
ro: read-only
No_root_squash: root for the shared directory when logged on to the host user root
Root _squash: When the host is logged in as the root user, it does not have root privileges and the user is compressed to anonymous users nobody
All_squash: The user is compressed to anonymous user nobody
Anonuid: for *_ Squash mentioned anonymous user, the UID of the user's self-setting
Anongid: With Anonuid, self-setting GID
Sync: Data synchronously written to memory and hard disk
Async: Data is staged in memory, not directly written to the hard disk
Example:
/home/public 192.168.0.* (rw) * (RO)
/tmp * (rw,no_root_squash)
/home/linux *.linux.org (Rw,all_squash, ANONUID=40,ANONGID=40)

2.2 Start service PORTMAP,NFSD
[[email protected] root]#/etc/rc.d/init.d/portmap start<== start Portmap
[[email protected] root]#/etc/rc.d/init.d/nfs start<== start NFS

2.3 Exportfs Command
Grammar:
[Email protected] root]# Exportfs [-aruv]
Parameter description:
-A: All mounts (or uninstalls) the settings in the/etc/exports file
-R: Re-mount the/etc/exports inside the settings, in addition, also synchronize updates/etc/exports and/var/lib/nfs/xtab content!
-U: Uninstalling a directory
-V: When you export, the shared directory is displayed on the screen!
Example:
[[email protected] root]# EXPORTFS-RV <== all re-export once!
[[email protected] root]# Exportfs-au <== all unloaded!

2.4/var/lib/nfs/xtab

2.5 showmount command, scan a host of NFS-shared directories that he provides
Grammar:
[Email protected] root]# showmount [-AE] hostname
-A: Displays the status of the current use directory on the screen that the host and Client are connected to
-e: Show hostname The/etc/exports of this machine!
Example:
[Email protected] root]# showmount-e 192.168.0.88

2.6 Instructions for RPC server, rpcinfo
Grammar:
[Email protected] root]# rpcinfo [-P] hostname (ORIP)
-P: Displays all the port and program information!

3.Client Terminal settings

3.1 Scan the Server directory that can be used;//reference Showmount Usage

3.2 Create a local mount directory on the Client local side by setting up Mount Point;//mkdir

3.3 Use mount to mount the directory shared by the remote host;
[Email protected] root]# MOUNT-T NFS hostname (ORIP):/directory/mount/point
[Email protected] root]# Umount/mount/point

4. Firewalls
Shutting down the firewall is a once in a while, otherwise open the relevant port

5. To be aware of when shutting down or closing the machine
Since this RPC used by NFS is connected to the client side of the host, then your host wants to shut down, which can become an "impossible task"
If you have a client on your server that is online, it is recommended that you uninstall the remote directory mount, "Turn off Portmap and NFS" before shutting down the computer.

Setting up NFS services under Linux

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.