Bitnami RabbitMQ Virtual Machine

Description

RabbitMQ is a messaging broker that gives your applications a common platform to send and receive messages, and your messages a safe place to live until received.

First steps with the Bitnami RabbitMQ Stack

Welcome to your new Bitnami application! This guide includes some basic information you will need to get started with your application.

How to import a Bitnami Virtual Machine?

Check the following instructions to import a Bitnami Virtual Machine:

Importing a Bitnami Virtual Machine in VirtualBox
  • Select the "File -> Import Appliance" menu option and select the .ova file downloaded from the Bitnami website. Then click "Continue".
  • Once it is imported, click the "Start" button in the VirtualBox toolbar.

For a detailed walkthrough, check our Virtualbox tutorial.

Importing a Bitnami Virtual Machine in a VMware product
  • Select the "File -> Import" menu option and select the .ova file downloaded from the Bitnami website. Then click "Continue".
  • Once the import is complete, click "Finish" to start the virtual machine.

For a detailed walkthrough, check our VMware tutorial, which uses VMware Fusion as an example. To learn how to use our virtual machines with other VMware products, refer to the VMware Workstation documentation or the VMware vSphere documentation.

What credentials do I need?

You need two sets of credentials:

  • The application credentials, consisting of a username and password. These credentials allow you to log in to your new Bitnami application.

  • The server credentials, consisting of an SSH username and password. These credentials allow you to log in to your Virtual Machines server using an SSH client and execute commands on the server using the command line.

What is the administrator username set for me to log in to the application for the first time?

Username: user

What is the administrator password?

Password: The administrator password to log in to your application is randomly generated during the first boot. Check the FAQ to learn how to retrieve it.

What SSH username should I use for secure shell access to my application?

SSH username: bitnami

What is my server IP address?

The IP address is displayed on screen at the end of the boot process, but you can check it at any time by running the following command:

  $ sudo ifconfig

Check server IP address

How do I get my SSH key or password?

You can obtain the SSH password from the virtual machine console when it starts up. Click here for more information.

How to start or stop the services?

Each Bitnami stack includes a control script that lets you easily stop, start and restart services. The script is located at /opt/bitnami/ctlscript.sh. Call it without any service name arguments to start all services:

$ sudo /opt/bitnami/ctlscript.sh start

Or use it to restart a single service, such as Apache only, by passing the service name as argument:

$ sudo /opt/bitnami/ctlscript.sh restart apache

Use this script to stop all services:

$ sudo /opt/bitnami/ctlscript.sh stop

Restart the services by running the script without any arguments:

$ sudo /opt/bitnami/ctlscript.sh restart

Obtain a list of available services and operations by running the script without any arguments:

$ sudo /opt/bitnami/ctlscript.sh

What is the default configuration of RabbitMQ?

  • Default access ports: 15672 port and the 5672 port.
    • Port 15672 is for the management panel and is open for connections from a different machine.
    • Port 5672 is for applications and can only be accessed from the internal network.
  • Default hostname and home: the default hostname of RabbitMQ is set to rabbitmq@SERVER-IP and the default home is /opt/bitnami/rabbitmq/rabbitmq_home. Change this in the /opt/bitnami/rabbitmq/etc/rabbitmq/rabbitmq-env.conf file.

What are the default ports?

A port is an endpoint of communication in an operating system that identifies a specific process or a type of service. Bitnami stacks include several services or servers that require a port.

Remember that if you need to open some ports you can follow the instructions given in the FAQ to learn how to open the server ports for remote access.

Port 22 is the default port for SSH connections.

The RabbitMQ access port is 5672. This port is closed by default, you must open it to enable remote access.

How to connect to the RabbitMQ management panel?

In order to connect to the RabbitMQ management panel, you have two options:

  • (Recommended): Access the RabbitMQ management panel through an SSH tunnel (refer to the FAQ for more information about SSH tunnels).
  • Open the port 15672 for remote access (refer to the FAQ for more information about opening ports).

IMPORTANT: Making this application's network ports public is a significant security risk. You are strongly advised to only allow access to those ports from trusted networks. If, for development purposes, you need to access from outside of a trusted network, please do not allow access to those ports via a public IP address. Instead, use a secure channel such as a VPN or an SSH tunnel. Follow these instructions to remotely connect safely and reliably.

Once you have an active SSH tunnel or you opened the port for remote access, you can then connect to RabbitMQ management panel by browsing to:

  • Access through an SSH tunnel: http://127.0.0.1:SOURCE-PORT/
  • Access opening ports: http://SERVER-IP:15672/

How to connect to RabbitMQ from a different machine?

For security reasons, the RabbitMQ ports in this solution cannot be accessed over a public IP address. To connect to RabbitMQ from a different machine, you must open ports 5672 and 5672 for remote access. Refer to the FAQ for more information on this.

IMPORTANT: Making this application's network ports public is a significant security risk. You are strongly advised to only allow access to those ports from trusted networks. If, for development purposes, you need to access from outside of a trusted network, please do not allow access to those ports via a public IP address. Instead, use a secure channel such as a VPN or an SSH tunnel. Follow these instructions to remotely connect safely and reliably.

If you want to use a transport connector to use RabbitMQ from a different machine, stop your RabbitMQ server and edit the /opt/bitnami/rabbitmq/etc/rabbitmq/rabbitmq.config file, setting the bind address from 127.0.0.1 to 0.0.0.0:

...
{rabbit,
  [%%
   %% Network Connectivity
   %% ====================
   %%

   %% By default, RabbitMQ will listen on all interfaces, using
   %% the standard (reserved) AMQP port.
   %%
    {tcp_listeners, [5672]},
...

If you don't want to connect to the management console from a different machine, edit the same file with the following configuration:

...
{rabbitmq_management,
[%% Pre-Load schema definitions from the following JSON file. See
 %% http://www.rabbitmq.com/management.html#load-definitions
 %%
 %% {load_definitions, "/path/to/schema.json"},

 %% Log all requests to the management HTTP API to a file.
 %%
 %% {http_log_dir, "/path/to/access.log"},

 %% Change the port on which the HTTP listener listens,
 %% specifying an interface for the web server to bind to.
 %% Also set the listener to use SSL and provide SSL options.
 %%
  {listener, [{port, 15672},{ip, "127.0.0.1"}]}
...

Restart the server for the changes to come into effect.

To connect to RabbitMQ from a different machine, use a command like the one below:

$ rabbitmqadmin -H SERVER-IP -u USER_NAME -p PASSWORD list vhosts

How can I run a command in the Bitnami RabbitMQ Stack?

Log in to the server console as the bitnami user and run the command as usual. The required environment is automatically loaded for the bitnami user.

How to enable a plugin on RabbitMQ?

To enable a plugin on RabbitMQ you have to follow the next steps:

  • Log in to your server console.

  • Run the following command to list all the plugins:

    $ sudo /opt/bitnami/rabbitmq/sbin/rabbitmq-plugins list
    
  • Run this command to enable one of them:

    $ sudo /opt/bitnami/rabbitmq/sbin/rabbitmq-plugins enable PLUGIN_NAME
    

Find out more about RabbitMQ's plugins.

How to use the admin console of RabbitMQ?

To use the RabbitMQ admin console, follow these steps:

  • Download the rabbitmqadmin application from http://SERVER-IP:15672/cli/. You will need Python 2.5, 2.6 or later.

  • Copy rabbitmqadmin to /usr/local/bin/ and give it execution permissions.

       $ chmod +x rabbitmqadmin
    
  • Invoke the following for usage instructions:

       $ rabbitmqadmin --help
    

    This command allows you to:

    • list exchanges, queues, bindings, vhosts, users, permissions, connections and channels.
    • show overview information.
    • declare and delete exchanges, queues, bindings, vhosts, users and permissions.
    • publish and get messages.
    • close connections and purge queues.
    • import and export configuration.

Examples:

  • To connect to your machine and list the vhosts that there are created:

     $ rabbitmqadmin -H SERVER-IP -u USER_NAME -p PASSWORD list vhosts
    
  • To declare a new user:

     $ rabbitmqadmin -H SERVER-IP -u USER_NAME -p PASSWORD declare user name=NEW_USER_NAME password=NEW_PASSWORD tags=username
    
  • To give access to the new user:

     $ rabbitmqadmin -H SERVER-IP -u USER_NAME -p PASSWORD declare permission vhost=/ user=NEW_USER_NAME configure=.* write=.* read=.*
    
    NOTE: You have to specify where the new user can configure, write or write. Use .* to specify all the exchanges in the vhost.
  • To delete a user:

     $ rabbitmqadmin -H SERVER-IP -u USER_NAME -p PASSWORD delete user name=NEW_USER_NAME
    
  • To declare an exchange:

     $ rabbitmqadmin -H SERVER-IP -u USER_NAME -p PASSWORD declare exchange name=NEW_EXCHANGE_NAME type=fanout
    
  • To declare a queue with optional parameters:

     $ rabbitmqadmin -H SERVER-IP -u USER_NAME -p PASSWORD declare queue name=NEW_QUEUE_NAME durable=false
    
  • To publish a message:

     $ rabbitmqadmin -H SERVER-IP -u USER_NAME -p PASSWORD publish exchange=amq.default routing_key=QUEUE_NAME payload="hello, world"
    
  • And to get it back:

     $ rabbitmqadmin -H SERVER-IP -u USER_NAME -p PASSWORD  get queue=QUEUE_NAME requeue=false
    
  • To export a configuration:

     $ rabbitmqadmin -H -u USER_NAME -p PASSWORD export rabbit.config
    
  • To import a configuration:

     $ rabbitmqadmin -H SERVER-IP -u USER_NAME -p PASSWORD -q import rabbit.config
    
  • To close all connections:

     $ rabbitmqadmin -H SERVER-IP -u USER_NAME -p PASSWORD -f tsv -q list connections name | while read conn ; do rabbitmqadmin -q close connection name=${conn} ; done
    

How to upgrade RabbitMQ?

It is strongly recommended to create a backup before starting the update process. If you have important data, create and try to restore a backup to ensure that everything works properly.

You can upgrade the application only without modifying any other stack components. Follow these steps:

  • Stop your server.

     $ sudo /opt/bitnami/ctlscript.sh stop rabbitmq
    
  • Copy the etc/, var/ and rabbitmq_home/ folders in the rabbitmq/ folder.

     $ mkdir ~/rabbitmq_backup
     $ sudo cp -r /opt/bitnami/rabbitmq/etc ~/rabbitmq_backup/
     $ sudo cp -r /opt/bitnami/rabbitmq/var ~/rabbitmq_backup/
     $ sudo cp -r /opt/bitnami/rabbitmq/rabbitmq_home ~/rabbitmq_backup
    
  • Download the latest version of RabbitMQ and uncompress it.

     $ tar -xvf rabbitmq-server-generic-unix-3.4.2.tar.g
    
  • Copy the uncompressed folder to /opt/bitnami/rabbitmq:

     $ sudo cp -r rabbitmq_server-3.4.2/* /opt/bitnami/rabbitmq/
    
  • Recover your backup files.

     $ sudo cp -r ~/rabbitmq_backup/* /opt/bitnami/rabbitmq/
    
  • Restart your server.

     $ sudo /opt/bitnami/ctlscript.sh start rabbitmq
    

How to create a full backup of RabbitMQ?

Backup

The Bitnami RabbitMQ Stack is self-contained and the simplest option for performing a backup is to copy or compress the Bitnami stack installation directory. To do so in a safe manner, you will need to stop all servers, so this method may not be appropriate if you have people accessing the application continuously.

Follow these steps:

  • Change to the directory in which you wish to save your backup:

      $ cd /your/directory
    
  • Stop all servers:

      $ sudo /opt/bitnami/ctlscript.sh stop
    
  • Create a compressed file with the stack contents:

      $ sudo tar -pczvf application-backup.tar.gz /opt/bitnami
    
  • Restart all servers:

      $ sudo /opt/bitnami/ctlscript.sh start
    

You should now download or transfer the application-backup.tar.gz file to a safe location.

Restore

Follow these steps:

  • Change to the directory containing your backup:

      $ cd /your/directory
    
  • Stop all servers:

      $ sudo /opt/bitnami/ctlscript.sh stop
    
  • Move the current stack to a different location:

      $ sudo mv /opt/bitnami /tmp/bitnami-backup
    
  • Uncompress the backup file to the original directoryv

      $ sudo tar -pxzvf application-backup.tar.gz -C /
    
  • Start all servers:

      $ sudo /opt/bitnami/ctlscript.sh start
    

If you want to create only a database backup, refer to these instructions for MySQL and PostgreSQL.

How to debug RabbitMQ errors?

To debug RabbitMQ's errors, check the log files of RabbitMQ at /opt/bitnami/rabbitmq/var.

How to change the RabbitMQ user password?

You can modify the RabbitMQ user password by running the following command:

$ sudo rabbitmqctl change_password USER_NAME NEW_PASSWORD
virtualMachine

Bitnami Documentation