RabbitMQ is a queueing service that implements the Advanced Message Queuing Protocol (AMQP). It is a fast and dependable open-source message server that supports a wide range of use cases including reliable integration, content-based routing and global data delivery, and high volume monitoring and data ingestion.
Additional Documentation:
General Install: https://www.rabbitmq.com/download.html
Setting up RabbitMQ Clustering: https://www.rabbitmq.com/clustering.html
Install RabbitMQ
Install RabbitMQ on Ubuntu
- Login as root
- Install RabbitMQ Server
apt-get install rabbitmq-server
- Verify status
rabbitmqctl status
- Install RabbitMQ Web Interface
rabbitmq-plugins enable rabbitmq_management
Install RabbitMQ on CentOS
- Login as root
- Install RabbitMQ Server
yum install epel-release yum install rabbitmq-server
- Verify status
rabbitmqctl status
- Install RabbitMQ Web Interface
rabbitmq-plugins enable rabbitmq_management
Setting up and Running RabbitMQ Cluster as a Cluster
If you want to setup multiple machines to work as a RabbitMQ Cluster you can follow these instructions. Otherwise you can follow “Running RabbitMQ as Single Node” instructions to get it running on a single machine.
Note: The machines you want to use in the cluster need to be able to communicate with each other.
- Follow the above “Install RabbitMQ” steps for on each node you want to add to the RabbitMQ Cluster
- Ensure the RabbitMQ daemons are not running
- See the “Running RabbitMQ as Single Node” section bellow
- Choose one of the nodes as MASTER
- On the non-MASTER nodes backup the .erlang.cookie file
mv /var/lib/rabbitmq/.erlang.cookie /var/lib/rabbitmq/.erlang.cookie.backup
- Copy the file “/var/lib/rabbitmq/.erlang.cookie” from the MASTER node to the other nodes and store it at the same location.
- Be careful during this step. If you copy the contents of the .erlang.cookie file and use the vi or nano editor to update the non-MASTER nodes .erlang.cookie file you may add a next line character to the file. You’re better off using an FTP service to copy the .erlang.cookie file down from the MASTER node and copy it onto the non-MASTER machines.
- Set permissions of the .erlang.cookie file
chown rabbitmq:rabbitmq /var/lib/rabbitmq/.erlang.cookie chmod 600 /var/lib/rabbitmq/.erlang.cookie
- Startup the MASTER RabbitMQ Daemon in detached mode (as root)
rabbitmq-server -detached
- On each of the of the non-MASTER nodes, add them to the cluster and start them up one at a time (as root)
#Stop App rabbitmqctl stop_app #Add the current machine to the cluster rabbitmqctl join_cluster rabbit@{MASTER_HOSTNAME} #Startup rabbitmqctl start_app #Check Status rabbitmqctl cluster_status
- The “Check Status” command should return something like the following:
-
Cluster status of node rabbit@{NODE_HOSTNAME} ... [{nodes,[{disc,[rabbit@{MASTER_HOSTNAME},rabbit@{NODE_HOSTNAME}]}]}, {running_nodes,[rabbit@{MASTER_HOSTNAME},rabbit@{NODE_HOSTNAME}]}]
-
- The “Check Status” command should return something like the following:
- Setup HA/Replication between Nodes
- Access the Management URL of one of the nodes (See “Managing the RabbitMQ Instance(s)” section bellow)
- Click on the Admin tab on top
- Click on the Policies tab on the right
- Add an HA policy
- Name: ha-all
- Pattern:
- leave blank
- Definitions:
- ha-mode: all
- ha-sync-mode: automatic
- Priority: 0
- Verify its setup correctly by navigating to the Queues section and clicking on one of the queues. You should see an entry in the Node and Slave section.
- Setup a load balancer to balance requests between the the Nodes
- Port Forwarding
- Port 5672 (TCP) → Port 5672 (TCP)
- Port 15672 (HTTP) → Port 15672 (HTTP)
- Health Check
- Protocol: HTTP
- Ping Port: 15672
- Ping Path: /
- Port Forwarding
- Point all processes to that LB
Controlling RabbitMQ
Start RabbitMQ
service rabbitmq-server start |
Stop RabbitMQ
service rabbitmq-server stop |
Restart RabbitMQ
service rabbitmq-server restart |
Getting RabbitMQ Status
service rabbitmq-server status |
Setting RabbitMQ to Run on Machine Startup
chkconfig rabbitmq-server on |
Managing the RabbitMQ Instance(s)
When the RabbitMQ daemons are started you can then visit the management Web UI in a Web Browser to monitor the RabbitMQ instance(s):
http://{ANY_RABBITMQ_NODE_HOSTNAME}:15672/
Default credentials: guest/guest
Note: Change the password
Pingback: Installing and Configuring Apache Airflow – Home
Pingback: Setting up an Apache Airflow Cluster - Home
Ram
Hi
Can you please let me know where can i find instructions for “Running RabbitMQ as Single Node”
Robert Sanders Post author
To run a RabbitMQ instance on a single node you can use the instructions listed on this blog. You only need to skip the “Setting up and Running RabbitMQ Cluster as a Cluster” section. The rest of the blog talks about how you can install RabbitMQ and Control it from that single instance.
Jing Li
Hi, you mentioned load balancer in step10 & step11 in “Setting up and Running RabbitMQ Cluster as a Cluster”. Could I know which load balancer and what configuration you are using? Thanks
AOK
Trying this in 2019 and getting here
http://{ANY_RABBITMQ_NODE_HOSTNAME}:15672/
Default credentials: guest/guest
Note: Change the password
The login failed. Any recommendations on steps to take?