Nginx+tomcat集群redis共享session应用方案
2018-01-10 11:01
501 查看
部署环境
主机 | 软件版本 |
192.168.88.1 | nginx-1.12.2+redis-3.2.11 |
192.168.88.2 | apache-tomcat-7.0.79 + jdk1.8 |
192.168.88.3 | apache-tomcat-7.0.79 + jdk1.8 |
所需tomcat jar包,下载
commons-pool-1.5.4.jarcommons-pool2-2.4.1.jar
jedis-2.6.2.jar
tomcat-juli-adapters.jar
tomcat-juli.jar
tomcat-redis-session-manager1.2.jar
Tomcat配置
把tomcat jar包复制到$TOMCAT_BASE 下的lib目录修改tomcat的配置文件conf/comtext.xml
#单点redis配置(我已经配置成功) <Context> <WatchedResource>WEB-INF/web.xml</WatchedResource> <Valve className="com.orangefunction.tomcat.redissessions.RedisSessionHandlerValve" /> <Manager className="com.orangefunction.tomcat.redissessions.RedisSessionManager" host="192.168.88.1" port="6379" database="0" maxInactiveInterval="60"/> </Context> #基于redis集群配置(我还没测试) <Context> <WatchedResource>WEB-INF/web.xml</WatchedResource> <Valve className="com.orangefunction.tomcat.redissessions.RedisSessionHandlerValve" /> <Manager className="com.orangefunction.tomcat.redissessions.RedisSessionManager" maxInactiveInterval="60" sentinelMaster="mymaster" sentinels="127.0.0.1:26379,127.0.0.1:26380,127.0.0.1:26381"/> </Context>
3、添加一个tomcat测试页index.jsp
# cat /opt/tomcat/webapps/ROOT/index.jsp <html> <head> <title>nginx tomcat session test</title> <meta name="Generator" content="EditPlus"> <meta name="Author" content=""> <meta name="Keywords" content=""> <meta name="Description" content=""> </head> <h1>tomcat88.2</h1> #这里192.168.88.3机器改为tomcat88.3 session: <%=session.getId()%> </html>
4、启动tomcat
nginx配置
worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; upstream tomcat { server 192.168.88.2:8080 weight=1; server 192.168.88.3:8080 weight=1; } server { listen 80; server_name localhost; location / { proxy_pass http://tomcat; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }
redis安装请看教程
各个组件下载
Redis: http://redis.ioJRedis: https://github.com/xetorthio/jedis
https://github.com/jcoleman/tomcat-redis-session-manager/do
http://commons.apache.org/proper/commons-pool/download_pool.cgi
相关文章推荐
- Nginx+Tomcat搭建集群,Spring Session+Redis实现Session共享
- Linux(CentOS)下Nginx+Tomcat集群+Redis共享Session搭建
- Nginx+Tomcat+Redis实现应用服务器集群负载均衡和Session共享
- Windows环境下Nginx+Tomcat+Redis实现应用服务器集群负载均衡和Session共享
- Nginx+Tomcat搭建集群,Spring Session+Redis实现Session共享
- Linux+Nginx+Tomcat+Redis实现负载均衡,应用集群及session共享
- Nginx+Tomcat搭建集群,Spring Session+Redis实现Session共享
- 使用redis集群+tomcat缓存共享下session丢失问题产生原因以及解决
- Nginx+Tomcat+Redis搭建共享SESSION集群
- Nginx+tomcat+redis集群共享session实现负载均衡
- Nginx+Tomcat搭建集群,Spring Session+Redis实现Session共享
- 分布式架构学习之:使用Redis3.0集群实现Tomcat集群的Session共享
- 搭建Tomcat集群&通过Redis缓存共享session的一种流行方案
- 搭建Nginx(负载均衡)+Redis(Session共享)+Tomcat集群
- Nginx +Tomcat集群搭建 Redis实现session共享
- tomcat集群共享session(nginx+redis)
- tomcat集群基于redis共享session解决方案
- nginx+tomcat+redis/Memcached集群完成session共享
- 搭建Tomcat集群&通过Redis缓存共享session的一种流行方案
- 使用nginx搭建集群tomcat8,redis实现session共享,文件共享问题