Thursday, July 12, 2012

Clustering RabbitMQ on CentOS 6

#Assuming you got to instances of RabbitMQ installed on two separate computers in the same LAN segment, run the following command on both nodes (A and B):

rabbitmqctl status

# verify that both RabbitMQ nodes run EXACTLY the same Erlang version
# if they do not - upgrade Erlang on one of them to match the second Erlang version
# at the beginning of its layout the command displays RabbitMQ node name, e.g. rabbit@my-server-A - note this node name for the later use

# Check that both machines A and B can talk to each other (no firewall issues etc)

telnet localhost 4369


# Let's work on server A configuring RabbitMQ there to be clustered with server B.
# all the work is done on server A only, nothing should be done on server B

# stop rabbitmq service on server A

service rabbitmq-server stop



# add alias for B an A:
vi /etc/hosts

# add to /etc/hosts the alias of server B like it is displayed in the "rabbitmqctl status" output after "@" symbol, e.g. "10.10.10.10   my-server-B"
# use internal IP for server B alias if you got such, so the connection between serves A and B will go over internal switch

# copy Erlang cookie from the server B to the server  A:
scp root@my-server-B:/var/lib/rabbitmq/.erlang.cookie /var/lib/rabbitmq/.erlang.cookie

# give the cookie file the correct ownership (comes with 'root' after copying)
chown rabbitmq:rabbitmq /var/lib/rabbitmq/.erlang.cookie

# start rabbitmq service
service rabbitmq-server start

#stop and reset the app
rabbitmqctl stop_app

rabbitmqctl reset

# cluster the current node (on server A) to the node on server B as a disk node
#(if you prefer to cluster node A to B as RAM node run       rabbitmqctl cluster rabbit@my-server-B)

rabbitmqctl cluster rabbit@my-server-B rabbit@my-server-A

# you should see the success message here

# start the app and enjoy
rabbitmqctl start_app

#verify that two nodes are indeed clustered: use management plugin
# go to server A, HTTP on port 55672
# you should see "node" column in the Queues view, filled in with 'my-server-B' node name










No comments: