For high availability and scalability purposes, you can set up a RabbitMQ cluster.

About this task

Run the following procedure on all hosts within your environment:

Procedure

  1. Log in as root on the current CentOS host.
  2. Copy the entire /etc/rabbitmq directory from the primary RabbitMQ node to the current node.
  3. Enable starting the RabbitMQ service on boot.

    chkconfig rabbitmq-server on

  4. Start the RabbitMQ service.

    service rabbitmq-server start

  5. Stop the RabbitMQ application.

    rabbitmqctl stop_app

  6. Reset the RabbitMQ server.

    rabbitmqctl reset

  7. Stop the RabbitMQ service.

    service rabbitmq-server stop

  8. Navigate to the /var/lib/rabbitmq directory.

    cd /var/lib/rabbitmq/

  9. To back up the .erlang.cookie file, run the following command.

    mv .erlang.cookie .erlang.cookie.OLD

  10. Run the following command.

    scp first_node:/var/lib/rabbitmq/ .erlang.cookie

  11. Change the ownership of the .erlang.cookie file.

    chown rabbitmq:rabbitmq .erlang.cookie

  12. Start the RabbitMQ service.

    service rabbitmq-server start

  13. Stop the RabbitMQ application.

    rabbitmqctl stop_app

  14. Join the current RabbitMQ node to the primary RabbitMQ node rabbit@first_node, as a RAM node.

    rabbitmqctl join_cluster --ram rabbit@first_node

  15. Start the RabbitMQ application.

    rabbitmqctl start_app

  16. Configure a high availability policy for queue mirroring.

    rabbitmqctl set_policy ha-all "" '{"ha-mode":"all","ha-sync-mode":"automatic"}'

  17. Verify the status of the cluster configuration.

    rabbitmqctl cluster_status

What to do next

You must configure the load balancer to route the traffic between the RabbitMQ nodes on SSL port 5671 and non-SSL port 5672.

You must configure TCP (not HTTP) to route on both ports on the load balancer.