<%@ page language="java" %>
Access ports 8080 of lab2 and lab3 respectively. The effect is as follows, and the session ID is constantly changing.
650) This. width = 650; "Title =" w%080.tmp "border =" 0 "alt =" w%080.tmp "src =" http://img1.51cto.com/attachment/201409/28/6837943_14119182847JKq.png "Height =" 130 "style =" border: 0px; padding-left: 0px; padding-Right: 0px; padding-top: 0px; Background-image: none; "/>
650) This. width = 650; "Title =" w0000081.tmp "border =" 0 "alt =" w0000081.tmp "src =" http://img1.51cto.com/attachment/201409/28/6837943_1411918284vFzm.png "Height =" 131 "style =" border: 0px; padding-left: 0px; padding-Right: 0px; padding-top: 0px; Background-image: none; "/>
3. Configure MSM (memcached-session-Manager)
1. Put the following jar package in the lib directory under the tomcat installation directory.
Javolution-5.5.1.jarmemcached-session-manager-1.8.2.jarmemcached-session-manager-tc7-1.8.2.jar (tc7 here is the tomcat version, to ensure that the tomcat version is consistent) msm-javolution-serializer-1.8.2.jarspymemcached-2.10.2.jar
2. Configure the tomcat configuration file server. xml and add the following content to the context of test:
<Manager classname = "de. javakaffee. web. MSM. memcachedbackupsessionmanager "memcachednodes =" N1: 172.16.21.1: 11211 "# the address of the memcached server is requesturiignorepattern = ". *\. (ICO | PNG | GIF | JPG | CSS | JS) $ "# Do not add cache transcoderfactoryclass =" de. javakaffee. web. MSM. serializer. javolution. javolutiontranscoderfactory "/>
3. Install and start the memcached server on the memcached server, restart the Tomcat service, and access Tomcat as follows:
650) This. width = 650; "Title =" w0000092.tmp "border =" 0 "alt =" w0000092.tmp "src =" http://img1.51cto.com/attachment/201409/28/6837943_1411918285PqdJ.png "Height =" 133 "style =" border: 0px; padding-left: 0px; padding-Right: 0px; padding-top: 0px; Background-image: none; "/>
After the original session ID, a "-1" character is added to prove that the MSM configuration has been successful \
4. Configure load balancing on httpd as follows:
ProxyVia OffProxyRequests OffProxyPass /jcenter balancer://jcenter/ProxyPass /test balancer://test/ProxyPassReverse /test balancer://test/ProxyPassReverse /jcenter balancer://jcenter/<proxy balancer://test>BalancerMember ajp://172.16.21.102:8009/test/ loadfactor=10BalancerMember ajp://172.16.21.103:8009/test/ loadfactor=10</proxy><proxy balancer://jcenter>BalancerMember ajp://172.16.21.102:8009/jcenter/ loadfactor=10BalancerMember ajp://172.16.21.103:8009/jcenter/ loadfactor=10</proxy>
At this time, we can access the backend Tomcat through 172.16.21.1, and the session will not change. The effect is as follows:
650) This. width = 650; "Title =" w1_0a3. TMP "border =" 0 "alt =" w4240a3. TMP "src =" http://img1.51cto.com/attachment/201409/28/6837943_1411918285gxs7.png "Height =" 143 "style =" border: 0px; padding-left: 0px; padding-Right: 0px; padding-top: 0px; background-image: none; "/>
650) This. width = 650; "Title =" w1_0a4. TMP "border =" 0 "alt =" w00000a4. TMP "src =" http://img1.51cto.com/attachment/201409/28/6837943_1411918285C6qc.png "Height =" 131 "style =" border: 0px; padding-left: 0px; padding-Right: 0px; padding-top: 0px; background-image: none; "/>
Each time you refresh the response, Tomcat is different, but the session ID does not change. In this case, we can deploy javacenter.
5. javacenter deployment
Access lab2, install MySQL, and authorize the jcenter user to access the jcenter database from the network segment 172.16.21 and lab.stu21.com, lab3.stu21.com, decompress the installation package to the webapps directory, and rename it as jcenter, then you can access 172.16.21.102: 8080/jcenter/install to install it. Follow the prompts to complete the installation.
Share the jcenter directory over NFS, allow access to 172.16.21.103, and mount it to the same directory as lab2 on lab3. Normal access is also allowed, note that the IP address of the database must be directed to 172.16.21.2. Otherwise, the database may not be accessed in lab3.
First, copy the configuration about MSM under test to jcenter. The effect is as follows:
<Context path="/jcenter" docBase="jcenter" > <Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager" memcachedNodes="n1:172.16.21.1:11211" requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$" transcoderFactoryClass="de.javakaffee.web.msm.serializer.javolution.JavolutionTranscoderFactory" /></Context>
Now we can restart the server and access it from 172.16.21.1. Now, no matter which server we are directed to, there will be no session loss, and there will be no problems such as logon failure.
650) This. width = 650; "style =" background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-Right: 0px; border-top: 0px; border-Right: 0px; padding-top: 0px; "Title =" wpse0b4. TMP "border =" 0 "alt =" w%0b4. TMP "src =" http://img1.51cto.com/attachment/201409/28/6837943_1411918291xRm4.png "Height =" 275 "/>
Deploying jcenter and MSM in lamt