SmoothLinux Blog

Ubuntu RabbitMQ Changing Database Location

09 April, 2016 | rabbitmq

I'm sitting up Sensu, which requires a RabbitMQ setup as well. I couldn't install Ubuntu's repo version of rabbitmq as it was outdated for Sensu so I ended installing the version that Sensu has on there site: rabbitmq-server_3.6.0-1_all.deb.

I burned about 30 minutes trying to figure out how to relocation rabbit's database to a new location. So here's the skinny I hope it saves you time.

Step 1) First be smart and stop rabbitmq

service rabbitmq-server stop

Step 2) I ran command:  dpkg -L rabbitmq-server  and took some guesses at where the configuration for the database would be. 

The file your after is: /usr/lib/rabbitmq/bin/rabbitmq-defaults

Step 3) The line you need to edit

Open that guy up and edit line: MNESIA_BASE=${SYS_PREFIX}/var/lib/rabbitmq/mnesia

Step 4) Change location /var/lib/rabbitmq/mnesia to what you would like your new location to be.

My line looks like this: MNESIA_BASE=${SYS_PREFIX}/storage/rabbitmq/mnesia

Step 5) When creating the new location make sure you give permission to rabbit to write.

chown rabbitmq:rabbitmq  /storage/rabbitmq

Step 6) Start rabbitmq

service rabbitmq-server start

Step 7) I trailed the logs and seen this figured I was good.

Database directory at /storage/rabbitmq/mnesia/rabbit@hostnamehere is empty. Initialising from scratch...


comments powered by Disqus