MySQL Router 2.1  /  ...  /  Configuration File Example

4.3.3 Configuration File Example

Here is a basic connection routing example to a MySQL InnoDB cluster named mycluster. Both classic and X protocols are enabled, it uses TCP/IP connections instead of UNIX domain sockets, and it was generated using --bootstrap as a standalone configuration with --directory set to "/opt/routers/myrouter".

In this example, read-write (primary) traffic is sent to port 6446 (classic) or 64460 (x), and read-only (secondaries) are accessed using port 6447 (classic) or 64470 (x).

The routing section keys (such as mycluster_default_rw) are optional, but using these descriptive section keys is helpful for debugging, and also allows multiple configuration sections for the same plugin.

# File automatically generated during MySQL Router bootstrap
[DEFAULT]
logging_folder=/opt/routers/myrouter/log
runtime_folder=/opt/routers/myrouter/run
data_folder=/opt/routers/myrouter/data
keyring_path=/opt/routers/router/data/keyring
master_key_path=/opt/routers/myrouter/mysqlrouter.key

[logger]
level = INFO

[metadata_cache:mycluster]
router_id=5
bootstrap_server_addresses=mysql://localhost:3310,mysql://localhost:3320,mysql://localhost:3330
user=mysql_router5_6owf3spq1c6n
metadata_cluster=mycluster
ttl=300

[routing:mycluster_default_rw]
bind_address=0.0.0.0
bind_port=6446
destinations=metadata-cache://mycluster/default?role=PRIMARY
mode=read-write
protocol=classic

[routing:mycluster_default_ro]
bind_address=0.0.0.0
bind_port=6447
destinations=metadata-cache://mycluster/default?role=SECONDARY
mode=read-only
protocol=classic

[routing:mycluster_default_x_rw]
bind_address=0.0.0.0
bind_port=64460
destinations=metadata-cache://mycluster/default?role=PRIMARY
mode=read-write
protocol=x

[routing:mycluster_default_x_ro]
bind_address=0.0.0.0
bind_port=64470
destinations=metadata-cache://mycluster/default?role=SECONDARY
mode=read-only
protocol=x

User Comments
User comments in this section are, as the name implies, provided by MySQL users. The MySQL documentation team is not responsible for, nor do they endorse, any of the information provided here.
  Posted by Giorgio Costamagna on April 15, 2017
If You want to use a round-robin policy for READ ONLY on all instances,
and not only on secondary ones, You can use the setting:

destinations=metadata-cache://mycluster/default?role=ALL

I didn't find where it is documented... but it works and can be useful.
Sign Up Login You must be logged in to post a comment.