高可用訊息佇列服務構建-RABBITMQ
Rabbitmq has his own buildin cluster management system. Here, we don’t need Pacemaker, everything is managed by RabbitMQ itself.
RabbitMQ or more generally the management queues layer is a critical component of OpenStack because every requests/queries use this layer to communicate.
CLUSTERING SETUP
1
|
|
RabbitMQ generates a cookie for each server instance. This cookie must be the same on each member of the cluster:
1 2 3 4 5 6 7 8 |
|
Check your cluster status, on the node 01 or 02, whatever:
1 2 3 4 5 |
|
Eventually check your queues on both nodes, they should be identical:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
|
Cluster nodes can be of two types: disk or ram. Disk nodes replicate data in ram and on disk, thus providing redundancy in the event of node failure and recovery from global events such as power failure across all nodes. Ram nodes replicate data in ram only and are mainly used for scalability. A cluster must always have at least one disk node.
You can also verify that the connection is well established between the node:
1 2 |
|
TIPS
CHANGE THE IP OR THE HOSTNAME OF A NODE
If you changed you IP address or your hostname, this is pretty nasty and harsh but it works:
1 2 3 4 5 6 |
|
The IP address and/or will be refresh in the rabbitmq database.
CONVERT RAM NODE TO DISK NODE
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
|
HAPROXY CONFIGURATION
Clustering doesn’t mean high-availability, this is why I put a load-balancer on top. Here HAProxy will balance the request only on one node, if this node fails the request will be route to the other node. It’s simple as that. The native port of HAproxy and the OpenStack queues ports are configured.
global
log 127.0.0.1 local0
#log loghost local0 info
maxconn 1024
#chroot /usr/share/haproxy
user haproxy
group haproxy
daemon
#debug
#quiet
defaults
log global
#log 127.0.0.1:514 local0 debug
log 127.0.0.1 local1 debug
mode tcp
option tcplog
option dontlognull
retries 3
option redispatch
maxconn 1024
# Default!
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
listen rabbitmq_cluster 0.0.0.0:4369
mode tcp
balance roundrobin
server server-07_active 172.17.1.8:4369 check inter 5000 rise 2 fall 3
server server-08_backup 172.17.1.9:4369 backup check inter 5000 rise 2 fall 3
listen rabbitmq_cluster_openstack 0.0.0.0:5672
mode tcp
balance roundrobin
server server-07_active 172.17.1.8:5672 check inter 5000 rise 2 fall 3
server server-08_backup 172.17.1.9:5672 backup check inter 5000 rise 2 fall 3
Et voilà!