RabbitMQ database files

2019-09-12 05:59发布

问题:

I'm running RabbitMQ V.2.0.0. on a Linux machine. The mnesia base is current the default, but the within that directory Rabbit creates directories, eg. rabbit@ip-123.1.1.123.

The ip in the directory name is based on the inet addr of the machine. This directories hold information about user, exchanges, vhost (I think).

My question is, how can I fix/config these directory names with ip to be not based on ip?

回答1:

To change the Mnesia directory, just set MNESIA_DIR in /etc/rabbitmq/rabbitmq.conf.

Also, a great place to ask RabbitMQ related questions is on the rabbitmq-discuss mailing list.



回答2:

It seems you can edit the scripts files (rabbitmq-server, rabbitmq-mulit and rabbitmqcti). In these scripts at the top is a hostname variable.

I set the hostname to localhost and restarted.

This is not the best, but good enough for my requirements. The hostname must be a proper address, it cannot be something arbitrary.



回答3:

The main problem is that your new machine has new hostname - and directory is named after it (just renaming directory as mentioned before, does not help) so we need to rename your machine hostname and make RabbitMq to work with old files. Let "ip-0-0-0-0" be old machine name (so there should be a mnesia folder /var/lib/rabbitmq/mnsesia/ip-0-0-0-0), and new machine host name is something like "ip-1-1-1-1", but new name doesnot matter as we will overwrite it. Execute following commands:

sudo -s
echo "127.0.0.1 ip-0-0-0-0" >> /etc/hosts 
echo "ip-0-0-0-0" > /etc/hostname
reboot

After reboot your machine will have a new name and RabbitMq should work with old files.