I was able to successfully setup Apache ActiveMQ Artemis Master/Slave
replication on my 2 VM cluster.
VM1 : 172.29.219.89
VM2 : 172.29.219.104
My broker.xml for Master node is :
<connectors>
<connector name="artemis">tcp://172.29.219.89:61616</connector>
<connector
name="cluster-connector">tcp://172.29.219.104:61616</connector>
</connectors>
<cluster-user>cluster-user</cluster-user>
<cluster-password>cluster-password</cluster-password>
<cluster-connections>
<cluster-connection name="cluster1">
<address>*</address>
<connector-ref>artemis</connector-ref>
<retry-interval>1000</retry-interval>
<message-load-balancing>ON_DEMAND</message-load-balancing>
<max-hops>1</max-hops>
<static-connectors>
<connector-ref>cluster-connector</connector-ref>
</static-connectors>
</cluster-connection>
</cluster-connections>
<ha-policy>
<replication>
<master>
<check-for-live-server>true</check-for-live-server>
</master>
</replication>
</ha-policy>
My broker.xml for Slave node is :
<connectors>
<connector name="artemis">tcp://172.29.219.104:61616</connector>
<connector
name="cluster-connector">tcp://172.29.219.89:61616</connector>
</connectors>
<cluster-user>cluster-user</cluster-user>
<cluster-password>cluster-password</cluster-password>
<cluster-connections>
<cluster-connection name="cluster1">
<address>*</address>
<connector-ref>artemis</connector-ref>
<retry-interval>1000</retry-interval>
<message-load-balancing>ON_DEMAND</message-load-balancing>
<max-hops>1</max-hops>
<static-connectors>
<connector-ref>cluster-connector</connector-ref>
</static-connectors>
</cluster-connection>
</cluster-connections>
<ha-policy>
<replication>
<slave>
<allow-failback>true</allow-failback>
</slave>
</replication>
</ha-policy>
The above configuration when deployed on just the 2 VMs works perfectly
fine. As soon as I take the Master down, the failover is instantaneous and
when I bring back the master, the fail back is instantaneous too.
Now I want to dockerize this.
My Docker file is :
COPY initialize.sh /
RUN chmod a+x initialize.sh
RUN yum clean all && yum install -y unzip java-1.8.0-openjdk.x86_64
RUN curl -f -L -o apache-artemis-2.4.0-bin.zip
http://apache.mirrors.spacedump.net/activemq/activemq-artemis/2.4.0/apache-artemis-2.4.0-bin.zip
RUN unzip -qd /opt apache-artemis-2.4.0-bin.zip
EXPOSE 8080 61616 5672 61613 5445 1883
ENTRYPOINT [ "/initialize.sh" ]
The initialize.sh just setups the brokers and loads the respective
broker.xml files for Master and Slave configs.
My Docker container for Master is deployed on Master node. I start the
docker container with the command :
docker run -p 8080:8080 -p 61616:61616 -p 5672:5672 -p 61613:61613 -p
5445:5445 -p 1883:1883 <container-id> --state master
My Docker container for Slave is deployed on Slave node. I start the docker
container with
docker run -p 8080:8080 -p 61616:61616 -p 5672:5672 -p 61613:61613 -p
5445:5445 -p 1883:1883 <container-id> --state slave
My broker.xml config is the same that I am loading into the containers.
But in this case when I take down the Master, the failover takes over 1 min
to happen.
The logs are ::
14:32:43,532 INFO [org.apache.activemq.artemis.core.server] AMQ221066:
Initiating quorum vote: LiveFailoverQuorumVote
14:32:43,535 INFO [org.apache.activemq.artemis.core.server] AMQ221067:
Waiting 30 seconds for quorum vote results.
14:32:43,535 INFO [org.apache.activemq.artemis.core.server] AMQ221068:
Received all quorum votes.
14:32:43,536 INFO [org.apache.activemq.artemis.core.server] AMQ221071:
Failing over based on quorum vote results.
14:32:43,561 INFO [org.apache.activemq.artemis.core.server] AMQ221037:
ActiveMQServerImpl::serverUUID=83d3b7c9-285d-11e8-bfc9-0242ac110001 to
become 'live'
14:32:43,591 WARN [org.apache.activemq.artemis.core.client] AMQ212004:
Failed to connect to server.
14:32:43,854 INFO [org.apache.activemq.artemis.core.server] AMQ221003:
Deploying queue DLQ on address DLQ
14:32:43,855 INFO [org.apache.activemq.artemis.core.server] AMQ221003:
Deploying queue ExpiryQueue on address ExpiryQueue
14:32:44,261 INFO [org.apache.activemq.artemis.core.server] AMQ221007:
Server is now live
14:32:44,318 INFO [org.apache.activemq.artemis.core.server] AMQ221020:
Started EPOLL Acceptor at 0.0.0.0:61616 for protocols
[CORE,MQTT,AMQP,STOMP,HORNETQ,OPENWIRE]
14:32:44,345 INFO [org.apache.activemq.artemis.core.server] AMQ221020:
Started EPOLL Acceptor at 0.0.0.0:5445 for protocols [HORNETQ,STOMP]
14:32:44,348 INFO [org.apache.activemq.artemis.core.server] AMQ221020:
Started EPOLL Acceptor at 0.0.0.0:5672 for protocols [AMQP]
14:32:44,365 INFO [org.apache.activemq.artemis.core.server] AMQ221020:
Started EPOLL Acceptor at 0.0.0.0:1883 for protocols [MQTT]
14:32:44,368 INFO [org.apache.activemq.artemis.core.server] AMQ221020:
Started EPOLL Acceptor at 0.0.0.0:61613 for protocols [STOMP]
And the fail back does not occur at all when the Master is back up.
On the slave container all I see in the logs is :
14:34:29,464 INFO [org.apache.activemq.artemis.core.server] AMQ221027:
Bridge ClusterConnectionBridge@66d554c6
[name=$.artemis.internal.sf.cluster1.f4ad2f1c-285d-11e8-acde-0242ac110001,
queue=QueueImpl[name=$.artemis.internal.sf.cluster1.f4ad2f1c-285d-11e8-acde-0242ac110001,
postOffice=PostOfficeImpl
[server=ActiveMQServerImpl::serverUUID=83d3b7c9-285d-11e8-bfc9-0242ac110001],
temp=false]@21ef670d targetConnector=ServerLocatorImpl
(identity=(Cluster-connection-bridge::ClusterConnectionBridge@66d554c6
[name=$.artemis.internal.sf.cluster1.f4ad2f1c-285d-11e8-acde-0242ac110001,
queue=QueueImpl[name=$.artemis.internal.sf.cluster1.f4ad2f1c-285d-11e8-acde-0242ac110001,
postOffice=PostOfficeImpl
[server=ActiveMQServerImpl::serverUUID=83d3b7c9-285d-11e8-bfc9-0242ac110001],
temp=false]@21ef670d targetConnector=ServerLocatorImpl
[initialConnectors=[TransportConfiguration(name=artemis,
factory=org-apache-activemq-artemis-core-remoting-impl-netty-NettyConnectorFactory)
?port=61616&host=172-29-219-89],
discoveryGroupConfiguration=null]]::ClusterConnectionImpl@1909325807[nodeUUID=83d3b7c9-285d-11e8-bfc9-0242ac110001,
connector=TransportConfiguration(name=artemis,
factory=org-apache-activemq-artemis-core-remoting-impl-netty-NettyConnectorFactory)
?port=61616&host=172-29-219-104, address=*,
server=ActiveMQServerImpl::serverUUID=83d3b7c9-285d-11e8-bfc9-0242ac110001]))
[initialConnectors=[TransportConfiguration(name=artemis,
factory=org-apache-activemq-artemis-core-remoting-impl-netty-NettyConnectorFactory)
?port=61616&host=172-29-219-89], discoveryGroupConfiguration=null]] is
connected
Does anyone have any idea why the Master/Slave replication isnt working in
docker form ?
--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html