Launch the second EC2 instance as a Slave
Procedure
-
Go into the directory
/opt/talend/activemq/current/bin/.
cd /opt/talend/activemq/current/bin/
-
Stop the ActiveMQ broker since it has been configured to start with the EC2
instance.
./activemq stop
-
Enter the /opt directory.
cd /opt
-
To mount the shared file system using the same mount command, you have two
options:
- Option 1: If you have copied the Amazon EC2 Mount instructions in your favorite editor.
- Option 2: If you did not copy/paste the Amazon EC2 Mount instructions.
-
Restart the ActiveMQ broker.
cd /opt/talend/activemq/current/bin/ ./activemq start
-
Open the file ActiveMQ log file at
/opt/talend/activemq/current/data/activemq.log using
cat or tail command.
You should see the following lines at the end of the file:
ec2-user@ip-10-0-0-28 bin]$ tailf /opt/talend/activemq/current/data/activemq.log 2017-03-15 21:25:45,713 | WARN | Temporary Store limit is 51200 mb (current store usage is 0 mb). The data directory: /opt/talend/activemq/apache-activemq-5.14.0/data only has 6664 mb of usable space. - resetting to maximum available disk space: 6664 mb | org.apache.activemq.broker.BrokerService | main 2017-03-15 21:25:46,372 | INFO | No Spring WebApplicationInitializer types detected on classpath | /admin | main 2017-03-15 21:25:46,507 | INFO | ActiveMQ WebConsole available at http://0.0.0.0:8161/ | org.apache.activemq.web.WebConsoleStarter | main 2017-03-15 21:25:46,507 | INFO | ActiveMQ Jolokia REST API available at http://0.0.0.0:8161/api/jolokia/ | org.apache.activemq.web.WebConsoleStarter | main 2017-03-15 21:25:46,547 | INFO | Initializing Spring FrameworkServlet 'dispatcher' | /admin | main 2017-03-15 21:25:46,848 | INFO | No Spring WebApplicationInitializer types detected on classpath | /api | main 2017-03-15 21:25:46,882 | INFO | jolokia-agent: Using policy access restrictor classpath:/jolokia-access.xml | /api | main 2017-03-15 21:39:14,900 | INFO | Refreshing org.apache.activemq.xbean.XBeanBrokerFactory$1@1e0c1853: startup date [Wed Mar 15 21:39:14 UTC 2017]; root of context hierarchy | org.apache.activemq.xbean.XBeanBrokerFactory$1 | main 2017-03-15 21:39:16,178 | INFO | Using Persistence Adapter: KahaDBPersistenceAdapter[/opt/efs/kahadb] | org.apache.activemq.broker.BrokerService | main 2017-03-15 21:39:16,199 | INFO | Database /opt/efs/kahadb/lock is locked by another server. This broker is now in slave mode waiting a lock to be acquired | org.apache.activemq.store.SharedFileLocker | main
The line telling that This broker is now in slave mode waiting a lock to be acquired is proof that the second instance has launched as a Slave in our Master/Slave configuration.Information noteNote:- The new broker shares the same EFS filesystem as the first broker
- Because the first broker is still running and has already acquired the file lock, the new broker goes into slave mode, waiting for the master to die and release the file lock to then become the master.
- The Master/Slave broker nodes will rotate depending on which one has acquired the file lock first
- Consumers and Producers of messages for the broker should be configured with the endpoint of both the master and slave broker instances so that they are agnostic to which broker is the master or slave.
Results
Congratulations, you have successfully installed and configured ActiveMQ in Master/Slave mode with KahaDB on AWS Elastic File System!
Did this page help you?
If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!