https://www.rabbitmq.com/clustering.html
https://kamaok.org.ua/?p=2689
https://blog.flux7.com/blogs/tutorials/how-to-creating-highly-available-message-queues-using-rabbitmq
1) add hostname (do real hostname) between master and slave to /etc/hosts
2) copy /var/lib/rabbitmq/.erlang.cookie from master to slave
systemctl restart rabbitmq-server (on slave)
3) join to cluster
rabbitmqctl stop_app
Stopping rabbit application on node rabbit@<hostname_slave> ...
Stopping rabbit application on node rabbit@<hostname_slave> ...
rabbitmqctl reset
Resetting node rabbit@<hostname_slave> ...
Resetting node rabbit@<hostname_slave> ...
rabbitmqctl join_cluster rabbit@<hostname_slave>
Clustering node rabbit@<hostname_slave> with rabbit@<hostname_master>
rabbitmqctl start_app
Starting node rabbit@<hostname_slave> ...
completed with 0 plugins.
4) check cluster
rabbitmqctl cluster_status
Cluster status of node rabbit@<hostname_slave> ...
[{nodes,[{disc,[rabbit@<hostname_master>,rabbit@<hostname_slave>]}]},
{running_nodes,[rabbit@<hostname_master>,rabbit@<hostname_slave>]},
{cluster_name,<<"rabbit@localhost">>},
{partitions,[]},
{alarms,[{rabbit@<hostname_master>,[]},{rabbit@<hostname_slave>,[]}]}]
5) Configure syncing queues police between master and slave nodes
Run on master
rabbitmqctl set_policy ha-all "" '{"ha-mode":"all","ha-sync-mode":"automatic"}'
for all vhost
from
https://www.rabbitmq.com/ha.html
ha-sync-mode: manual
- this is the default mode. A new queue mirror will not receive existing messages, it will only receive new messages. The new queue mirror will become an exact replica of the master over time, once consumers have drained messages that only exist on the master. If the master queue fails before all unsychronised messages are drained, those messages will be lost. You can fully synchronise a queue manually, refer to unsynchronised mirrors section for details.
ha-sync-mode: automatic
- a queue will automatically synchronise when a new mirror joins. It is worth reiterating that queue synchronisation is a blocking operation. If queues are small, or you have a fast network between RabbitMQ nodes and the ha-sync-batch-size was optimised, this is a good choice.
for / vhost
rabbitmqctl set_policy ha-all "" '{"ha-mode":"all","ha-sync-mode":"automatic"}'
Setting policy "ha-all" for pattern "" to "{"ha-mode":"all","ha-sync-mode":"automatic"}" with priority "0" for vhost "/" ...
for vhost1 vhost
rabbitmqctl set_policy ha-all "" '{"ha-mode":"all","ha-sync-mode":"automatic"}' -p vhost1
Setting policy "ha-all" for pattern "" to "{"ha-mode":"all","ha-sync-mode":"automatic"}" with priority "0" for vhost "vhost1" ...
https://www.rabbitmq.com/ha.html
ha-sync-mode: manual
- this is the default mode. A new queue mirror will not receive existing messages, it will only receive new messages. The new queue mirror will become an exact replica of the master over time, once consumers have drained messages that only exist on the master. If the master queue fails before all unsychronised messages are drained, those messages will be lost. You can fully synchronise a queue manually, refer to unsynchronised mirrors section for details.
ha-sync-mode: automatic
- a queue will automatically synchronise when a new mirror joins. It is worth reiterating that queue synchronisation is a blocking operation. If queues are small, or you have a fast network between RabbitMQ nodes and the ha-sync-batch-size was optimised, this is a good choice.
for / vhost
rabbitmqctl set_policy ha-all "" '{"ha-mode":"all","ha-sync-mode":"automatic"}'
Setting policy "ha-all" for pattern "" to "{"ha-mode":"all","ha-sync-mode":"automatic"}" with priority "0" for vhost "/" ...
for vhost1 vhost
rabbitmqctl set_policy ha-all "" '{"ha-mode":"all","ha-sync-mode":"automatic"}' -p vhost1
Setting policy "ha-all" for pattern "" to "{"ha-mode":"all","ha-sync-mode":"automatic"}" with priority "0" for vhost "vhost1" ...
Комментариев нет:
Отправить комментарий