You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Fabien JALABERT <fa...@gmail.com> on 2019/05/23 22:51:15 UTC

how to configure 2 nodes with HA / Replication

Hello,

I'm trying to configure a simple cluster with HA master slave 
replication. My goal is only to implement an easy failover, I do not 
have load requirements.

My two node configurations are below (amq-n1 as  master and amq-n2 as 
slave host).

1) When I success to post a message on the n1 queue, then the message is 
not visible on the n2, so that means that replications seems not working.

2) How can I manage that the shutdown of the n1 should switch on n2 ? 
It's autotic when connecting with ha parameter ? When I try using a "2 
tcp connection", I cannot send a message, that only works when I put 
only one host in the URL:

jms.broker.url=(tcp://amq-n1:61616,tcp://amq-n2:61616)?ha=true&retryInterval=1000&retryIntervalMultiplier=1.0&reconnectAttempts=-1 
--> does not work

jms.broker.url=tcp://amq-n1:61616?ha=true&retryInterval=1000&retryIntervalMultiplier=1.0&reconnectAttempts=-1 
--> works

Thanks for your help.

MASTER CONF :

   <connectors>
<connector name="netty-connector">tcp://0.0.0.0:61616 
<http://0.0.0.0:61616></connector>
<connector name="netty-backup-connector">tcp://amq-n2:61616</connector>
  </connectors>

       <acceptors><acceptor 
name="netty-acceptor">tcp://0.0.0.0:61616?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE;useEpoll=true;amqpCredits=1000;amqpLowCredits=300 
<http://0.0.0.0:61616?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE;useEpoll=true;amqpCredits=1000;amqpLowCredits=300></acceptor></acceptors>

       <cluster-connections>
          <cluster-connection name="my-cluster">
<connector-ref>netty-connector</connector-ref>
             <static-connectors>
  <connector-ref>netty-backup-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>


SLAVE CONF:

       <connectors>
<connector name="netty-connector">tcp://0.0.0.0:61616 
<http://0.0.0.0:61616></connector>
<connector name="netty-live-connector">tcp://amq-n1:61616</connector>
  </connectors>
    <acceptors>
          <acceptor 
name="netty-acceptor">tcp://0.0.0.0:61616?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE;useEpoll=true;amqpCredits=1000;amqpLowCredits=300 
<http://0.0.0.0:61616?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE;useEpoll=true;amqpCredits=1000;amqpLowCredits=300></acceptor>
       </acceptors>
<ha-policy>
          <replication>
             <slave>
                <allow-failback>true</allow-failback>
                <!-- not needed but tells the backup not to restart 
after failback as there will be > 0 backups saved -->
  <max-saved-replicated-journals-size>0</max-saved-replicated-journals-size>
             </slave>
          </replication>
       </ha-policy>

    <cluster-connections>
          <cluster-connection name="my-cluster">
<connector-ref>netty-connector</connector-ref>
             <static-connectors>
  <connector-ref>netty-live-connector</connector-ref>
             </static-connectors>
          </cluster-connection>
       </cluster-connections>


Re: how to configure 2 nodes with HA / Replication

Posted by Justin Bertram <jb...@apache.org>.
> When I success to post a message on the n1 queue, then the message is not
visible on the n2, so that means that replications seems not working.

What exactly do you mean that "the message is not visible on the n2"? If
the slave is actually acting as a slave then it will be receiving messages
from the live broker, but it won't be "active" in a such a way that you can
look at the message counts of the various queues, etc.

When you start both brokers do you see slave announce itself to the master
broker and do you see the master broker synchronize its data with the slave
(i.e. send its journal files)?

> How can I manage that the shutdown of the n1 should switch on n2 ?

The slave should activate automatically when it loses its network
connection with its master and after a quorum vote has indicated it is
safe. In your case, with just a single master/slave pair the slave will
activate immediately when it loses its connection to the master since there
is no way to establish a quorum (i.e. the cluster is too small).

> It's autotic when connecting with ha parameter ?

When using ha=true from a core client then the master broker will inform
the client about the slave behind the scenes and when the master dies the
client will automatically attempt to connect to the slave.

> When I try using a "2 tcp connection", I cannot send a message, that only
works when I put only one host in the URL...

What exactly happens when you try to send a message when you specify 2
brokers in your URL?


Justin

On Thu, May 23, 2019 at 8:16 PM Fabien JALABERT <fa...@gmail.com>
wrote:

> Hello,
>
> I'm trying to configure a simple cluster with HA master slave
> replication. My goal is only to implement an easy failover, I do not
> have load requirements.
>
> My two node configurations are below (amq-n1 as  master and amq-n2 as
> slave host).
>
> 1) When I success to post a message on the n1 queue, then the message is
> not visible on the n2, so that means that replications seems not working.
>
> 2) How can I manage that the shutdown of the n1 should switch on n2 ?
> It's autotic when connecting with ha parameter ? When I try using a "2
> tcp connection", I cannot send a message, that only works when I put
> only one host in the URL:
>
> jms.broker.url=(tcp://amq-n1:61616,tcp://amq-n2:61616)?ha=true&retryInterval=1000&retryIntervalMultiplier=1.0&reconnectAttempts=-1
>
> --> does not work
>
> jms.broker.url=tcp://amq-n1:61616?ha=true&retryInterval=1000&retryIntervalMultiplier=1.0&reconnectAttempts=-1
>
> --> works
>
> Thanks for your help.
>
> MASTER CONF :
>
>    <connectors>
> <connector name="netty-connector">tcp://0.0.0.0:61616
> <http://0.0.0.0:61616></connector>
> <connector name="netty-backup-connector">tcp://amq-n2:61616</connector>
>   </connectors>
>
>        <acceptors><acceptor
> name="netty-acceptor">tcp://
> 0.0.0.0:61616?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE;useEpoll=true;amqpCredits=1000;amqpLowCredits=300
> <
> http://0.0.0.0:61616?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE;useEpoll=true;amqpCredits=1000;amqpLowCredits=300
> ></acceptor></acceptors>
>
>        <cluster-connections>
>           <cluster-connection name="my-cluster">
> <connector-ref>netty-connector</connector-ref>
>              <static-connectors>
>   <connector-ref>netty-backup-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>
>
>
> SLAVE CONF:
>
>        <connectors>
> <connector name="netty-connector">tcp://0.0.0.0:61616
> <http://0.0.0.0:61616></connector>
> <connector name="netty-live-connector">tcp://amq-n1:61616</connector>
>   </connectors>
>     <acceptors>
>           <acceptor
> name="netty-acceptor">tcp://
> 0.0.0.0:61616?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE;useEpoll=true;amqpCredits=1000;amqpLowCredits=300
> <
> http://0.0.0.0:61616?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE;useEpoll=true;amqpCredits=1000;amqpLowCredits=300
> ></acceptor>
>        </acceptors>
> <ha-policy>
>           <replication>
>              <slave>
>                 <allow-failback>true</allow-failback>
>                 <!-- not needed but tells the backup not to restart
> after failback as there will be > 0 backups saved -->
>
>   <max-saved-replicated-journals-size>0</max-saved-replicated-journals-size>
>              </slave>
>           </replication>
>        </ha-policy>
>
>     <cluster-connections>
>           <cluster-connection name="my-cluster">
> <connector-ref>netty-connector</connector-ref>
>              <static-connectors>
>   <connector-ref>netty-live-connector</connector-ref>
>              </static-connectors>
>           </cluster-connection>
>        </cluster-connections>
>
>