3.镜像配置示例(可通过多种方式)
下面的例子将“ha.”开头的queue mirror到cluster中所有节点
rabbitmqctl rabbitmqctl set_policy ha-all "^ha\." ‘{"ha-mode":"all"}‘
HTTP API PUT /api/policies/%2f/ha-all {"pattern":"^ha\.", "definition":{"ha-mode":"all"}}
Web UI Navigate to Admin > Policies > Add / update a policy.
Enter "ha-all" next to Name, "^ha\." next to Pattern, and "ha-mode" = "all" in the first line next to Policy.
Click Add policy.
下面的例子将“two.”开头的queue mirror到cluster中两个节点,且自动同步
rabbitmqctl rabbitmqctl set_policy ha-two "^two\." ‘{"ha-mode":"exactly","ha-params":2,"ha-sync-mode":"automatic"}‘
HTTP API PUT /api/policies/%2f/ha-two {"pattern":"^two\.", "definition":{"ha-mode":"exactly", "ha-params":2,"ha-sync-mode":"automatic"}}
Web UI Navigate to Admin > Policies > Add / update a policy.
Enter "ha-two" next to Name and "^two\." next to Pattern.
Enter "ha-mode" = "exactly" in the first line next to Policy, then "ha-params" = 2 in the second line, then "ha-sync-mode" = "automatic" in the third, and set the type on the second line to "Number".
Click Add policy.
下面的例子将“nodes.”开通的queue mirror到cluster中特定的node
rabbitmqctl rabbitmqctl set_policy ha-nodes "^nodes\." ‘{"ha-mode":"nodes","ha-params":["nodeA", "nodeB"]}‘
HTTP API PUT /api/policies/%2f/ha-nodes {"pattern":"^nodes\.", "definition":{"ha-mode":"nodes", "ha-params":["nodeA", "nodeB"]}
Web UI Navigate to Admin > Policies > Add / update a policy.
Enter "ha-nodes" next to Name and "^nodes\." next to Pattern.
Enter "ha-mode" = "nodes" in the first line next to Policy, then "ha-params" in the second line, set the second line‘s type to "List", and then enter "nodeA" and "nodeB" in the sublist which appears.
Click Add policy.