Friday, October 4, 2013

RabbitMQ Upgrade


Problem







I am currently running vFabric RabbitMQ 2.8.6 that was installed using the generic installer  vfabric-rabbitmq-server-2.8.6.tar.gz in a customized directory /apps/appuser/springsource/vfabric-rabbitmq-server-2.8.6/

Now, it is required to upgrade it to vFabric RabbitMQ 3.0.4.

** Although I am using vFabric RabbitMQ, but the same is applicable on the native RabbitMQ

Analysis

The default RPM installer will use the standard path /var/lib/rabbitmq/mnesia/ to store mnesia database that contains the queues and exchanges definitions, also the persistent messages are located under the same directory /var/lib/rabbitmq/mnesia/rabbit\@<hostname>/

The generic installer vfabric-rabbitmq-server-2.8.6.tar.gz stored mnesia database and persistent messages under a customized directory path  /apps/appuser/springsource/vfabric-rabbitmq-server-2.8.6/var/lib/rabbitmq/mnesia.

As described in the RabbitMQ 3.0.4 Release Notes, to upgrade a non-clustered RabbitMQ 2.8.6 to 3.0.4, simply install the new version 3.0.4 and all configuration and persistent message data is retained but as per our standards the new 3.0.4 installation will be at  /apps/appuser/springsource/vfabric-rabbitmq-server-3.0.4/ and it will not detect the old mnesia directory which mean none of the configuration or messages will be migrated to 3.0.4 installation.

Workaround

As a workaround, you can overcome this limitation by:


  1. Check the queues and messages from the RabbitMQ 2.8.6 console http://<hostname:55672>
  2. Shutdown RabbitMQ 2.8.6
  3. Backup the installation directory (/apps/appuser/springsource/vfabric-rabbitmq-server-2.8.6/)
  4. Install the RabbitMQ 3.0.4 to the new customized directory /apps/appuser/springsource/vfabric-rabbitmq-server-3.0.4/
  5. Make sure that RabbitMQ is not running
  6. Copy all files under the old mnesia directory from /apps/appuser/springsource/vfabric-rabbitmq-server-2.8.6/var/lib/rabbitmq/mnesia/rabbit@<hostname> to /apps/appuser/springsource/vfabric-rabbitmq-server-3.0.4/var/lib/rabbitmq/mnesia/rabbit@<hostname>
  7. Start RabbitMQ 3.0.4
  8. Check if the queues, exchanges and messages from the RabbitMQ 3.0.4 console http://<hostname:15672>
  9. Your queues, exchanges, and messages will be there :)

Limitaions

This workaround is only valid on the same host server, moving mnesia database is not supported between different hosts with different hostnames.