tomcat6+memcached+nginx(windows本地)

1.下载安装tomcat、memcached、nginx

2.解压tomcat,copy一份,然后更改copy之后tomcat的端口。

3.准备好jar包(附件),把jar放到tomcat安装目录的lib下面


4.配置两个tomcat,在con/context.xml文件里面增加如下配置:

 <Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"   
    memcachedNodes="n1:localhost:11211"   
    requestUriIgnorePattern=".*/.(png|gif|jpg|css|js)$"   
    sessionBackupAsync="false"   
    sessionBackupTimeout="100"   
    transcoderFactoryClass="de.javakaffee.web.msm.serializer.javolution.JavolutionTranscoderFactory"   
    copyCollectionsForSerialization="false"   
    />  

5.在一个个tomcat的 webapps/ROOT目录下写一个测试页面test.jsp

<%@ page language="java" %>
<html>
  <head><title>Tomcat1</title></head>
  <body>
    <h1><font color="red">Tomcat1</font></h1>
    <table align="centre" border="1">
      <tr>
        <td>Session ID</td>
    <% session.setAttribute("test","test"); %>
        <td><%= session.getId() %></td>
      </tr>
    </table>
  </body>
</html>

另一个tomcat

<%@ page language="java" %>
<html>
  <head><title>Tomcat2</title></head>
  <body>
    <h1><font color="red">Tomcat2</font></h1>
    <table align="centre" border="1">
      <tr>
        <td>Session ID</td>
    <% session.setAttribute("test","test"); %>
        <td><%= session.getId() %></td>
      </tr>
    </table>
  </body>
</html>
6.配置ngnix

http节点下面配置

 upstream  localhost { 
          server   127.0.0.1:8090 weight=1  max_fails=2 fail_timeout=30s;
          server   127.0.0.1:8091 weight=1  max_fails=2 fail_timeout=30s;
    }

server节点

 location / {
            root   html;  
            index  index.html index.htm;  
            proxy_pass    http://localhost;  
        }

7.测试。启动两个tomcat和ngnix,用ngnix访问,因为是默认80端口,直接访问http://localhost/test.jsp,页面不断变化,但是sessionId没变。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值