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

[经验分享] Terracotta集群Tomcat实现Session同步

[复制链接]

尚未签到

发表于 2017-1-30 07:31:20 | 显示全部楼层 |阅读模式
作者:姚星火 个人主页:http://fantasyplace.googlepages.com/index.html

Setting up a Tomcat Web Cluster

在每一台机器上安装Terracotta 

生成boot jar 
  可能需要生成Boot jar。脚本文件: make-boot-jar.sh  [-o /usr/local/terracotta-2.4.0/lib/dso-boot] -f /tmp/tc-config.xml

启动Terracotta Server
  准备配置文件/tmp/tc-config.xml:

<!---->
<tc:tc-config xsi:schemalocation="&amp;lt;a goog_ds_charindex=" href="http://www.terracotta.org/schema/terracotta-4.xsd">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></servers>
    <server host="%i" name="sample"></server>
      <data></data>data/server-data
      <logs></logs>logs/server-logs
   
 
  <!---->
  <clients></clients>
    <logs></logs>logs/client-logs/%(webserver.log.name)
    <modules></modules>
      <module name="clustered-apache-struts-1.1" version="1.1.0"></module>
   
 
  <application></application>
    <dso></dso>
      <!---->
      <instrumented-classes></instrumented-classes>
        <!---->
        <include></include>
          <class-expression></class-expression>*..*
       
        <!---->
        <exclude></exclude>org.apache.coyote..*
        <exclude></exclude>org.apache.catalina..*
        <exclude></exclude>org.apache.jasper..*
        <exclude></exclude>org.apache.tomcat..*
     
      <!---->
      <web-applications></web-applications>
        <web-application></web-application>Cart
     
      <!----></tc:tc-config>

        <roots></roots>
            <root></root>
              <field-name></field-name>demo.townsend.service.ProductCatalog.catalog
              <root-name></root-name>ProductCatalog
            
        
   
 


 

WebSphere6.1中的设置:

...

<clients></clients>
    <logs></logs>logs/client-logs/%(webserver.log.name)
    <modules></modules>
      <module name="clustered-apache-struts-1.1" version="1.1.0"></module>
      <module name="clustered-websphere-6.1.0.7" version="1.0.0"></module>
   
 

...

        <exclude></exclude>com.ibm..*
        <exclude></exclude>org.eclipse..*
        <exclude></exclude>com.ddtek..*
        <exclude></exclude>tcl.lang..*
        <exclude></exclude>org.omg..*
        <exclude></exclude>sunlabs.brazil..*
        <exclude></exclude>com.sun.mail..*

...

 

WebLogic8.1 中的设置:

...

        <exclude></exclude>weblogic..*
        <exclude></exclude>com.rsa..*
...


[orion@tcserver ~]$ terracotta/bin/start-tc-server.sh -f /tmp/tc-config.xml &
[1] 13545
[orion@tcserver ~]$ 2007-06-07 18:25:57,850 INFO - Terracotta version 2.3.0,
as of 20070427-110443 (Revision 2739 by cruise@rh4mo0 from 2.3)
2007-06-07 18:25:59,875 INFO - Configuration loaded from the file at '/home/orion/tc-config.xml'.
2007-06-07 18:26:00,387 INFO - Log file: '/home/orion/logs/server-logs/terracotta-server.log'.
2007-06-07 18:26:01,962 INFO - JMX Server started. Authentication OFF -
Available at URL[service:jmx:rmi:///jndi/rmi://localhost:9520/jmxrmi]
2007-06-07 18:26:03,706 INFO - Terracotta Server has started up as
ACTIVE node on port 9510 successfully, and is now ready for work.
[orion@tcserver ~]$





 




启动Tomcat Servers

start-tomcat-dso.sh:(可能运行前要export一些环境变量)

TERRACOTTA_SERVER=10.22.23.31
TC_CONFIG_PATH="${TERRACOTTA_SERVER}:9510"


 

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

 

export JAVA_OPTS="${TC_JAVA_OPTS}"
$CATALINA_HOME/bin/startup.sh

  或者如下设置JAVA_OPTS环境变量,启动


[orion@domU-12-31-35-00-31-63 ~]$ . set-tc-env.sh
[orion@domU-12-31-35-00-31-63 ~]$ echo $JAVA_OPTS
-Xbootclasspath/p:/home/orion/terracotta/lib/dso-boot/dso-boot-hotspot_linux_150_12.jar
-Dtc.install-root=/home/orion/terracotta -Dtc.config=tcserver:9510
[orion@domU-12-31-35-00-31-63 ~]$ tomcat/bin/catalina.sh start
Using CATALINA_BASE:   /home/orion/tomcat
Using CATALINA_HOME:   /home/orion/tomcat
Using CATALINA_TMPDIR: /home/orion/tomcat/temp
Using JRE_HOME:       /home/orion/java
[orion@domU-12-31-35-00-31-63 ~]$





  在catalina.out log文件中应该要看到类似的信息,如下,说明TOMCAT启动时,Terracotta起作用;在Terracotta Server端如果打开/usr/local/terracotta-2.4.0/bin/admin.sh(AdminConsole)也会显示有App Server连上的信息:


2007-06-07 18:29:23,208 INFO - Terracotta version 2.3.0, as of 20070427-110443 (Revision 2739 by cruise
@rh4mo0 from 2.3)
2007-06-07 18:29:24,451 INFO - Configuration loaded from the server at 'tcserver:9510'.






Configure and Start the Load Balancer (实际用IBM EDGE)
  In a production environment, you should use a production quality hardware or software load balancer. For testing purposes, Terracotta comes with a simple TCP proxy that may be used like a load balancer. You should not use this TCP proxy in a production environment.
  Here's a sample script to start the TCP proxy:


TC_INSTALL_DIR=
exec "${JAVA_HOME}/bin/java" \
-Dtc.install-root="${TC_INSTALL_DIR}" -Ddaemon=true \
${JAVA_OPTS} \\
-cp "${TC_INSTALL_DIR}/lib/tc.jar" \
com.tc.net.proxy.TCPProxy <port to="" listen=""></port> <web host=""></web>:<port></port>,<web host=""></web>:<port></port>,<web host=""></web>:<port></port>





  Here's a version of the script with the terracotta installation directory and the web hosts filled in:


[orion@loadbalancer ~]$ cat bin/start-loadbalancer.sh
TC_INSTALL_DIR=/home/orion/terracotta
exec "${JAVA_HOME}/bin/java" \
-Dtc.install-root="${TC_INSTALL_DIR}" -Ddaemon=true \
${JAVA_OPTS} \
-cp "${TC_INSTALL_DIR}/lib/tc.jar" \
com.tc.net.proxy.TCPProxy 8080 web01:8080,web02:8080,web03:8080





  To run the TCP proxy, execute the script on the load balancer machine:


[orion@loadbalancer ~]$ bin/start-loadbalancer.sh  
Thu Jun 07 18:56:02 EDT 2007: Starting listener on port 8080, proxying to [web01/10.255.54.145:8080],
[web02/10.255.54.97:8080], [web03/10.255.54.146:8080] with 0ms delay






  

运维网声明 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-335093-1-1.html 上篇帖子: Tomcat启动的初始内存设置(Tomcat 的JVM 内存溢出) 下篇帖子: Tomcat下中文的彻底解决
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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