http://linuxpitstop.com/rabbitmq-cluster-on-centos-7
In this article we are going to setup RabbitMQ Cluster on CentOS 7 Operating system. RabbitMQ is an Open Source message-queuing software called a message broker or queue manager. We can say , it is a software where queues can be defined, applications may connect to the queue and transfer a message onto it. The queue-manager software stores the messages until a receiving application connects and takes a message off the queue. The receiving application then processes the message in an appropriate manner. A message can include any kind of information for example, it could have information about a process/task that should start on another application may be on another server or it could be just a simple text message.
It is a fast, nimble, and resilient messaging system that just keeps going and going. If you’re interested in the Internet of Things, you must need to catch onto Rabbit MQ.
In this article we will be using two Linux CentOS 7 servers with following host names.
RabbitMQ Master Server:
RabbitMQ Slave Server:
Make sure that your both servers are date with latest updates and
patches by running the following command with root or sudo user
privileges.
Once the EPEL release has been installed on your system, then you can install Erlang on CentOS 7 by issuing the following command.
after resolving the dependencies, you will be asked to proceed or not. Press ‘y’ key and hit enter to continue. This will install Erlang and its all required dependencies on your system as shown.
Let’s copy the download source address and run the following ‘wget’ command to download the RPM package on your system.
Then run the command below to install the RabbitMQ RPM package on your system.
Now we have installed RabbitMQ server on both of our nodes. start is service and check the status using below commands.
You might the below error , run the below command and check the status again.
Once you have restarted RabbitMQ services you should see the following output on both nodes.
In our case we will using out ‘linux’ node. There’s a cookie file which resides on each one of the nodes, but in order to join all nodes into a cluster, this cookie file needs to be identical on all machines in the cluster, use the cookie file from the Master node and copy it to the rest of the nodes.
You can find this under below path.
Sample output:
Now copy this key o all of your current node that you want to join
with the cluster and change its permissions using the follow commands.
Now we will run the commands to join each node to the cluster using below command
In order to check the status of your cluster run the below command.
OR
Here is the sample output:
You can do the same by going to the directory where the RabbitMQ is installed.
The rabbitmq_management plugin is a combination of the following
plugins. All of the following plugins will be enabled when you execute
the above command:
http://your_servers_ip:15672/
The default user name and passowrd of RabbitMQ Management console sn ‘guest’, ‘guest’ . But you can also create new admin user using below commands.
After providing the right credentials you be directed towards the RabbitMQ Dashboard where you can configure and utilize it awesome features.
In this article we are going to setup RabbitMQ Cluster on CentOS 7 Operating system. RabbitMQ is an Open Source message-queuing software called a message broker or queue manager. We can say , it is a software where queues can be defined, applications may connect to the queue and transfer a message onto it. The queue-manager software stores the messages until a receiving application connects and takes a message off the queue. The receiving application then processes the message in an appropriate manner. A message can include any kind of information for example, it could have information about a process/task that should start on another application may be on another server or it could be just a simple text message.
It is a fast, nimble, and resilient messaging system that just keeps going and going. If you’re interested in the Internet of Things, you must need to catch onto Rabbit MQ.
Prerequisites
The basic requirement for RabbitMQ Cluster setup is to have minimum 2 nodes with CentOS 7 that we will using in this articles. Setup their FQDN and basic network settings and make sure that you are connected to the Internet.In this article we will be using two Linux CentOS 7 servers with following host names.
RabbitMQ Master Server:
[root@linux ~]# hostname
linux
linux
[root@node2 ~]# hostname
node2
node2
yum -y update
Installing ERLANG
After basic system setup, we are going to start installation of RabbitMQ’s main dependencies such Erlang. To install Erlang on our system, we will be using the latest EPEL repository. Let’s run the following command to install the latest EPEl release.
yum install epel-release
Once the EPEL release has been installed on your system, then you can install Erlang on CentOS 7 by issuing the following command.
yum install erlang
after resolving the dependencies, you will be asked to proceed or not. Press ‘y’ key and hit enter to continue. This will install Erlang and its all required dependencies on your system as shown.
Installing RabbitMQ
After completing the installation of Erlang, now we are going to install RabbitMQ using its latest RPM package available on RabbitMQ Resource Page.Let’s copy the download source address and run the following ‘wget’ command to download the RPM package on your system.
wget https://www.rabbitmq.com/releases/rabbitmq-server/v3.6.1/rabbitmq-server-3.6.1-1.noarch.rpm
rpm -i rabbitmq-server-3.6.1-1.noarch.rpm
Now we have installed RabbitMQ server on both of our nodes. start is service and check the status using below commands.
rabbitmqctl status
/etc/init.d/rabbitmq-server restart
rabbitmqctl status
RabbitMQ Cluster Setup:
In order to create a RabbitMQ cluster, first choose your fisrt node which is going to be the Master.In our case we will using out ‘linux’ node. There’s a cookie file which resides on each one of the nodes, but in order to join all nodes into a cluster, this cookie file needs to be identical on all machines in the cluster, use the cookie file from the Master node and copy it to the rest of the nodes.
You can find this under below path.
[root@linux ~]# cat /var/lib/rabbitmq/.erlang.cookie
SVTRZKAOOADLOJQAOBJQ
chown rabbitmq:rabbitmq /var/lib/rabbitmq/*
chmod 400 /var/lib/rabbitmq/.erlang.cookie
rabbitmqctl stop_app
rabbitmqctl join_cluster --ram rabbit@node_name
rabbitmqctl start_app
rabbitmqctl cluster_status
/usr/sbin/rabbitmqctl cluster_status
Cluster status of node rabbit@node2 ...
[{nodes,[{disc,[rabbit@node2]}]},
{running_nodes,[rabbit@node2]},
{cluster_name,<>},
{partitions,[]},
{alarms,[{rabbit@linux,[]}]}]
[{nodes,[{disc,[rabbit@node2]}]},
{running_nodes,[rabbit@node2]},
{cluster_name,<>},
{partitions,[]},
{alarms,[{rabbit@linux,[]}]}]
Enable RabbitMQ Management Plugin
Our RabbitMQ Cluster has been installed and setup using two CentOS 7 nodes, let’s run the following commands to enable RabbitMQ management plugin.
rabbitmq-plugins enable rabbitmq_management
chown -R rabbitmq:rabbitmq /var/lib/rabbitmq/
You can do the same by going to the directory where the RabbitMQ is installed.
cd /usr/lib/rabbitmq/lib/rabbitmq_server-3.6.1
sbin/rabbitmq-plugins enable rabbitmq_management
- mochiweb
- webmachine
- rabbitmq_web_dispatch
- amqp_client
- rabbitmq_management_agent
- rabbitmq_management
sbin/rabbitmqctl stop
sbin/rabbitmq-server -detached
RabbitMQ Web Management:
Now you access your RabbitMQ server from any of your web browser with mentioned below port.http://your_servers_ip:15672/
The default user name and passowrd of RabbitMQ Management console sn ‘guest’, ‘guest’ . But you can also create new admin user using below commands.
rabbitmqctl add_user mqadmin mqadmin
rabbitmqctl set_user_tags mqadmin administrator
rabbitmqctl set_permissions -p / mqadmin ".*" ".*" ".*"
After providing the right credentials you be directed towards the RabbitMQ Dashboard where you can configure and utilize it awesome features.
No comments:
Post a Comment