1

how to configure gemfire in a ha mode in cache.xml

<?xml version="1.0" encoding="UTF-8"?><cache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://geode.apache.org/schema/cache" xsi:schemaLocation="http://geode.apache.org/schema/cache http://geode.apache.org/schema/cache/cache-1.0.xsd" version="1.0" lock-lease="120" lock-timeout="60" search-timeout="300" is-server="false" copy-on-read="false"/>
<!-- Run one secondary server -->
<cache>
   <pool name="red1" subscription-enabled="true" subscription-redundancy="1">
   <locator host="node5" port="41111"/>
   <locator host="node6" port="41111"/>
   </pool>
</cache>
tom.jack
  • 43
  • 4

1 Answers1

2

To get HA, you need to have multiple GemFire/Geode locators and servers running.

gfsh>start locator --name=loc1 --port=10334
gfsh>start locator --name=loc2 --port=10335
gfsh>start server --name=serv1 --server-port=40404
gfsh>start server --name=serv2 --server-port=40405
gfsh>start server --name=serv3 --server-port=40406

You then need to make sure that your region has redundant copies. For a Partition Region this can be defined as follows:

gfsh>create region --name=myPR --type=PARTITION_REDUNDANT

This will gurantee that you will be able to tolerate loss of one Geode Server. You can configure upto 3 redundant copies for a Partition Region, make sure that these redundant copies are on different racks etc. please see docs for how to accomplish this. A Replicated region has same data on all servers, so it is always highly available.

Once, you have the server side configured, you need to point your client connection pool to the locator. The client pool will establish connection to available servers, in case of server failures, the pool will automatically try to re-execute the operation on another server. To configure a pool, simply point to the locators, and then use the pool in region definition.

<client-cache>
  <pool name="publisher" subscription-enabled="true">
    <locator host="lucy" port="41111"/> 
    <locator host="lucy" port="41111"/> 
  </pool>
...
<region name="clientRegion" ...
  <region-attributes pool-name="publisher" ...

Please refer to the docs for more details.

Swapnil
  • 1,191
  • 7
  • 8
  • thanks, and how to make gemfire cluster failover ? – tom.jack Jan 15 '17 at 10:25
  • just like master-standby ,if master is stopped, then standby is activitied up – tom.jack Jan 15 '17 at 12:45
  • For the entire cluster to failover, you need to start with two clusters, start gateway senders in one cluster and receivers in another cluster, configure your regions to use the gateway senders. [docs](http://gemfire.docs.pivotal.io/geode/topologies_and_comm/multi_site_configuration/setting_up_a_multisite_system.html) cover these steps in detail. One more thing worth mentioning is that you can configure both clusters to send updates to one another i.e active-active mode, rather than master slave only. – Swapnil Jan 18 '17 at 15:22