Author |
Message |
![[Post New]](../../../templates/default/images/icon_minipost_new.gif) 03/19/2010 03:25:47
|
zhangb
journeyman
Joined: 02/28/2010 21:40:20
Messages: 19
Offline
|
经过大家的帮助,集群终于成功了,但是session貌似不能共享啊:
这个是我的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">
<tc-properties>
<property name="session.cookie.domain" value=".aptx4869.com"/>
</tc-properties>
<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>
<jmx-port>9520</jmx-port>
<data>tc_data/server1/server-data</data>
<logs>tc_data/server1/server-logs</logs>
<statistics>tc_data/server1/server-statistics</statistics>
<dso>
<persistence>
<mode>permanent-store</mode>
</persistence>
</dso>
</server>
<server host="192.168.2.3" name="ceshi">
<dso-port>9510</dso-port>
<jmx-port>9520</jmx-port>
<data>tc_data/server2/server-data</data>
<logs>tc_data/server2/server-logs</logs>
<statistics>tc_data/server2/server-statistics</statistics>
<dso>
<persistence>
<mode>permanent-store</mode>
</persistence>
</dso>
</server>
<!--
<mirror-groups>
<mirror-group group-name="aptx4869">
<members>
<member>sales01</member>
<member>sales02</member>
</members>
</mirror-group>
</mirror-groups>-->
<ha>
<mode>networked-active-passive</mode>
<networked-active-passive>
<election-time>5</election-time>
</networked-active-passive>
</ha>
</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>
<!-- 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-application>jsp-examples3</web-application>
</web-applications>
</dso>
</application>
</tc:tc-config>
启动terracotta的时候也很清楚的看到了集群成功的字样,这个是日志:
F:\terracotta>bin\start-tc-server.bat -n zhangbei
2010-03-19 17:07:18,562 INFO - Terracotta 3.2.1, as of 20100302-130324 (Revision
14673 by cruise@su10mo5 from 3.2)
2010-03-19 17:07:19,125 INFO - Configuration loaded from the file at 'F:\terraco
tta\tc-config.xml'.
2010-03-19 17:07:19,390 INFO - Log file: 'F:\terracotta\tc_data\server1\server-l
ogs\terracotta-server.log'.
2010-03-19 17:07:19,765 INFO - Available Max Runtime Memory: 504MB
2010-03-19 17:07:20,171 INFO - JMX Server started. Available at URL[service:jmx:
jmxmp://0.0.0.0:9520]
2010-03-19 17:07:26,093 INFO - Becoming State[ ACTIVE-COORDINATOR ]
2010-03-19 17:07:26,140 INFO - Terracotta Server instance has started up as ACTI
VE node on 0.0.0.0:9510 successfully, and is now ready for work.
2010-03-19 17:07:37,421 INFO - NodeID[192.168.2.3:9510] joined the cluster
然后我就用tomcat里面的例子来测试(jsp-examples和jsp-examples3,其实都是一样的文件)。
打开http://192.168.2.13:8080/jsp-examples/cal/login.html,登陆后就开始修改日志,我在同一台机器上修改后,可以看到效果,但用另一台登陆后,就看不到修改后的效果了···
这个是怎么回事?
是我的tc-config.xml没配好?
有的时候登陆后,修改时,页面还有这个错误:You must enter your name and email address correctly.
这个是怎么回事?
还有就是TC的控制台,虽然觉得非常美观,但我不怎么会看,有这方面的资料提供吗?
|
|
 |
![[Post New]](../../../templates/default/images/icon_minipost_new.gif) 03/19/2010 05:08:20
|
lima
consul
Joined: 06/22/2009 10:12:31
Messages: 361
Offline
|
你说用另一台机器登录,是指登录另一台Tomcat还是用另一台机器做客户端?你用另一台机器作客户端,它产生的session根本地产生的session已经不一样了,所以不能共享session。
测试方法应该是从同一台机器上,相同的浏览器打开两个窗口,分别登录两台不同的tomcat,他们的session应该是可以共享的。
另外通过dev-console去看看Object Browser里面有几个session对象被创建了。需要展开session相关的数据结构去看。
有关dev-console的文档在这里:
http://terracotta.org/confluence/display/docs/Terracotta%20Developer%20Console
老马
|
|
 |
![[Post New]](../../../templates/default/images/icon_minipost_new.gif) 03/22/2010 20:00:16
|
chad
journeyman
Joined: 01/25/2010 17:43:32
Messages: 13
Offline
|
1、将解压后的terracotta-3.2.1/session/conf-samples下的context.xml
文件分别覆盖到两台tomcat/conf/下替换掉默认的
vim context.xml
将localhost改为192.168.0.203(tcserver的ip)保存退出
2、将terracotta-3.2.1/session/terracotta-session-1.0.0.jar加入jar包到tomcat的lib目录下
tc启动正常
2010-03-24 02:16:18,059 INFO - Terracotta Server instance has started up as ACTIVE node on 0:0:0:0:0:0:0:0:9510 successfully, and is now ready for work
tomcat启动信息
INFO: Starting Servlet Engine: Apache Tomcat/6.0.26
2010-03-24 10:16:25,069 INFO - Terracotta 3.2.1, as of 20100302-120333 (Revision 14673 by cruise@su10mo5 from 3.2)
2010-03-24 10:16:25,978 INFO - Configuration loaded from the server at '192.168.0.203:9510'.
2010-03-24 10:16:26,160 INFO - Configuration loaded from the file at '/usr/tomcat1/temp/tc-config59007.xml'.
WARN: The log directory, '/root/terracotta/client-logs', is already in use by another Terracotta process. Logging will proceed to the console only.
2010-03-24 10:16:28,442 WARN - Can't connect to server[127.0.0.1:9510:127.0.0.1:9510]. Retrying...
到这里就停住了不动了...
首先我想问一下各位大哥,这里can;t connect to server 127.0.0.1:9510这里的127.0.0.1是在哪里修改,是tomcat端还是tc端?
上面有一行Configuration loaded from the server at '192.168.0.203:9510'.
也已经连接到tc了可为什么下面有有一行can't connect to server 127.0.0.1:9510?
再有 我没有配置tc的配置文件,因为这种配置方法是朋友告诉我的,他说不用配置其他的,但是启动之后从到这里卡住了。
并且我在控制台看到也只有127.0.0.1本机的信息 根本看不到客户端的连接!
谢谢各位!
|
|
 |
![[Post New]](../../../templates/default/images/icon_minipost_new.gif) 03/22/2010 20:44:43
|
lima
consul
Joined: 06/22/2009 10:12:31
Messages: 361
Offline
|
contex.xml应该拷贝到web应用的META-INF目录下。
另外请删除 tomcat/config/Catalina下的所有文件。
还有就是你的tomcat启动脚本中是否还有dso相关的配置?如果有,也需要去掉。
老马
|
|
 |
![[Post New]](../../../templates/default/images/icon_minipost_new.gif) 03/22/2010 20:58:10
|
chad
journeyman
Joined: 01/25/2010 17:43:32
Messages: 13
Offline
|
你好lima
你说的问题我该修改的已经该了
现在tomcat启动还是
INFO: Starting Servlet Engine: Apache Tomcat/6.0.26
2010-03-24 11:00:07,597 INFO - Terracotta 3.2.1, as of 20100302-120333 (Revision 14673 by cruise@su10mo5 from 3.2)
2010-03-24 11:00:08,557 INFO - Configuration loaded from the server at '192.168.0.203:9510'.
2010-03-24 11:00:08,717 INFO - Configuration loaded from the file at '/usr/tomcat1/temp/tc-config46725.xml'.
2010-03-24 11:00:08,876 INFO - Log file: '/root/terracotta/client-logs/terracotta-client.log'.
2010-03-24 11:00:10,731 WARN - Can't connect to server[127.0.0.1:9510:127.0.0.1:9510]. Retrying...
到这里就卡住了
这是为什么呢?并且控制台也根本看不到客户端的信息!
|
|
 |
![[Post New]](../../../templates/default/images/icon_minipost_new.gif) 03/22/2010 21:00:22
|
lima
consul
Joined: 06/22/2009 10:12:31
Messages: 361
Offline
|
在tomcat根目录上搜索一下:
Code:
find . -exec grep -H 127.0.0.1:9510 {} \;
看看能找到什么。
老马
|
|
 |
![[Post New]](../../../templates/default/images/icon_minipost_new.gif) 03/22/2010 21:03:05
|
chad
journeyman
Joined: 01/25/2010 17:43:32
Messages: 13
Offline
|
./temp/tc-config53710.xml: <server host="127.0.0.1" name="127.0.0.1:9510" bind="0.0.0.0">
./temp/tc-config53710.xml: <member>127.0.0.1:9510</member>
./temp/tc-config43739.xml: <server host="127.0.0.1" name="127.0.0.1:9510" bind="0.0.0.0">
./temp/tc-config43739.xml: <member>127.0.0.1:9510</member>
./temp/tc-config57520.xml: <server host="127.0.0.1" name="127.0.0.1:9510" bind="0.0.0.0">
./temp/tc-config57520.xml: <member>127.0.0.1:9510</member>
./temp/tc-config37402.xml: <server host="127.0.0.1" name="127.0.0.1:9510" bind="0.0.0.0">
./temp/tc-config37402.xml: <member>127.0.0.1:9510</member>
./temp/tc-config19527.xml: <server host="127.0.0.1" name="127.0.0.1:9510" bind="0.0.0.0">
./temp/tc-config19527.xml: <member>127.0.0.1:9510</member>
./temp/tc-config14348.xml: <server host="127.0.0.1" name="127.0.0.1:9510" bind="0.0.0.0">
./temp/tc-config14348.xml: <member>127.0.0.1:9510</member>
./temp/tc-config55714.xml: <member>127.0.0.1:9510</member>
./temp/tc-config41495.xml: <server host="127.0.0.1" name="127.0.0.1:9510" bind="0.0.0.0">
./temp/tc-config41495.xml: <member>127.0.0.1:9510</member>
./temp/tc-config55714.xml.bak: <server host="127.0.0.1" name="127.0.0.1:9510" bind="0.0.0.0">
./temp/tc-config55714.xml.bak: <member>127.0.0.1:9510</member>
./temp/tc-config59007.xml: <server host="127.0.0.1" name="127.0.0.1:9510" bind="0.0.0.0">
./temp/tc-config59007.xml: <member>127.0.0.1:9510</member>
./temp/tc-config46725.xml: <server host="127.0.0.1" name="127.0.0.1:9510" bind="0.0.0.0">
./temp/tc-config46725.xml: <member>127.0.0.1:9510</member>
./temp/tc-config51848.xml: <server host="127.0.0.1" name="127.0.0.1:9510" bind="0.0.0.0">
./temp/tc-config51848.xml: <member>127.0.0.1:9510</member>
./logs/catalina.out:2010-03-24 11:00:10,731 WARN - Can't connect to server[127.0.0.1:9510:127.0.0.1:9510]. Retrying...
产生的临时文件都是127.0.0.1:9510,我的context.xml
<Valve className="org.terracotta.session.TerracottaTomcat60xSessionValve" tcConfigUrl="192.168.0.203:9510"/>
里面已经定义服务器端IP了
|
|
 |
![[Post New]](../../../templates/default/images/icon_minipost_new.gif) 03/22/2010 21:08:07
|
lima
consul
Joined: 06/22/2009 10:12:31
Messages: 361
Offline
|
好像是服务器上tc-config.xml里面还在用127.0.0.1。把它改成真正的服务器地址。从新启动服务器试试。
老马
|
|
 |
![[Post New]](../../../templates/default/images/icon_minipost_new.gif) 03/22/2010 21:53:20
|
chad
journeyman
Joined: 01/25/2010 17:43:32
Messages: 13
Offline
|
没有..我的服务器端的tc-config.xml里就是192.168.0.203
|
|
 |
![[Post New]](../../../templates/default/images/icon_minipost_new.gif) 03/23/2010 04:16:12
|
lima
consul
Joined: 06/22/2009 10:12:31
Messages: 361
Offline
|
启动服务器的时候,用 -f <folder>/tc-config.xml指定一下tc-config.xml文件的目录。
你最后提交的log显示tc-config.xml保存在了:
/usr/tomcat1/temp/tc-config46725.xml
Code:
2010-03-24 11:00:08,717 INFO - Configuration loaded from the file at '/usr/tomcat1/temp/tc-config46725.xml'.
可是那里面显示的服务器ip是127.0.0.1.
Code:
./temp/tc-config46725.xml: <server host="127.0.0.1" name="127.0.0.1:9510" bind="0.0.0.0">
./temp/tc-config46725.xml: <member>127.0.0.1:9510</member>
老马
|
|
 |
![[Post New]](../../../templates/default/images/icon_minipost_new.gif) 03/23/2010 23:23:59
|
chad
journeyman
Joined: 01/25/2010 17:43:32
Messages: 13
Offline
|
谢谢lima
问题解决了!
|
|
 |
![[Post New]](../../../templates/default/images/icon_minipost_new.gif) 08/02/2013 02:50:21
|
itliuliu
neo
Joined: 07/22/2013 23:23:19
Messages: 2
Offline
|
正常的应该是多台客户端都可以访问session的,但为啥我始终是session其他机子访问不到
|
|
 |
|