Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the right MariaDB Galera jdbc URL properties for loadbalance

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.

like image 452
Max Avatar asked Oct 28 '13 08:10

Max


People also ask

What is the JDBC driver name for MariaDB?

MariaDB Connector/J is a Type 4 JDBC driver.

Can I use MySQL JDBC with MariaDB?

Yes, MySQL's Connector/J is compatible with MariaDB.

What is Galera in MariaDB?

MariaDB Galera Cluster is a virtually synchronous multi-primary cluster for MariaDB. It is available on Linux only, and only supports the InnoDB storage engine (although there is experimental support for MyISAM and, from MariaDB 10.6, Aria.

How do I get MariaDB connection string?

MariaDB uses the connection string to authenticate your account and allow you to extract the relevant data for your account. To create the connection string: Open the lib directory for the connector. This is the default path: C:\Program Files\CData\CData JDBC Driver for <Driver Name> 2019\lib .


1 Answers

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.

like image 188
Vladislav Vaintroub Avatar answered Sep 29 '22 05:09

Vladislav Vaintroub