Pre-General Availability: 2023-05-24
MySQL Router is a building block for high availability (HA) solutions. It simplifies application development by intelligently routing connections to MySQL servers for increased performance and reliability.
MySQL Router is part of InnoDB Cluster and is lightweight middleware that provides transparent routing between your application and back-end MySQL servers. It is used for a wide variety of use cases, such as providing high availability and scalability by routing database traffic to appropriate back-end MySQL servers. The pluggable architecture also enables developers to extend MySQL Router for custom use cases.
MySQL Group Replication replicates databases across multiple servers while performing automatic failover in the event of a server failure. When used with a InnoDB Cluster, MySQL Router acts as a proxy to hide the multiple MySQL instances on your network and map the data requests to one of the cluster instances. As long as there are enough online replicas and communication between the components is intact, applications are able to contact one of them. MySQL Router also makes this possible by having applications connect to MySQL Router instead of directly to MySQL.
For more information on the installation of MySQL Router, see Installing MySQL Router.
For more information on the deployment of MySQL Router, see Deploying MySQL Router.
For more information on the configuration of MySQL Router, see Configuring MySQL Router.
When you have set up an InnoDB Cluster and have MySQL Router running, you can test the InnoDB Cluster and MySQL Router setup using MySQL Shell Consoles.
By default, InnoDB Cluster can be reached by connecting to:
classic MySQL protocol
Read/Write Connections: instance-address: port 6446
Read/Only Connections: instance-address: port 6447
Read/Write Connections: instance-address: port 6448
Read/Only Connections: instance-address: port 6449
Instead of connecting to one of the MySQL server instances directly, connect through the MySQL Router.
Issue the following connection command, where the user is
demo-userand the address of the instance is
demo-instance, and classic MySQL protocol is being used:
Provide the root password to connect to the InnoDB Cluster.
Check the status of the InnoDB Cluster by creating a variable
clusterand assigning it with the value of the
cluster = dba.getCluster()
Switch to SQL mode:
Query the port the instance is running on, by issuing:
SELECT @@port; +--------+ | @@port | +--------+ | 3310 | +--------+ 1 row in set (0.0007 sec)
In this example, InnoDB Cluster is running on port 3310, so MySQL Router has been configured correctly and is running successfully.