当前位置: 首页 > news >正文

tomcat集成redis实现共享session

中间件:Tomcat、Redis、Nginx

jar包要和tomcat相匹配

jar包:commons-pool2-2.2.jar、jedis-2.5.2.jar、tomcat-redis-session-manage-tomcat7.jar

配置Tomcat

/conf/context.xml

<?xml version='1.0' encoding='utf-8'?>
<!--Licensed to the Apache Software Foundation (ASF) under one or morecontributor license agreements.  See the NOTICE file distributed withthis 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 withthe License.  You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed 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 andlimitations under the License.
-->
<!-- The contents of this file will be loaded for each web application -->
<Context><!-- Default set of monitored resources --><WatchedResource>WEB-INF/web.xml</WatchedResource><!-- Uncomment this to disable session persistence across Tomcat restarts --><!--<Manager pathname="" />--><!-- Uncomment this to enable Comet connection tacking (provides eventson session expiration as well as webapp lifecycle) --><!--<Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />--><Valve className="com.orangefunction.tomcat.redissessions.RedisSessionHandlerValve" /><Manager className="com.orangefunction.tomcat.redissessions.RedisSessionManager"host="192.168.2.223"port="6379"       database="3"maxInactiveInterval="60" /></Context>

配置NGINX

nginx.conf


#user  nobody;
worker_processes  1;#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;#pid        logs/nginx.pid;events {worker_connections  1024;
}http {include       mime.types;default_type  application/octet-stream;#log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '#                  '$status $body_bytes_sent "$http_referer" '#                  '"$http_user_agent" "$http_x_forwarded_for"';#access_log  logs/access.log  main;sendfile        on;#tcp_nopush     on;#keepalive_timeout  0;keepalive_timeout  65;#gzip  on;upstream nginx-xxxx{server 192.168.2.211:8011;server 192.168.2.211:8021;}server {listen       7013;server_name  localhost;location /{proxy_pass  http://nginx-xxxx/;proxy_redirect default;     proxy_set_header Host $host:$server_port;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_connect_timeout 10;proxy_read_timeout 60;proxy_send_timeout 60;}}# HTTPS server##server {#    listen       443 ssl;#    server_name  localhost;#    ssl_certificate      cert.pem;#    ssl_certificate_key  cert.key;#    ssl_session_cache    shared:SSL:1m;#    ssl_session_timeout  5m;#    ssl_ciphers  HIGH:!aNULL:!MD5;#    ssl_prefer_server_ciphers  on;#    location / {#        root   html;#        index  index.html index.htm;#    }#}}

http://www.dtcms.com/a/148701.html

相关文章:

  • AWS S3企业级部署解决方案:从入门到高可用性实践
  • 108. 将有序数组转换为二叉搜索树
  • 诠视科技MR眼镜如何使用头瞄点和UGUI交互
  • Unity-GC详解
  • 机器学习逻辑回归损失函数与正则化技术深度解析
  • 网络协议之详解(Detailed Explanation of Network Protocol)
  • 第33周JavaSpringCloud微服务 面试题
  • 【数据可视化-21】水质安全数据可视化:探索化学物质与水质安全的关联
  • Qt开发:软件崩溃时,如何生成dump文件
  • ffmpeg 硬解码相关知识
  • Spring之我见 - Spring MVC重要组件和基本流程
  • 开启报名!火山引擎 x PICO-全国大学生物联网设计竞赛赛题发布
  • 【MATLAB第117期】#源码分享 | 基于MATLAB的SSM状态空间模型多元时间序列预测方法(多输入单输出)
  • 【随手记】jupyter notebook绘制交互式图像
  • Shell循环语句---for和while
  • 【上海大学数据库原理实验报告】MySQL数据库的C/S模式部署
  • 发送百度地图的定位
  • 物联网蓬勃发展是助力楼宇自控技术迈向成熟的关键
  • AI 健康小屋:开启智慧健康管理新范式
  • # 06_Elastic Stack 从入门到实践(六)
  • ffmpeg av_buffer_unref的逻辑实现; av_freep 和 av_freep函数的区别
  • 用c语言实现——一个带头节点的链队列,支持用户输入交互界面、初始化、入队、出队、查找、判空判满、显示队列、遍历计算长度等功能
  • 神经网络权重优化秘籍:梯度下降法全解析(五)
  • 记录一次使用面向对象的C语言封装步进电机驱动
  • Shell脚本中的字符串截取和规则变化
  • 深度学习基石:神经网络核心知识全解析(一)
  • 运行neo4j.bat console 报错无法识别为脚本,PowerShell 教程:查看语言模式并通过注册表修改受限模式
  • 【Java面试笔记:基础】5.String、StringBuffer、StringBuilder有什么区别?
  • transformer 子层连接结构
  • 迅为iTOP-RK3576开发板/核心板6TOPS超强算力NPU适用于ARM PC、边缘计算、个人移动互联网设备及其他多媒体产品