问题
My setup:
Two MySQL servers running with Master-Master replication using third party Tungsten Replicator (for a legacy reasons, can't change that now).
Typically this cluster is used as Active-Standby. In normal operation all queries should hit first server. Only in case of first DB server failure queries should hit secondary server. Master-Master is for convinience of not using any master failover scripting. If primary server is back online, all queries should be sent to it.
I'm now using Galera Load Balancer configured in active-standby mode with simple health check (no mysql ping for x times = skip this server) and it works OK.
Problem:
I'd like to migrate glbd to ProxySQL and to replicate my setup. Started with two hosts with different weights ie 100000 vs 1.
Byt apparently ProxySQL uses it to weight traffic and 100000 queries go to primary, one next go to secondary and so on. It causes problems when sometimes replication lag is high, 1 of every 100000 queries will hit secondary server that could have some stale data.
How can I configure ProxySQL to send all queries only to my primary server when health check says it's OK, and to secondary server only if primary is unhealthy? When primary goes back alive all queries should be migrated to it.
来源:https://stackoverflow.com/questions/58080480/proxysql-active-standby-setup