标签:session共享
本次测试使用的是tomcat7,使用tomcat7的话jdk就一定要使用1.7版本的。
使用组件版本nginx:1.8.0 tomcat两个:7.0.67 redis:2.4.10 JDK:1.7.0_79
(1)将下面所有依赖的这些jar包放在$TOMCAT_HOME/lib中:
jedis-2.2.1.jar
tomcat-redis-session-manager-1.2-tomcat-7.jar
commons-pool-1.6.jar
2) 两个tomcat分别配置conf/context.xml,增加:
<ValveclassName="com.radiadesign.catalina.session.RedisSessionHandlerValve"/>
<ManagerclassName="com.radiadesign.catalina.session.RedisSessionManager"
host="localhost"
port="6379"
database="0"
maxInactiveInterval="60" />
nginx的配置如下:
#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 {
upstream cluster_redis{
server10.20.9.175:8080;
server10.20.9.176:8080;
}
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;
之后把nginx,tomcat,redis启动之后进行测试
参考资料:
http://dinguangx.iteye.com/blog/2230980
http://xstarcd.github.io/wiki/Java/tomcat_cluster.html
http://www.cnblogs.com/lengfo/p/4260363.html
标签:session共享
原文地址:http://881955.blog.51cto.com/871955/1726192