zoukankan      html  css  js  c++  java
  • Tomcat会话保持之session server

    author:JevonWei
    版权声明:原创作品


    Tomcat会话保持之session server

    拓扑图
    image
    环境

    tomcatA    172.16.253.108
    tomcatB    172.16.253.105
    memcachedA 172.16.253.108
    memcachedB 172.16.253.105
    代理服务器 172.16.253.191
    

    下载相关程序到Tomcat主机的//usr/share/java/tomcat目录下

    javolution-5.4.3.1.jar
    memcached-session-manager-1.8.3.jar
    memcached-session-manager-tc7-1.8.3.jar
    msm-javolution-serializer-1.8.3.jar 
    spymemcached-2.11.1.jar /usr/share/java/tomcat
    

    memcachedA

    [root@TomcatA ~]# yum -y install memcached
    [root@TomcatA ~]# systemctl start memcached.service 
    [root@TomcatA ~]# ss -ntl
    

    memcachedB

    [root@TomcatB ~]# yum -y install memcached
    [root@TomcatB ~]# systemctl start memcached.service 
    [root@TomcatB ~]# ss -ntl
    

    Tomcat A

    在Tomcat安装完成的基础上    
    将程序包下载到 /usr/share/java/tomcat
    
    [root@TomcatA ~]# vim /etc/tomcat/server.xml
        <Engine name="Catalina" defaultHost="localhost">
        </Host>
            <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
            <Context path="/test" docBase="test" reloadable="true">
              <Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
                memcachedNodes="n1:172.16.253.108:11211,n2:172.16.253.105:11211" \指定memcached的服务器,并使用n1,n2区别节点 
                failoverNodes="n1"
                requestUriIgnorePattern=".*.(ico|png|gif|jpg|css|js)$"
                transcoderFactoryClass="de.javakaffee.web.msm.serializer.javolution.JavolutionTranscoderFactory"
            />
            </Context>
        </Host>
    [root@TomcatA ~]# systemctl start tomcat                       
    [root@TomcatA ~]# ss -ntl
    

    Tomcat B

    在Tomcat安装完成的基础上    
    将程序包下载到 /usr/share/java/tomcat
    
    [root@TomcatB ~]# vim /etc/tomcat/server.xml
        <Engine name="Catalina" defaultHost="localhost" jvmRoute="tcB">
         <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
            <Context path="/test" docBase="test" reloadable="true">
              <Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
                memcachedNodes="n1:172.16.253.108:11211,n2:172.16.253.105:11211"
                failoverNodes="n1"
                requestUriIgnorePattern=".*.(ico|png|gif|jpg|css|js)$"
                transcoderFactoryClass="de.javakaffee.web.msm.serializer.javolution.JavolutionTranscoderFactory"
              />
             </Context>
        </Host>
    [root@TomcatB ~]# systemctl start tomcat                       
    [root@TomcatB ~]# ss -ntl
    

    代理服务器

    [root@danran conf.d]# vim tomcat-http.conf                  
        <proxy balancer://appsrvs>
            BalancerMember http://172.16.253.108:8080
            BalancerMember http://172.16.253.105:8080
            ProxySet lbmethod=byrequests
        </Proxy>
        <VirtualHost *:80>
            ServerName www.danran.com
            ProxyVia On
            ProxyRequests Off
            ProxyPreserveHost On
            <Proxy *>
                Require all granted
            </Proxy>
            ProxyPass / balancer://appsrvs/
            ProxyPassReverse / balancer://appsrvs/
            <Location />
                Require all granted
            </Location>
        </VirtualHost>
    

    client

    TomcatA.magedu.com
    
    Session ID	Session ID 	D63DF5FE54F9D8EADB833AEE0E7DD00B-n2.tcA \n2为创建会话时的Tomcat主机,tcA为当前Tomcat
    
    Created on 	1504354197906
    
    
    TomcatB.magedu.com
    
    Session ID 	D63DF5FE54F9D8EADB833AEE0E7DD00B-n2.tcB
    Created on 	1504354197906
  • 相关阅读:
    indexOf--之美
    uniapp_切换主题
    ueditor调用其中的附件上传功能
    php7 编译安装 apache
    快速排序单循环
    插入排序
    走进svg
    phpstorm内网远程debug
    sass&compass&grunt
    centos7+nginx 1.9.0+php-fpm+phpstorm+xdebug+vmware开发环境搭建
  • 原文地址:https://www.cnblogs.com/JevonWei/p/7468471.html
Copyright © 2011-2022 走看看