Centos6.9 build rabbitmq 3.6.8 cluster

I. Overview

RabbiMQ is developed with Erang, clustering is very convenient, because Erlang is a distributed language by nature, but it does not support Load Balancing.

RabbiMQ mode

The RabbitMQ mode is roughly divided into the following three types:
(1) Single mode.
(2) Normal mode (the default cluster mode).
(3) Mirror mode (make the required queue into a mirror queue, which exists in multiple nodes, belongs to the HA scheme of RabbiMQ, and is more suitable for occasions that require high business reliability).
To realize the mirroring mode, you need to build a common cluster mode first, and then configure the mirroring mode on the basis of this mode to achieve high availability.

RabbiMQ features

The cluster nodes of RabbitMQ include memory nodes and disk nodes. RabbitMQ supports the persistence of messages
That is, the data is written on the disk. The most suitable solution is to have both memory nodes and disk nodes.

2. Formally set up

surroundings

Operating system ip hostname configuration
centos 6.9 192.168.31.7 mq_01 1 core 2g
centos 6.9 192.168.31.216 mq_02 1 core 2g
centos 6.9 192.168.31.214 mq_03 1 core 2g

Note that the three servers here are all connected to the Internet. In addition, the RabbitMQ cluster nodes must be in the same network segment. If it is across the wide area network, the effect will be worse.

Configure the hosts file

Modify host name

Change the computer names of the three MQ nodes to mq_01, mq_02 and mq_03, and then modify the hosts configuration file

vim /etc/hostname

The content is as follows:

mq_01

The other two have the same operation but different content.

Add hosts record

vi /etc/hosts

The content is as follows:

192.168.31.7 mq_01
192.168.31.216 mq_02
192.168.31.214 mq_03

The other two have the same operation and the same content.

In order to make the hostname permanent, restart 3 servers.

reboot -f

Configure yum source

3 Install both servers

yum install -y epel-release

Install erlang

3 Install both servers

wget https://www.rabbitmq.com/releases/erlang/erlang-19.0.4-1.el6.x86_64.rpm
yum install -y socat
rpm -ivh erlang-19.0.4-1.el6.x86_64.rpm

Install rabbitmq-server

3 Install both servers

wget https://www.rabbitmq.com/releases/rabbitmq-server/v3.6.8/rabbitmq-server-3.6.8-1.el6.noarch.rpm
rpm -ivh rabbitmq-server-3.6.8-1.el6.noarch.rpm

Create a directory

3 Run it on both servers

mkdir -p /data/log/rabbitmq
mkdir -p /data/rabbitmq/mnesia
chown -R rabbitmq.rabbitmq -R /data/log/rabbitmq /data/rabbitmq/mnesia

Create configuration file

3 Run it on both servers

vi /etc/rabbitmq/rabbitmq-env.conf

The content is as follows:

RABBITMQ_LOG_BASE=/data/log/rabbitmq
RABBITMQ_MNESIA_BASE=/data/rabbitmq/mnesia

Start rabbit

3 Run it on both servers

/etc/init.d/rabbitmq-server start

Copy erlang.cookie

The Rabbitmq cluster is dependent on the erlang cluster to work, so the erlang cluster must be built first. Each node in the Erlang cluster is implemented through a magic cookie, which is stored in /var/lib/rabbitmq/.erlang.cookie, and the file has a permission of 400. Therefore, it is necessary to ensure that the cookies of each node are consistent, otherwise the nodes cannot communicate.

Log in to the mq_01 node and view erlang.cookie

# cat /var/lib/rabbitmq/.erlang.cookie 
RUIRJRRZDNYEHCCWITRS

Copy the value of the .erlang.cookie of the mq_01 node to the other two nodes by means of scp.

scp /var/lib/rabbitmq/.erlang.cookie [email protected]:/var/lib/rabbitmq/.erlang.cookie

scp /var/lib/rabbitmq/.erlang.cookie [email protected]:/var/lib/rabbitmq/.erlang.cookie

Set permissions, execute the other two

chown -R rabbitmq.rabbitmq /var/lib/rabbitmq/.erlang.cookie
chmod 400/var/lib/rabbitmq/.erlang.cookie

Install plugin

RabbitMQ provides a very friendly graphical monitoring page plug-in (rabbitmq_management), which allows us to see the status of Rabbit or cluster status at a glance.

3 Run it on both servers

rabbitmq-plugins enable rabbitmq_management

View port

netstat -napt|grep 5672

Join the mq01 node cluster

Add mq_02 and mq_03 as memory nodes to the mq01 node cluster

Execute the following commands on mq_02 and mq_03:

Stop the rabbit app

rabbitmqctl stop_app

Join to disk node

rabbitmqctl join_cluster --ram rabbit@mq_01

Start the rabbit app

rabbitmqctl start_app

(1) By default, rabbitmq is a disk node after startup. Under this cluster command, mq02 and mq03 are memory nodes, and mq01 is a disk node.
(2) If you want to make mq02 and mq03 both disk nodes, just remove the --ram parameter.
(3) If you want to change the node type, you can use the command rabbitmqctl change_cluster_node_type disc(ram), provided that the rabbit application must be stopped

View cluster status

3 Every node, execute it

rabbitmqctl cluster_status

Add an administrative user

3 Every node, execute it

rabbitmqctl add_user admin 'admin123'
rabbitmqctl set_permissions -p / admin ...
rabbitmqctl set_user_tags admin administrator

Explanation:

The first command line indicates that the user admin is created, and the password is admin123

The second line of the command indicates that the admin user has configuration, write, and read permissions for all resources of the virtual host as'/'. Note: The following 3 dots indicate these 3 permissions.

The third line of command indicates that the admin user is assigned administrator rights.

Log in to rabbitmq web management console

Open the browser and enter http://192.168.31.7:15672,

Username: admin, password: admin123

After login, the interface as shown in the figure appears.

Reference link for this article:

https://www.cnblogs.com/shihaiming/p/11014257.html

Recommended Posts

Centos6.9 build rabbitmq 3.6.8 cluster
Centos7 build Kubernetes cluster
CentOs7.3 build RabbitMQ 3.6 stand-alone service
CentOS7 install rabbitmq cluster (binary)
CentOs7.3 build SolrCloud cluster service
RabbitMQ cluster deployment record under Centos6.9
Build a PXC cluster under CentOS8
CentOS7 build jenkins
Centos build lnmp
Centos7 build python3.8.5+scrapy+gerapy
centOs install rabbitMQ
centos6.9 rabbitmq 3.6.8 upgrade 3.8.2
(1) Centos7 installation to build a cluster environment
CentOS7.3 64 bit, build Zabbix3.4
CentOS online installation RabbitMQ3.7
CentOS build private git
Linux (centos7) build gitlab
Build k8s1.9.9 on centos7
Build a ScaleIO distributed storage cluster under CentOS7
CentOS6.7 build LNMP environment
CentOS7.3.1611 deploys k8s1.5.2 cluster
CentOS6 install couchdb2 cluster
Centos7.6 build LNMP environment
Install RabbitMQ on CentOS 7
CentOS 7 deploys RabbitMQ service
CentOS 6.8 deploy zookeeper cluster
Centos7 mqtt cluster installation
Jenkins build on centos
Build Hadoop in CentOS
CentOS cluster related issues
Centos7 deploys Kubernetes cluster
Centos7 build DNS service
install RabbitMQ on centos
Install RabbitMQ on CentOS 7
CentOS online installation RabbitMQ3.7
CentOS7 deploys k8s cluster
Install RabbitMQ on CentOS7
CentOS 7 build LNMP environment
Build docker environment under Centos6.5
CentOs7.3 build Solr stand-alone service
Build OpenV** Server under CentOS7
Build zabbix monitoring zabbix4.2 in CentOS7.6
Centos7.4 deployment configuration Elasticsearch5.6 cluster
Build OpenLDAP server under CentOS7
Glusterfs cluster installation on Centos7
Redis cluster installation under CentOS
Build zabbix monitoring zabbix4.2 in CentOS7.6
CentOS 7 Galera Cluster installation guide
Centos7.2/7.3 cluster install Kubernetes 1.8.4 + Dashboard
Build MariaDB replication on CentOS
CentOs7.3 build ZooKeeper-3.4.9 stand-alone service
Redis cluster installation under CentOS
centos6.9 rabbitmq set up SSL
Centos7 install k8s cluster 1.15.0 version
CentOS 6 automatically installs RabbitMQ script
First try to build a Ceph storage cluster on Centos7
CentOS 8 (2)
CentOS8.1 build Gitlab server detailed tutorial
Centos7 hadoop cluster installation and configuration
Elasticsearch cluster deployment record under CentOS7
Centos6 method steps to build gitlab