In this tutorial we will learn a lot of stuff :)
- How to install Terracotta in an Active/Passive HA (High Availability) model.
- How to configure Tomcat 6.0 to store/retrieve sessions on Terracotta.
- How to install and configure Apache Web Server configure it to relay requests to Tomcat.
Why?
i can do session replication using Tomcat built-in clustering module, so why do i use Terracotta?
well, the Tomcat clustering works just perfect with major four concerns:
- Clients' sessions data are part of the Tomcat JVM instance.
- There is extra work for Tomcat to make sure that the sessions and its data are replicated among the cluster
- not suitable for larger cluster because of using multicasting, imagine the network traffic generated by eight tomcat nodes replicating their sessions.
- You can't store an object which is not serializable.
Our Final architecture
it is really simple:
- Both Tomcats store/retrieve sessions on the active Terracotta server.
- Apache web server forwards requests to both Tomcats.
- If the active Terracotta fails the passive Terracotta will be the active.
Let's Digg in
First things first! we need:
My five servers built on a single windows 7 box as a POC, you should have no troubles with running the same example on Linux, only minor chages are needed.Install and Configure Terracotta
open a terminal and change the directory to the place where you downloaded terracotta-3.7.0-installer.jar
java -jar terracotta-3.7.0-installer.jar
now, go to ${TC_HOME} and create a new directory called 'config', this directory will contain our Terracotta configuration file that will set up the Terracotta cluster.
create a new file inside the config directory called tc-config.xml with the following content:
<tc-config xmlns="/config"> <servers secure="false" xmlns:tc="/config" xmlns:con="/config" xmlns=""> <server bind="0.0.0.0" host="127.0.0.1" name="node1"> <data>C:\terracotta\server-data</data> <logs>C:\terracotta\server-logs</logs> <statistics>C:\terracotta\server-statistics</statistics> <dso-port bind="0.0.0.0">9510</dso-port> <jmx-port bind="0.0.0.0">9520</jmx-port> <l2-group-port bind="0.0.0.0">9530</l2-group-port> <data-backup>C:\terracotta\data-backup</data-backup> <index>C:\terracotta\server-data\index</index> <dso> <client-reconnect-window>120</client-reconnect-window> <persistence> <mode>temporary-swap-only</mode> </persistence> <garbage-collection> <enabled>true</enabled> <verbose>false</verbose> <interval>3600</interval> </garbage-collection> </dso> </server> <server bind="0.0.0.0" host="127.0.0.1" name="node2"> <data>C:\terracotta\server-data2</data> <logs>C:\terracotta\server-logs2</logs> <statistics>C:\terracotta\server-statistics2</statistics> <dso-port bind="0.0.0.0">9511</dso-port> <jmx-port bind="0.0.0.0">9521</jmx-port> <l2-group-port bind="0.0.0.0">9531</l2-group-port> <data-backup>C:\terracotta\data-backup2</data-backup> <index>C:\terracotta\server-data\index2</index> <dso> <client-reconnect-window>120</client-reconnect-window> <persistence> <mode>temporary-swap-only</mode> </persistence> <garbage-collection> <enabled>true</enabled> <verbose>false</verbose> <interval>3600</interval> </garbage-collection> </dso> </server> <mirror-groups> <mirror-group> <members> <member>node1</member> <member>node2</member> </members> </mirror-group> </mirror-groups> <ha> <mode>networked-active-passive</mode> <networked-active-passive> <election-time>5</election-time> </networked-active-passive> </ha> <update-check> <enabled>true</enabled> <period-days>7</period-days> </update-check> </servers> <system xmlns:tc="/config" xmlns:con="/config" xmlns=""> <configuration-model>production</configuration-model> </system> <clients xmlns:tc="/config" xmlns:con="/config" xmlns=""> <logs>%(user.home)/terracotta/client-logs</logs> <modules> <module name="terracotta-toolkit-1.6" group-id="org.terracotta.toolkit"/> </modules> </clients> </tc-config>
the important thing to note here is the servers node
- for each Terracotta server that will run in the cluster you need to define a server node.
- the server tag has three attributes:
- bind: the default bind address which Terracotta listen to.
- host: the IP address that will be used to connect to the Terracotta server.
- name: the name of this node
we have now defined two servers, we need to define how they would work.
- mirror-group: a tag to define Terracotta groups
- members: a tag to add a server to a group using its name
- mode: networked-active-passive it means that the communications between the servers will relay on networking.
- election-time: the Terracotta server would wait for that time to decide if it should start as an Active or passive.
- open three consoles and navigate to ${TC_HOME}\bin on the three of them
- Start node1
start-tc-server.bat -f ..\config\tc-config.xml -n node1
you should seeBecoming State[ ACTIVE-COORDINATOR ] Terracotta Server instance has started up as ACTIVE node on 0.0.0.0:9510 successfully, and is now ready for work.
- Start node2
start-tc-server.bat -f ..\config\tc-config.xml -n node2
you should seeNodeID[127.0.0.1:9510] joined the cluster Moved to State[ PASSIVE-UNINITIALIZED ] Moved to State[ PASSIVE-STANDBY ]
- on the third console start the Terracotta Development Console
dev-console.bat
connect to either 127.0.0.1:9520 or 127.0.0.1:9521, you should see this screen
as per the screen shot, node1 is active and node2 is passive, play around by taking node1 down and see if node2 becomes the active and then Vice Versa.
相关推荐
terracotta-toolkit-1.3-runtime-3.2.0.jar 集群实现JAR
Terracotta集群Tomcat的配置是一项复杂而关键的任务,它涉及到分布式系统中的高可用性和负载均衡。以下将详细解释这个过程中的各个步骤和相关知识点。 首先,安装Terracotta 3.2.1版本是非常基础的一步。需要注意的...
1. **分布式内存管理**:Terracotta使Java应用能够透明地跨多台服务器共享内存,提供近乎实时的数据访问速度,消除了传统数据库的I/O瓶颈。 2. **无锁数据一致性**:通过其独特的无锁数据一致性模型,Terracotta确保...
【 Terracotta + Tomcat 集群配置详解】 在分布式计算环境中,集群技术是提升系统可用性和性能的重要手段。本文将深入探讨 Terracotta 与 Tomcat 集群的配置,以及如何利用 Terracotta 实现高效、可靠的 session ...
terracotta-3.7.7-installer.jar
### 通过Terracotta实现基于Tomcat的Web应用集群 #### 概述 本文主要介绍了如何利用Terracotta与Tomcat构建高效的Web应用集群。在实际应用中,通过集群技术可以显著提升系统的可用性和伸缩性,特别是对于高流量、...
terracotta-eclipse-plugin-3.7.7-2013-08-19_16-03-48.tar(terracotta的Eclipse插件) 发现官网挺卡的,有时候下不了,先传上来吧,供国内用户下载,这个算最新的吧。2014-02-17下载的。
terracotta-3.7.7-2013-08-19_16-03-48-installer(jar安装包) 官方网站卡得要死,有时候不一定能下载,把最近自己用的,算最新版吧,提供在国内网站下载吧。 2014-02-17下载的。
terracotta-ee-3.5.2破解版
1. Ehcache简介 Ehcache是基于内存的缓存解决方案,它提供了本地缓存、持久化存储和二级缓存等功能。通过将频繁访问的数据保存在内存中,Ehcache可以显著降低数据库的负载,提高应用程序响应速度。 2. Terracotta...
记载了terracotta如何与tomcat、jetty等服务器的集群,解释了tc-config.xml中各个配置的作用
Apache 2.2、mod_JK、Tomcat 7 和 Terracotta 3.7 是构建高可用性和可伸缩性Web应用集群的关键组件。这个集群解决方案旨在通过将负载分散到多个服务器上,提高应用程序的性能和稳定性。下面将详细阐述这些组件以及...
### Terracotta:分布式内存管理解决方案 #### 一、Terracotta概述 Terracotta是一种分布式内存管理和数据共享平台,其核心产品BigMemory Max旨在帮助应用程序实现数据在内存中的高效管理,尤其适用于分布式服务器...
jar包,官方版本,自测可用
【标题】"Terracotta - Web CMS-开源" 指的是一个名为Terracotta的开源Web内容管理系统。这个系统采用PHP编程语言开发,具备高度灵活性和可扩展性,允许用户管理和发布网站内容。"开源"意味着源代码对公众开放,用户...
资源分类:Python库 所属语言:Python 资源全名:terracotta-toolbelt-0.0.5.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
做ehcache分布式缓存用的! ehcache-2.6.6.jar和terracotta-toolkit-1.6-runtime-5.5.0.jar 主要是给自己写的博客中做一个下载资源链接!
- **Session 同步优化**:Terracotta 的 session 同步机制是对传统 Tomcat 集群机制的一种优化。传统的 session 复制机制会在 session 发生任何变化时将整个 session 数据进行序列化并广播到所有节点,这可能导致...