Tuesday Sep 23, 2014

Accessing Fabric HA Groups from Java

It's been almost a year now since the initial release of MySQL Fabric. It is maturing and reached a GA state earlier this year as part of MySQL Utilities 1.4. Developers and architects are evaluating it for their applications, learning the capabilities of the system, and providing feedback for future features and usability enhancements. Connector/J has supported Fabric from the very beginning and continues to support the latest features. This blog post is an introductory level guide to using Fabric for high-availability from Java applications. Sharding features and Java APIs will be covered in a later post. The commands shown and feature descriptions are current for Fabric 1.5.1. In addition, Connector/J 5.1.32 and later support only Fabric 1.5 due to communication protocol differences from Fabric 1.4.

High-availability is a core concept in Fabric and is implemented by HA groups. An HA group is a set of servers configured with MySQL replication in a master/slaves topology. Fabric can take care of the replication configuration, so you only need to have the servers configured properly and Fabric will take care of the rest. The example included here will use three MySQL servers for the application; one master and two slaves. There is an additional database for the backing store for the Fabric node, but it's not considered from the application's perspective. If you plan to follow along, you should setup your Fabric node, MySQL backing store for Fabric and three MySQL 5.6 instances for the application.

[Read More]

Wednesday Apr 02, 2014

Connector/J 5.1.30 is out with Fabric support

Today marks the release of several exciting pieces of software from Oracle. In addition to MySQL server 5.7.4 DMR, MySQL Fabric is out as a release candidate 1.4.2 and Connector/J 5.1.30 has full support. MySQL Fabric is a new way to implement high-availability and scale-out with MySQL server. It provides a way to group sets of servers into high-availability groups with automatic replication configuration. If scale-out is important, sharding can be defined in terms of these high-availability groups.

To use Connector/J with Fabric, you only need to add the jar to your classpath. If you are still using Java 5, you will need to manually load the com.mysql.fabric.jdbc.FabricMySQLDriver class to register the driver. Fabric-aware connections are made with a JDBC URL of the form jdbc:mysql:fabric://host:port/db. Several connection properties are available to influence the behavior of Fabric-aware connections. You can find the documentation for them at Connection Properties. Fabric-aware connections also expose a separate API called FabricMySQLConnection.

Connector/J supports both high-availability configurations and sharding on top of them. A basic high-availability configuration would consist of several servers in a master-slave configuration all belonging to the same group in Fabric. Connector/J can create a Fabric-aware connection to this group and send all writes to the master and load-balance between the slaves for all reads. This type of connection can be made by specifying the fabricServerGroup connection property or using the setServerGroupName() method in the FabricMySQLConnection API.

To implement a Fabric-aware connection with a sharded setup, you would typically specify the table name with the fabricShardTable connection property and use the setShardKey() method of the FabricMySQLConnection API to choose a shard. If the shard key is not provided, or set to null, all queries will be sent to the global group associate with the chosen shard table. If you only need to access a single shard for the duration of a connection, you can just as easily specify the fabricShardKey as a connection property. It doesn't become fixed for the duration of the connection, so you can also use it as a default if most connections won't need to change it.

There are plenty of other ways to use connection properties and APIs to interact with Fabric. You can find the full Connector/J documentation for Fabric-aware connections at Using Connector/J with MySQL Fabric. There are also several demos in the Connector/J source under the src/demo/fabric directory. Check out other resources available at:


Do you want to participate?

There is a lot you can do if you want to help improve MySQL Fabric.

Blogs about MySQL Fabric


Saturday Sep 21, 2013

MySQL Connector/J with Fabric Support

As Tomas announced in his keynote at MySQL Connect 2013, we are working on a brand new product called MySQL Fabric. Along with this release of MySQL Fabric, we are releasing Connector/J 5.1.26 with Fabric support on labs.mysql.com. This is an alpha-quality release that adds support for scalability features in MySQL Fabric. Sharding and read/write splitting are the initial features supported by Connector/J.

In a setup involving read/write splitting or customized sharding, we generally have to duplicate knowledge of this configuration in the client applications. This is done in connection strings specified in configuration files or directly in code. With MySQL Fabric, we can express our system-wide configuration of database servers in a way that it can be accessed by client applications. In cases where this needs to change (and it always does..), the configurations affecting client applications no longer need to be changed. The connector will access the configuration change through the MySQL Fabric server and automatically route new connections to the appropriate servers.

In addition to the JDBC API, this release includes integration for using Hibernate with MySQL Fabric. Based on Hibernate's built-in multi-tenancy support, you can access your sharded data with little effort.

This is a big step forward for handling large datasets and we encourage you try out the new features! Download MySQL Utilities: Fabric and Connector/J with Fabric support from labs.mysql.com. For more details, refer to the README.1ST file in the Connector/J package.

There are several blogs posts by other developers involved that provide an introduction to the concepts of MySQL Fabric and it's operation. Vn's MySQL Fabric - Sharding - Introduction gives the background for the motivation for the development of Fabric and lays out the basic system architecture. A high-level overview of the high-availability features can be found in Mats' A Brief Introduction to MySQL Fabric. Finally, get an idea of how to use MySQL Fabric in your application by reading Alfranio's post Writing a Fault-tolerant Database Application using MySQL Fabric. Keep on the lookout for future blog posts about MySQL Fabric and future releases.


MySQL and Java


« August 2016