What is MySQL Shell Utility:

MySQL Shell’s instance dump utility, schema dump utility, and table dump utility provide Oracle Cloud Infrastructure Object Storage streaming, MySQL HeatWave Service compatibility checks and modifications, parallel dumping with multiple threads, and file compression, which are not provided by mysqldump. Progress information is displayed during the dump. You can carry out a dry run with your chosen set of dump options to show information about what actions would be performed, what items would be dumped, and (for the instance dump utility and schema dump utility) what MySQL HeatWave Service compatibility issues would need to be fixed, when you run the utility for real with those options.

Prerequisites

There are a few things we need before we can get started with this blog migration.

  1. An OCI account. If you do not have one, you can sign up for an account here.
  2. The OCI Command Line Interface (CLI) and MySQL Shell  configured on OCI Compute Instance from which you will run the commands.
  3. Google Cloud SQL for MySQL
  4. Required Network connectivity and ports are already opened as per the recommended method. We are using the public IP for GCP as we are more focused on the migration approach.

 

Main Steps, we are going to perform:

 

  1. GCP Source Databases:
  • Begin by a comprehensive list of the source databases/Tables within Google Cloud Platform (GCP).
  1. Provision OCI Object Storage Bucket:
  • Create an Object Storage Bucket within Oracle Cloud Infrastructure (OCI) to serve as the destination for the database dump.
  1. Dry Run Database Dump (Using MySQL Shell):
  • Perform a dry run of the database dump process using MySQL Shell on an OCI Compute instance.
  • This step allows you to validate the process without creating actual dumps.
  1. Execute Actual Database Dump (Using MySQL Shell):
  • Once the dry run is successful, proceed to execute the actual database dump using MySQL Shell on an OCI Compute instance.
  1. Verify Dump File in Object Storage:
  • Confirm that the database dump files have been successfully created and stored in the designated OCI Object Storage Bucket.
  1. Create MySQL HeatWave System on OCI:
  • Set up a MySQL HeatWave system on Oracle Cloud Infrastructure (OCI) and Utilize the dumped database files to import the data into the MySQL HeatWave system on OCI.
  1. Database validation after migration:
  • Access the OCI MySQL HeatWave environment
  • Ensure that all data has been successfully imported and is accessible.

 

List all the databases in the source (GCP MySQL):

Login from your OCI Compute Instance where mysql shell is installed and connect to GCP MySQL:

[opc@mysql-shell ~]$mysqlsh -p -h XX.XX.XXX.125 -u root –sql

MySQL xx.xx.xxx.125:3306 ssl SQL > show databases;

 

Output:

+——————–+

| Database           |

+——————–+

| employees          |

| guestbook          |

| information_schema |

| mysql              |

| performance_schema |

| sys                |

+——————–+

Note: The information_schemamysqlndbinfoperformance_schema, and sys schemas are excluded from an instance dump.

 

Now in employees database, check the tables:

Default schema set to `employees`

MySQL xx.xx.xxx.125:3306 ssl  SQL > use employees;

 

MySQL xx.xx.xxx.125:3306 ssl  employees  SQL > show tables;

 

output:

+———————-+

| Tables_in_employees  |

+———————-+

| GG_Persons           |

| Persons              |

| Persons_GCP          |

| current_dept_emp     |

| departments          |

| dept_emp             |

| dept_emp_latest_date |

| dept_manager         |

| employees            |

| salaries             |

| titles               |

+———————-+

11 rows in set (0.2155 sec)

 

Count the rows of employees table, that we will match after the migration into OCI:

MySQL xx.xx.xxx.125:3306 ssl  employees  SQL > select count(*) from employees;

 

Output:

+———-+

| count(*) |

+———-+

|   300024 |

+———-+

1 row in set (0.2676 sec)

 

Create a Bucket in OCI Console “migrationbucket_v1” as in following steps:

     Click on Hamburger menu  ->  Storage -> Object Storage -> Bucket

 

 

mysql_bucket_storage_hamburger_v1

 

mysql_create_bucket

 

Now from OCI Compute instance run the following command to get the details of the bucket:

oci os bucket get –name migrationbucket_v1

 

bucket_ns_get

 

Now we will do dry run of MySQL Shell Dump on Source GCP, replace your values of Bucket/Namespace as per your environment  :

mysqlsh -p -h xx.xx.xxx.125 -u root

 

MySQL xx.xx.xxx.125:3306 ssl JS > util.dumpInstance(“gcpmysql”, {“osBucketName”: “migrationbucket_v1”, “osNamespace”: “XXXXXXXXXXXXX01”, “ocimds”: “true”, “compatibility”:[“strip_restricted_grants”, “strip_definers”,”skip_invalid_accounts”,”create_invisible_pks”], users: “true”, dryRun:”true”})

 

Output:

mysql_export_dump_instance_dry_run

 

Now run actual MySQL Shell dump into object storage having dryRun value to false :

MySQL xx.xx.xxx.125:3306 ssl JS > util.dumpInstance(“gcpmysql”, {“osBucketName”: “migrationbucket_v1”, “osNamespace”: “XXXXXXXXXXXXX01”, “ocimds”: “true”, “compatibility”:[“strip_restricted_grants”, “strip_definers”,”skip_invalid_accounts”,”create_invisible_pks”], users: “true”, dryRun:”false”})

 

Output:

mysql_export_dump_instance_actual_run

Now you can see the objects, would have been uploaded into the OCI object storage bucket “migrationbucket_v1” :

 

mysql_object_Storage_output

We will create a MySQL HeatWave System and import the dump data from object storage using PAR URL during the provisioning of MySQL HeatWave in OCI Console:

 

In OCI Console -> Hamburger Menu -> Databases -> DB Systems

db_system_navigation_V7

 

Click on “Create DB System”:

create_db_system_button_v8

 

 

 

db_system_details

 

credential_networking_Details_db_system

Choose the Require Shape and Click on “Show advanced options”

 

storage_shape

 

 

Click on the “Data import” tab and then “Click here to create a PAR URL for an existing bucket”

 

click_here_par_button

 

Choose the bucket which we created earlier, then click on “Create and set PAR URL”:

existing_bucket_par_url_creation_v17

 

Now PAR Source URL would be auto populated and click on “Create” button:

 

mysql_dataimport_par_url_v17

 

MySQL DB System will be created(It took 19 minutes for this configuration,it may vary based on your configuration/data size):

mysql_heatwave_active_v18

 

In the endpoints, there will be IP address of this DB System:

mysql_endpoint__details_v19

 

Now we will connect using the MySQL Shell to OCI MySQL HeatWave:

 

MysqlShell_to_OCI_Login_v20

 

Verify the Non Default databases, which have been migrated from GCP to OCI:

mysql_oci_HW_show_db_after_migration_v21

 

mysql_hw_oci_tables_detail_v22

 

Verify the number of rows of tables in OCI:

mysql_hw_employees_rows_count

 

For more information see the following resources:

Instance Dump Utility, Schema Dump Utility, and Table Dump Utility

MySQL HeatWave: One Database for OLTP, OLAP, ML & Lakehouse

HeatWave—In-Memory Query Accelerator with Built-in ML