Skip to content

Rabbitmq deployment guide

1. Prepare Environment

  1. rabbitmq-server-generic-unix-3.6.15.tar.xz
  2. otp_src_19.3.tar.gz

2. Install Erlang

  1. Downlaod Erlang source code(otp_src_19.3.tar.gz), and extract to /data/fate/projects/common
tar -zxvf otp_src_19.3.tar.gz  -C /data/projects/fate/common
  1. Configure ERL_TOP
cd  /data/projects/fate/common/otp_src_19.3/
export ERL_TOP=`pwd`
  1. Compile

Use the following command:

./configure --prefix=/data/projects/fate/common/erlang
make
make install

If error **No curses library functions found**raised, please install ncuress; first downlaod ncurses-6.0.tar.gz

tar -zxvf ncurses-6.0.tar.gz
cd ncurses-6.0
./configure --with-shared --without-debug --without-ada --enable-overwrite  
make
make install (If error Permission denied is raised, execute with root priviliges)
  1. Set Environment Variable

After compilation, edit ERL_HOME. Edit file /etc/profile, add the following:

cat >> /etc/profile << EOF
export ERL_HOME=/data/projects/fate/common/erlang
export PATH=$PATH:/data/projects/fate/common/erlang/bin
EOF
  1. Check

run command: erl

If successfully entering Erlang environemnt, installation is success.

3. Install RabbitMQ

  1. Download RabbitMq Server and extract to /data/projects/common
xz -d rabbitmq-server-generic-unix-3.6.15.tar.xz
tar xvf rabbitmq-server-generic-unix-3.6.15.tar  -C /data/projects/fate/common
  1. Start standalone RabbitMQ, generate cookie
cd /data/projects/fate/common/rabbitmq_server-3.6.15 && ./sbin/rabbitmq-server -detached
  1. Change File Permissions

Set cookie file permission to 400:

chmod -R 400 .erlang.cookie 
  1. Cluster Deploy

  2. Follow step 1-3 for all hosts

  3. Synchronise cookie:

    After installation by the above steps, Erlang cookie file should locate at /home/app/.erlang.cookie

    Copy cookie from any host in the cluster to other hosts to replace original cookies
    
  4. Cluster Start:

    Based on mq1

    (1) Stop Erlang node for mq2, mq3

    sbin/rabbitmqctl stop
    

​ (2) Start Erlang node for mq2, mq3

```bash

​ sbin/rabbitmq-server -detached ```

​ (3) Stop the RabbitMQ application on mq2、mq3

 ```bash
sbin/rabbitmqctl stop_app
 ```

​ (4) Join mq2, mq3 to mq1 as a cluster

​ On mq2、mq3 run:

 ```bash
 sbin/rabbitmqctl join_cluster rabbit@mq1
 ```

​ (5) Start the RabbitMQ application mq2, mq3 ​

### 4. rabbitmq configuration

  1. Check cluster status
 rabbitmqctl cluster_status
  1. Enable federation (enable/disable):
 rabbitmq-plugins enable rabbitmq_management
 rabbitmq-plugins enable rabbitmq_federation
 rabbitmq-plugins enable rabbitmq_federation_management  
  1. Add user:

 rabbitmqctl add_user fate fate
4. Add role:

 rabbitmqctl set_user_tags fate administrator
  1. Set permissions:
 rabbitmqctl set_permissions -p / fate ".*" ".*" ".*" 

Last update: 2023-06-14