<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}根据实际的应用服务器类型选择:
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文件内容如下:
<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,按如下配置: