Tag: queue

RabbitMQ Cluster Setup


RabbitMQ Queue

rabbitmq-plugins enable rabbitmq_management
service rabbitmq_server restart
rabbitmqadmin declare queue name=”mohantest-queue”
rabbitmqadmin declare exchange name=”mohantest-direct-exchange” type=”direct”
rabbitmqadmin declare binding source=”mohantest-direct-exchange” destination_type=”queue” destination=”mohantest-queue” routing_key=”mohantest-dxqb-key”
rabbitmq-plugins disable rabbitmq_management
service rabbitmq_server restart

RabbitMQ configuration

[ {rabbit, [{tcp_listeners, [{“”, 5672}]}]}]

rabbitmqctl stop_app
rabbitmqctl start_app
RabbitMQ Cluster Setup

Step A: The cookie .erlang.cookie is to be the same for all nodes which is to be part of cluster.
1. Stop RabbitMQ and Erlang instance
service rabbitmq-server stop
epmd -kill
2. Make same copy of .erlang.cookie to all nodes
3. Start the RabbitMQ
service rabbitmq-server start
Step B: Join rabbit@rabbit2 with rabbit@rabbit1
NodeName: rabbit2
rabbitmqctl stop_app
rabbitmqctl join_cluster rabbit@rabbit1
rabbitmqctl start_app

Step C: Join rabbit@rabbit3 with rabbit@rabbit2
NodeName: rabbit3
rabbitmqctl stop_app
rabbitmqctl join_cluster rabbit@rabbit2
rabbitmqctl start_app

Step D: Check the cluster status and verify rabbit1, rabbit2 and rabbit3 are clustered together.
rabbitmqctl cluster_status

if need to detach the node from the cluster:

rabbitmqctl stop_app
rabbitmqctl reset
rabbitmqctl start_app

RabbitMQ HA Mode

rabbitmqctl set_policy ha-mohantest “^(mohantest-queue$)” ‘{“ha-mode”:”all”, “ha-sync-mode”:”automatic”}’ -p /
rabbitmqctl list_policies
rabbitmqctl list_connections

To remove policy:
rabbitmqctl clear_policy ha-mohantest