Connect Django 1.11 to Mariadb Galera cluster

Question:

I am using Django 1.11 with MariaDB 10.1 Galera cluster
I didn`t find in the documentation how to connect to a cluster.

I tried using gcomm://NODE1,NODE2 url with no success… any idea?

Asked By: Oz Bar-Shalom

||

Answers:

According to a ticket that I opened to Django project, there is no support in MariaDB Galera cluster and they probably will not add support for that soon

https://code.djangoproject.com/ticket/28270

Answered By: Oz Bar-Shalom

You shall put a load balancer such as haproxy in front of your cluster, as all nodes of gelara cluster are same, this is fully acceptable for example:

apt-get install haproxy
sudo vi /etc/haproxy/haproxy.cfg
# Add the following lines to the end of file:
listen galera
    # Replace "IP" by server local IP
    bind IP:3306
    balance roundrobin
    mode tcp
    option tcpka
    option mysql-check user haproxy
    # Replace "IP" by galera-mariadb-1 local IP
    server galera-mariadb-1 IP:3306 check weight 1
    # Replace "IP" by galera-mariadb-2 local IP
    server galera-mariadb-2 IP:3306 check weight 1
    # Replace "IP" by galera-mariadb-3 local IP
    server galera-mariadb-3 IP:3306 check weight 1
# link: https://cyral.com/blog/how-to-galera-mariadb-haproxy/

Although this will result in a paradoxical situation where you find yourself not actually high available using one-node haproxy, that also is solvable using keepalived…

Answered By: Yosef SL
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.