整合Terracotta+Tomcat的过程和遇到的问题

整合Terracotta+Tomcat的过程

一、首先在服务器端

使用的版本为linux rhel4 up7

内网ip192.168.5.186

1、 安装Terracotta-3.1.0

http://s3.amazonaws.com/TCreleases/terracotta-3.1.0.tar.gz?Signature=GFcrO3EUxUbMuET6aj4ZM%2FjiS5o%3D&Expires=1255167277&AWSAccessKeyId=1ASD4K6SWEHW65J0HV82下载,然后tar -zxvf terracotta-3.1.0.tar.gz –C terracotta ,

2、配置tc-config.xml为:

<tc:tc-config xmlns:tc="http://www.terracotta.org/config"

  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

  xsi:schemaLocation="http://www.terracotta.org/schema/terracotta-4.xsd">

 <servers>

 <!-- For more information on working with the Terracotta configuration file, including how to add

      more servers, see http://www.terracotta.org/web/display/docs/About+Terracotta+Configuration+Files.

     

      Edit the following server element so that its host attribute contains the value matching the

      hostname for the Terracotta server. -->

         <server host="192.168.5.186">

       <dso-port>9510</dso-port>

     </server>

         <update-check>

       <enabled>true</enabled>

    </update-check>

 </servers>

 <!-- Check that the TIM shown in the <module> element's name attribute matches the Tomcat version you

      are using. The TIM listed here, "tim-tomcat-5.5" is for Tomcat 5.5. For example, if you are using

      Tomcat 6.0, edit the name to "tim-tomcat-6.0".  -->

      <clients>

    <modules>

      <module name="tim-tomcat-5.5" version="2.0.0" />

    </modules>

  </clients>

 <!-- Using <web-application> elements, enter the context root of the web application being clustered.

      If you are clustering more than one web application, use one <web-application> element per application.

      Two example <web-application> elements are shown below. Edit or remove these elements as needed.

      To set the value of the <web-application> element to the default web-application context, use the

      special value "ROOT" (without quotation marks). -->

 

 <application>

  <dso>

               <additional-boot-jar-classes>

        <include>java.util.TimeZone</include>

        <include>sun.util.calendar.ZoneInfo</include>

       </additional-boot-jar-classes>

      <instrumented-classes>

         <include>

           <class-expression>num.NumberGuessBean</class-expression>

         </include>

         <include>

           <class-expression>cal.*</class-expression>

         </include>

    </instrumented-classes>

    <web-applications>

      <web-application>jsp-examples</web-application>

    </web-applications>

  </dso>

 </application>

</tc:tc-config>

注:需要说明的是,这里是按照您写的文章里面的配置下来的,因为中间在启动tomcat的过程中遇到了您所说的:

com.tc.exception.TCNonPortableObjectError:

*******************************************************************************

Attempt to share an instance of a non-portable class referenced by a portable class. This unshareable class must be in the DSO boot jar. It also has superclasses which must be in the DSO boot jar. Please add all of these classes to the boot jar configuration and re-create the DSO boot jar.

因此在原来的配置文件里面按照提示增加了:

  <additional-boot-jar-classes>

        <include>java.util.TimeZone</include>

        <include>sun.util.calendar.ZoneInfo</include>

       </additional-boot-jar-classes>

然后$TERRACOTTA_HOME/bin/make-boot-jar.sh -f $TOMCAT_HOME/tc-config.xml,重新生成了boot jar文件。

另外需要做的就是下载和安装tim-tomcat:

$TERRACOTTA_HOME/bin/tim-get.sh install tim-tomcat-6.0

$TERRACOTTA_HOME/bin/tim-get.sh install tim-tomcat-5.5

$TERRACOTTA_HOME/bin/tim-get.sh install tim-tomcat-5.0

详细的方法见:

http://forge.terracotta.org/releases/projects/tim-tomcat/index.html

二、客户端的配置:

      两个客服端的机器也是采用linux rhel4 up7

        Ip分别为192.168.5.237192.168.5.243

        Tomcat的版本为5.5.26,这是terracotta所支持的一个版本

1、  安装terracotta的过程见服务器端安装

2、  将在terracotta服务器端(192.168.5.186)所配置过的tc-config.xml拷贝到新的机器上192.168.5.237192.168.5.243上面,然后$TERRACOTTA_HOME/bin/make-boot-jar.sh -f $TOMCAT_HOME/tc-config.xml,重新生成了boot jar文件

3、  安装tim-tomcat,方法服务器端的配置过程

4、  修改tomcat的启动脚本catalina.sh加入:

JAVA_OPTS='-server -Xms512m -Xmx512m -XX:PermSize=256M -XX:MaxPermSize=256m -Djava.awt.headless=true -Xbootclasspath/p:/root/terraco

tta/lib/dso-boot/dso-boot-hotspot_linux_150_12.jar -Dtc.install-root=/root/terracotta  -Dtc.config=192.168.5.186:9510'

5、  制作启动脚本($tomcat/bin下):

TC_INSTALL_DIR=/root/terracotta

TC_CONFIG_PATH=/root/terracotta/bin/tc-config.xml

$TC_INSTALL_DIR/bin/dso-env.sh -q

export JAVA_OPTS="$JAVA_OPTS $TC_JAVA_OPTS"

.         startup.sh

查看tomcat的启动日志出现了:

2009-10-20 11:40:47,470 INFO - Terracotta 3.1.0, as of 20090820-100801 (Revision 13440 by cruise@su10mo5 from 3.1)

2009-10-20 11:41:28,135 INFO - Configuration loaded from the server at '192.168.5.186:9510'.

2009-10-20 11:41:28,417 INFO - Log file: '/usr/local/tomcat/bin/logs-127.0.0.1/terracotta-client.log'.

2009-10-20 11:41:31,267 INFO - Connection successfully established to server at 192.168.5.186:9510

 

使用netstat -ant | grep 95查看服务器端(192.168.5.186):

tcp        0      0 ::ffff:192.168.5.186:9510   ::ffff:192.168.5.243:33352  ESTABLISHED

tcp        0      0 ::ffff:192.168.5.186:9510   ::ffff:192.168.5.237:14371  ESTABLISHED

这说明tomcatterracotta服务器端同步成功。这也说明配置的过程还是十分成功的,但是问题出现在了下面。

按照文档里面说的:处理完上述问题后,例子程序中会显示一个日历管理系统。您可以在里面配置一天的工作日程。
在第一台Tomcat服务器上配置好一天的日程,然后到第二台服务器上,打开相同的页面,您会看到前面输入的日程已经显示出来了。您还可以试着在第二台服务器上对日程进行修改,再到第一台上面刷新页面,前面的修改也会立即显示出来。这说明两台Tomcat服务器的session信息已经完全同步了。

 

可是我按照文档里面做了,单个的tomcat访问都没有问题,但是并没有出现session的同步,也就没有出现文档里面所说的效果了。不过您所说的以及finikes的测试过程我这里也是进行了仔细的学习,如果真是tomcat版本的问题的话,我这里也会在接下来进行相应的测试。这里再次感谢您的回复,也希望测试的过程对后来的人也有一定的帮助意义。祝工作顺利。

 

                                                                                                       Liuyunfengheda

                                                                                             20091020日下午330

你可能感兴趣的:(java,tomcat,server,服务器,application,include)