tomcat session共享

1.版本

  redis3.2   nginx   tomcat8.5

2.下载jar包  tomcat-cluster-redis-session-manager

  解压后大家可以看看 readMe.txt,有需要的基本要求

  lib 的jar包,将这些放入tomcat->lib包里

  

  conf->redis-data-cache.properties,放入自己tomcat->conf里 是redis的路径、密码,把路径密码对应自己的redis

  

3.配置tomcat

  tomcat->conf->server.xml,配置端口号,因为是2个tomcat,所以自己定义两个tomcat的端口号

  

  

  tomcat->conf->context.xml,添加2行

  

<Context>

    <!-- Default set of monitored resources. If one of these changes, the    -->
    <!-- web application will be reloaded.                                   -->
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
    <WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>

   <Valve className="tomcat.request.session.redis.SessionHandlerValve"/> <Manager className="tomcat.request.session.redis.SessionManager"/> <!-- Uncomment this to disable session persistence across Tomcat restarts --> <!-- <Manager pathname="" /> --> </Context>

  tomcat->conf->tomcat-users.xml,最初内容是空的,所以都要添加

<tomcat-users xmlns="http://tomcat.apache.org/xml"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
              version="1.0">

  <role rolename="tomcat"/>
  <role rolename="role1"/>
  <role rolename="admin-gui"/>
  <user username="admin" password="admin" roles="admin-gui,tomcat,role1"/>
  <user username="tomcat" password="tomcat" roles="tomcat"/>
  <user username="both" password="tomcat" roles="tomcat,role1"/>
  <user username="role1" password="tomcat" roles="role1"/>
</tomcat-users>

 

4.nginx

  

5.测试

  

 

 

                朱星翰

posted @ 2019-05-15 10:42  易之盛  阅读(989)  评论(0编辑  收藏  举报