Introduction
MySQL InnoDB Cluster provides native, highly available, and
fault-tolerant database services. It packages three components—MySQL Shell
(for configuration), MySQL Router (for connection handling), and the Group
Replication plugin—into one cohesive solution. This guide outlines the
setup on four Linux nodes.
Prerequisites
Before starting, ensure all four Linux nodes (node1 through node4)
meet these requirements:
- MySQL
Server: MySQL 8.4 installed on the first three nodes (Refer to
my blog on how to install MySQL 8.4.0 https://edson-help.blogspot.com/2025/08/step-by-step-guide-to-setup-mysql-84-on.html)
- Network: All
nodes can communicate with each other on the necessary ports (3306, 33060,
and Group Replication ports 33061-33062).
- Enable
ports 6446 and 6447 on the database nodes for read/write and read only
connections.
- Initial Setup: Each MySQL instance must be initialized, running, and accessible via the MySQL Shell.
- Download the required binaries for MySQL Shell & MySQL Router
unzip MySQLShell.zip
yum install
mysql-shell-commercial-8.4.7-1.1.el8.x86_64.rpm
2. Add the hostname of each VM on each server for internal DNS resolution.
mysqlsh root@mysql-db-02:3307
mysqlsh root@mysql-db-02:3307
mysqlsh root@mysql-db-03:3307
4. Check the instance configuration
5. Use MySQL Shell to fix issues (confirm required changes)
The MySQL instance will restart
during this process.
dba.configureInstance('admin@mysql2:3307')
6. Execute the check the instance
configuration again after fixing the issues. Repeat for all three database
nodes.
\connect
admin@mysql-db-01:3307
var
cluster = dba.createCluster('cdlcluster')
8. Add the remaining two nodes to the newly created cluster.
cluster.addInstance('admin@mysql-db-02:3307')
cluster.addInstance('admin@mysql-db-03:3307')
9. Check the status of the InnoDB Cluster
MySQL
Router Deployment
1. Enable port 6446 and 6447 for
connections from the router to the InnoDB cluster.
Execute
the below commands for all three database nodes.
2. Unzip the MySQLRouter binary file
3. Install MySQL Router via rpm package
4. Grant access on the databases to allow connections from the Router.
sudo mysqlrouter --bootstrap admin@mysql-db-01:3307
--user=mysqlrouter
6. Start the MySQL Router
sudo systemctl start mysqlrouter
7. Test the connection with a mysql client connect to 6446 port (read/write). The connection takes you to the primary node mysql-db-01
mysqlsh admin@127.0.0.1:6446
8. Test the connection with a client connect to 6447 port (read only mode). The connection takes you to one of the secondary node mysql-db-02/03