Build Nginx + tomcat + MySQL + memcached environment.

Source: Internet
Author: User
Tags memcached server port jcenter

Build Nginx + tomcat + MySQL + memcached environment.

The top map is as follows

650) this.width=650; "title=" clipboard "style=" border-top:0px;border-right:0px;border-bottom:0px;border-left:0px; " Border= "0" alt= "clipboard" src= "Http://img1.51cto.com/attachment/201409/28/4489523_1411913447dh84.png" height= " 398 "/>

Java programs need to run on Tomcat, and Tomcat is a Java program. This Java program is required to run on a virtual machine in Java.

So, we're going to install the Java Virtual machine on the node where Tomcat is installed, that is, install the JDK environment.

Memcached services are installed on the 172.16.26.5 [6] two cluster nodes. and Tomcat services.

Use Nginx as the dispatch node by 172.16.26.1.

Configuration of 172.16.26.1 Nginx

Upstream www.tomcat1.com {server 172.16.26.6:8080 weight=1;       = = back-end node 1server 172.16.26.5:8080 weight=1;   ==> Back-end node 2least_conn;}       server {Listen 80;server_name www.tomcat1.com;    = = Virtual hostname CharSet utf-8;location/{root html;index index.jsp index.html index.htm; Proxy_pass http://www.tomcat1.com; = = All Access/path, all agents to http://www.tomcat1.com up Proxy_set_header X-real-ip $remote _addr;client_max_body_size 100m;}}

Configuration of Node 1 172.16.26.5 [6]

Software that needs to be prepared

jdk-7u9-linux-x64.rpm

Apache-tomcat-7.0.55.tar.gz

Install the JDK first

[email protected]_6 ~]# rpm-ivh jdk-7u9-linux-x64.rpm = Install JDK environment
Preparing ... ########################################### [100%]
1:JDK ########################################### [100%]
Unpacking JAR files ...
Rt.jar ...
Error:could not open input file:/usr/java/jdk1.7.0_09/jre/lib/rt.pack
Jsse.jar ...
Error:could not open input file:/usr/java/jdk1.7.0_09/jre/lib/jsse.pack
Charsets.jar ...
Error:could not open input file:/usr/java/jdk1.7.0_09/jre/lib/charsets.pack
Tools.jar ...
Error:could not open input file:/usr/java/jdk1.7.0_09/lib/tools.pack
Localedata.jar ...
Error:could not open input file:/usr/java/jdk1.7.0_09/jre/lib/ext/localedata.pack

[email protected]_6 bin]# pwd
/usr/java/jdk1.7.0_09/bin = This is the installed Java Virtual machine running program directory.
[[email protected]_6 bin]# ls = Directory with Java virtual machines in various ways
Appletviewer java javaws jmap JVISUALVM rmid Wsgen
Apt Javac jcmd JPS keytool rmiregistry wsimport
ControlPanel Javadoc jconsole jrunscript native2ascii schemagen XJC
Extcheck javafxpackager Jcontrol jsadebugd ORBD serialver
IDLJ javah jdb jstack pack200 servertool
Jar JAVAP jhat Jstat policytool tnameserv
Jarsigner java-rmi.cgi jinfo jstatd rmic unpack200

To easily use the various methods of Java virtual machines, add a usage environment variable to it

# vim/etc/profile.d/java.sh

Java_home=/usr/java/latest = Latest is a soft link to/usr/java/jdk1.7.0_09

Path= $JAVA _home/bin: $PATH

Export Java_home

Export PATH

Decompression tomcat/usr/local/apache-tomcat-7.0.42/bin/support for Java EE, Web servlets, JSP

# tomcat is just a program running in a Java virtual machine, the JVM ==> the program running in the virtual machine, remember

[email protected]_6 ~]# tar-xf apache-tomcat-7.0.55.tar.gz-c/usr/local/

To facilitate the use of the Tomcat program, we also export an environment variable to it

# vim/etc/profile.d/tomcat.sh

Catalina_home=/usr/local/tomcat

Path= $CATALINA _home/bin: $PATH

Export Catalina_home

Export PATH

[[email protected]_6 conf] #catalina. SH start = To ensure that 8080 ports are not in use, you can start Tomcat.

[email protected]_6 conf]# pwd
/usr/local/tomcat/conf
[email protected]_6 conf]# vim Server.xml

You want to use Memcached-session-manager to configure Tomcat and memcached for session sharing.

You need to use the following packages to download them to the Tomcat Lib directory, which is the package that the MSM relies on.

Http://memcached-session-manager.googlecode.com/files/memcached-session-manager-1.3.0.jar

Http://memcached-session-manager.googlecode.com/files/msm-javolution-serializer-jodatime-1.3.0.jar

Http://memcached-session-manager.googlecode.com/files/msm-javolution-serializer-cglib-1.3.0.jar

Http://spymemcached.googlecode.com/files/memcached-2.4.2.jar

Http://memcached-session-manager.googlecode.com/files/javolution-5.4.3.1.jar

After the package is downloaded, it is placed in the/usr/local/tomcat/lib directory.

<context path= "/test"  docbase= "test" >  => Create a test directory to verify that memcached is working properly .                 <manager classname = "De.javakaffee.web.msm.MemcachedBackupSessionManager"          Memcachednodes= "n1:172.16.26.5:11211,n2:172.16.26.6:11211"     => simultaneous configuration of two memcached nodes          failovernodes= "N1"          Requesturiignorepattern= ". *\. (ICO|PNG|GIF|JPG|CSS|JS) $ "        transcoderfactoryclass=" De.javakaffee.web.msm.serializer.javolution.JavolutionTranscoderFactory "                 />             </Context>             <context path= "/jcenter"  docbase= "Jcenter" >    => This directory is used to configure a project called Javacenter                  <manager classname= "De.javakaffee.web.msm.MemcachedBackupSessionManager"          memcachednodes= "n1:172.16.26.5:11211,n2:172.16.26.6:11211"          failovernodes= "N1"          Requesturiignorepattern= ". *\. (ICO|PNG|GIF|JPG|CSS|JS) $ "        transcoderfactoryclass=" De.javakaffee.web.msm.serializer.javolution.JavolutionTranscoderFactory "                 />             </Context>

172.16.26.5 [6] nodes are installed on the memcached

# yum Install memcached-y Yum installation memcached Service

# service Memcached start = launch memcached Services

On two nodes, create the following directory

/usr/local/tomcat/webapps/test # Note that the directory JSP program runs, requires Web-inf directory, Web-inf directory needs to have lib,classes two subdirectories

In the two-node test directory, create the index.jsp file

Content 172.16.26.5 for

<%@ page language= "Java"  %>

Content 172.16.26.6 to

<%@ page language= "Java"  %>

Java and memcached configuration complete, start Tomcat, memcached

# service Tomcat Restart + = reboot Tomcat

# service Memcached restart = Restart memcached

Modifying the Hosts file on the client

172.16.26.1 www.tomcat1.com

650) this.width=650; "title=" clipboard[1] "style=" border-top:0px;border-right:0px;border-bottom:0px;border-left:0 px; "border=" 0 "alt=" clipboard[1] "src=" Http://img1.51cto.com/attachment/201409/28/4489523_1411913452dDN0.png " height= "375"/>

650) this.width=650; "title=" clipboard[2] "style=" border-top:0px;border-right:0px;border-bottom:0px;border-left:0 px; "border=" 0 "alt=" clipboard[2] "src=" Http://img1.51cto.com/attachment/201409/28/4489523_1411913459ygYG.png " height= "431"/>

Depending on the results of the visit, the response is different, stating that the nodes are responding differently, but the SessionID are the same

Indicates that the memcached share has been successful. Then we have to finish the Javacenter deployment.

Install MARIADB (process omitted, the need to see my blog, about the length of mariadb installation);

MariaDB [(None)]> CREATE Database jcenter; = = CREATE Database Jcenter as the main library of the Javacenter project

MariaDB [(None)]> grant all on jcenter.* to [e-mail protected] ' 172.16.26.% ' identified by ' ABCABC '; + = Authorized User connection

Download JAVACENTER_HOME_2.0_GBK.TAR.BZ2 Program Compression pack

Unzip to the/usr/local/tomcat/webapps/jcenter directory of the node 172.16.26.5

#---------------Javacenter Home Settings---------------

# database server address (typically local localhost or 127.0.0.1)

dbhost=172.16.26.5 = because it is a shared library, it is written as an IP address

# Database server port number (typically 3306)

dbport=3306

# Database User Name

Dbuser=jcenter

# Database Password

Dbpw=abcabc

# database name

Dbname=jcenter

# table name prefix (cannot be the same as the table name prefix for the forum)

Tablepre=jchome_

Configuration complete, access to Jcenter project with IP address, program installation

650) this.width=650; "title=" clipboard[3] "style=" border-top:0px;border-right:0px;border-bottom:0px;border-left:0 px; "border=" 0 "alt=" clipboard[3] "src=" Http://img1.51cto.com/attachment/201409/28/4489523_1411913464lQvv.png " height= "462"/>

Follow as long as the correct fill in the database information, fill in the Installation Project administrator information, you can complete.

650) this.width=650; "title=" clipboard[4] "style=" border-top:0px;border-right:0px;border-bottom:0px;border-left:0 px; "border=" 0 "alt=" clipboard[4] "src=" Http://img1.51cto.com/attachment/201409/28/4489523_1411913470irQn.png " Height= "/>"

This will, the installation is complete, the installation of the/usr/local/tomcat/webapps/jcenter directory, the entire package, and sent to the 172.16.26.6 host, and extracted to the same location

650) this.width=650; "title=" clipboard[5] "style=" border-top:0px;border-right:0px;border-bottom:0px;border-left:0 px; "border=" 0 "alt=" clipboard[5] "src=" Http://img1.51cto.com/attachment/201409/28/4489523_1411913477iQ6f.png " height= "503"/>

This will, with the virtual host can also be normal access.

This article is from the "909 is a goal" blog, please be sure to keep this source http://robert1joy.blog.51cto.com/4489523/1559188

Build Nginx + tomcat + MySQL + memcached environment.

Related Article

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.