Nginx+tomcat+memcached Building session Sharing cluster

Source: Internet
Author: User
Tags memcached

First, install the configuration tomcat

Pre-configuration instructions:

System for CENTOS7

M1.xsllqs.com address is 192.168.1.107

C1.xsllqs.com address is 192.168.1.114

C2.xsllqs.com address is 192.168.1.113

Install tomcat with JDK, JDK with Oracle JDK and open JDK two

Oracle JDK8: http://www.oracle.com/technetwork/cn/java/javase/downloads/jdk8-downloads-2133151-zhs.html

Tomcat's: http://tomcat.apache.org/

c1.xsllqs.com (192.168.1.114) Download and install the JDK (recommended to load locally on the go) and Tomcat

[[email protected] ~]# wget http://download.oracle.com/otn-pub/java/jdk/8u73-b02/ jdk-8u73-linux-x64.rpm[[email protected] ~]# wget http://mirror.bit.edu.cn/apache/tomcat/ tomcat-8/v8.0.36/bin/apache-tomcat-8.0.36.tar.gz[[email protected] ~]#  lsapache-tomcat-8.0.36.tar.gz  jdk-8u73-linux-x64.rpm[[email protected] ~]# yum  Install jdk-8u73-linux-x64.rpm[[email protected] ~]# vim /etc/profile.d/java.shexport  java_home=/usr/java/latestexport path= $JAVA _home/bin: $PATH [[email protected] ~]# .  /etc/profile.d/java.sh[[email protected] ~]# java -versionjava version  " 1.8.0_73 "[[email protected] ~]# tar xf apache-tomcat-8.0.36.tar.gz -c /usr/ Local[[email protected] ~]# cd /usr/local/[[email protected] local]# ln  -sv apache-tomcat-8.0.36 tomcat "TomcAt " -> " apache-tomcat-8.0.36 "[[email protected] tomcat]# vim /etc/profile.d/ Tomcat.shexport catalina_home=/usr/local/tomcatexport path= $CATALINA _home/bin: $PATH [[email  protected] tomcat]# . /etc/profile.d/tomcat.sh

c2.xsllqs.com (192.168.1.113) download install JDK and tomcat

[[email protected] ~]# wget http://download.oracle.com/otn-pub/java/jdk/8u73-b02/ jdk-8u73-linux-x64.rpm[[email protected] ~]# wget http://mirror.bit.edu.cn/apache/tomcat/ tomcat-8/v8.0.36/bin/apache-tomcat-8.0.36.tar.gz[[email protected] ~]#  lsapache-tomcat-8.0.36.tar.gz  jdk-8u73-linux-x64.rpm[[email protected] ~]# yum  install jdk-8u73-linux-x64.rpm [[email protected] ~]# vim /etc/profile.d/ Java.shexport java_home=/usr/java/latestexport path= $JAVA _home/bin: $PATH [[email protected]  ~]# . /etc/profile.d/java.sh[[email protected] ~]# java -versionjava  version  "1.8.0_73" [[email protected] ~]# tar xf apache-tomcat-8.0.36.tar.gz  -C /usr/local[[email protected] ~]# cd /usr/local/[[email protected]  Local]# ln -sv apache-tomcat-8.0.36 tomcaT "Tomcat"  ->  "apache-tomcat-8.0.36" [[email protected] tomcat]# vim /etc/ Profile.d/tomcat.shexport catalina_home=/usr/local/tomcatexport path= $CATALINA _home/bin: $PATH [[Email  protected] tomcat]# . /etc/profile.d/tomcat.sh
Second, modify the Tomcat configuration file
[Email protected] tomcat]# cd/usr/local/tomcat/webapps/[[email protected] webapps]# mkdir Myapp/{lib,classes,web-inf , Meta-inf}-pv[[email protected] webapps]# CD myapp/

Add c1 and C2 home page files

[[Email protected] myapp]# vim indix.jsp<%@ page language= "Java"  %> 

Modify Tomcat-user.xml (c1 and C2 are changed)

[[email protected] conf]# vim/usr/local/tomcat/conf/tomcat-users.xml# add <role rolename= in </tomcat-users> " Manager-gui "/> <role rolename=" Admin-gui "/> <user username=" Tomcat "password=" <tomcat> "roles=" Manager-gui,admin-gui "/>

Modify Server.xml (c1 and C2 are changed)

[[email protected] conf]# vim /usr/local/tomcat/conf/server.xml# modifies the master configuration file, AppBase is followed by the relative path of the application or it can be an absolute path 

Test configuration file

[[email protected] ~]# catalina.sh configtest[[email protected] ~]# catalina.sh configtest[[email protected] ~]# Catalina . SH start[[email protected] ~]# catalina.sh start
Iii. Installation of MSM

C1 and c2 to download the jar packages required by MSM

[[email protected] ~]# wget http://repo1.maven.org/maven2/de/javakaffee/msm/ Memcached-session-manager/1.9.4/memcached-session-manager-1.9.4.jar[[email protected] ~]# wget  http://repo1.maven.org/maven2/de/javakaffee/msm/memcached-session-manager-tc8/1.9.4/ memcached-session-manager-tc8-1.9.4.jar[[email protected] ~]# wget http://repo1.maven.org/ maven2/de/javakaffee/msm/msm-javolution-serializer/1.9.4/msm-javolution-serializer-1.9.4.jar[[email  Protected] ~]# wget http://repo1.maven.org/maven2/net/spy/spymemcached/2.11.1/ spymemcached-2.11.1.jar[[email protected] ~]# wget http://www.java2s.com/code/jardownload/ Javolution/javolution-5.4.3.1.jar.zip[[email protected] ~]# mv javolution-5.4.3.1.jar  memcached-session-manager-1.9.4.jar memcached-session-manager-tc8-1.9.4.jar  Msm-javolution-serializer-1.9.4.jar spymemcached-2.11.1.jar /usr/local/tomcat/lib/ 

Install memcached on M1 and C2

[[email protected] ~]# yum install memcached[[email protected] ~]# Yum install memcached

Installation of Nginx modified Nginx configuration file on M1

[[email protected] ~]# yum install nginx[[email protected] ~]# vim/etc/nginx/nginx.conf#server add upstream Tcsrvs {ser    Ver 192.168.1.114:8080; Server 192.168.1.113:8080;} #server内加入 location ~* \.    (Jsp|do) $ {proxy_pass Http://tcsrvs; }[[email protected] ~]# nginx-t

Start the service

[[email protected] ~]# systemctl start nginx.service[[email protected] ~]# systemctl start memcached[[email protected] ~]# Systemctl start memcached
Iv. Testing

650) this.width=650; "src=" Http://www.178linux.com/ueditor/php/upload/image/20160625/1466856090346241.jpg "title= "1466856090346241.jpg" alt= "1466856090346241.jpg"/>

650) this.width=650; "src=" Http://www.178linux.com/ueditor/php/upload/image/20160625/1466856132442425.jpg "title= "1466856132442425.jpg" alt= "2016-6-25-tomcat-c2.jpg"/>

650) this.width=650; "src=" Http://www.178linux.com/ueditor/php/upload/image/20160625/1466856090746365.gif "title= "1466856090746365.gif" alt= "1466856090746365.gif"/>



This article is from the "Wind" blog, please be sure to keep this source http://xsllqs.blog.51cto.com/2308669/1825680

Nginx+tomcat+memcached Building session Sharing cluster

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.