首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

Terracotta and Tomcat Clustering - Page 一

2013-11-30 
Terracotta and Tomcat Clustering - Page 1原网址:http://javadrama.blogspot.com/2012/10/terracotta-an

Terracotta and Tomcat Clustering - Page 1
原网址:http://javadrama.blogspot.com/2012/10/terracotta-and-tomcat-clustering-page-1.htmlIn this tutorial we will learn a lot of stuff :)

  1. How to install Terracotta in an Active/Passive HA (High Availability) model.
  2. How to configure Tomcat 6.0 to store/retrieve sessions on Terracotta.
  3. 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:
  1. Clients' sessions data are part of the Tomcat JVM instance.
  2. There is extra work for Tomcat to make sure that the sessions and its data are replicated among the cluster
  3. not suitable for larger cluster because of using?multicasting, imagine the network traffic generated by eight tomcat nodes replicating their sessions.
  4. You can't store an object which is not serializable.
So, moving this responsibility to Terracotta would help?eliminating those four concerns.

Our Final?architecture?Terracotta and Tomcat Clustering - Page 一??it is really simple:?
  1. Both Tomcats store/retrieve sessions on the active Terracotta server.
  2. Apache web server forwards requests to both Tomcats.
  3. If the active Terracotta fails the passive Terracotta will be the active.

Let's Digg inFirst things first! we need:
  1. terracotta-3.7.0-installer.jar
  2. apache-tomcat-6.0.35
  3. mod_jk.so
  4. httpd-2.2.22
  5. JDK 1.6
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 Terracottaopen a terminal and change the directory to the place where you downloaded terracotta-3.7.0-installer.jar
the important thing to note here is the servers node?
  1. for each Terracotta server that will run in the cluster you need to define a server node.
  2. 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
  • data: is where this server stores its data (make it unique for each server if you are running the cluster on one box)
  • logs: is where the server store its logs?(make it unique for each server if you are running the cluster on one box)
  • statistics:??is where the server store its statistics?(make it unique for each server if you are running the cluster on one box)
  • port configurations: JMX, DSO and group ports?(make it unique for each server if you are running the cluster on one box)
  • data-backup:?is where the server store its data backups??(make it unique for each server if you are running the cluster on one box)
  • index: is?where the server store its index files??(make it unique for each server if you are running the cluster on one box)
  • dso: is the Distributed Shared Objects specific options.

    we have now defined two servers, we need to?define how they would work.

    1. mirror-group: a tag to define Terracotta groups?
    • members: a tag to add a server to a group using its name
    • ha: is a tag to define the High?Availability options of the group
      • 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.let's start out cluster an make sure everything is OK.
        ?
        1. open three consoles and navigate to ${TC_HOME}\bin on the three of them
        2. Start node1
          Terracotta and Tomcat Clustering - Page 一?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. 

热点排行