设为首页 收藏本站
查看: 411|回复: 0

[经验分享] Terracotta and Tomcat Clustering

[复制链接]

尚未签到

发表于 2017-1-26 08:43:41 | 显示全部楼层 |阅读模式
  原网址:http://javadrama.blogspot.com/2012/10/terracotta-and-tomcat-clustering-page-2.html
  Now, download apache-tomcat-6.0.35 and extract it twice to two directories of your choice, i will refer to them as ${CATALINA_HOME_NODE1} and ${CATALINA_HOME_NODE2}.



Copy Terracotta Libraries

we need two jar files to be copied to both Tomcats lib directory.

${TC_HOME}\common\terracotta-toolkit-1.6-runtime-5.0.0.jar

${TC_HOME}\sessions\terracotta-session-1.3.0.jar

 

Copy Terracotta Config File

we need to copy the same Terracotta configuration file to the conf directory of bothTomcats

${TC_HOME}\config\tc-config.xml




one small change to do, the client log location, both clients (Tomcat servers) can't be configured with the same client log location.




edit ${CATALINA_HOME_NODE2}\conf\tc-config.xml

change log location under the clients tag 
<logs>%(user.home)/terracotta/client-logs</logs>



to be 
<logs>%(user.home)/terracotta/client-logs2</logs>



Terracotta Valve



Tomcat connects to Terracotta by intercepting requests via a value, now let's hook that valve.

under the conf directory of both Tomcats, edit the file context.xml to look like this: 
<Context>
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<Manager pathname="" />
<!-- Hook the Terracotta Valve and configure it using the tc-config.xml file -->
<Valve className="org.terracotta.session.TerracottaTomcat60xSessionValve" tcConfigUrl="../conf/tc-config.xml"/>
</Context>




note that we have disabled session persistence across Tomcat restarts because that is a task for Terracotta now.

Tomcat HA Configurations



 

 

jvmRoute

 

we need to define a unique jvmRoute for each Tomcat server.




edit ${CATALINA_HOME_NODE1}\conf\server.xml, change the Engine tag to look like this: 
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat1">



 

edit ${CATALINA_HOME_NODE2}\conf\server.xml, change the Engine tag to look like this: 
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat2">


Make sure you don't have port conflicts

as i am running both Tomcats on the same box, i had to change the ports for the second Tomcat.
in ${CATALINA_HOME_NODE2}\conf\server.xml, i have changed
shutdown port: 8005 to 8006
http port: 8080 to 8081
ajp port: 8009 to 8010

Run both Tomcats



open two more terminals and navigate to ${CATALINA_HOME_NODE1}\bin on one and ${CATALINA_HOME_NODE2}\bin on the other, on both terminals execute: 
startup.bat




if everything went as it should, you should see something like that on both Tomcat terminals 
Terracotta 3.7.0, as of 20120717-133013 (Revision unknown-20453 by cruise@rh5vmo113.terracotta.lan from 3.7.0)
Successfully loaded base configuration from file at 'H:\terracotta\apache-tomcat-6.0.35\bin\.\..\conf\tc-config.xml'.
Successfully loaded base configuration from file at 'H:\terracotta\apache-tomcat-6.0.35\temp\tc-config8509448930662041153.xml'.
Log file: 'C:\terracotta\client-logs\terracotta-client.log'.
Connection successfully established to server at 127.0.0.1:9510


Test it

Tomcat comes by default with a web application called examples, we will use it till the end of this tutorial to test our setup

point your browser to http://localhost:8080/examples/ and http://localhost:8081/examples/ and make sure both servers are responding.

open your Terracotta Development Console and make sure that both clients (the tomcat server) are present as below.

http://five.rdaili.com/sohu.com.php?u=2hpDLnla4MzrNVZwR47dqRDhGv36V5faha1RhECmgMDBe0zfjq1X4kAPlCcOabRbRzsKY852vv%2B5EL7ZUKHnjRBltsoaurGvi2YHAObjQvgWmg%3D%3D&b=3

 

also note that the sessions button is now active.

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-333503-1-1.html 上篇帖子: Tomcat优化之简单集合经验 下篇帖子: (转载)Tomcat性能调优方案
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表