This page provides some worked examples of data refresh scenarios in an InnoDB Cluster environment.
mysource - Standalone Source Database
MySQL 5.7
Stored Procedures without DETERMINISTIC assertion
Table without a Primary Key
mynode1 - InnoDB Cluster Primary
mynode2 - InnoDB Replica
mynode3 - InnoDB Replica
MySQL 8.0
The easiest way to resolve this is to dissolve the cluster, recreate the database, import the data, fix/workaround the issues and recreate the cluster....
On the InnoDB Cluster Primary...
mkdir /backup/mydumpdir
rm -rf /backup/mydumpdur/*
mysqlsh
\c icadmin@mynode1
\js
var cluster = dba.getCluster("mycluster")
cluster.dissolve( { interactive:true } )
\c root@localhost
\sql
SET GLOBAL local_infile = ON;
SET GLOBAL log_bin_trust_function_creators = 1;
SET GLOBAL super_read_only = OFF;
SET GLOBAL read_only = OFF;
DROP DATABASE mydatabase;
CREATE DATABASE mydatabase;
\c root@mysource
\js
util.dumpInstance("/backup/mydumpdir")
\c root@localhost
util.loadDump("/backup/mydumpdir",
{ ignoreVersion: true,
threads: 4,
loadData: true,
resetProgress: true } )
\sql
ALTER TABLE mydatabase.mytable
ADD COLUMN _autopk BIGINT UNSIGNED NOT NULL
AUTO_INCREMENT INVISIBLE,
ADD PRIMARY KEY (_autopk);
SET GLOBAL log_bin_trust_function_creators = 0;
SET GLOBAL local_infile = OFF;
\js
\c icadmin@mynode1
dba.dropMetadataSchema()
dba.checkInstanceConfiguration()
dba.configureInstance()
var cluster = dba.createCluster("mycluster");
cluster.status()
cluster.rescan()
cluster.status()
cluster.addInstance("icadmin@mynode2:3306",
{ recoveryMethod: "clone" } )
cluster.status()
cluster.addInstance("icadmin@mynode3:3306",
{ recoveryMethod: "clone" } )
cluster.status()
Create a directory to hold a backup of the source database
Remove any existing backup files
Start MySQL Shell
Connect to the cluster admin account on mynode1
Javascript
Define the cluster variable
Dissolve the cluster
Connect to the local MySQL root account on mynode1
SQL
Allow local files to be loaded
Allow stored procedures without DETERMINISTIC assertion
Make sure that the database is writable
DROP the database
ReCREATE the database
Connect to mysource database
Javascript
Dump the instance to the local dump directory on mynode1
Connect to the local MySQL root account on mynode1
Load the database from the dump directory on mynode1
Allow a MySQL 5.7 database to load into MySQL 8.0
Run four parallel threads
Load the Data
Always start from the beginning (don't try to pick up from a previous load)
SQL
Add an invisble auto_increment primary key to the table
Reset parameters (as necessary)
Javascript
Reconnect to the cluster admin account on mynode1
Remove any leftover cluster metadata
Check that nothing will prevent the Instance from being clustered
Configure the instance for clustering
Create cluster
Check Cluster status
Rescan Cluster to remove things like lingering internal cluster users
Check Cluster status
Add mynode2 (clone from mynode1)
Check Cluster status
Add mynode3 (clone from mynode1 or mynode2)
Check Cluster status