RabbitMQ. Cluster, HA, Commands, Python code

TAGS: rabbitmq HA python mq

Some things i’v learnt after few days on some site

Cluster

Install repos for RHEL7 , yum install rabbitmq-server and other stuff:
erlang-20.2.2-1.el7.centos.x86_64 rabbitmq-server-3.7.2-1.el7.noarch glibc-common-2.17-196.el7.x86_64 python2-pip-8.1.2-5.el7.noarch haproxy-1.5.18-6.el7.x86_64 haproxy-1.5.18-6.el7.x86_64 1:net-snmp-libs-5.7.2-28.el7.x86_64 1:net-snmp-agent-libs-5.7.2-28.el7.x86_64 keepalived-1.3.5-1.el7.x86_64 2:nmap-ncat-6.40-7.el7.x86_64 2:nmap-6.40-7.el7.x86_64 3:traceroute-2.0.22-2.el7.x86_64 arptables-0.0.4-8.el7.x86_64 td-agent-bit-0.12.14-1.x86_64

Install plugins: wget https://github.com/deadtrickster/prometheus_rabbitmq_exporter/releases/download/v3.7.2.1/accept-0.3.3.ez -O /usr/lib/rabbitmq/lib/rabbitmq_server-3.7.2/plugins/accept-0.3.3.ez wget https://github.com/deadtrickster/prometheus_rabbitmq_exporter/releases/download/v3.7.2.1/prometheus-3.4.5.ez -O /usr/lib/rabbitmq/lib/rabbitmq_server-3.7.2/plugins/prometheus-3.4.5.ez wget https://github.com/deadtrickster/prometheus_rabbitmq_exporter/releases/download/v3.7.2.1/prometheus_cowboy-0.1.4.ez -O /usr/lib/rabbitmq/lib/rabbitmq_server-3.7.2/plugins/prometheus_cowboy-0.1.4.ez wget https://github.com/deadtrickster/prometheus_rabbitmq_exporter/releases/download/v3.7.2.1/prometheus_httpd-2.1.8.ez -O /usr/lib/rabbitmq/lib/rabbitmq_server-3.7.2/plugins/prometheus_httpd-2.1.8.ez wget https://github.com/deadtrickster/prometheus_rabbitmq_exporter/releases/download/v3.7.2.1/prometheus_process_collector-1.3.1.ez -O /usr/lib/rabbitmq/lib/rabbitmq_server-3.7.2/plugins/prometheus_process_collector-1.3.1.ez wget https://github.com/deadtrickster/prometheus_rabbitmq_exporter/releases/download/v3.7.2.1/prometheus_rabbitmq_exporter-v3.7.2.1.ez -O /usr/lib/rabbitmq/lib/rabbitmq_server-3.7.2/plugins/prometheus_rabbitmq_exporter-v3.7.1.1.ez

Enable all plugins
Install keepalived, with basic config
keepalived.conf

Configure track_script
chk_rabbit.py

Restart keepalived
service keepalived restart

Customize net_ticktime
vim /etc/rabbitmq/advanced.config [ {kernel, [{net_ticktime, 10}]} ].

Enable autoheal of partitions
vim /etc/rabbitmq/rabbitmq.conf cluster_partition_handling = autoheal

On each node create the SAME erlang cookie (value doesn’t matter it just need to be the same across nodes)
vim /var/lib/rabbitmq/.erlang.cookie DntiDNrDJSnrne
Update daemon to increase limit for open files
vim /usr/lib/systemd/system/rabbitmq-server.service LimitNOFILE=65536
Reload & Restart
systemctl daemon-reload && systemctl restart rabbitmq-server

On every SLAVE node run this stuff to join cluster
rabbitmqctl stop_app rabbitmqctl join_cluster rabbit@rabbit_master rabbitmqctl start_app

Check that everything is fine
rabbitmqctl cluster_status

Configure vhosts/users/policies and etc
rabbitmqcl create_vhost blabla rabbitmqctl -p blabla set_policy ha-all "^ha\." '{"ha-mode":"all","ha-sync-mode":"automatic", "queue-master-locator":"client-local"}' # I remind to you that only ONE policy works for each queue, so be aware

Written on February 19, 2018

Archive

linux openstack kubernetes gluster ceph ansible docker systemctl python openshift log centos sed registry kolla kibana keepalived elasticsearch deploy cloud-init auth HA zabbix vsphere vmware venv tools swift ssl ssh scm ruby rsyslog rhel rbac rabbitmq prometheus postgres policy pgpool2 patrole pacemaker ntp nfs net mq monitoring mongo mbr lvm logstash kubespray kubeadm kolla-ansible jenkins jekyII java ironic helm heketi harbor grub github ganesha fluentd fluent-bit fio drbd diskimage-builder devstack debug deb db cisco cicd ceph-ansible calico build bitbucket benchmarking apparmor api NUMA Linux Golang Go ELK 3par