rabbitmq cluster mirror queue centos7
================== rabbitmq version ==================
rabbitmq-server-3.7.15-1
https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.7.15/rabbitmq-server-3.7.15-1.el7.noarch.rpm
================== needed erlang version ==================
erlang >= 20.3.x and erlange <= 22.0.x
https://github.com/rabbitmq/erlang-rpm/releases/download/v22.0.2/erlang-22.0.2-1.el7.x86_64.rpm
0.common network setting
https://www.cnblogs.com/xiayudashan/p/10494725.html
1.change hostname
vi /etc/hostname
rabbit-server1
2.change hosts
vi/etc/hosts
127.0.0.1 rabbit-server1 localhost
::1 rabbit-server1 localhost
192.168.1.131 rabbit-server1
192.168.1.132 rabbit-server2
2.1.reboot
reboot
3.install erlang
rpm -ivh erlang-22.0.2-1.el7.x86_64.rpm
4.install socat
yum install -y socat
5.install rabbitmq
rpm -ivh rabbitmq-server-3.7.15-1.el7.noarch.rpm
6.start rabbitmq
rabbitmq-server -detached
7.enable management
rabbitmq-plugins enable rabbitmq_management
8.add new admin user for management remote access
rabbitmqctl add_user rabbit rabbit
rabbitmqctl set_user_tags rabbit administrator
rabbitmqctl set_permissions -p / rabbit ".*" ".*" ".*"
rabbitmqctl add_user runner runner
rabbitmqctl set_user_tags runner none
rabbitmqctl set_permissions -p / runner ".*" ".*" ".*"
9.copy rabbit-server1 /var/lib/rabbitmq/.erlang.cookie to other rabbit-server
chown rabbitmq:rabbitmq /var/lib/rabbitmq/.erlang.cookie
chmod 600 /var/lib/rabbitmq/.erlang.cookie
10.view cluster status
rabbitmqctl cluster_status
11.join a cluster
# on rabbit-server2
rabbitmq-server -detached
rabbitmq-plugins enable rabbitmq_management
rabbitmqctl stop_app
rabbitmqctl reset
rabbitmqctl join_cluster rabbit@rabbit-server1
rabbitmqctl start_app
12.ha queue setting
rabbitmqctl
== rabbitmqctl set_policy ha-all "^ha\." '{"ha-mode":"all"}'
rabbitmqctl (Windows)
== 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.