Tomcat-session-memcached

Source: Internet
Author: User
Tags jcenter

Tomcat-session-memcached

TomcatA-vm1: 172.16.3.2/16
TomcatB-vm2: 172.16.3.3/16
Apache + mysql-vm3: 172.16.3.10/16
Memcached-vm4: 172.16.3.20/16
Testing Machine: 172.16.20.109/16

650) This. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "Title =" Topology "border =" 0 "alt =" Topology "src =" http://img1.51cto.com/attachment/201409/29/1384120_14119952322Owj.jpg "1047" Height = "342"/>

1. tomcat-vm1: 172.16.3.2/16
1. Tomcat Basic installation
Official Website: tomcat.apache.org
Package:
Jdk-7u9-linux-x64.rpm
Apache-tomcat-7.0.42.tar.gz
(1) install the JDK Environment
# Rpm-IVH jdk-7u9-linux-x64.rpm
Specify the Java path (easy to use)
# Vim/etc/profile. d/Java. Sh

Java_home =/usr/Java/latest
Path = $ java_home/bin: $ path
Export java_home path
~
#./Etc/profile. d/Java. Sh

[[Email protected] jdk1.7.0 _ 09] # Can I use Java-version normally?
Java version "1.7.0 _ 09"
Java (TM) se Runtime Environment (build 1.7.0 _ 09-b05)
Java hotspot (TM) 64-bit server VM (build 23.5-b02, mixed mode) java mode is run on the mixed client and server side

(2) install Tomcat
# Tar xf apache-tomcat-7.0.42.tar.gz-C/usr/local
# Cd/usr/local/Apache-Tomcat-7.0.42
# Ln-sv apache-Tomcat-7.0.42/tomcat create a connection file
# Vim/etc/profile. d/tomcat. Sh specifies the Tomcat path

Export catalina_home =/usr/local/tomcat
Export Path = $ catalina_home/bin: $ path
#./Etc/profile. d/tomcat. Sh
# Catalina. Sh configtest: Check whether the configuration file script is correct.
# Catalina. Sh start Tomcat

Test:
Http: // 172.16.3.2: 8080 the default listening port is port 8080.
(3) define the startup script (complex scripts can be viewed after yum is installed)
# Chkconfig -- add Tomcat
# Chkconfig -- list Tomcat
Tomcat 0: off 1: off 2: On 3: On 4: On 5: on 6: Off
# Service Tomcat restart
2. modify the configuration file
# Vim/usr/local/tomcat/CONF/server. xml
<Host name = "localhost" appbase = "webapps"
Unpackwars = "true" autodeploy = "true"> specify the default site location

<Context Path = "/test" docbase = "/usr/local/tomcat/webapps/test" reloadable = "true"> Configuration/test directory
<Manager classname = "De. javakaffee. Web. MSM. memcachedbackupsessionmanager"
Memcachednodes = "N1: 172.16.3.20: 11211" specifies the address and port of memcached.
Requesturiignorepattern = ". * \. (ICO | PNG | GIF | JPG | CSS | JS) $" website in the format of session cache
Transcoderfactoryclass = "De. javakaffee. Web. MSM. serializer. javolution. javolutiontranscoderfactory"/>

</Context>
<Valve classname = "org. Apache. Catalina. Valves. accesslogvalve" directory = "logs"
Prefix = "localhost_access_log." suffix = ". txt"
Pattern = "% H % L % u % T & quot; % R & quot; % S % B"/>

</Host>
<Host name = "www.ning1.com" appbase = "/Ning" specifies the website to be customized.
Unpackwars = "true" autodeploy = "true">
<Context Path = "" docbase = "/Ning"/>
</Host>
3. Provide JSP sites under test/test
# Mkdir-PV/usr/local/tomcat/webapplications/test/WEB-INF/{classes, lib}
# Vim/usr/local/tomcat/webapps/test/index. jsp
Add the following content:
<% @ Page Language = "Java" %>
<HTML>
<Head> <title> tomcata </title> <Body>
<H1> <font color = "red"> tomcata.magedu.com </font> <Table align = "center" border = "1">
<Tr>
<TD> session ID </TD>
<% Session. setattribute ("magedu.com", "magedu.com"); %>
<TD> <% = session. GETID () %> </TD>
</Tr>
<Tr>
<TD> created on </TD>
<TD> <% = session. getcreationtime () %> </TD>
</Tr>
</Table>
</Body>
</Html>
TomcatB-vm2: 172.16.3.3/16
1. tomcat installation is the same as above. It is not described again here.
2. modify the configuration file:
# Vim/usr/local/tomcat/CONF/server. xml
<Host name = "localhost" appbase = "webapps"
Unpackwars = "true" autodeploy = "true">
<Context Path = "/test" docbase = "/usr/local/tomcat/webapps/test" reloadable = "true">
<Manager classname = "De. javakaffee. Web. MSM. memcachedbackupsessionmanager"
Memcachednodes = "N1: 172.16.3.20: 11211"
Requesturiignorepattern = ". * \. (ICO | PNG | GIF | JPG | CSS | JS) $"
Transcoderfactoryclass = "De. javakaffee. Web. MSM. serializer. javolution. javolutiontranscoderfactory"/>
</Context>
<Valve classname = "org. Apache. Catalina. Valves. accesslogvalve" directory = "logs"
Prefix = "localhost_access_log." suffix = ". txt"
Pattern = "% H % L % u % T & quot; % R & quot; % S % B"/>

</Host>
<Host name = "www.ning3.com" appbase = "/Ning"
Unpackwars = "true" autodeploy = "true">
<Context Path = "" docbase = "/Ning"/>
</Host>
</Engine>
3. Provide JSP sites under test/test
# Mkdir-PV/usr/local/tomcat/webapplications/test/WEB-INF/{classes, lib}
# Vim/usr/local/tomcat/webapps/test/index. jsp
Add the following content:
<% @ Page Language = "Java" %>
<HTML>
<Head> <title> tomcatb </title> <Body>
<H1> <font color = "blue"> tomcatb.magedu.com </font> <Table align = "center" border = "1">
<Tr>
<TD> session ID </TD>
<% Session. setattribute ("magedu.com", "magedu.com"); %>
<TD> <% = session. GETID () %> </TD>
</Tr>
<Tr>
<TD> created on </TD>
<TD> <% = session. getcreationtime () %> </TD>
</Tr>
</Table>
</Body>
</Html>
Apache + mysql-vm3: 172.16.3.10/16
1. Apache proxy configuration
# Yum install httpd MySQL mysql-Server
# Vim/etc/httpd/CONF/httpd. conf (enable the VM function and do not declare it again)
<Proxy balancer: // tomcat1> specifies the proxy group
Balancermember http://www.ning1.com: 8080/Ning loadfactor = 1
Balancermember http://www.ning3.com: 8080/Ning loadfactor = 1
Proxyset lbmethod = byrequests specify the Scheduling Algorithm
</Proxy>
<Virtualhost *: 80> specify the first virtual host
Servername www.liang.com specifies the server name of the VM.
Proxyvia off does not add via information in the Response Message Header
Proxyrequests off disable forward proxy
Proxypreservehost on enables support for Tomcat Virtual Host
Proxypass/balancer: // tomcat1/specifies the URL of the VM (which proxy group is known here)
Proxypassreverse/balancer: // tomcat1/
<Proxy *> allow all proxy access permissions (after apache2.4, you must add them)
Order allow, deny
Allow from all
</Proxy>
</Virtualhost>

<Virtualhost *: 80> specify the second virtual host
Servername www.hong.com
Proxyvia off
Proxyrequests off
Proxypreservehost on
Proxypass/balancer: // tomcat/
Proxypassreverse/balancer: // tomcat/
<Proxy *>
Order allow, deny
Allow from all
</Proxy>
</Virtualhost>
<Proxy balancer: // Tomcat> specifies the proxy group
Balancermember http: // 172.16.3.2: 8080 loadfactor = 1 specify the backend Tomcat and weight
Balancermember http: // 172.16.3.3: 8080 loadfactor = 1
Proxyset lbmethod = byrequests specify the Scheduling Algorithm
</Proxy>
2. MySQL configuration (mainly for websites in www.liang.com)

Authorization:
> Grant all on Ning. * to [email protected] '2017. 172.% 'identified by 'ning ';
> Flush privilieges;
> Create Database Ning;
4: memcached-vm4: 172.16.3.20/16
# Yum install memcached
# Service memcached start
# SS-tnl (check whether memcached port 11211 is enabled)
V. test:
1. http://www.liang.com

650) This. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "Title =" jcenter Fig 1 "border =" 0 "alt =" jcenter Fig 1 "src =" http://img1.51cto.com/attachment/201409/29/1384120_14119952374pyH.jpg "700" Height = "315"/>
2. http://www.hong.com/test (figure)

650) This. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "Title =" test Fig 2 "border =" 0 "alt =" test Fig 2 "src =" http://img1.51cto.com/attachment/201409/29/1384120_14119952428iT4.jpg "547" Height = "239"/>

650) This. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "Title =" test Figure 3 "border =" 0 "alt =" test Figure 3 "src =" http://img1.51cto.com/attachment/201409/29/1384120_1411995245tnmL.jpg "550" Height = "255"/>

Tomcat-session-memcached

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.