Unable to install a RabbitMQ server


When installing RabbitMQ using zstack-ctl install_rabbitmq you may encounter a failure caused by unable to start RabbitMQ server, the error message in /tmp/zstack_installation.log is like:

TASK: [enable RabbitMQ] *******************************************************
failed: [] => {"failed": true}
msg: Starting rabbitmq-server: FAILED - check /var/log/rabbitmq/startup_{log, _err}

This is most likely caused by you have changed your hostname and a previous RabbitMQ server still retains an old hostname. RabbitMQ relies on hostname as node name, changing hostname may cause issues that you can find details in RabbitMQ in Amazon EC2(see details in section "Issues with hostname").


1. Stop RabbitMQ server

As the tool rabbitmqctl may have failed because of hostname change, you may need to stop all running RabbitMQ related processes by Linux kill command with -9 option.

Make sure no RabbitMQ related processes running

The service rabbitmq-server stop will mislead you that the RabbitMQ server is stopped but if you ps -aux | grep rabbitmq you will see a bunch of RabbitMQ process still running. So please use ps to check your system before proceeding.

2. Reset environment variable HOSTNAME to current hostname

If you haven't logout/login shell sessions after changing the hostname, the environment variable HOSTNAME will remain to the old one that fails rabbitmqctl. You can change the $HOSTNAME by:

export HOSTNAME=`hostname`

or simply logout then login your shell

3. Start RabbitMQ server

Now you can start the server by:

service rabbitmq-server start

The hostname may need to be routable

We have seen some articles saying that the hostname must be routable otherwise RabbitMQ server won't work. However, in version (3.x) of RabbitMQ we don't see this issue. If you encounter it, please follow above RabbitMQ in Amazon EC2 to add IP/hostname pair in /etc/hosts file.