tomcat session共享

1.版本nginx

  redis3.2   nginx   tomcat8.5git

2.下載jar包  tomcat-cluster-redis-session-managergithub

  解壓後你們能夠看看 readMe.txt,有須要的基本要求web

  lib 的jar包,將這些放入tomcat->lib包裏redis

  

  conf->redis-data-cache.properties,放入本身tomcat->conf裏 是redis的路徑、密碼,把路徑密碼對應本身的redisapache

  

3.配置tomcattomcat

  tomcat->conf->server.xml,配置端口號,由於是2個tomcat,因此本身定義兩個tomcat的端口號session

  

  

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

  

<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.測試

  

 

 

                朱星翰

相關文章
相關標籤/搜索