MySQL InnoDB Cluster
Purpose
To attempt installing a 3 node cluster.
Process
Started with downloading and installing mysql80-community-release-el7-3.noarch.rpm on each node, and the workstation I used for the admin API.
- Install and configure mysql server on first node. In my case this is Amazon Linux 2
sudo yum install mysql-community-server sudo systemctl enable --now mysqld.service
- Grab the temp password from /var/log/mysqld.log [1] and run secure setup.
- Root by default is restricted to localhost. I added an account for the mysqlsh to connect from my workstation. Also added the permissions to configure the clusteradmin
mysql> create user 'root'@'ip address' identified with mysql_native_password BY 'password'; mysql> grant all privileges on *.* to 'root'@'ip address'; mysql> GRANT CLONE_ADMIN, CONNECTION_ADMIN, CREATE USER, EXECUTE, FILE, GROUP_REPLICATION_ADMIN, PERSIST_RO_VARIABLES_ADMIN, PROCESS, RELOAD, REPLICATION CLIENT, REPLICATION SLAVE, REPLICATION_APPLIER, REPLICATION_SLAVE_ADMIN, ROLE_ADMIN, SELECT, SHUTDOWN, SYSTEM_VARIABLES_ADMIN ON *.* TO 'root'@'ip address' WITH GRANT OPTION; mysql> flush privileges;
Configure Nodes with MySQL Shell
- Installed mysql shell on my Fedora 33 workstation.
sudo dnf install -y mysql-shell
- Set variables and run setup function.
mysqlsh MySQL JS > var values={'password':'<root password>', 'clusterAdmin':'<cluster admin name>', 'clusterAdminPassword':'<cluster password>'} MySQL JS > dba.configureInstance('root@node1:3306', values )
- At this point I exited mysql shell with ctrl+d and connected to node1 directly using shell (This can be reworked from the beginnging)
mysqlsh --mysql -u root -h nod1 MySQL node1:3306 ssl JS > var cluster = dba.createCluster('testcluster')
- I left shell open since it had the cluster functions configure. Using a separate ssh session I connected to the other two nodes, repeating the steps above until I got to the cluster config.
- Now we add the two additional nodes to the cluster from the first shell I already had open. I used the clone option for this.
MySQL node1:3306 ssl JS > cluster.addInstance('mysql02.domout.net')
MySQL Router
Using the same shell as above, create an account for the mysql router.
cluster.setupRouterAccount('routerusername')