Chapter 6 Use Cases and Examples

MySQL Router use cases and examples.

HA with a Connector

One basic use-case provides MySQL Fabric support to legacy connectors. Here we create a configuration file named fabric_ha.ini with sections for the Fabric Cache and Connection Router plugins.

[DEFAULT]
logging_folder =
plugin_folder = /usr/local/lib/mysqlrouter
config_folder = /etc/mysql
runtime_folder = /var/run
 
[logger]
level = INFO

[fabric_cache:my_cache]
address = fabric.example.com
user = admin

[routing]
bind_address = 127.0.0.1:7002
destinations = fabric+cache://my_cache/group/my_group
mode = read-write
  • Our [DEFAULT] section defines default paths to several folders.

  • Our [logger] instructs the logger to log information messages.

  • Our [fabric_cache:my_cache] section enables and configures the Fabric Cache plugin. We fetch the farm data from the MySQL Fabric instance at fabric.example.com and cache it into memory. It assigns a key named my_cache to the section so that it can be referenced later.

  • Our [routing] section enables and configures connection routing to listen (bind to) port 7002 on localhost in order to fetch destination information from the Fabric Cache given by the key my_cache, and route the packets to the primary in the high-availability (HA) group named my_group.

Now, start MySQL Router loading our configuration file:

shell> mysqlrouter --config=fabric_ha.ini  

You will be prompted for the Fabric user password, and after this you can connect to the bind address of the router using a normal MySQL connector or client.