Technically, these instructions should work on most Debian based systems (Ubuntu, pop_OS etc.), but this is the process I go through when setting up RabbitMQ on a Raspberry Pi. Though yes, I should have this automated with Ansible already; there's a future post right there!
I'll assume you've got access to the command line on the Pi. Either connected directly, or via SSH or similar method.
1. Install RabbitMQ Server
This is the simplest part of the process. Run:
sudo apt install -y rabbitmq-server
That will download and install the required packages.
2. Create a User
To do anything in RabbitMQ, you will need a user. Some installs create the user
guest with password
guest, but that has limitations.
In the terminal, run
rabbitmqctl add_user username password
The username and password can be anything, but will be used for connecting to the server to publish items to queues and consume them.
3. Set User Permissions
rabbitmqctl set_permissions -p / username ".*" ".*" ".*"
Okay, this one is somewhat more complicated, so let's break this down further:
-p /This tells the command to set the permissions against the vhost
/. A vhost is like a folder to store different queues. Unless you're using RabbitMQ for a lot of different things, you're not likely to use more than the default
/. Vhosts are used to logically group a set of queues/resources, and therefore limit access to information
- The first
".*"sets the name of the exchange(s) that the user has access the permissions will apply to. By using
.*here, it means it will apply it to all.
- The second
".*sets the write permissions for messages on the queues in the exchange. Again the
.*means all messages. This allows the user to publish messages in the queues
- The third
".*"sets the read permissions on queues in the exchange, allowing the user to consume the queues. As with the first and second of these,
4. Install the Management Plugin (optional)
RabbitMQ has a lot of different commands which can be used to administer it, and to view the state of queues. However that means having access to the CLI all the time, and remembering all of the relevant commands. Instead, the managing of it can be mostly done via a web interface which is easier to use. This requires the management plugin to be enabled.
rabbitmq-plugins enable rabbitmq_management
This will enable the relevant plugins for the management interface. It will make RabbitMQ available via a browser on port
5. Set the User as an Administrator
Access to the management interface is only allowed to management users. This means the user you created in step 2 won't be able to log in.
rabbitmqctl set_user_tags username administrator
Once this has been done, the user will be able to log in to the management interface from step 4 with the username and password set in step 2.
An Alternative? Docker
When I wrote this, I was setting up stand-alone servers and trying things out on a Raspberry Pi (which is why I needed the steps for repetition). At the time I was setting up some older servers, and this was easy. Since then Ubuntu Server (which is my server OS of choice) has stopped 20.04 being supported, and 22.04 has issues with the required version of erlang which RabbitMQ needs. To get round that, I install Docker, and use docker images of RabbitMQ now. It's a lot faster to set up, and removes the slight differences in software versions between servers.