Terrocotta 共享Session

1、./WEB-INF/lib中需要有两个jar
./META-INF
./META-INF/MANIFEST.MF
./META-INF/context.xml
./index.jsp
./WEB-INF
./WEB-INF/web.xml
./WEB-INF/lib
./WEB-INF/lib/terracotta-session-1.3.5.jar
./WEB-INF/lib/terracotta-toolkit-1.6-runtime-5.5.0.jar
./WEB-INF/classes
./WEB-INF/classes/com

 

2、web.xml配置 

<filter>
  <filter-name>terracotta-filter</filter-name>
        <filter-class>org.terracotta.session.TerracottaJetty61xSessionFilter</filter-class>
        <init-param>
                <param-name>tcConfigUrl</param-name>
                <param-value>192.168.1.191:9510</param-value>
        </init-param>
</filter>
<filter-mapping>
  <filter-name>terracotta-filter</filter-name>
          <url-pattern>/*</url-pattern>
          <dispatcher>ERROR</dispatcher>
          <dispatcher>INCLUDE</dispatcher>
          <dispatcher>FORWARD</dispatcher>
          <dispatcher>REQUEST</dispatcher>
  </filter-mapping>
</web-app>

 

3、./META-INF/context.xml 文件内容

 

<!-- The following is an example of a Tomcat Valve declaration to add to your application to enable
     terracotta express session clustering.
    
     In the example below you will likely need to adjust the className attribute to match
     your desired application server and the "tcConfigUrl" attribute should be changed to
     match the location of your Terracotta server(s).
    
     The order of <Valve> elements is relevant. The Terracotta Valve should always be listed first.
    
     This file should be placed at META-INF/context.xml for WAR deployment on tomcat, or at
     WEB-INF/context.xml for Jboss WAR deployment      
    
     Tomcat 5.0.x users must add a path attribute to the <Context path="/myApp"> element since it is not
     optional in that version
-->


<Context>
  <Valve className="org.terracotta.session.TerracottaTomcat60xSessionValve" tcConfigUrl="192.168.1.191:9510"/>
</Context>

 

<!-- tomcat 5.5.x -->
<!-- <Context> -->
<!--   <Valve className="org.terracotta.session.TerracottaTomcat55xSessionValve" tcConfigUrl="localhost:9510"/> -->
<!-- </Context> -->

<!-- tomcat 5.0.x -->
<!-- <Context path="/myApp"> -->
<!--   <Valve className="org.terracotta.session.TerracottaTomcat50xSessionValve" tcConfigUrl="localhost:9510"/> -->
<!-- </Context> -->

<!-- jboss 5.1.x -->
<!-- <Context> -->
<!--   <Valve className="org.terracotta.session.TerracottaJboss51xSessionValve" tcConfigUrl="localhost:9510"/> -->
<!-- </Context> -->

<!-- jboss 4.2.x -->
<!-- <Context> -->
<!--   <Valve className="org.terracotta.session.TerracottaJboss42xSessionValve" tcConfigUrl="localhost:9510"/> -->
<!-- </Context> -->

<!-- jboss 4.0.x -->
<!-- <Context> -->
<!--   <Valve className="org.terracotta.session.TerracottaJboss40xSessionValve" tcConfigUrl="localhost:9510"/> -->
<!-- </Context> -->

 

4、最重要的一点是:如果部署于两台机器 192.168.1.101 192.168.1.102 这两个机器作为后置机

前端必须有一个lvs , 用户通过lvs进入访问 ,这时session才能共享。

我用是nginx

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值