Build an NFS environment

Source: Internet
Author: User


I. INTRODUCTION

What is NFS? NFS is the abbreviation for the network file system's Web filesystem, and his main function is to allow files or directories to be shared between different host systems over a network (usually a local area network).

More suitable for IDC room, cluster. At Work, NFS is typically used to store static files such as videos, images, attachments, or to understand that files uploaded by users are suitable for NFS sharing.

There is a similar service called Samba, which is more like a Windows file share, more for office scenes.


Two. Have to say

For the NFS service to run successfully, Rpcbind support is also required (called Portmap before CENTOS6). I am more vulgar, so the saying is Rpcbind is a rental intermediary, want to mount a shared directory (like renting a house) without it.

There is a stolen picture below, clearly explain the role of Rpcbind.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/89/F5/wKioL1gi47SAmdSFAAIWr1YAaOU736.png "/>


Three. Preparation of the experimental environment

First prepare two virtual machines, the system is CentOS6.3 x64, a server, a client. Need to install Nfs-utils and rpcbind, turn off selinux and firewalls.


Four. Start building Nfs-server Server

Install Nfs-utils and Rpcbind services, check after installation

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/89/F9/wKiom1gi47WCIV2AAAAEaQdzhDo874.png "/>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/89/F9/wKiom1gi47WiaeomAAAGYsxto4w623.png "/>

Start the Rpcbind service and check

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/89/F5/wKioL1gi47WT_r78AAAHgKJVrt8108.png "/>

Rpcbind service runs on port 111 of TCP/UDP

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/89/F5/wKioL1gi47Xirud9AAANA2g1t3U211.png "/>

# rpcinfo p localhost View the current resource pool

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/89/F9/wKiom1gi47aSUPitAAAIJwpdlEg145.png "/>

Start the NFS service and check

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/89/F9/wKiom1gi47azid7rAAARo3ELVps822.png "/>

To view the primary port number for NFS 2049

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/89/F5/wKioL1gi47bQoPg0AAAIaQr9fx8170.png "/>

# vim/etc/rc.local Edit/etc/rc.local file, add rpcbind,nfs-utils to boot

Note Order: Rpcbind in front, nfs-utils in the rear

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/89/F5/wKioL1gi47bTRIlWAAAF2rb3Z4Q734.png "/>

The next step is to edit the NFS configuration file. The path is/etc/exports, and the file is empty by default

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/89/F9/wKiom1gi47eToszeAAADlGK23H0979.png "/>

The/data directory as the directory to be shared, * means that any host can access, and have read and write permissions, sync for the client can synchronously write to the server disk, to ensure that the file is not lost

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/89/F9/wKiom1gi47fAAUIAAAAC77tHXls789.png "/>

Create a/data directory and create several subdirectories to facilitate later experimentation

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/89/F5/wKioL1gi47eQfDACAAAEKcPN6_E571.png "/>

Reload enables smooth load services without impacting online customers

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/89/F5/wKioL1gi47eDC1kxAAAD9-oAnro261.png "/>

See which shared directories are available on this machine (Showmount e 127.0.0.1)

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/89/F9/wKiom1gi47iy9bIeAAAHHhyogWk237.png "/>

Native mounted shared directory test, Mount point is/mnt

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/89/F5/wKioL1gi47jyvHS8AAAF2G5sXsA461.png "/>


Five. Client Configuration

Also need to install Nfs-utils and Rpcbind

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/89/F9/wKiom1gi47iB9OahAAAEmXCZHLo978.png "/>

Determine that the Rpcbind service is working properly

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/89/F5/wKioL1gi47jDpwmEAAAHdUGbgSc336.png "/>

# vim/etc/rc.local Add rpcbind service to boot

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/89/F9/wKiom1gi47mxR36NAAAEsdh8rqU652.png "/>

Test if you can communicate with Nfs-server and see which shared directories

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/89/F5/wKioL1gi47ny9CBYAAAGYpSQ1b4029.png "/>

Mount the/data directory to the local/mnt directory of the Nfs-test1

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/89/F9/wKiom1gi47qTnMbwAAAZQyK5hpo301.png "/>

Successful access

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/89/F9/wKiom1gi47rgT_D5AAADtoFMUtE550.png "/>

However, it is not possible to create any files in the/mnt directory of the shared directory by NFS-TEST1 because the Nfs-server server-side configuration permission is logged on by default to 65534 users, and the path to the file is/var/lib/nfs/etab

The 65534 is a pseudo-user of the NFS service and can be viewed in/etc/passwd. For example, the user name is Nfsnobody

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/89/F6/wKioL1gi47qQZa7XAAAHEBItvaI207.png "/>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/89/F6/wKioL1gi47uSd1RMAAALfTstya0558.png "/>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/89/F9/wKiom1gi47viSoHdAAAIq3W6ebc001.png "/>

Change the owner of the shared directory to be the Nfsnobody

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/89/F6/wKioL1gi47uBYeOCAAAEhpfXtp4718.png "/>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/89/F9/wKiom1gi47uST0VUAAAHnM6L_wA275.png "/>

Make a change, get a smooth load.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/89/F6/wKioL1gi47zh__rYAAAGGX6ZR7E793.png "/>

In the back to Nfs-test1 test, you can implement the/data directory to set the RW permissions, but the directory file created by the user's owner group is Nfsnobody

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/89/F9/wKiom1gi47zxcBu4AAAEs6WOB_0197.png "/>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/89/F6/wKioL1gi47zA4hpHAAAI2t30cdE931.png "/>

Finally, add the mount directory to the boot./etc/rc.local

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/89/F9/wKiom1gi473SJwUzAAAHlvLt9ng819.png "/>

Ok. The test was successful.


Six. focus on Services for NFS summary

/etc/exports Service Master Profile, NFS-specific Shared services location, default is empty.

Showmount e 192.168.87.135 Check for information that has permission to mount before loading

About Boot from:

1)/etc/rc.local disadvantage: Occasionally boot up, work in addition to the boot configuration, but also to monitor whether to mount

2)/etc/fstab Fstab takes precedence over the network being loaded by the Linux system. The network does not start, fstab will certainly cause the NFS server side to fail to mount the boot


This article is from the "LULU" blog, make sure to keep this source http://aby028.blog.51cto.com/5371905/1871156

Build an NFS environment

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.