Re: ConnectorJ and MySQL MASTER-SLAVE replication
Posted by: Filipe Silva
Date: June 28, 2018 04:06AM

Hi,

When you create a connection using `jdbc:mysql:replication://...` you provide the list of hosts that compose the master-slave replication setup. Internally, the driver creates two load balancing connections, one for the master(s) host(s) and another for the slaves. The master(s) sub-connection is used by default. Setting the replication connection to read-only (`Connection.setReadOnly(true)`) switches to the slaves sub-connection and vice-versa.

The connection options `allowMasterDownConnections` and `allowSlaveDownConnections` allow you to control if you want to permit creating the replication connection even if one of the sub-connections can't be created.

Connector/J doesn't support slave to master promotions through its API. Obviously you can issue the SQL command that does it, but the client side connections setup wont match the new replication topology. You can do live reconfiguration of the replication topology, though. You do this by setting up a replication connection group and using the `ReplicationConnectionGroupManager` class, however, the recommended way is to manage these connection groups externally from a JMX MBean. Please check the documentation for more details:

- https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-master-slave-replication-connection.html
- https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-master-slave-replication-connection.html

IHTH

Options: ReplyQuote


Subject
Written By
Posted
Re: ConnectorJ and MySQL MASTER-SLAVE replication
June 28, 2018 04:06AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.