Monday, June 26, 2023

MySQL: Migrate MySQL to OCI MySQL Heatwave - Part 1/3

 

This will be a workshop to show how to migrate MySQL data from MySQL 8 Community Edition running on OCI compute instance to OCI MySQL Heatwave. This will be covered over three blog posts. 

Note: the source MySQL may be running on-premises as well.

In this blog, we will cover installing MySQL 8 Community Edition in Oracle OCI compute instance.

-        Prerequisites

Ø  An Oracle cloud fee trial or paid account.

Step #1: Create and configure virtual cloud network (VCN) in OCI.

1. Login to OCI. Navigate to “Networking” > “Virtual Cloud Networks”.


2. Once on the Virtual Cloud Networks page, click “Start VCN Wizard” and select “Create VCN with Internet Connectivity”.

3. Name you VCN “MySQL-VCN”. Make sure to pick up the correct compartment.                                                        
Leave everything as it is and click “Next”. Review all information and click “Create”.


4. Once VNC is created, click “View Virtual Cloud Network”.


5. 
Once on the MySQL-VCN page, under “Resources” click “Subnets” and go to the “Private-Subnet-MySQL-VCN”.




6. On the Private Subnet page, under “Security Lists”, click on “Security List for Private Subnet-MySQL-VCN” and select “Add Ingress Rules”.


7. 
Enter below rule info.


Step #2: Create SSH Key in OCI using Cloud Shell


1. Navigate to "Cloud Shell" under 'Developer tools' next to your Home Region.


2. Inside your Cloud Shell, execute below command to create an SSH key-pair.
     
     ssh-keygen -t rsa=



       3. After your public/private rsa key pair has been created, go to the '.ssh' directory and copy 
            the contents of the "id_rsa.pub" file. 
    cd .ssh
    cat id_rsa.pub

Step #3: Setup a Compute Instance

1. Navigate to “Compute” > “Instances”. Make sure you are in the correct compartment and click “Create instance”.

2. Name your compute instance "MySQL-Compute". 
For Placement, leave it at default. For Image and shape, make sure "Oracle Linux 8" is selected and choose an appropriate shape that fits your needs. Under Networking, make sure the Public Subnet of your MySQL-VCN is selected.                       

      3. For the 'Add SSH keys', select "Paste public keys" and paste the contents of the id_rsa.pub file here that we copied in step “SSH Key in OCI using Cloud Shell”. After pasting your public key, leave everything default and click "Create".


    4. Once compute instance is ready. Copy the Public IP address of your Compute instance, then ssh to compute instance from the “Cloud Shell”.


   Step #4: Install MySQL 8 Community Edition in OCI compute instance


     1. Once connected to compute instance, download MySQL Community Edition on the Compute instance by executing below command.









     2. Start the MySQL server after it has been successfully installed onto your Compute instance. Once the server starts, login to MySQL.
      Note: during the installation of the MySQL server, it created a root account without a password. 








        3. Change the root password using “ALTER USER” command.



4. Download and install MySQL Shell onto compute instance.





Step #5: Load the sample database into the MySQL database instance


    1. Download the sample 'world' database onto your Compute instance, unzip the file, and load it onto MySQL database instance.

      Note: additional sample MySQL databases can be found here: https://dev.mysql.com/doc/index-other.html

wget https://downloads.mysql.com/docs/world-db.zip

unzip world-db.zip

cd world-db

mysql -u root -p < world.sql














2. Login to MySQL instance and check sample database.

























Next blog, we will cover performing MySQL shell dump.

Next blog => MySQL: Migrate MySQL from on-premises to OCI MySQL Heatwave - Part 2/3 


No comments:

Post a Comment

OCW 2024: What to Expect Around Oracle 23ai

  I’m so excited to share that I’ll be attending Oracle CloudWorld 2024 this year!. I’m thrilled as It will be my first OCW event to attend ...