[Logo] Terracotta Discussion Forums (LEGACY READ-ONLY ARCHIVE)
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
[Expert]
terracotta集群tomcat时,多台机器该怎么做? 好混乱啊  XML
Forum Index -> Terracotta 中文社区 Go to Page: 1, 2 Next 
Author Message
zhangb

journeyman

Joined: 02/28/2010 21:40:20
Messages: 19
Offline

我是照着老马的文章做的,我想是我太菜了,人家都写的那么详细了 我还看不懂。
这个是老马写的安装过程:
安装过程
1、在所有机器上安装Java

2、在所有机器上安装Terracotta

3、选一台机器作为Terracotta服务器

4、在所有运行Tomcat的机器上也安装Terracotta,他们将称为Terracotta客户端

5、在应用服务器节点上安装Tomcat

6、把要部署的Web应用部署在所有Tomcat上

假如我现在有2台pc(ip1和ip2),4个tomcattomcat(t1,t2,t3,t4)。
我是不是该在2台pc上都安装terracotta;
然后就混乱了,选一台机器做terracotta的服务器是怎么回事?
这样的话,2个terracotta的tc-config.xml会有什么不同?
如果我想在每台pc上安装2个tomcat,我是不是只要把tomcat解压到terracotta的session文件夹下?项目是不是部署在tomcat的webapps里面?
dongen

master

Joined: 01/19/2010 19:07:23
Messages: 78
Offline

问题1然后就混乱了,选一台机器做terracotta的服务器是怎么回事?
当使用多台terracotta服务器的时候,在开源的版本里只会有一台作为active服务端,其他都是作为备份,主要是为了failover(容灾)。选取一个terracotta服务器作为active由terracotta阵列自己来推选出。
问题2这样的话,2个terracotta的tc-config.xml会有什么不同?
在发布上线的时候,当然最好是2个terracotta配置文件一样。tc客户端都通过配置server1:9510,server2:9510的方式去获得tc-config.xml文件。
问题3如果我想在每台pc上安装2个tomcat,我是不是只要把tomcat解压到terracotta的session文件夹下?项目是不是部署在 tomcat的webapps里面?
为什么要把tomcat解压到terracotta的session文件下?不是这样的。tomcat可以安装或者是解压到任何地方,只要启动时候调用tc指定tc-config.xml文件就可以。项目当然要放在tomcat的webapps下。不然你用什么来部署你的应用。
zhangb

journeyman

Joined: 02/28/2010 21:40:20
Messages: 19
Offline

那tc-cofing.xml中,只要在server标签下多加一个server就可以了?
client不需要改变? 是这样的吗:
<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="server1">
<dso-port>9510</dso-port>
</server>
<server host="server2">
<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.1.1"/>
</modules>
</clients>

在集群的时候会开启很多个tomcat,那tomcat的端口是不是都要修改,避免冲突啊?
dongen

master

Joined: 01/19/2010 19:07:23
Messages: 78
Offline

第一个问题是对的。第二个关于tomcat端口号,在同一个机器上的多个tomcat肯定要修改tomcat的。不然怎么去访问不同的tomcat呢??
zhangb

journeyman

Joined: 02/28/2010 21:40:20
Messages: 19
Offline

dongen:
非常谢谢你耐心的指导。
zhangb

journeyman

Joined: 02/28/2010 21:40:20
Messages: 19
Offline

遇到问题了,我在tc-config.xml里面配了2个server,结果再启动服务时报错了:

F:\terracotta>bin\start-tc-server.bat
2010-03-16 10:52:07,250 INFO - Terracotta 3.2.1, as of 20100302-130324 (Revision
14673 by cruise@su10mo5 from 3.2)
2010-03-16 10:52:07,796 INFO - Configuration loaded from the file at 'F:\terraco
tta\tc-config.xml'.


Fatal Terracotta startup exception:


*******************************************************************************
You have not specified a name for your L2, and there are 2 L2s defined in the co
nfiguration file. You must indicate which L2 this is.
*******************************************************************************


Server startup failed.

顺便还想了解的是,配置webAppliction的时候,一台pc上有2个tomcat的话,直接写工程名,没关系吗?

你们的客户端中为什么填这么多啊,什么意思呢?
<modules>
<module name="tim-tomcat-6.0" version="2.1.0"/>
<module name="tim-session-common" version="2.1.0"/>
<module name="tim-tomcat-common" version="2.1.0"/>
<module name="tim-tomcat-5.5" version="2.1.0"/>
</modules>
而我的modules里面只有一个:<module name="tim-tomcat-5.5" version="2.1.0"/>
dongen

master

Joined: 01/19/2010 19:07:23
Messages: 78
Offline

配置多个server的时候最好这样
<server host="192.168.200.70" name="dongen">
host是装tc的ip,name随便你取。启动bin/start-tc-server.sh -n dongen -f path-to-tc-config.xml

顺便还想了解的是,配置webAppliction的时候,一台pc上有2个tomcat的话,直接写工程名,没关系吗?
对,直接配置工程名。因为tc只对你指定的tomcat客户端起作用。

<modules>
<module name="tim-tomcat-6.0" version="2.1.0"/>
<module name="tim-session-common" version="2.1.0"/>
<module name="tim-tomcat-common" version="2.1.0"/>
按照需求来选择你的module。因为我的项目跟你不同。我用的是tomcat6.0.20所以要使用tim-tomcat-6.0,如果你用的是tomcat5.0.28就选择tim-tomcat-5.x,像tim-session-common是我做dso方式session集群说需要的
zhangb

journeyman

Joined: 02/28/2010 21:40:20
Messages: 19
Offline

还是有错:
2010-03-16 12:06:25,593 INFO - Configuration loaded from the file at 'F:\terr
tta\tc-config.xml'.
2010-03-16 12:06:25,781 INFO - Log file: 'C:\Documents and Settings\Administr
r\tools\terracotta\85\server-logs\terracotta-server.log'.


Fatal Terracotta startup exception:


*************************************************************************
At least one server defined in the Terracotta configuration file is in
'temporary-swap-only' persistence mode. (Servers in this mode:
[zhangbei, ceshi].)

If even one server has persistence mode set to temporary-swap-only,
then High Availability mode must be set to 'networked-active-passive'

For servers in a mirror group, High Availability mode can be set per
mirror group. A mirror-group High Availability setting overrides the main
High Availability for that mirror group.

See the Terracotta documentation for more details.
*************************************************************************
dongen

master

Joined: 01/19/2010 19:07:23
Messages: 78
Offline

贴出你的配置文件。tc-config.xml
zhangb

journeyman

Joined: 02/28/2010 21:40:20
Messages: 19
Offline

这个是我的tc-config.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<tc:tc-config xsi:schemaLocation="http://www.terracotta.org/schema/terracotta-4.xsd" xmlns:tc="http://www.terracotta.org/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<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.2.13" name="zhangbei">
<dso-port>9510</dso-port>
</server>

<server host="192.168.2.19" name="ceshi">
<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.1.1"/>
<module name="tim-session-common" version="2.1.1"/>
<module name="tim-tomcat-common" version="2.1.1"/>
</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>
<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>


跟这个错误一样:http://forums.terracotta.org/forums/posts/list/2112.page

我bin\start-tc-server.bat -n zhangbei后得到的错误信息就是:
*************************************************************************
At least one server defined in the Terracotta configuration file is in
'temporary-swap-only' persistence mode. (Servers in this mode:
[zhangbei, ceshi].)

If even one server has persistence mode set to temporary-swap-only,
then High Availability mode must be set to 'networked-active-passive'

For servers in a mirror group, High Availability mode can be set per
mirror group. A mirror-group High Availability setting overrides the main
High Availability for that mirror group.

See the Terracotta documentation for more details.
*************************************************************************
不加 -n 错误信息就是:
*******************************************************************************
You have not specified a name for your L2, and there are 2 L2s defined in the co
nfiguration file. You must indicate which L2 this is.
*******************************************************************************
你说的那个 -f后面接的是什么意思 我不是很明白,我加了之后就报找不到文件的错误。
dongen

master

Joined: 01/19/2010 19:07:23
Messages: 78
Offline

-f 后面是你的tc-config.xml文件的路径。比如你的tc-config.xml放在C:\terracotta3.2.1下的话启动就是bin\start-tc-server.sh -n dongen -f c:\terracotta.3.2.1\tc-config,xml(我使用的windows系统。如果是linux把“\”装化成“/”)


另外你配置这个是干嘛?<web-applications>
<web-application>jsp-examples</web-application>
</web-applications>
这个你用不上。

DSO的时候不用配置<web-applications>,做session集群才要配置这个。

最后日志已经提醒你修改你的配置文件,添加temporary-swap-only或者是networked-active-passive读一下日志就明白了。
zhangb

journeyman

Joined: 02/28/2010 21:40:20
Messages: 19
Offline

我做的是terracotta集群tomcat,这个不是session集群吗?
他们有区别?
dongen

master

Joined: 01/19/2010 19:07:23
Messages: 78
Offline

呵呵,你做terracotta和tomcat集群也是做tomcat中某个项目的集群。所以你配置jsp-example就是要做jsp-example这个项目进行sessio集群,我给你发了个站内信
lima

consul
[Avatar]
Joined: 06/22/2009 10:12:31
Messages: 361
Offline

当有两台Terracotta服务器运行的时候,必须配置成permanent-store。下面是一个服务器配置的例子:
Code:
 <servers>
    <server host="server1.host.name" name="server1">
       <data>%(user.home)/terracotta/terracotta-3.2.1-ee/server1/server-data</data>
       <logs>%(user.home)/terracotta/terracotta-3.2.1-ee/server1/server-logs</logs>
       <statistics>%(user.home)/terracotta/terracotta-3.2.1-ee/server1/server-statistics</statistics>
       <dso-port>9510</dso-port>
       <jmx-port>9520</jmx-port>
       <dso>
         <persistence>
           <mode>permanent-store</mode>
         </persistence>
       </dso>
     </server>
    <server host="server2.host.name" name="server2">
       <data>%(user.home)/terracotta/terracotta-3.2.1-ee/server2/server-data</data>
       <logs>%(user.home)/terracotta/terracotta-3.2.1-ee/server2/server-logs</logs>
 	  <statistics>%(user.home)/terracotta/terracotta-3.2.1-ee/server2/server-statistics</statistics>
       <dso-port>9510</dso-port>
       <jmx-port>9520</jmx-port>
       <dso>
         <persistence>
           <mode>permanent-store</mode>
         </persistence>
       </dso>
     </server>
 </servers>
 


老马
zhangb

journeyman

Joined: 02/28/2010 21:40:20
Messages: 19
Offline

老马哥:
我按你的tc-config.xml文件配下去结果没有集群起来,但也没有报错,2个terracotta服务器开启之后,在terracotta控制台上看着,server1和server2在那里乱晃,要么server1变成红色,要么server2变成红色,苦闷啊。
而我按这个这个tc-config.xml:
<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.2.13" name="zhangbei">
</server>

<server host="192.168.2.19" name="ceshi">
</server>

<ha>
<mode>networked-active-passive</mode>
<mode>
</mode>
</ha>

<update-check>
<enabled>true</enabled>
</update-check>

</servers>
文件配了之后,能显示集群成功,在打开测试页面的时候报TCNonPortableObjectError,是关于boot jar的错误,我按要求修改了tc-config.xml文件后,重启tomcat时 却发现tomcat启动报错,连锁异常··
 
Forum Index -> Terracotta 中文社区 Go to Page: 1, 2 Next 
Go to:   
Powered by JForum 2.1.7 © JForum Team