Skip to content

Instantly share code, notes, and snippets.

@mikeblum
Created January 30, 2017 15:47
Show Gist options
  • Save mikeblum/19185836bedf98803ac8b706a24a6d0b to your computer and use it in GitHub Desktop.
Save mikeblum/19185836bedf98803ac8b706a24a6d0b to your computer and use it in GitHub Desktop.
Clustered RabbitMQ installation
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
# config.vm.box = "bento/ubuntu-16.04"
config.vm.box = "ubuntu/trusty64"
# RabbitMQ ports
config.vm.network :forwarded_port, guest: 5672, host: 5672
config.vm.network :forwarded_port, guest: 5673, host: 5673
config.vm.network :forwarded_port, guest: 15672, host: 15672
config.vm.network :forwarded_port, guest: 15673, host: 15673
# Enable provisioning with a shell script. Additional provisioners such as
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
# documentation for more information about their specific syntax and use.
config.vm.provision "shell", inline: <<-SHELL
echo 'deb http://www.rabbitmq.com/debian/ testing main' |
sudo tee /etc/apt/sources.list.d/rabbitmq.list
wget -O- https://www.rabbitmq.com/rabbitmq-release-signing-key.asc |
sudo apt-key add -
sudo apt-get update
sudo apt-get install -q -y screen htop vim curl wget
sudo apt-get install -q -y rabbitmq-server
# RabbitMQ Plugins
sudo service rabbitmq-server stop
# create a two-node cluster
sudo RABBITMQ_NODE_PORT=5672 RABBITMQ_SERVER_START_ARGS="-rabbitmq_management listener [{port,15672}]" RABBITMQ_NODENAME=rabbit su root -c 'rabbitmq-server -detached'
sudo RABBITMQ_NODE_PORT=5673 RABBITMQ_SERVER_START_ARGS="-rabbitmq_management listener [{port,15673}]" RABBITMQ_NODENAME=tortoise su root -c 'rabbitmq-server -detached'
# stop secondary node
sudo rabbitmqctl -n tortoise stop_app
# join the cluster
sudo rabbitmqctl -n tortoise join_cluster rabbit@`hostname -s`
sudo rabbitmqctl -n tortoise start_app
# create a test user since guest/guest login is disabled for the RabbitMQ admin
sudo rabbitmqctl add_user test test
sudo rabbitmqctl set_user_tags test administrator
sudo rabbitmqctl set_permissions -p / test ".*" ".*" ".*"
sudo rabbitmq-plugins enable rabbitmq_management
# start nodes
sudo rabbitmq-plugins list
SHELL
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment