MySQL Router Deployment Guide
This article explains how to use innodb_cluster_router.yml to deploy MySQL Router on top of an existing InnoDB Cluster.
1. Scope
- The upstream Cluster has already been deployed by
innodb_cluster.yml - Supports both single-node App mode and two-node keepalived HA mode
- The Router REST API is enabled by default so
mysqlrouter_exportercan be added later
2. Dependency chain
| Item | Details |
|---|---|
| Prerequisites | dbbotctl env setup is complete, innodb_cluster.yml has already succeeded, the [dbbot_router] inventory is ready, and Router nodes can reach the Cluster nodes |
| Required variables | router_bootstrap_server, mysql_cluster_admin_user / mysql_cluster_admin_password, mysql_router_user / mysql_router_password; HA mode also requires router_enable_ha, router_vip, and router_ha_nodes |
| Conditional variables | When router_rest_api_auth_mode: file, also set router_rest_api_file_user / router_rest_api_file_password; if you change the REST API port, update router_ports.http.port at the same time |
| Next step | If Router metrics are required, continue with router_exporter_install.yml, then register the targets in Prometheus with dbbotctl exporter register -t router |
3. Inventory
innodb_cluster_router.yml uses a dedicated host group:
[dbbot_router]
192.0.2.151 ansible_user=root ansible_ssh_pass="'<your_password>'"
192.0.2.152 ansible_user=root ansible_ssh_pass="'<your_password>'"
The IPs above use RFC 5737 documentation ranges and are examples only. Replace them with your actual host addresses.
If you only need single-node App mode, keep a single Router host and set router_enable_ha: false.
4. Key variables
Edit mysql_ansible/playbooks/vars/var_innodb_cluster_router.yml:
router_enable_ha: true
router_bootstrap_server: 192.0.2.131
mysql_cluster_admin_user: clusteradmin
mysql_cluster_admin_password: "Dbbot_clusteradmin@8888"
mysql_router_user: mysqlrouter
mysql_router_password: "Dbbot_mysqlrouter@8888"
router_vip: 192.0.2.150
router_ha_nodes:
- ip: 192.0.2.151
role: MASTER
priority: 100
- ip: 192.0.2.152
role: BACKUP
priority: 90
router_rest_api_auth_mode: file
router_rest_api_file_user: router_api_user
router_rest_api_file_password: "Dbbot_router_api_user@8888"
Notes:
router_bootstrap_servermust be a reachable node in the current Cluster.mysql_cluster_admin_*is used bymysqlrouter --bootstrap.mysql_router_*is the account used by Router to read Cluster metadata.router_rest_api_file_*only applies whenrouter_rest_api_auth_mode: file; the latermysqlrouter_exporterflow reuses these credentials by default.
5. Execute deployment
cd /usr/local/dbbot/mysql_ansible/playbooks
ansible-playbook innodb_cluster_router.yml
During execution, enter confirm as prompted.
6. Post-deployment validation
Common checks:
systemctl status mysqlrouter- In HA mode, also check
systemctl status keepalived ss -lntp | egrep '6446|6447|8443'
Connection example:
mysql -h 192.0.2.150 -P 6446 -u<user> -p
In single-node App mode, replace the address above with that Router host IP.
7. Next step
If you want to connect Router metrics to Prometheus, continue with: mysqlrouter_exporter and Router Registration.