RabbitmQ Master & Slave Installation Documents:
apt-get update
apt-get install rabbitmq-server
Enable the plugin - cd /etc/rabbitmq - rabbitmq-plugins enable rabbitmq_management
Master:
vi /etc/rabbitmq/rabbitmq-env.conf
NODENAME=rabbit@rabbitmaster (must be unique, can be arbitrary)
chown rabbitmq:rabbitmq /etc/rabbitmq/*
chmod 400 /etc/rabbitmq/*
vi /etc/hosts - add the following line (must match the content after "@" in the rabbitmq-env.conf NODENAME
127.0.0.1 rabbitmaster
systemctl restart rabbitmq-server - a success message is displayed when the restart completes successfully.
Slave:
vi /etc/rabbitmq/rabbitmq-env.conf
NODENAME=rabbit@rabbitslave
vi /etc/hosts - add the following lines:
Note: 192.168.7.* is the local IPv4 address of the master server (e.g., 192.x.x.x)
192.168.7.* rabbitmaster
127.0.0.1 rabbitslave
sudo chown rabbitmq:rabbitmq /etc/rabbitmq/*
ls -a - show the hidden files & folders
ls -la - show the hidden files & folders with permission
execute below commands in master to slave
before copying please take .erlang.cookie in slave server.
scp -r /var/lib/rabbitmq/.erlang.cookie root@192.168.7.189:/var/lib/rabbitmq/
chown rabbitmq:rabbitmq /var/lib/rabbitmq/.erlang.cookie
chmod 600 /var/lib/rabbitmq/.erlang.cookie
systemctl restart rabbitmq-server
execute below commands in master
systemctl restart rabbitmq-server
rabbitmqctl start_app
Before this step, you have to reboot your slave servers. Run this at all slave nodes;
systemctl status rabbitmq-server
rabbitmqctl stop_app
rabbitmqctl reset
rabbitmqctl join_cluster rabbit@rabbitmaster
rabbitmqctl start_app
Execute the below commands in master server
Verify the cluster with running this command at master node;
rabbitmqctl cluster_status
Adding new administrator user
Add a new/fresh user, say user ‘test’ and password ‘test’
rabbitmqctl add_user test test
Give administrative access to the new user
rabbitmqctl set_user_tags test administrator
Set permission to newly created user
rabbitmqctl set_permissions -p / test ".*" ".*" ".*"
HA Queues
To make all queues HA run this command at master. With this policy enabled RabbitMQ sync all queues to all nodes.
rabbitmqctl set_policy ha-all "" '{"ha-mode":"all","ha-sync-mode":"automatic"}'
apt-get update
apt-get install rabbitmq-server
Enable the plugin - cd /etc/rabbitmq - rabbitmq-plugins enable rabbitmq_management
Master:
vi /etc/rabbitmq/rabbitmq-env.conf
NODENAME=rabbit@rabbitmaster (must be unique, can be arbitrary)
chown rabbitmq:rabbitmq /etc/rabbitmq/*
chmod 400 /etc/rabbitmq/*
vi /etc/hosts - add the following line (must match the content after "@" in the rabbitmq-env.conf NODENAME
127.0.0.1 rabbitmaster
systemctl restart rabbitmq-server - a success message is displayed when the restart completes successfully.
Slave:
vi /etc/rabbitmq/rabbitmq-env.conf
NODENAME=rabbit@rabbitslave
vi /etc/hosts - add the following lines:
Note: 192.168.7.* is the local IPv4 address of the master server (e.g., 192.x.x.x)
192.168.7.* rabbitmaster
127.0.0.1 rabbitslave
sudo chown rabbitmq:rabbitmq /etc/rabbitmq/*
ls -a - show the hidden files & folders
ls -la - show the hidden files & folders with permission
execute below commands in master to slave
before copying please take .erlang.cookie in slave server.
scp -r /var/lib/rabbitmq/.erlang.cookie root@192.168.7.189:/var/lib/rabbitmq/
chown rabbitmq:rabbitmq /var/lib/rabbitmq/.erlang.cookie
chmod 600 /var/lib/rabbitmq/.erlang.cookie
systemctl restart rabbitmq-server
execute below commands in master
systemctl restart rabbitmq-server
rabbitmqctl start_app
Before this step, you have to reboot your slave servers. Run this at all slave nodes;
systemctl status rabbitmq-server
rabbitmqctl stop_app
rabbitmqctl reset
rabbitmqctl join_cluster rabbit@rabbitmaster
rabbitmqctl start_app
Execute the below commands in master server
Verify the cluster with running this command at master node;
rabbitmqctl cluster_status
Adding new administrator user
Add a new/fresh user, say user ‘test’ and password ‘test’
rabbitmqctl add_user test test
Give administrative access to the new user
rabbitmqctl set_user_tags test administrator
Set permission to newly created user
rabbitmqctl set_permissions -p / test ".*" ".*" ".*"
HA Queues
To make all queues HA run this command at master. With this policy enabled RabbitMQ sync all queues to all nodes.
rabbitmqctl set_policy ha-all "" '{"ha-mode":"all","ha-sync-mode":"automatic"}'
No comments:
Post a Comment