Shared file System and NFS introduction and use

Source: Internet
Author: User

Shared file System and NFS introduction and use

1 , the origin of the story

Many, many years ago, did a small system, is a small system related to payment. Because it's a small system, everything is so simple. An application server, a database server, files, pictures are placed on the application server, everything is so dull, everything is so taken for granted.

suddenly one day, payment became a fashionable topic; Suddenly one day, the platform was conceived to be the core system of a new payment company, and the system's access was going to skyrocket. It was all so sudden ...

2 , adjusted system simple architecture

Step by step, the front end uses the load balancer device to dispatch uniformly, the mid-end corresponds to the server to scale out, the backend to upgrade the database. The rest is how to put files, pictures, and eventually our file system uses the shared storage server NFS. Our multiple application servers share a server's storage space via NFS.


3 , NFS Introduction

NFS ( Network File System ) is the network file system, which is FreeBSD one of the supported file systems that allows computers in the network to pass between TCP/IP network shared resources. In NFS applications, client applications for local NFS can transparently read and write to files located on the Remote NFS server. Just like accessing a local file.

If there are three machinesA,B,C, their applications require a directoryIMGThe traditional practice is to put these pictures in theA,B,Cof the three serversIMGthe directory. But usingNFSjust put it inAon theIMGdirectory, and thenAshare the picture directory toBand theCcan be. During the visit,Band theCis to access it through the Internet.Aon theIMGdirectory.

4 , Configuration NFS

NFS configuration only needs to edit the configuration file /etc/exports can be.

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

/home/10.0.2.0/114 (rw,sync,all_squash,anonuid=118114,anongid=118114)

The simple meaning of this command:

where the directory to be shared is /Home , the trusted host is 10.0.2.0/114 This network segment, the permissions for read and write, synchronization, limited to all users, and limited UID and the GID are for 118114 .

This configuration file is a simple line. is divided into three parts, the first part is to share the local directory, 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 the , for some permission options.

RW : Read and write;

ro : Read only;

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

Async : Does not synchronize, writes the in-memory data to the disk regularly;

No_root_squash : After adding this option, Root The user will have high permissions control over the shared directory, as if it were a native directory operation. Unsafe, not recommended for use;

Root_squash : Corresponds to the above options, Root user permissions on the shared directory are not high, only the rights of ordinary users, that is, limit the Root ;

all_squash : Regardless of the use nfs who is the user, His identity will be limited to a specified ordinary user identity;

anonuid/anongid : To and root_squash All_squash used together to specify the use of nfs user-defined uid gid /ETC/PASSWD uid gid

5 , using NFS

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

[[Email protected] ~]# service Portmap start; Servicenfs start

NFS is based on Portmap , so the first thing to start Portmap , and then start NFS can be the configuration that was just in effect. After you start NFS, you should use Service for NFS.

[email protected] ~]# showmount-e 127.0.0.1 (used in Client on)

Export list for 127.0.0.1:

/Home 10.0.2.0/114

withshoumount-ePlusIPwill be able to viewNFS, in the example above, you can see127.0.0.1the shared directory is /Home, the trusted host is10.0.2.0/114this network segment. The other one .ShowmountThe command also has a common option -A, it means to connect the machine to theNFSof theClientall listed.

NFS There is also a common command in the service that is Exportfs , its common options are [-aruv] .

-A : Mount or uninstall all;

- R : Re-mount;

- u : Uninstalls a directory;

- v : Displays the shared directory;

Use Exportfs command, when changed /etc/exports after the configuration file, do not restart NFS Service directly with this Exportfs can be.

server if you want to use nfs Span style= "Color:rgb (51,51,51)", you need to pass mount command to mount nfs -t NFS Span style= "Color:rgb (51,51,51)" >nfs nfs Span style= "Color:rgb (51,51,51)" >nolock nfs service is not locked.

we can also put a mount NFS directory is written to Client on the /etc/fstab file, you only need to mount the mount-a can be.

Finish Writing /etc/fstab file, you only need to mount-a Ready to Mount NFS the shared directory of the service.

6 , Performance

under normal circumstances, when NFS when the number of clients is small, NFS There is no problem with performance; NFS The number of servers is too high, and is the kind of operations that read and write more frequently, the results are not what we expect.

Shared file System and NFS introduction and use

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.