简体   繁体   English

MariaDB Galera Cluster php驱动程序

[英]MariaDB Galera Cluster php driver


I want to setup a master-slave MariaDB Galera cluster like this: 我想像这样设置主从MariaDB Galera集群:
I have 3 machines with LAMP and in front of them a load balancer. 我有3台装有LAMP的机器,在它们前面有一个负载平衡器。
Every machine have the same front-end to process php requests from users. 每台机器都有相同的前端来处理用户的php请求。
Every php request will either write or read from the database. 每个php请求都会从数据库中写入或读取。
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. 我知道在这种情况下,MongoDB驱动程序具有所有的魔力,您只需在连接时给他所有节点地址即可。 Does this work for MariaDB too, cause I couldn't find any info on this, not even in PHP PDO. 这对MariaDB也有用吗,因为即使在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. 我知道HAProxy能够管理此操作,知道谁是向其发送写操作的主服务器,但是我不想通过将SQL请求发送到将在一个节点中循环返回的HAProxy来创建循环。
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. 即使我具有前端与后端分离的3层配置,这也代表了一个问题,我如何在不使用HAProxy的情况下从一个前端连接到群集主机。
Is there any way around this, a PHP library or something, or do I need a cluster manager like a HAProxy? 有什么办法可以解决这个问题,PHP库或其他什么方法?还是需要像HAProxy这样的集群管理器?
Note: I setup my cluster initially using this guide. 注意:我最初是使用指南设置集群的。

I would suggest to use MaxScale, a proxy made for mariaDB which has been made for this purpose. 我建议使用MaxScale,这是为此mariaDB创建的代理。

https://mariadb.com/products/technology/maxscale https://mariadb.com/products/technology/maxscale

I do not understand why you try to avoid a proxy?? 我不明白您为什么尝试避免使用代理?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM