Installing Apache ActiveMQ in a master/slave (active/passive) environment

Overview

This article explains how to install and configure ActiveMQ in cluster mode (master/slave: active/passive).

 

Environment

For this configuration, a shared folder is required.

 

Procedure

  1. Create a shared folder called /share/esb_activemq_store.
  2. Open the file /esb/activemq/conf/activemq.xml and apply following two changes:

    1. Change the data directory from:

      <broker xmlns="http:/ /activemq.apache.org/schema/core" 
      brokerName="localhost" 
      dataDirectory="${activemq.data}">

      To:

      <broker xmlns="http:/ /activemq.apache.org/schema/core" 
      brokerName="localhost" 
      dataDirectory="/share/esb_activemq_store">
    2. Change the persistence adapter from:

      <persistenceAdapter>
      <kahaDB directory="${activemq.data}/kahadb"/>
      </persistenceAdapter>

      To:

      <persistenceAdapter>
      <kahaDB directory="/share/esb_activemq_store/kahadb"/>
      </persistenceAdapter>
  3. Save the file and restart the ActiveMQ service in both nodes. If you look at the activemq/data/activemq.log in both nodes, the first node to start will work as the master and will show normal logs. The second node to start will become the slave and show the following log:

    2017-04-20 03:19:25,056 | INFO | Database /share/esb_activemq_store/kahadb/lock is locked by another server. This broker is now in slave mode waiting for a lock to be acquired | org.apache.activemq.store.SharedFileLocker | WrapperSimpleAppMain
Version history
Revision #:
4 of 4
Last update:
‎09-27-2017 11:01 AM
Updated by:
 
Labels (2)
Tags (1)