RabbitMq mirrored high availability clustering mode

A, rabbitmq has three modes, but the cluster model are two kinds.

Single mode: a stand-alone operation rabbitmq only, without any cluster

Normal mode: the default cluster mode to two points (rabbit01, rabbit02) as an example. For the queue, the message entity exists only in one of the nodes rabbit01, rabbit01 and rabbit02 two nodes have the same data. When the message queue node into the rabbit01, if the consumer from the consumer node 2, the temporarily rabbitmq message transmission between rabbit01, rabbit02, the entity A is removed and the message is sent to B via consumer. Therefore, a consumer should be connected to each of the nodes from which messages take. I.e., a logical queue for the same, to create a plurality of nodes in the physical queue. Otherwise, whether consumer or even rabbit01 rabbit02, total exports in rabbit01, create a bottleneck. When rabbit01 node failure, rabbit02 nodes should be taken to message entities rabbit01 node has not consumed. If you make the message persistence, then have to wait rabbit01 node recovery before it can be consumed; if not persistent, it would generate a message to be lost

Mirror Mode: Normal mode-based cluster, you can add a mirror strategies in the policy inside. The need to make a mirror queue queues belonging HA solutions. The model solves the problem in the normal mode, the fundamental difference is that the entity will automatically synchronize messages between the mirror node, rather than the temporary pull when the client pull data. Of course, the drawbacks is that degrade system performance, a large number of write messages, network bandwidth within the cluster will be greatly consumed.

Second, the node type:

1.RAM Node
memory node, all the queues, switches, binding, vhost user rights and metadata stored in memory, you can make the switch statement queue and more convenient.
2. Disk Node
when the metadata stored on disk, single-node system, just run Disk types of nodes, preventing the restart RabbitMQ, loss of configuration information system

Three, the ErLang Cookie
the ErLang Cookie is to ensure that share the same Cookie, cluster deployment time communication between different nodes between different nodes, you need to copy the data to a different node, so that the same cookie.

Fourth, the installation service

1.安装erlang
# wget http://www.rabbitmq.com/releases/erlang/erlang-18.1-1.el6.x86_64.rpm
# rpm -ivh erlang-18.1-1.el6.x86_64.rpm 
 确认erlang安装成功
# erl
2.安装rabbitmq-server
# wget https://github.com/rabbitmq/rabbitmq-server/releases/download/rabbitmq_v3_6_12/rabbitmq-server-3.6.12-1.el6.noarch.rpm
# yum install -y socat
# rpm -ivh rabbitmq-server-3.6.12-1.el6.noarch.rpm
4.安装插件管理 【http://ip:55672】
# rabbitmq-plugins enable rabbitmq_management
5.启动服务
# rabbitmq-server -deched

V. Cluster Setup
1. Copy the files under 1 .eralang.cookie illustrated catalog node to other nodes rabbit, because they are certified unified communications clusters Based on this cookie.
Here Insert Picture Description
2. Configure command

主服务节点配置命令
rabbitmqctl stop_app 
rabbitmqctl reset
rabbitmqctl start_app

这个是用来在node1上执行的,这个也可以不执行,直接在节点服务器执行下边的脚本,不过得保证这个rabbitmq服务是正常启动的.

节点服务配置命令
rabbitmqctl stop_app
rabbitmqctl reset
rabbitmqctl join_cluster --ram rabbit@node1
rabbitmqctl start_app

和主服务配置脚本的唯一区别是多了第三行的内容,其中--ram指的是作为内存节点,之前已经讲述了内存节点和磁盘节点的优缺点,要是想做为磁盘节点的话,就去掉--ram这个参数了,把第3行写成这样就好了
rabbitmqctl join_cluster  rabbit@node1
若执行这条命令,则node2将成为磁盘节点加入集群
PS:只要在节点列表里包含了本身,它就成为一个磁盘节点。在RabbitMQ集群里,必须至少有一个磁盘节点存在

先执行主节点上的命令,等待执行完成之后再执行服务节点的脚本,顺序不要错了哦~

执行完之后分别在每台机器上查看节点状态
rabbitmqctl cluster_status

Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
So far, the general pattern has been successfully deployed the cluster.

VI queue mirror
image queue based on conventional trunked mode

1. Click on admin menu -> right side of Policies Options -> Under the leftmost bottom of the Add / Update A Policy
2. According to the contents of the figure according to their needs to fill
3. Click Add policy to add the policy, so you still have to configure common cluster before you can set up a mirror queue.
Here Insert Picture Description
Let's add a queue queues to see the effect, but here the test results, other do not fill the first
Here Insert Picture Description
note red box x-ha-policy = all this, that there is no online this is not to copy, but when I tested the like can be replicated, at least queues queue is, first add it.
when you add in the edge here is to specify the node option is put the queues on which node node but to make a mirror when not necessary

Here in the queues are mirrored cluster description here, in order to achieve high availability, with the required software oh HA Interface Poll ram rabbitmq two nodes (ip: 5672) disc as a backup node node Usually, production is also not not consumption.

Seven, commonly used commands

1.用户管理
(1)新增用户
rabbitmqctl add_user 用户名 密码
(2)删除用户
rabbitmqctl delete_user 用户名
(3)修改用户的密码
rabbitmqctl change_password 用户名  新密码
(4)查看当前用户列表
rabbitmqctl list_users
2.用户角色
(1)超级管理员: administrator
(2)监控者: monitoring
(3)策略制定者: policymaker
(4)普通管理者 management
(5)其他
设置用户角色的命令为:
rabbitmqctl set_user_tags 用户名  角色(上述五种角色 administrator monitoring policymaker management)
也可以给同一用户设置多个角色,例如
rabbitmqctl set_user_tags user01  monitoring policymaker
3.用户权限
用户权限指的是用户对exchange,queue的操作权限,包括配置权限,读写权限,配置权限会影响到exchange,queue的声明和删除。读写权限影响到从queue里取消息,向 exchange发送消息以及queue和exchange的绑定操作
(1)设置用户权限
rabbitmqctl set_permissions -p vhostpath user confp writep readp
(2) 查看(指定hostpath)所有用户的权限信息
rabbitmqctl list_permissions [-p VHostPath]
(3) 查看指定用户的权限信息
rabbitmqctl list_user_permissions User
(4) 清除用户的权限信息
rabbitmqctl clear_permissions [-p VHostPath] User
rabbitmqctl set_permissions -p / admin ‘.’ '.’ ‘.*’

Guess you like

Origin blog.csdn.net/zhutongcloud/article/details/93074158