目标:多台tomcat 使用redis实现共享session。redis的安装请参阅:centos上安装redis

  nginx 作为目前最流行的开源反向代理HTTP Server,用于实现资源缓存、web server负载均衡等功能,由于其轻量级、高性能、高可靠等特点在互联网项目中有着非常普遍的应用,相关概念网上有丰富的介绍。分布式web server集群部署后需要实现session共享,本文主要介绍了使用 redis 服务器进行 session 统一存储管理的共享方案。

  

首先你需要一台机器上安装过如下软件,并进行了如下配置:

   Version  Port
 nginx  1.8  80
 tomcat_1  7.0.64  8080
 tomcat_2  7.0.64  8090
 redis  2.8.19  6379

另外需要将一些jar添加到两个tomcat lib 目录,tomcat lib 增加过jar后截图如下(点击下载全部jar):

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAUMAAAJnCAIAAACChKbtAAAgAElEQVR4nO3d+5Mc1X338fkpIam4/KRs5w8hFUWeevLDExyXk4oqRRKqgsxFIBiTi02Mb4BBBpxHAh6gpmwnMQQhjAMVw4JYVjtaFiGt0AW00kpgVitpRyvtSgLdRtLuau87O/P8MJc+p/ucnp7dnunp77xf1UVpZ7pPnx3NZ7pn1PMhMTAwMB62oWMn3nv/gzfe7GJhYWnOkmhEks+cvXQxN14E0CyNSnLUvxfQXsxJ/vtX+v/o8e1ffizzpce6v2xZvvRY95cfy/zR49v//pV+kgxEy5zkrzy+ffORq788dPmXhy4/f+jyCwOXXxjIvTBw+flDzlK6d/ORq195fDtJBqJlTvIXN3RnTk796YvDqzcPf/Wl7J9tyf6fX4382Zbs6s3Dq18sL3/64vCqF4e7T059cUO3T5LnrmydPv/c1LlnJ0efmjj15MTIU9eyG6+e+Gnu2GOXjj5y+fjTUxf7Ivz9ARnMSf79H28r6H7Pc4t6ly3JhcLS9PlnF2c6lxYvTl16/srpTScHHlyY3rG08EFpmZ/KXDi6MdqHABDAnOQbfrytUCh85b73M9ve+dEPf1QoFH734W2FQuHo4OCng4ODR48OHj366eDg4OCnpbt8jsnT559dnN22OLutWMwXi/nRg/cd3b9h5upb+fldi7PvLUxtPzfw3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WgaACQgyYAEJBmQgCQDEpBkQAKSDEhAkgEJSDIgAUkGJCDJgAQkGZCAJAMSkGRAApIMSECSAQlIMiABSQYkIMmABCQZkIAkAxKQZECC/w8wKlBSLbbw8gAAAABJRU5ErkJggg==" alt="" />

两台tomcat的conf下context.xml文件修改如下:

<?xml version='1.0' encoding='utf-8'?>
<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 events
on 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="localhost"
port="6379"
database="0"
maxInactiveInterval="60" /> </Context>

我们还需要给nginx配置文件中增加轮询机制,配置文件如下:

upstream site {
server localhost:8080;
server localhost:9080;
} server {
listen 80 default_server;
server_name 你的域名; location / {
index index_tel.jsp index.jsp index.html index.htm ;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_buffers 32 4k;
proxy_connect_timeout 3;
proxy_send_timeout 30;
proxy_read_timeout 30;
proxy_pass http://site;
}
}

最后我们进行测试,往tomcat1 ROOT下放个a.jsp:

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>测试session同步</title>
</head>
<body>
这是tomcat 8080,当前sessionId:<%=session.getId()%>
<%
session.setAttribute("name","我的博客");
%>
</body>
</html>

往tomcat1 ROOT下放个a.jsp,但内容不同:

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>测试session同步</title>
</head>
<body>
这是tomcat 8090,当前sessionId:<%=session.getId()%> 从session中取name:
<%=session.getAttribute("name")%>
</body>
</html>

最后我们重启两个tomcat,nginx。然后访问http://你的域名/a.jsp,会看到会切换到不同的tomcat下,但是sessionid相同,并且都可以在session中取到name这个属性的值。

下面是我的截图:

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABOUAAABICAIAAAA28NbzAAAUUElEQVR4nO2d3YEqrRJFJyMjMiCzMRjz8Tw4agP1s2loDzOz1tO9SldDAUXtwjnf1x0AAAAAAABgPb7+dwcAAAAAAAAADNCrAAAAAAAAsCLoVQAAAAAAAFgR9CoAAAAAAACsCHoVAAAAAAAAVgS9CgAAAAAAACuCXgUAAAAAAIAVQa8CAAAAAADAiqBXAQAAAAAAYEXQqwAAAAAAALAi6FUAAAAAAABYEfQqAAAAAAAArAh6FQAAAAAAAFYEvQoAAAAAAAArMkev3i6nr9PlNsUWAAAAAADA/SEzAp2RfA2f4Hr+Ol+PMy/q1dvlFHTjdjl9fX0d2k/4e1zPXzviT7BUD95Lvw72NQDAj+R2OTnB+3r+jWH9cVx1JgxxZjuXRwd/nd8/Bnp1Fomr3vHBjyG+3SMnQdOreeIqRsBvQxKsvC2V51znlO3cZtdz4Wt35sp2R4Xa2+Vk9NTRq7HqfI6/aXL4Vhrm4esDj7Nm9yXvOlCviutPXaZP2vjSPtJns2hdLR4vmmlrLLJsviAzGw0+Dbx+Xhu/vvSmt4vVF8bjMh9JfeQPvWmsBtl00MbA0/E+28cNd+0IwdfXc+8Cq426fi4bis2sxln/cg92rIV8wLHhsrW9C449jMb16twsYXIK4zzX5dPtCZfnph3h1Oz5gnp1l8bfg3cM9HjQUlmbJBG9KiPr1df/lf2675ZJRf49cLawr+ev0/ma9XJcr/6anx53DMTxmifJsmbq2Wm2O8L3jpS0Vr4rR+MHPxaWB/h294GdXESvOkdX/RqxWdnXZGV32TRNbpvG0SyYyNSya7yjp0UvssCbSTfr7Y4zrYTCpavEuS/giRpFDLJDgxbqbFGrDquq0hIqEv67y/az9WrPBqjau4069Go+4MykEHgcm3MY06tzs4TJKYw/3m59+zI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QAAAAAA4PQgbgEAAAAAAOD0IG4BAAAAAADg9CBuAQAAAAAA4PQgbgEAAAAAAOD0IG4BAAAAAADg9CBuAQAAAAAA4PT8A5cTd9n6zZnQAAAAAElFTkSuQmCC" alt="" />

nginx redis tomcat 分布式web应用 session共享的更多相关文章

  1. tomcat+nginx+redis实现均衡负载、session共享(二)

    今天我们接着说上次还没完成session共享的部分,还没看过上一篇的朋友可以先看下上次内容,http://www.cnblogs.com/zhrxidian/p/5432886.html. 1.red ...

  2. tomcat+nginx+redis实现均衡负载以及session共享

    1.redis简介及下载安装 作为这次的主角,相信大家对redis应该都一定印象,redis是一款开源的高性能key-value数据库,拥有丰富的键值储存类型,并提供多种语言的API. 与一般数据库不 ...

  3. tomcat+nginx+redis实现均衡负载、session共享(一)

    在项目运营时,我们都会遇到一个问题,项目需要更新时,我们可能需先暂时关闭下服务器来更新.但这可能会出现一些状况: 1.用户还在操作,被强迫终止了(我们可以看日志等没人操作的时候更新,但总可能会有万一) ...

  4. 【转载】tomcat+nginx+redis实现均衡负载、session共享(一)

    http://www.cnblogs.com/zhrxidian/p/5432886.html 在项目运营时,我们都会遇到一个问题,项目需要更新时,我们可能需先暂时关闭下服务器来更新.但这可能会出现一 ...

  5. (转)tomcat+nginx+redis实现均衡负载、session共享(一)

    在项目运营时,我们都会遇到一个问题,项目需要更新时,我们可能需先暂时关闭下服务器来更新.但这可能会出现一些状况: 1.用户还在操作,被强迫终止了(我们可以看日志等没人操作的时候更新,但总可能会有万一) ...

  6. Nginx和Tomcat负载均衡实现session共享(转)

    以前的项目使用Nginx作为反向代理实现了多个Tomcat的负载均衡,为了实现多个Tomcat之间的session共享,使用了开源的Memcached-Session-Manager框架. 此框架的优 ...

  7. Nginx和Tomcat负载均衡实现session共享

    以前的项目使用Nginx作为反向代理实现了多个Tomcat的负载均衡,为了实现多个Tomcat之间的session共享,使用了开源的Memcached-Session-Manager框架. 此框架的优 ...

  8. 【转载】tomcat+nginx+redis实现均衡负载、session共享(二)

    今天我们接着说上次还没完成session共享的部分,还没看过上一篇的朋友可以先看下上次内容,http://www.cnblogs.com/zhrxidian/p/5432886.html. 1.red ...

  9. 转 tomcat+nginx+redis实现均衡负载、session共享(二)

    http://www.cnblogs.com/zhrxidian/p/5491285.html http://www.cnblogs.com/zhrxidian/p/5432886.html

随机推荐

  1. Windows Phone 8 开发环境搭建

    原地址:http://blog.csdn.net/md521/article/details/11015139 Windows Phone 8将采用与Windows 8相同的NT内核,这就意味着WP8 ...

  2. Python 全栈开发 -- 开发环境篇

    开发环境是一个文本编辑器和 Python 解释器的组合.文本编辑器用来写代码,解释器提供了一种方法来运行编写的代码.一个文本编辑器可以像 Windows 上的 Notepad 一样简单,或是一个复杂的 ...

  3. 【NOIP 2015 DAY2 T3】 运输计划 (树链剖分-LCA)

    题目背景 公元 2044 年,人类进入了宇宙纪元. 题目描述 L 国有 n 个星球,还有 n-1 条双向航道,每条航道建立在两个星球之间,这 n-1 条航道连通了 L 国的所有星球. 小 P 掌管一家 ...

  4. SQLite入门与分析(八)---存储模型(3)

    写在前面:接上一节,本节主要讨论索引页面格式,以及索引与查询优化的关系. (1)索引页面格式sqlite> select * from sqlite_master;table|episodes| ...

  5. INF文件

    百度百科:http://baike.baidu.com/view/637107.htm?fr=ala0_1_1 INF简介 INF是Device INFormation File的英文缩写,是Micr ...

  6. Type-C设计上的防护

    Type C设计上各家芯片公司都提供了很多方案,但在防护方面很多留给了客户自己选择,这方面我可以重点聊聊,说起防护,无非就是过压过流防护. 过压防护,Type C的信号线有很多,都需要做静电防护,US ...

  7. JAVA信号量使用示例程序

    JAVA里也有强大的信号量工具Semaphore,使用信号量可以很方便的实现线程同步功能,以解决类似于 生产者——消费者 之类的典型问题. 下面是我的测试程序,大部分看注释就可以明白用法: impor ...

  8. jdk1.7升级到jdk1.8后出错: [ERROR] javadoc: warning - Multiple sources of package comments found for package

    from: http://blog.joda.org/2014/02/turning-off-doclint-in-jdk-8-javadoc.html [ERROR] javadoc: warnin ...

  9. URAL1244. Gentlemen(背包)

    链接 以前做的题 VJ太水了 数组里面的数可能会小于0 当时没判断 #include <iostream> #include<cstdio> #include<cstri ...

  10. AlarmManager用法

    源http://blog.csdn.net/wangxingwu_314/article/details/8060312