4

I've read both the clustering and HA chapters and got a fair understanding on RabbitMQ clustering. One thing I did not understand is, having 2+ nodes on the cluster and a set of HA queues, how connections can be made by the clients so that if one node fails they automatically and seamlessly connect to the remaining node(s). Can this be achieved by a load balancer such as, say, Amazon ELB for deployments made in AWS?

Martin
  • 1,317
  • 3
  • 13
  • 18

3 Answers3

2

Using a load balancer like Amazon ELB or HAProxy is exactly how you should route traffic to the available nodes in the Rabbit cluster.

I'd recommend HAProxy. Here's a sample HAProxy config:

global
        log 127.0.0.1   local1
        maxconn 4096
        #chroot /usr/share/haproxy
        user haproxy
        group haproxy
        daemon
        #debug
        #quiet

defaults
        log     global
        mode    tcp
        option  tcplog
        retries 3
        option redispatch
        maxconn 2000
        timeout connect 5000
        timeout client 50000
        timeout server 50000

listen  stats :1936
        mode http
        stats enable
        stats hide-version
        stats realm Haproxy\ Statistics
        stats uri /

listen aqmp_front :5672
        mode            tcp
        balance         roundrobin
        timeout client  3h
        timeout server  3h
        option          clitcpka
        server          aqmp-1 rabbitmq1.domain:5672  check inter 5s rise 2 fall 3
        server          aqmp-2 rabbitmq2.domain:5672  backup check inter 5s rise 2 fall 3

Note the last two lines. You'll need to substitute rabbitmq1.domain and rabbitmq2.domain with the location of your two nodes. Since the second server is setup as backup check HAProxy will balance the request only on the first node, and if this node fails the request will be route to the second node.

Rick Hanlon II
  • 20,549
  • 7
  • 47
  • 53
0

I would use simple keepalived deamon on all rabbit nodes. It just adds a virtual IP address shared between nodes which you can use for client access. Configuration is very simple, check this Hollenback's page.

Sample config:

vrrp_instance VI_1 {
  state MASTER
  interface eth0
  virtual_router_id 1
  priority 100

  virtual_ipaddress {
    192.168.1.1/24 brd 192.168.1.255 dev eth0
  }
}
Jan ZahradnĂ­k
  • 2,417
  • 2
  • 33
  • 44
0

You have to configure mirror queue between rabbitmq-servers.

   rabbitmqctl set_policy HA '^(?!amq\.).*' '{"ha-mode": "all"}'

In the example rabbitmq will be mirror queue have prefix with amq. When server A fail, those queue unitl exit on server B. You also HA on code(connect to server fail, then connect to server B) or using HA rabbitmq port using keepalive

Son Lam
  • 1,229
  • 11
  • 16