Create RabbitMQ cluster in docker containers.
172.17.0.2 node2
172.17.0.3 node1
5672
# create queues
#!/bin/bash
while read queue; do
rabbitmqadmin declare queue --vhost=pools name=${queue} durable=true
done < queue.txt
# bind queues to exchange
#!/bin/bash
while read queue; do
rabbitmqadmin --vhost="pools" declare binding source="messages" destination_type="queue" destination="${queue}" routing_key="${queue}"
done < queue.txt
# fast purge queues
#!/bin/bash
while read queue; do
rabbitmqctl purge_queue -p pools ${queue}
done < queue.txt
кластер на докерах
root@node1:/tmp# cat /etc/rabbitmq/rabbitmq.config
[
{ rabbit, [
{ loopback_users, [ ] },
{ tcp_listeners, [ 5672 ] },
{ ssl_listeners, [ ] },
{cluster_nodes, {['rabbit@node1','rabbit@node2'], disc}},
{ hipe_compile, false }
] },
{ rabbitmq_management, [ { listener, [
{ port, 15672 },
{ ssl, false }
] } ] }
].
root@node1:/tmp# cat /etc/hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.17.0.3 node1
172.17.0.2 node2
------------------
rabbitmqctl stop_app
rabbitmqctl join_cluster rabbit@node2
-----------------
root@node2:/# cat /etc/rabbitmq/rabbitmq.config
[
{ rabbit, [
{ loopback_users, [ ] },
{ tcp_listeners, [ 5672 ] },
{ ssl_listeners, [ ] },
{cluster_nodes, {['rabbit@node1','rabbit@node2'], disc}},
{ hipe_compile, false }
] },
{ rabbitmq_management, [ { listener, [
{ port, 15672 },
{ ssl, false }
] } ] }
].
root@node2:/# cat /etc/hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.17.0.2 node2
172.17.0.3 node1