Using RabbitMQ on EC2 is no more complex than running it on other platforms. Although we don't support our own AMI images, we make sure that RabbitMQ does work on current Ubuntu AMIs.
First, you need to choose what instance type to run. RabbitMQ will work on every instance type, but there are a few considerations worth bearing in mind:
Although RabbitMQ is tested with most major Linux distributions, Ubuntu support for Amazon EC2 seems to be strongest. You can get the list of Ubuntu AMI images here:
http://uec-images.ubuntu.com/releases/
You may find more information
in Ubuntu
EC2 Starters Guide.
Ubuntu ships with RabbitMQ but it's often not the latest version. If you want the recent version, you may use our Debian repository. Here is a shell script rabbitmq-user-data.sh that automates RabbitMQ installation on Ubuntu:
#!/bin/sh cat <<EOF > /etc/apt/sources.list.d/rabbitmq.list deb http://www.rabbitmq.com/debian/ testing main EOF curl http://www.rabbitmq.com/rabbitmq-signing-key-public.asc -o /tmp/rabbitmq-signing-key-public.asc apt-key add /tmp/rabbitmq-signing-key-public.asc rm /tmp/rabbitmq-signing-key-public.asc apt-get -qy update apt-get -qy install rabbitmq-server
Instead of running it manually, you can tell the instance to run this script automatically during the first start. You can do it using the user-data-file command line option for the ec2-run-instances command. For example:
$ ec2-run-instances ami-XXX \
--key ${EC2_KEYPAIR} \
--instance-type m1.large \
--region eu-west-1 \
--user-data-file rabbitmq-user-data.sh
Put your chosen AMI id in the place of ami-XXX. The
string ${EC2_KEYPAIR} should be replaced with the
public ssh keypair name that is going to be used to log in to
the instance. You can find more information
about ec2-run-instances command in
EC2 Getting Started Guide.
RabbitMQ writes data to the following directories on Ubuntu:
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
RabbitMQ names the database directory using the current hostname of the system. If the hostname changes, a new empty database is created. To avoid data loss it's crucial to set up a fixed and resolvable hostname. For example:
sudo -s # become root echo "rabbit" > /etc/hostname echo "127.0.0.1 rabbit" >> /etc/hosts hostname -F /etc/hostnameWhenever the hostname changes you should restart RabbitMQ:
$ /etc/init.d/rabbitmq-server restart
Once RabbitMQ has been started, confirm that it actually works. You can do this by installing the RabbitMQ Java client and running the test scripts that come with it. Use the following instructions to install the required packages on the instance:
apt-get install openjdk-6-jre
curl http://www.rabbitmq.com/releases/rabbitmq-java-client/v3.1.0/rabbitmq-java-client-bin-3.1.0.tar.gz \
-o rabbitmq-java-client-bin-3.1.0.tar.gz
tar xzf rabbitmq-java-client-bin-3.1.0.tar.gz
cd rabbitmq-java-client-bin-3.1.0
When the dependencies are available, you can run the test:
rabbitmq:~/rabbitmq-java-client-3.1.0$ sh ./runjava.sh com.rabbitmq.examples.MulticastMain
On the screen you should see output similar to this:
starting consumer #0 starting producer #0 recving rate: 2920 msg/s, min/avg/max latency: 13431/137515/349586 microseconds sending rate: 7182 msg/s recving rate: 4513 msg/s, min/avg/max latency: 352244/535973/715864 microseconds sending rate: 4897 msg/s recving rate: 4119 msg/s, min/avg/max latency: 654393/829167/1021911 microseconds sending rate: 4989 msg/s
If you have any comments please let us know.