NFS file Sharing Server build-up

Source: Internet
Author: User

Demand:

Deploy the same tomcat on multiple different machines to do server load Balancing (nginx), each Tomcat instance has the ability to upload static itself (compared to slices). But when it comes to external visits, a unified export is needed. So the NFS file sharing service is used here.

The construction process is as follows:



NFS File Sharing Service Setup


1. Environment:

Server for NFS Address: 192.168.0.100

TOMCAT1 Address: 192.168.0.101

TOMCAT2 Address: 192.168.0.102


2. Install Server for NFS (192.168.0.100): sudo apt-get install Nfs-kernel-server


3. Configure the shared directory for Server for NFS:

sudo vim/etc/exports

Add a line to the last face:/nfs * (Insecure,rw,sync,no_root_squash,no_subtree_check)

(/nfs is a new folder in the root directory, this folder is the NFS service to the external shared directory, the name can be casually.)

, note that if the current logged-on user is not root, the directory must be in the root directory and not the root of the currently logged-on user.


Start Server for NFS (if firewall is turned off): sudo service nfs-kernel-server start|restart|stop


The NFS server is built.



4. Configuring the NFS Client (192.168.0.101,192.168.0.102)

Suppose the TOMCAT1,TOMCAT2 instance uploads the file to its own/home/pan/upload directory (two machines have this directory)

For this directory to be executed: chmod 777/home/pan/upload command


This is the time to mount the contents of the/home/pan/upload directory in both servers to the Shared Services Directory of NFS through the NFS sharing service.


There are 3 kinds of configurations, here in the simplest kind:

sudo mount-t NFS 192.168.0.100:/nfs/home/pan/upload

If you don't have a problem, you can see if it's mounted.

sudo showmount-e 192.168.0.100



You can mount the NFS service configuration to this client.



5. Testing


Create a new File/folder in the/home/pan/upload directory of any Tomcat-located machine


Then go to the 192.168.0.100 NFS server to see if the same file/folder already exists under the/nfs directory


Note: When Nginx accesses, you can configure a server that accesses static resources, and then root points to this NFS shared folder









This article is from the "re-learn Java" blog, please be sure to keep this source http://3131854.blog.51cto.com/3121854/1684433

NFS File Sharing Server build

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.