9
votes

I have setup have 2 nodes of MariaDB 10.0 Galera cluster running on both private IPs of 192.168.2.51 and 192.168.2.52. I'm about to try connecting to the cluster using MariaDB's JDBC Client (org.mariadb.jdbc.Driver) provided by MariaDB's website.

It worked with the regular url like: "jdbc:mariadb://192.168.2.51:3306,192.168.2.52:3306/dbname".

But what I am trying to achieve is the possibility with the MySQL JDBC Driver, with url like: "jdbc:mysql://192.168.2.51,192.168.2.52/dbname?autoReconnect=true&autoReconnectForPools=true&failoverReadonly=false&roundRobinLoadBalance=true"

I have compared the properties stated in MariaDB (https://mariadb.com/kb/en/about-the-mariadb-java-client/) and MySQL (http://dev.mysql.com/doc/refman/5.5/en/connector-j-reference-configuration-properties.html). For the MariaDB JDBC Client, it doesn't seem to have properties that deal with loadbalance or autoReconnect.

So my question is: Is there a right recommended way to connect (with loadbalance and failover capability) to MariaDB Galera through the MariaDB JDBC Driver or should I fall back to MySQL's ConnectorJ and how compatible is ConnectorJ with regards to MariaDB Galera cluster?

Thank you.

2

2 Answers

2
votes

There is no loadbalance or failover capability in MariaDB JDBC . Even the multiple endpoint feature you used is not documented and is experimental. ConnectorJ loadbalancing should work fine, because to it, MariaDB Galera is just instances of regular MySQL.

2
votes

You just use failover. From what I observe, jdbc:mariadb:failover in mariadb connector equals jdbc:mysql:loadbalance in mysql connector; and jdbc:mariadb:sequential in mariadb equals jdbc:mysql:failover in mysql.

This is a bit confusing.

In Mariadb, even the word is failover, the read/write load is actually spread across all nodes. I prefer to use sequential so that the connections are always to one node, which is more reliable in some cases, such as with galera multi-master cluster.

https://mariadb.com/kb/en/library/about-mariadb-connector-j/