展示不使用Terracotta DSO如何集群Web Sessions。

  1、要求

    1)jdk1.6或者更高版本

    2)Terracotta 3.7或者更高版本

    3)所有被集群的对象需要实现序列化,如果不想实现序列化,必须使用Terracotta DSO定制Web Sessions的安装

  2、安装Terracotta Sessions jar

    1)为保证兼容性,请使用已安装的Terracotta的jar文件

    2)为了使应用的web Sessions在集群中共享,添加下列jar文件到应用服务器的的lib目录中

${TERRACOTTA_HOME}/sessions/terracotta-session-<version>.jar

    ${TERRACOTTA_HOME} 是指Terracotta的安装目录,<version>是指当前使用的terracotta session的版本,我这里就是D:/terracotta/terracotta-3.7.2/sessions/terracotta- session-1.3.1.jar。

${TERRACOTTA_HOME}/common/terracotta-toolkit-<API-version>-runtime-ee-<version>.jar

     The Terracotta Toolkit JAR包含了Terracotta客户端类库,<API-version> 就是指Terracotta Toolkit API version. <version>就是当前使用的Terracotta Toolkit JAR版本,我这里就是:D:/terracotta/terracotta-3.7.2/common/terracotta-toolkit- 1.6-runtime-5.2.0.jar

     3)上述session和toolkit的jar文件在各种应用服务器中的存放路径

Application Server Suggested Location for Terracotta Sessions JAR File
JBoss AS (earlier than 6.0) < jboss install dir>/lib
JBoss AS 6.0 < jboss install dir>/common/lib (REQUIRED)
JBoss AS 7.0 or 7.1 < jboss install dir>/WEB-INF/lib
Jetty WEB-INF/lib
Tomcat 5.0 and 5.5 $CATALINA_HOME/server/lib
Tomcat 6.0 and 7.0 $CATALINA_HOME/lib
WebLogic WEB-INF/lib

  3、配置web-session集群

     1)Terracotta servers和Terracotta clients通过 Terracotta配置文件运行在集群中的应用服务器上,默认的配置文件是tc-config.xml,服务器启动的时候不指定配置文件就默认使用 tc-config.xml。

    2)为了把Terracotta集群添加到我们的应用中,需要通过web.xml或者context.xml文件指定Terracotta clients如何获取配置。

    3)Jetty, WebLogic, and WebSphere需要添加以下配置到web.xml文件中

<filter>     <filter-name>terracotta</filter-name>     <!-- The filter class is specific to the application server. -->      <filter-class>org.terracotta.session.{container-specific-class}</filter-class>     <init-param>         <param-name>tcConfigUrl</param-name>   <!-- <init-param> of type tcConfigUrl has a <param-value> element containing the URL or filepath (for example, /lib/tc-config.xml) to tc-config.xml. If the Terracotta configuration source changes at a later time,  it must be updated in configuration. -->         <param-value>localhost:9510</param-value>     </init-param> </filter> <filter-mapping> <!-- Must match filter name from above. -->  <filter-name>terracotta</filter-name> <url-pattern>/*</url-pattern> <!-- Enable all available dispatchers. --> <dispatcher>ERROR</dispatcher> <dispatcher>INCLUDE</dispatcher>  <dispatcher>FORWARD</dispatcher> <dispatcher>REQUEST</dispatcher> </filter-mapping>

      <filter-class>中的{container-specific-class}根据实际的应用服务器类型选择:

Container Value of <filter-class>
Jetty 6.1 org.terracotta.session.TerracottaJetty61xSessionFilter
Jetty 7.4.1 org.terracotta.session.TerracottaJetty74xSessionFilter
WebLogic 9 org.terracotta.session.TerracottaWeblogic9xSessionFilter
WebLogic 10 org.terracotta.session.TerracottaWeblogic10xSessionFilter
WebSphere 6.1 org.terracotta.session.TerracottaWebsphere61xSessionFilter
WebSphere 7.0 org.terracotta.session.TerracottaWebsphere70xSessionFilter

      4)Tomcat and JBoss AS 6.0 or Earlier

        使用war包发布的应用,如果是tomcat,确保context.xml文件在/META-INF目录下,如果是JBoss,确保context.xml文件在/WEB-INF目录下。

        context.xml文件内容如下:

<Valve className="org.terracotta.session.{container-specific-class}" tcConfigUrl="localhost:9510"/>

       {container-specific-class}根据实际的应用服务器类型选择:

Container Value of className
JBoss Application Server 4.0 org.terracotta.session.TerracottaJboss40xSessionValve
JBoss Application Server 4.2 org.terracotta.session.TerracottaJboss42xSessionValve
JBoss Application Server 5.1 org.terracotta.session.TerracottaJboss51xSessionValve
JBoss Application Server 6.0 org.terracotta.session.TerracottaJboss60xSessionValve
Tomcat 5.0 org.terracotta.session.TerracottaTomcat50xSessionValve
Tomcat 5.5 org.terracotta.session.TerracottaTomcat55xSessionValve
Tomcat 6.0 org.terracotta.session.TerracottaTomcat60xSessionValve
Tomcat 7.0 org.terracotta.session.TerracottaTomcat70xSessionValve

        例如在tomcat6.0中,context.xml内容如下:

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

        确保Terracotta Value是context.xml文件中的第一个<Value>元素。

        如果在tomcat中使用了authenticator,在Terracotta集群运行的时候有可能会遇到UnsupportedOperationException,在tomcat5.5以上可以禁用changeSessionIdOnAuthentication来防止这种错误:

<Valve changeSessionIdOnAuthentication="false" className="org.apache.catalina.authenticator.BasicAuthenticator"/>

      5)JBoss7.0 or 7.1  

      添加以下内容到WEB-INF/jboss-web.xml中

<?xml version="1.0" encoding="UTF-8"?><jboss-web>...  <valve>    <class-name>org.terracotta.session.TerracottaJboss7xSessionValve</class-name>              <param>        <param-name>tcConfigUrl</param-name>
<param-value>localhost:9510</param-value> </param> </valve>...</jboss-web>

  4、启动集群

    1)启动 Terracotta server:

      UNIX/Linux

${TERRACOTTA_HOME}/bin/start-tc-server.sh &

      Microsoft Windows

${TERRACOTTA_HOME}/bin/start-tc-server.bat

    2)启动应用服务器

    3)启动Terracotta 控制台

    UNIX/Linux

${TERRACOTTA_HOME}/bin/dev-console.sh &

    Microsoft Windows

${TERRACOTTA_HOME}/bin/dev-console.bat

    4)启动控制台后,可以看到集群中Terracotta Server和客户端

  5、Terracotta配置

    这里配置展示如何在分开的机器上运行服务器和客户端,增加容灾(高可用性),扩展集群和添加高可用性可以按照下面的步骤: 

  • Moving the Terracotta server to its own machine
  • Creating a cluster with multiple Terracotta servers
  • Creating multiple application nodes

    1)关闭Terracotta Cluster

    2)创建Terracotta配置文件tc-config.xml:

<tc:tc-config>
<servers> <!-- Sets where the Terracotta server can be found. Replace the value of host with the server's IP address. --> <server host="server.1.ip.address" name="Server1">   <data>%(user.home)/terracotta/server-data</data>   <logs>%(user.home)/terracotta/server-logs</logs> </server> <!-- If using a standby Terracotta server, also referred to as an ACTIVE-PASSIVE configuration, add the second server here. --> <server host="server.2.ip.address" name="Server2">    <data>%(user.home)/terracotta/server-data</data>    <logs>%(user.home)/terracotta/server-logs</logs> </server> <!-- If using more than one server, add an <ha> section. --> <ha>    <mode>networked-active-passive</mode>    <networked-active-passive>     <election-time>5</election-time>   </networked-active-passive> </ha></servers> <!-- Sets where the generated client logs are saved on clients. -->
<clients> <logs>%(user.home)/terracotta/client-logs</logs></clients></tc:tc-config>

    3)在tc-config.xml中配置的每一台服务器机器上安装terracotta3.7.2

    4)把tc-config.xml文件复制到每一台服务器中的terracotta Server可以访问的位置

    5)在每一台服务器中按照上面步骤(2、安装Terracotta Sessions jar)安装Terracotta Sessions jar

    6)在每一台应用服务器中配置web.xml或者context.xml

      如果使用的是web.xml,按如下配置:

<param-value>server.1.ip.address:9510,server.2.ip.address:9510</param-value>

      如果使用的是context.xml,按如下配置:

tcConfigUrl="server.1.ip.address:9510,server.2.ip.address:9510"

      tc-config.xml中配置了多少台服务器,web.xml或者context.xml就要配置多少。

    7)启动Terracotta Server

    UNIX/Linux

${TERRACOTTA_HOME}/bin/start-tc-server.sh -f <path/to/tc-config.xml> -n Server1 &

    Microsoft Windows

${TERRACOTTA_HOME}/bin/start-tc-server.bat -f <path/to/tc-config.xml> -n Server1 

    ${TERRACOTTA_HOME}是指terracotta的安装目录

    <path/to/tc-config.xml>是指tc-config.xml文件的完整存放路径

    Server1是指在tc-config.xml文件中配置的ServerName

    在每一台服务器上启动各自的Terracotta Server,注意启动的时候 -n 指定各自的ServerName,第二台和往后启动的Terracotta Server处于备用状态。

    8)在每一台服务器上启动各自的应用服务器

    9)启动Terracotta控制台查看集群

Web Sessions Installation的更多相关文章

  1. Add Columns to the Web Sessions List

    To add custom columns to the Web Sessions List, add rules using FiddlerScript. The BindUIColumn Attr ...

  2. Customize Web Sessions List

    To customize Fiddler's Web Sessions List, add rules using FiddlerScript to the OnBeforeRequest funct ...

  3. The Web Sessions List

    The Web Sessions list contains the list of HTTP Requests that are sent by your computer. You can res ...

  4. Pause Web Sessions

    To pause specific sessions, add rules using FiddlerScript to the OnBeforeRequest function (except wh ...

  5. WEB/HTTP 调试利器 Fiddler 的一些技巧分享

    1.原理简介: Fiddler 是目前最强大最好用的 Web 调试工具之一,它能记录所有客户端和服务器的http和https请求, 允许你监视,设置 CGI 请求的断点,甚至修改输入输出数据.同类的工 ...

  6. Nginx+Tomcat+Terracotta的Web服务器集群实做

    1.准备工作两个Linux服务器,可以用VMware装一个,然后配置好再克隆一个,修改IP即可.Host1:192.168.0.79Host2:192.168.0.80先配置好jdk1.6.0和tom ...

  7. Web调试利器fiddler使用

    fiddler官网:http://fiddler2.com/ http://wenku.baidu.com/view/053e79d776a20029bd642dc1 http://www.cnblo ...

  8. [Windows Azure] Developing Multi-Tenant Web Applications with Windows Azure AD

    Developing Multi-Tenant Web Applications with Windows Azure AD 2 out of 3 rated this helpful - Rate ...

  9. [转]Creating an OData v3 Endpoint with Web API 2

    本文转自:https://docs.microsoft.com/en-us/aspnet/web-api/overview/odata-support-in-aspnet-web-api/odata- ...

随机推荐

  1. 怎么能让json_decode解析带斜杠的字符串

    比如前台一个js object:{  aa: "cc\dd"}$d = '{\"aa\": \"cc\\dd\"}';这时候用 json_d ...

  2. 安装部署Apache Hadoop (完全分布式模式并且实现NameNode HA和ResourceManager HA)

    本节内容: 环境规划 配置集群各节点hosts文件 安装JDK1.7 安装依赖包ssh和rsync 各节点时间同步 安装Zookeeper集群 添加Hadoop运行用户 配置主节点登录自己和其他节点不 ...

  3. CCF CSP 201412-4 最优灌溉

    CCF计算机职业资格认证考试题解系列文章为meelo原创,请务必以链接形式注明本文地址 CCF CSP 201412-4 最优灌溉 问题描述 雷雷承包了很多片麦田,为了灌溉这些麦田,雷雷在第一个麦田挖 ...

  4. myql root用户远程访问

    虚拟机搭建的lnmp开发环境,mysql在虚拟机正常访问,想在物理机通过数据库管理工具Navicat远程登录,方便建表查询等操作.经网上一查,有答案了. [以下是转载]http://www.cnblo ...

  5. Android中Xposed框架篇-微信实现本地视频发布到朋友圈功能

    微信非常庞大,还好有一些强大的工具,下面就来总结收获的知识. 一.使用adb shell dumpsys activity top命令快速定位页面 二.使用Jadx进行方法跟踪时候如果发现没有结果,可 ...

  6. volatile 和锁的内存语义

    一.volatile 的内存语义 1. volatile 的特性 volatile变量自身具有以下特性: 可见性 :对一个volatile变量的读,总是能看到(任意线程)对这个volatile变量最后 ...

  7. 浅谈Comparable与Comparator的区别

    平时进行自定义排序一直使用实现Comparable接口,一段时间后操作的时候居然发现有了个Comparator接口 上网差了些资料,总结笔记一下. 基本原理就是比较,底层是二叉树 比如是3,6,5,1 ...

  8. 美团DB数据同步到数据仓库的架构与实践

    背景 在数据仓库建模中,未经任何加工处理的原始业务层数据,我们称之为ODS(Operational Data Store)数据.在互联网企业中,常见的ODS数据有业务日志数据(Log)和业务DB数据( ...

  9. centOS7 apache ssl证书安装配置

    背景说明:服务器是centOS7.4 七牛申请的免费ssl证书 默认apache是没有安装SSL模块的,所以需要安装,接着使用命令: yum install -y mod_ssl apache目录 / ...

  10. Alpha 冲刺报告8

    组长:吴晓晖 今天完成了哪些任务: maven和idea用的不熟啊,jar包或者war包导出来一直有问题:生气了把ide扔到服务器里去运行springboot了,卡哭了,终于可以运行了,然后debug ...