RabbitMQ is a popular open-source message broker. You can run RabbitMQ on your Opalstack account with the following steps:
- Create a new shell user then log in to SSH and run the following commands:
mkdir -p ~/tmp ~/src ~/lib
export TMPDIR=~/tmp
export PATH=$HOME/bin:$PATH
Create a 'nginx proxy port' application named 'epmd' in the dashboard to reserve a port for epmd. (11111 in the examples below)
Create a 'nginx proxy port' application named 'rabbitmq' in the dashboard to reserve a port for RabbitMQ. (22222 in the examples below)
Install Erlang and run epmd:
cd ~/src
wget http://erlang.org/download/otp_src_26.2.1.tar.gz
tar zxf otp_src_26.2.1.tar.gz
cd otp_src_26.2.1
./configure --prefix=$HOME
make
make install
epmd -port 11111 -daemon
- Install RabbitMQ:
cd ~/src
wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.12.12/rabbitmq-server-generic-unix-3.12.12.tar.xz
tar xf rabbitmq-server-generic-unix-3.12.12.tar.xz
ln -s $PWD/rabbitmq_server-3.12.12 ~/lib/erlang/lib/
- Set CONFIG_FILE, LOG_BASE, and MNESIA_BASE in
~/src/rabbitmq_server-3.12.12/sbin/rabbitmq-defaults
(replace username with your username)
CONFIG_FILE=/home/username/src/rabbitmq_server-3.12.12/sbin/
LOG_BASE=/home/username/logs/apps/rabbitmq
MNESIA_BASE=/home/username/src/rabbitmq_server-3.12.12/sbin/
- Set your epmd and RabbitMQ ports at end of
~/src/rabbitmq_server-3.12.12/sbin/rabbitmq-env
:
export ERL_EPMD_PORT=11111
export RABBITMQ_NODE_PORT=22222
export ERL_INETRC=$HOME/.erl_inetrc
- Create
~/hosts
with the following contents (replace opalNN with your server hostname):
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
127.0.0.1 opalNN opalNN.opalstack.com
- Create
~/.erl_inetrc
with the following contents (replace username with your username):
{hosts_file, "/home/username/hosts"}.
{lookup, [file,native]}.
- Test RabbitMQ:
~/src/rabbitmq_server-3.12.12/sbin/rabbitmq-server -detached
~/src/rabbitmq_server-3.12.12/sbin/rabbitmqctl status
- Secure your RabbitMQ by creating a user for it and removing guest access (replace username, password, and vhostname with whatever you want to use):
~/src/rabbitmq_server-3.12.12/sbin/rabbitmqctl add_user <username> <password>
~/src/rabbitmq_server-3.12.12/sbin/rabbitmqctl set_user_tabs <username> administrator
~/src/rabbitmq_server-3.12.12/sbin/rabbitmqctl add_vhost <vhostname>
~/src/rabbitmq_server-3.12.12/sbin/rabbitmqctl set_permissions -p <vhostname> <username> ".*" ".*" ".*"
~/src/rabbitmq_server-3.12.12/sbin/rabbitmqctl clear_permissions -p <vhostname> guest
That's it - RabbitMQ is now up and running on its assigned port.