Introduction to InnoDB Cluster
If you have not heard about MySQL InnoDB Cluster MySQL, InnoDB Cluster is a built-in high-availability solution for MySQL. The key benefit over old high-availability solutions is that InnoDB Cluster is built into MySQL and supported on all platforms where MySQL is supported.
The key components of MySQL InnoDB Cluster:
- MySQL Group Replication
- MySQL Shell
- MySQL Router
MySQL Group Replication is a plugin that makes sure that; data is distributed to all nodes, conflicts are handled and also recovery if needed.
MySQL Shell makes is easy to configure and administer your InnoDB Cluster.
MySQL Router is the last part of InnoDB cluster, it's a lightweight middleware that provides transparent routing between the application and back-end MySQL Servers part of group replication.
If you want to get started with InnoDB Cluster:
Clone a test/development environment from InnoDB Cluster
Most users need some way to periodically refresh test and development environments from production. In the past many users solved thus using traditional master-slave replication, the solution was to setup a MySQL slave that use LVM to leverage snapshots to create new test/developer environments.
For InnoDB Cluster we can use MySQL Clone (available from MySQL 8.0.l7) to creating a test or development environment much easier.
Steps needed on InnoDB Cluster (create a dedicated clone user for the donor):
You might limit the clone user to only be able to connect from some sub-net and not from all host (%). The InnoDB Cluster must run MySQL 8.0.17 or later.
CREATE USER clone_user@'%' IDENTIFIED BY 'clone_password'; GRANT BACKUP_ADMIN ON *.* to clone_user@'%'; GRANT SELECT ON performance_schema.* TO clone_user@'%'; GRANT EXECUTE ON *.* to clone_user@'%';
Next we need to create the test or development server.
1) Start a new MySQL instance (using MySQL 8.0.17 or later).
2) Provision data using clone:
Some notes on above, you need to configure the clone_valid_donor_list to the IP of the donor instance in the cluster you have selected. The log level is set to 3 so you can monitor progress of clone in the log file.
INSTALL PLUGIN clone SONAME 'mysql_clone.so'; INSTALL PLUGIN group_replication SONAME 'group_replication.so'; SET GLOBAL clone_valid_donor_list = '10.0.0.17:3306'; SET global log_error_verbosity=3; CLONE INSTANCE FROM firstname.lastname@example.org:3306 identified by 'clone_password'; UNINSTALL PLUGIN clone; UNINSTALL PLUGIN group_replication;
There are some controls in the MySQL Server that forces us to load the group replication plugin prior to executing the clone command. If you do not load the group replication plugin you will get an error like: ERROR 3870 (HY000): Clone Donor plugin group replication is not active in Recipient
Of course, the final step will be to clean/wash the data before handing over the MySQL instance to test or development, this step is not covered by this blog but using our masking and De-Identification can be used to solve this step ;)
I have tested above procedures using MySQL 8.0.18.