jetty使用terracotta集群配置

1, 复制jetty-terracotta-sessions-6.1.25.jar到${JETTY_HOME}/lib/ext下
2,在jetty.xml中增加
<New id="tcIdManager" class="org.mortbay.terracotta.servlet.TerracottaSessionIdManager">
        <Arg>
            <Ref id="Server" />
        </Arg>
        <Set name="workerName">
            <SystemProperty name="jetty.node" default="node1" />
        </Set>
    </New>
    <Call name="setAttribute">
        <Arg>tcIdManager</Arg>
        <Arg>
            <Ref id="tcIdManager" />
        </Arg>
    </Call>

3,在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>10.192.33.93:9510,10.192.33.94:9510,192.168.1.100:9510,192.168.1.101: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>

4,在terracotta的tc-config.xml中增加
<clients>
	<modules>
		<module name="tim-jetty-6.1" version="2.2.0"/>
	</modules>
    <logs>%(user.home)/terracotta/client-logs</logs>
  </clients>


然后启动TCserver和jetty服务器即可

你可能感兴趣的:(xml,Web,ext)