Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RabbitMQ settings disappear on restart. Why?

This is on EC2. I have an init script that does some basic setup like installing rabbitmq, creating a virtual host, user, setting permissions, etc. So basically it goes:

sudo yum --enablerepo=epel install rabbitmq-server
/etc/init.d/rabbitmq-server start
rabbitmqctl add_user username password
rabbitmqctl add_vhost vhost
rabbitmqctl set_permissions -p vhost username ".*" ".*" ".*"
rabbitmqctl stop

Then I exit the shell, and create an EBS image from the instance. Amazon automatically reboots the server to create the image.

Now the weird part...after a reboot everything was still set except the permissions.

Then when I started a new instance from the image, there was no username or host in rabbitmq.

Is there something that needs to be done in rabbitmq to save changes?

like image 615
Lee Schmidt Avatar asked Aug 10 '12 18:08

Lee Schmidt


People also ask

Why are messages lost when I restart a RabbitMQ broker?

Messages, exchanges, and queues that are not durable and persistent will be lost during a broker restart. If you cannot afford to lose any messages, make sure that your queue is declared as durable and your messages are sent with delivery mode "persistent".

Can RabbitMQ lost messages?

If a queue is not durable, all messages will be lost if RabbitMQ is shut down for any reason. For messages to survive restarts, both of these configurations must be true. This article talks about RabbitMQ Durable queues extensively.


2 Answers

If the settings disappear when you "stop" and "restart" the instance opposed to rebooting it, it is because the ip address is changing and RabbitMQ settings are bound to the ip.

See RabbitMQ on Amazon EC2 instances

like image 120
cwd Avatar answered Nov 13 '22 09:11

cwd


I think it maybe be this, from http://www.rabbitmq.com/ec2.html

Persistent data on EBS device

RabbitMQ writes data to the following directories on Ubuntu:

/var/lib/rabbitmq/ to store persistent data like the messages or queues

/var/log/rabbitmq/ to store logs

If you want to use EBS block device to store RabbitMQ data, just link these directories to your EBS device. Stop RabbitMQ before making any changes to the data directory:

$ /etc/init.d/rabbitmq-server stop

like image 34
stryderjzw Avatar answered Nov 13 '22 07:11

stryderjzw