Here is a basic connection routing example to a MySQL
InnoDB Cluster named myCluster
. Both
classic MySQL protocol and X Protocol 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
/tmp/router
.
In this example, read-write (primary) traffic is sent to port 6446 (classic) or 6448 (X Protocol), and read-only (secondaries) are accessed using port 6447 (classic) or 6449 (X Protocol).
The routing section keys (such as myCluster_rw) are optional but descriptive section keys help while debugging and also allows multiple configuration sections for the same plugin.
The destinations
option
references metadata-cache to utilize InnoDB
cluster's metadata cache that dynamically configures host
information. Alternatively, destinations
could
be a comma-separated list of hosts to accommodate basic
connection routing without InnoDB cluster.
The options starting with [http_server]
reference the REST API that is enabled by default. For
additional details, see Chapter 6, MySQL Router REST API
Press CTRL+C to copy# File automatically generated during MySQL Router bootstrap [DEFAULT] logging_folder=/tmp/router/log runtime_folder=/tmp/router/run data_folder=/tmp/router/data keyring_path=/tmp/router/data/keyring master_key_path=/tmp/router/mysqlrouter.key connect_timeout=15 read_timeout=30 dynamic_state=/tmp/router/data/state.json client_ssl_cert=/tmp/router/data/router-cert.pem client_ssl_key=/tmp/router/data/router-key.pem client_ssl_mode=PREFERRED server_ssl_mode=AS_CLIENT server_ssl_verify=DISABLED [logger] level = INFO [metadata_cache:myCluster] cluster_type=gr router_id=1 user=mysql_router1_x9v4uk10nbcd metadata_cluster=myCluster ttl=0.5 auth_cache_ttl=-1 auth_cache_refresh_interval=2 use_gr_notifications=0 [routing:myCluster_rw] bind_address=0.0.0.0 bind_port=6446 destinations=metadata-cache://myCluster/?role=PRIMARY routing_strategy=first-available protocol=classic [routing:myCluster_ro] bind_address=0.0.0.0 bind_port=6447 destinations=metadata-cache://myCluster/?role=SECONDARY routing_strategy=round-robin-with-fallback protocol=classic [routing:myCluster_x_rw] bind_address=0.0.0.0 bind_port=6448 destinations=metadata-cache://myCluster/?role=PRIMARY routing_strategy=first-available protocol=x [routing:myCluster_x_ro] bind_address=0.0.0.0 bind_port=6449 destinations=metadata-cache://myCluster/?role=SECONDARY routing_strategy=round-robin-with-fallback protocol=x [http_server] port=8443 ssl=1 ssl_cert=/tmp/router/data/router-cert.pem ssl_key=/tmp/router/data/router-key.pem [http_auth_realm:default_auth_realm] backend=default_auth_backend method=basic name=default_realm [rest_router] require_realm=default_auth_realm [rest_api] [http_auth_backend:default_auth_backend] backend=metadata_cache [rest_routing] require_realm=default_auth_realm [rest_metadata_cache] require_realm=default_auth_realm