GitHub user Luskan777 added a comment to the discussion: DB connection is 
interrupted with multiple management servers

Hi @weizhouapache ,

I was able to test the Failover configuration by configuring the client URI and 
I liked it much more than using HAproxy, it is simpler and more practical.

Thank you very much for introducing me to this approach @weizhouapache .

Of the failover/HA modes available in the MariaDB documentation, I tested the 
sequential, replication and load-balance-read modes.

The one that made the most sense to me was the replication mode, since I have 4 
nodes, 2 of which work as primary/master (write/read), and the other 2 as 
replica (read only). However, of the 2 primary/master nodes, only 1 is used for 
writing, and the other is used as a "backup", thus avoiding deadlock problems 
(at least that was the behavior I was able to observe). With this approach, I 
can achieve both HA/failover and better performance, since I can direct read 
queries to less overloaded servers.

I tested Failover between the primary/master servers, and it worked very well, 
as soon as one of the primary/master servers went down, it directed the 
workloads to another node.

My database connection URI configuration (cloud and cloud_usage) looks like 
this:

cloud:
```
db.cloud.uri=jdbc:mariadb:replication://address=(type=master)(host=xx.xx.xx.1)(port=3306),address=(type=master)(host=xx.xx.xx.2)(port=3306),address=(type=replica)(host=xx.xx.xx.3)(port=3306),address=(type=replica)(host=xx.xx.xx.4)(port=3306)/cloud?autoReconnect=true&prepStmtCacheSize=517&cachePrepStmts=true&sessionVariables=sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'&serverTimezone=UTC
```

cloud_usage:
```
db.usage.uri=jdbc:mariadb:replication://address=(type=master)(host=xx.xx.xx.1)(port=3306),address=(type=master)(host=xx.xx.xx.2)(port=3306),address=(type=replica)(host=xx.xx.xx.3)(port=3306),address=(type=replica)(host=xx.xx.xx.4)(port=3306)/cloud_usage?autoReconnect=true&prepStmtCacheSize=517&cachePrepStmts=true&sessionVariables=sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'&serverTimezone=UTC
```
ps: To ensure that the "replica" nodes only receive read requests, and not 
write requests, I activated the read_only option in the my.cnf file 
configuration.

GitHub link: 
https://github.com/apache/cloudstack/discussions/10471#discussioncomment-12391219

----
This is an automatically sent email for users@cloudstack.apache.org.
To unsubscribe, please send an email to: users-unsubscr...@cloudstack.apache.org

Reply via email to