Saturday, November 13, 2010

EhCache Servers Clustering

1) Repeat the 3.4 installation steps on each participating server in the cluster.
2) Create a file /opt/terracotta-3.4/config/tc-config.xml.

Here is the production recommended version of tc-config.xml.
Following is a sample for two node cluster.

<?xml version="1.0" encoding="UTF-8" ?>
<tc:tc-config xmlns:tc="
http://www.terracotta.org/config"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.terracotta.org/schema/terracotta-6.xsd">
<tc-properties>
 <property name="l2.nha.dirtydb.autoDelete" value="true"/>
 <property name="l1.cachemanager.enabled" value="true"/>
 <property name="logging.maxLogFileSize" value="1024"/>
 <property name="l2.l1reconnect.enabled" value="true" />
    <property name="l2.l1reconnect.timeout.millis" value="5000"/>
 <property name="l2.healthcheck.l2.ping.idletime" value="5000" />
 <property name="l2.healthCheck.l2.ping.interval" value="1000" />
 <property name="l2.healthCheck.l2.ping.probes" value="3" />
 <property name="l2.healthCheck.l2.socketConnect" value="true" />
 <property name="l2.healthCheck.l2.socketConnectCount" value="5" />
 <property name="l1.healthCheck.l2.ping.idletime" value="5000" />
 <property name="l1.healthCheck.l2.ping.interval" value="1000" />
 <property name="l1.healthCheck.l2.ping.probes" value="3" />
 <property name="l1.healthCheck.l2.socketConnect" value="true" />
 <property name="l1.healthCheck.l2.socketConnectCount" value="8" />
 <property name="l2.healthCheck.l1.ping.idletime" value="5000" />
 <property name="l2.healthCheck.l1.ping.interval" value="1000" />
 <property name="l2.healthCheck.l1.ping.probes" value="3" />
 <property name="l2.healthCheck.l1.socketConnect" value="true" />
 <property name="l2.healthCheck.l1.socketConnectCount" value="5" />
</tc-properties>
<servers>
 <server host="myhost1" name="primary" bind="172.x.x.1">
  <data>/opt/terracotta-3.4/server-data</data>
  <logs>/opt/terracotta-3.4/server-logs</logs>
  <statistics>/opt/terracotta-3.4/server-statistics</statistics>
  <dso-port bind="172.x.x.1">9540</dso-port>
  <jmx-port bind="172.x.x.1">9550</jmx-port>
  <l2-group-port bind="172.x.x.1">9560</l2-group-port>
  <authentication>
   <mode>
     <password-file>/home/cacheadm/terracotta-access/jmxremote.password</password-file>
   </mode>
   <access-file>/home/cacheadm/terracotta-access/jmxremote.access</access-file>
  </authentication>
  <dso>
   <client-reconnect-window>120</client-reconnect-window>
   <persistence>
    <mode>permanent-store</mode>
    <offheap>
     <enabled>false</enabled>
     <maxDataSize>5g</maxDataSize>
    </offheap>
   </persistence>
   <garbage-collection>
    <enabled>true</enabled>
    <verbose>true</verbose>
    <interval>3600</interval>
   </garbage-collection>
  </dso>
 </server>
 <server host="myhost2" name="secondary" bind="172.x.x.2">
  <data>/opt/terracotta-3.4/server-data</data>
  <logs>/opt/terracotta-3.4/server-logs</logs>
  <statistics>/opt/terracotta-3.4/server-statistics</statistics>
  <dso-port bind="172.x.x.2">9540</dso-port>
  <jmx-port bind="172.x.x.2">9550</jmx-port>
  <l2-group-port bind="172.x.x.2">9560</l2-group-port>
  <authentication>
   <mode>
     <password-file>/home/cacheadm/terracotta-access/jmxremote.password</password-file>
   </mode>
   <access-file>/home/cacheadm/terracotta-access/jmxremote.access</access-file>
  </authentication>
  <dso>
   <client-reconnect-window>120</client-reconnect-window>
   <persistence>
    <mode>permanent-store</mode>
    <offheap>
     <enabled>false</enabled>
     <maxDataSize>5g</maxDataSize>
    </offheap>
   </persistence>
   <garbage-collection>
    <enabled>true</enabled>
    <verbose>true</verbose>
    <interval>3600</interval>
   </garbage-collection>
  </dso>
 </server>
 <mirror-groups>
  <mirror-group group-name="group1">
   <members>
    <member>primary</member>
    <member>secondary</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>false</enabled>
  <period-days>10</period-days>
 </update-check>
</servers>
<clients>
 <logs>/opt/terracottalogs</logs>
</clients>
</tc:tc-config>

Note:
Authentication is enabled. You can disable it if you don't need them

Default ports are modified. It is a good security practice to modify default vendor supplied ports for production environments.

The above config is just a sample. You should tune the environment based on your specific needs

3) Copy tc_config.xml to each participatinng server in a cluster.
4) Start server with option -f  tc_config.xml (Refer to scripts posting)

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home

Newer›  ‹Older