搭建 RabbitMQ 镜像集群(高可用)

搭建镜像集群前先要搭建好主备集群

# 策略说明
rabbitmqctl set_policy [-p <vhost>] [--priority <priority>] [--apply-to <apply-to>] <name> <pattern> <definition>
-p Vhost:  可选参数,针对指定vhost下的queue进行设置
Name:      policy的名称
Pattern:   queue的匹配模式(正则表达式)
Definition: 镜像定义,包括三个部分ha-mode, ha-params, ha-sync-mode
			ha-mode:指明镜像队列的模式,有效值为all/exactly/nodes
			        all: 表示在集群中所有的节点上进行镜像
			        exactly: 表示在指定个数的节点上进行镜像,节点的个数由ha-params指定
			        nodes: 表示在指定的节点上进行镜像,节点名称通过ha-params指定
			ha-params: ha-mode模式需要用到的参数
            ha-sync-mode :进行队列中消息的同步方式,有效值为automatic和manual
            priority: 可选参数,policy的优先级

# 1.查看当前策略
rabbitmqctl list_policies

# 2.添加策略
rabbitmqctl set_policy ha-all '^hello' '{"ha-mode":"all","ha-sync-mode":"automatic"}'
说明:策略正则表达式为 "^" 表示所有匹配所有队列名称   ^hello:匹配hello开头队列

# 3.删除策略
rabbitmqctl clear_policy all 


rabbitmqctl set_policy all   '^' '{"ha-mode":"all","ha-sync-mode":"automatic"}'
rabbitmqctl set_policy all   '^' '{"ha-mode":"all","ha-sync-mode":"automatic"}'


注意:测试的时候路由 / 必须是是 / ,如果设置的是 /clf 测试的时候脚本新建的必须是 /clf





posted @   六月OvO  阅读(4)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 零经验选手,Compose 一天开发一款小游戏!
· 因为Apifox不支持离线,我果断选择了Apipost!
· 通过 API 将Deepseek响应流式内容输出到前端
点击右上角即可分享
微信分享提示