I want to setup a master-slave MariaDB Galera cluster like this:
I have 3 machines with LAMP and in front of them a load balancer.
Every machine have the same front-end to process php requests from users.
Every php request will either write or read from the database.
I want writes to be done on a single node to avoid deadlocks, so no multi master configuration, and reads can be done on any node.
My problem is how I know which node is the master, maybe the one I bootstrap the cluster from shut down and another is the master now, so I can connect to it to make a write.
I understood that MongoDB driver makes all the magic in this case, you just give him all the nodes addresses when connecting. Does this work for MariaDB too, cause I couldn't find any info on this, not even in PHP PDO.
I'm aware a HAProxy is able to manage that, knowing who is the master to send writes to, but I don't want to create a loop by sending the SQLs requests to a HAProxy that will loop back in one of the nodes.
This represents a problem even if I have a 3 layer configuration with the front-ends separated from the back-ends, how I connect from one front-end to the cluster master without HAProxy to help.
Is there any way around this, a PHP library or something, or do I need a cluster manager like a HAProxy?
Note: I setup my cluster initially using this guide.
Asked
Active
Viewed 1,196 times
1

Victor Laurentiu
- 145
- 1
- 2
- 9
1 Answers
1
I would suggest to use MaxScale, a proxy made for mariaDB which has been made for this purpose.
https://mariadb.com/products/technology/maxscale
I do not understand why you try to avoid a proxy??

BlackFlag
- 150
- 8
-
MaxScale should be on another machine, right? So if I want a three node cluster I need four machines, 3 for the nodes and one for the proxy that sits in front of the nodes. – Victor Laurentiu Jul 24 '17 at 08:31
-
Yeah that's for sure the recommended approach. But if you need 3 machines, does it really count to purchase/organize a fourth one? I mean you wannt HA and HA is basically not that cheap... – BlackFlag Jul 25 '17 at 09:11
-
It isn't about cost, but the time to take care of one more machine. I for instance like the idea to have another machine which takes care of this. I knew about Mongo that you don't need another machine in front of the cluster, you just pass all IPs when you connect and the driver takes care of the rest so I was interested if the same thing was available for MariaDB/MySQL. Thanks for your answer. – Victor Laurentiu Jul 26 '17 at 07:19
-
AFAIK there is not other solution provided by mariaDB at the moment. The thing is that they wrote maxscale for exact those reasons but not only that, maxscale has a lot of other functionalities e.g. filtering, audit, DOS-prevention, failover, etc. – BlackFlag Jul 27 '17 at 08:25