本文记录nginx+redis+tomcat实现session共享的过程
nginx安装:http://blog.csdn.net/grhlove123/article/details/47834673
redis安装:http://blog.csdn.net/grhlove123/article/details/47783471
准备两个tomcat,修改相应的端口
名称 | IP | 端口 | tomcat版本 | JDK |
tomcat1 | 10.4.247.100 | 81 | 7.0.65 | 1.7.0_25 |
tomcat2 | 10.4.247.100 | 82 | 7.0.65 | 1.7.0_25 |
tomcat配置
下载:http://download.csdn.net/detail/u010438469/9483973
拷贝附件4个jar包到$TOMCAT_HOME/lib中
修改两tomcat的context.xml:
新增内容如下<Valve className="com.orangefunction.tomcat.redissessions.RedisSessionHandlerValve" />
<Manager className="com.orangefunction.tomcat.redissessions.RedisSessionManager"
host="127.0.0.1"
port="6379"
database="0"
maxInactiveInterval="60" />
1、nginx
启动:/usr/local/nginx/sbin/nginx
停止/重新加载:/usr/local/nginx/sbin/nginx -s stop(quit、reload)
2、redis
启动redis
/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf
3、tomcat
cd /usr/local/webServer/tomcat7065_81/bin
cd /usr/local/webServer/tomcat7065_82/bin
启动:./catalina.sh run 或者 ./startup.sh
停止:./shutdown.sh
参考文档:http://blog.csdn.net/grhlove123/article/details/48047735