RABBITMQ cluster deployment configuration under Linux CentOS6.5

Source: Internet
Author: User
Tags node server rabbitmq

First, server and host name list

Environment: 2 Linux hosts, hostname and IP as follows, RABBITMQ execution user is RABBITMQ, owning group is RABBITMQ ecs003 ecs004

Second, on a node server to do the hosts parse

#cat >>/etc/hosts< ecs003 ecs004


Third, install RABBITMQ at each node

1. Install Epel source and Rabbit-relang source

[email protected]:~# wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

[Email protected]:~# rpm-ivh epel-release-6-8.noarch.rpm

[email protected]:~# wget-o/etc/yum.repos.d/epel-erlang.repo [email protected]:~# Http://repos.fedorapeople.org/repos/peter/erlang/epel-erlang.repo

2. Installing Erlang

[Email protected]:~# yum install Erlang Xmlto git-y


3, Installation RABBITMQ

[Email protected]:~# wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.5.6/rabbitmq-server-3.5.6-1.noarch.rpm

[email protected]:~ #rpm-IVH rabbitmq-server-3.5.6-1.noarch.rpm

Perform the same installation operation on the ecs0004

4. RABBITMQ page (web) management

To enable the Web plugin:

[Email protected]:~# rabbitmq-plugins Enable Rabbitmq_management

Close the Web plugin

[email protected]:~#rabbitmq-plugins Disable rabbitmq_management

can use the default account guest,guest login http:// host ip:15672, if you want to telnet, you need to create an account, because it is a cluster, so long as a host set up, the others will automatically sync.

[email protected]:~# rabbitmqctl add_user dtom 123456 #dtom为新建的用户, 123456 for password

[email protected]:~# rabbitmqctl set_user_tags dtom Administrator #将用户设置为管理员角色

[email protected]:~# rabbitmqctl set_permissions-p/IOM " . *". * "". * "#在/Virtual host settings dtom User Configuration permissions, write permissions, read Permissions: * is the usage in regular expressions. The permissions of RABBITMQ are configured according to different virtual hosts, which may not be the same as users in different virtual hosts (Vsan).

5, start each node rabiitmq, and verify the startup situation

[Email protected]:~# rabbitmq-server--detached &

[Email protected]:~# ps-aux |grep RABBITMQ

Four, RABBITMQ cluster environment configuration

A RABBITMQ cluster can share user,virtualhosts,queues (open highly Available queues), exchanges, and so on. But the message is only transmitted on the node that was created. When the message enters the A-node queue, consumer pulls from the B-node, RABBITMQ temporarily transmits the message between A and B, takes the message entity in a and sends it to the consumer by B. So consumer should try to connect to each node and fetch messages from it.

RABBITMQ cluster nodes include memory nodes, disk nodes. The memory node's metadata is only placed in memory, and performance is higher than the disk node. However, if message persistence is turned on when message is posted, the performance of memory nodes can only be reflected in resource management, such as adding or removing queues (queue), virtual hosts (vrtual hosts), switches (Exchange), etc. Send and receive message speeds as with disk nodes. A cluster must have at least one disk node.

Cluster Environment Description:

ecs003 as a disk node, ecs004 as a memory node

1. Synchronous Erlang.cookie

Kill ecs004 's RABBITMQ process

[Email protected]:~#/etc/rabbitmq# ps-ef|grep Rabbitmq|awk ' {print $} ' |xarge kill-9

2, login ecs003 machine, execute:

[Email protected]:~# cd/var/lib/rabbitmq/

[email protected]:~# /var/lib/rabbitmq# SCP. Erlang.cookie [Email protected]:/var/lib/rabbitmq/

Start RABBITMQ on the ecs004

[Email protected]:~#/etc/rabbitmq# rabbitmq-server--detached & or/etc/init.d/rabbitmq-server start

3. Join the Cluster

View ecs003 cluster status

[email protected]:~# /var/lib/rabbitmq# rabbitmqctl cluster_status

Cluster Status of node [email protected] ...

[{Nodes,[{disc,[[email protected]}]},

{Running_nodes,[[email protected]]},

{cluster_name,<< "[email protected]" >>},


4, ecs004 join ecs003 cluster:

[email protected]:~# rabbitmqctl stop_app #关闭ecs004中rabbitmq服务

[Email protected]:~# rabbitmqctl Stop_app #初始化node状态, the node is removed from the cluster and all data is removed from the management database, such as vhosts, and so on. The RABBITMQ application must be stopped before initialization

[email protected]:~# /etc/rabbitmq# rabbitmqctl join_cluster [email protected] #ecs004加入ecs003集群

clustering node [email protected] with [email protected] ...

[email protected]:~# /etc/rabbitmq# rabbitmqctl Start_app #启动rabbitmq服务

starting node [email protected] ...

RabbitMQ 3.5.6. Copyright (C) 2007-2015 Pivotal Software, Inc.

# # # # # Licensed under the MPL. See http://www.rabbitmq.com/

##  ##

########## Logs:/var/log/rabbitmq/[email protected]

###### # #/var/log/rabbitmq/[email protected]


Starting broker ... completed with 6 plugins.

[email protected]:~# /var/lib/rabbitmq# rabbitmqctl cluster_status #再次查看集群状态

Cluster Status of node [email protected] ...

[{nodes,[{disc,[[email protected]]},{ram,[[email protected]}]},

{running_nodes,[[email protected],[email protected]},

{cluster_name,<< "[email protected]" >>},


– The first row is a node member in the cluster, disc indicates that these are disk nodes, and RAM is represented as memory nodes.

– The second row is a node member that is running

5. Change node Properties:

[email protected]:~# rabbitmqctl Stop_app – Stop RABBITMQ service

[email protected]:~# rabbitmqctl change_cluster_node_type disc/ram – Change node to disk or memory node

[Email protected]:~# rabbitmqtl start_app– Open RABBITMQ Service

6, RABBITMQ exit the cluster

Suppose you want to ecs004 out of the cluster and execute it on ecs004:

[Email protected]:~# rabbitmqctl Stop_app

[Email protected]:~# rabbitmqctl Reset

[Email protected]:~# rabbitmqctl Start_app

Execute on the cluster master node

[email protected]:~# rabbitmqctl forget_cluster_node [email protected]ecs004

7. RABBITMQ Cluster restart

When the cluster restarts, the last node that is hung up should be the first reboot, if for a special reason (such as a power outage at the same time), without knowing which node is the last one to hang up. The following methods can be used to restart:

Execute on one node first

#rabbitmqctl Force_boot

#service rabbitmq-server Start

Execute on other nodes

#service rabbitmq-server Start

See if the cluster status is normal (to query on all nodes).

#rabbitmqctl Cluster_status

If a node does not join the cluster, you can first exit the cluster and then rejoin the cluster.

Note: The above method is not suitable for the memory node restart, the memory node restarts when the disk node to synchronize data, if the disk node is not up, the memory node has failed.

Five, matters needing attention

    • The cookie must be exactly the same on all nodes and must be noted when synchronizing.

    • Erlang connects the service through the hostname, and must ensure that each host name can be ping-through. You can manually add host names and IP correspondence by editing/etc/hosts. If the hostname ping is not available, the RABBITMQ service startup will fail.

    • If the queue is a non-persistent queue, if the node that created the queue fails, the sender and receiver can create the same queue to continue working. However, if the queue is persisted, the service can only continue until the node that created the queue resumes.

    • Disk node is required to be online when the cluster metadata is changed, but all disk nodes must be online when the node joins or exits. If you do not exit disk node correctly, the cluster will assume that the node is down and do not join other nodes until the node is restored.

Six, the installation process encountered error resolution:

Join rabbit cluster times wrong-error:mnesia_unexpectedly_running

[Email protected]:~# Rabbitmqctl Stop_app

[Email protected]:~# Rabbitmqctl Reset

[email protected]:~#rabbitmqctl cluster [email protected]

[Email protected]:~# Rabbitmqctl Start_app

This article is from the "Dotlim blog" blog, make sure to keep this source http://dotlim.blog.51cto.com/12633007/1956374

RABBITMQ cluster Deployment configuration under Linux CentOS6.5

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.