NFS Service Configuration

Source: Internet
Author: User

19th NFS service configuration


" What is NFS"


NFS is often used to share storage on the network. So, you may not know much about NFS , so I would like to cite an example to illustrate what NFS is for. If there are three machines a,b,C, they need to access the same directory, the directory is a picture, the traditional practice is to put these pictures in A,b,C. But using NFS only needs to be placed on a , then a is shared with B and C . At the time of the visit,B and C go through the network to access the directory on a .


" Configure NFS"


NFS is quite simple to configure, just edit the configuration file /etc/exports . The following author first creates a simple NFS server.


[Email protected] ~]# cat/etc/exports


/home/ 10.0.2.0/24 (rw,sync,all_squash,anonuid=501,anongid=501)


This configuration file is a simple line. is divided into three parts, the first part is the local directory to be shared, the second part is allowed to access the host (can be an IP can also be an IP segment) The third part is the parentheses inside, for some permission options. About the third part, the author briefly introduces:


RW : Read and write;


ro : Read only;


Sync: Synchronous mode, in-memory data is always written to disk;


Async : Out-of-sync, write in-memory data to disk on a regular basis;


No_root_squash : With this option, theroot user has high control over the shared directory, as if it were a native directory operation. Unsafe, not recommended for use;


Root_squash : And the above options correspond to theroot user permissions on the shared directory is not high, only the normal user's permission, that is, limit the root;


All_squash : Regardless of the user who uses NFS , his identity will be limited to a designated ordinary user identity;


Anonuid/anongid : To be used with Root_squash and all_squash to specify a user-defined UID that uses NFS and GID, provided that this uid and gidexist in the /etc/passwd of this machine.


After introducing the relevant permission options above, I will analyze the /etc/exports file I have just configured. Where to share the directory is /home, the trusted host is 10.0.2.0/24 This network segment, permissions for read-write, synchronization, limit all users, and the qualified uid and gid are 501.


" using NFS"


When you finish editing the configuration file /etc/exports , it is time to start the NFS service. The Startup method is:


[[email protected] ~]# service portmap start; service NFS Start


NFS is based on Portmap , so start portmapFirst, and then Start NFS before the configuration takes effect. After you start NFS , you should use service for NFS .


[[email protected] ~]# showmount-e 127.0.0.1 (used on the client )


Export list for 127.0.0.1:


/Home 10.0.2.0/24


shoumount-e plus IP can be used to view the sharing of NFS , in the above example, you can see the 127.0.0.1 shared directory is/home, the trusted host is 10.0.2.0/24 this network segment. Another common option for this showmount command is-A, which means that the client of NFS connected to the machine is all listed.


[[email protected] ~]# mount-t NFS 10.0.2.69:/home/mnt (client )


[[email protected] ~]# showmount-a (onNFS server)


All mount points on localhost:


10.0.2.69:/home


The preceding Mount command is to mount the NFS shared directory, and I believe you can read this format. The showmount-a command lists all the clinet.


There is also a common command in service for NFS that is Exportfs, and its common option is [-aruv].


-A: Mount or uninstall all;


- R : re-mount;


- u : Uninstalls a directory;


- v : Displays the shared directory;


With the Exportfs command, you can use this exportfs without restarting the NFS service after changing the /etc/exports configuration file.


[Email protected] ~]# cat/etc/exports


/tmp/ 10.0.2.0/24 (Rw,sync,no_root_squash)


[[email protected] ~]# exportfs-arv (onNFS server)


Exporting 10.0.2.0/24:/tmp


After you change the directory, the direct Exportfs-arv will take effect.


The Mount command is used above to Mount NFS, but there are some claims for Mount NFS service. The first is to use- t NFS to specify that the mount type is NFS. In addition, when using NFS , one of the most common options is nolock , which is not locked when the NFS service is mounted.


[Email protected] ~]# mount-t nfs-o nolock 10.0.2.69:/tmp/mnt/


[Email protected] ~]# showmount-a


All mount points on localhost:


10.0.2.69:/home


10.0.2.69:/tmp


In addition, we can also write the NFS directory to be mounted to the /etc/fstab file on the client , only mount-a is required to mount the load.


[Email protected] ~]# cat/etc/fstab


label=//ext3 Defaults 1 1

Label=/boot/boot ext3 Defaults 1 2

TMPFS/DEV/SHM TMPFS Defaults 0 0

Devpts/dev/pts devpts gid=5,mode=620 0 0

Sysfs/sys Sysfs Defaults 0 0

PROC/PROC proc Defaults 0 0

Label=swap-hda2 swap swap defaults 0 0

10.0.2.69:/tmp /mnt NFS nolock 0 0


After you finish writing the /etc/fstab file, you only need to mount-a to mount the shared directory for the NFS service.


[[email protected] ~]# umount/mnt/ First uninstall the NFS you just mounted


[Email protected] ~]# mount-a


[Email protected] ~]# df-h


Filesystem Size used Avail use% mounted on

/dev/hda3 7.3G 3.7G 3.3G 53%/

/DEV/HDA1 99M 12M 83M 12%/boot

Tmpfs 84M 0 84M 0%/dev/shm

10.0.2.69:/tmp 7.3G 3.7G 3.3G 53%/mnt


On the NFS part of the talk so much, the content is not much, I believe you will soon be able to master!

Copyright notice: I feel like I'm doing a good job. I hope you can move your mouse and keyboard for me to order a praise or give me a comment, under the Grateful!_____________________________________________________ __ Welcome reprint, in the hope that you reprint at the same time, add the original address, thank you with

NFS Service Configuration

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.