tomcat8.5.34集群利用redis设置session共享

rsm-xx-with-dependencies-3.1.0-SNAPSHOT.zip

利用redis实现tomcat8集群的session共享,需要rsm-lettuce-with-dependencies-3.1.0-SNAPSHOT.jar和rsm-redisson-with-dependencies-3.1.0-SNAPSHOT.jar两个jar包,相关配置见https://blog.csdn.net/ylfmsn/article/details/105114115

立即下载
  • 环境
    jdk1.8.0_181
    tomcat8.5.34
    redis 3.0.6
  • 安装redis,并设置密码为test123456
  • git下载redis-session-manager
    地址https://github.com/chexagon/redis-session-manager
  • mvn环境下,编译,打包
  • 将生成的rsm-lettuce-with-dependencies-<VERSION>-SNAPSHOT.jarrsm-redisson-with-dependencies-<VERSION>-SNAPSHOT.jar拷贝到tomcat/lib下
  • 配置tomcat/conf/context.xml,如下:
<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<!-- The contents of this file will be loaded for each web application -->
<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>

    <!-- Uncomment this to disable session persistence across Tomcat restarts -->
    <!--
    <Manager pathname="" />
    -->
    
	# 下面为添加的内容
    <Manager className="com.crimsonhexagon.rsm.redisson.SingleServerSessionManager"
        endpoint="redis://localhost:6379"
        sessionKeyPrefix="_rsm_"
        saveOnChange="false"
        forceSaveAfterRequest="false"
        dirtyOnMutation="false"
        ignorePattern=".*\\.(ico|png|gif|jpg|jpeg|swf|css|js)$"
        connectionPoolSize="100"
        database="1"
        password="test123456"
        timeout="60000"
        pingTimeout="1000"
        retryAttempts="20"
        retryInterval="1000"
    />

</Context>
  • 重启tomcat,其他节点同理配置并重启
发布了10 篇原创文章 · 获赞 0 · 访问量 246
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览