Migrating to Cloud SQL from Amazon RDS for MySQL Using Database Migration Service
Architecture Diagram
Objectives
How to configure a one-time Database Migration Service job to migrate databases from a cloud-based MySQL instance to Cloud SQL for MySQL.
- Create a profile for a source connected to a cloud-based MySQL instance (Amazon RDS for MySQL).
- Configure connectivity between source and destination instances using an IP allowlist.
- Create and run a one-time migration job using Database Migration Service.
- Verify that the migration job has completed successfully.
Prerequisites
Database Migration API is enabled
- To install dig in Cloud Shell, run the following command:
sudo apt-get update && sudo apt-get install dnsutils -y
dig HOSTNAME
copy ip name ex: 169.254.169.254
Task 1. Install and configure the AWS CLI tool in GCP Cloud Shell
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
- To configure the AWS CLI tool in Cloud Shell, run the following command:
aws configure
AWS Access Key ID [None] enter the provided value for AWS Access Key
AWS Secret Access Key [None] enter the provided value for AWS Secret Key
Default region name [None] put region name
Default output format [None] to accept the default
Task 2. Create a new connection profile for the Amazon RDS instance for MySQL
- In the Google Cloud Console, on the Navigation menu
click Database Migration > Connection profiles.
- Click Create Profile.
- For Source database engine, select Amazon RDS for MySQL.
- Enter the required information for a connection profile:
Connection profile name — — -mysql-rds
Connection profile ID — — -put value
Hostname or IP address — -enter the IP address you identified for the Amazon RDS instance in the Setup tasks (such as 54.84.181.60)
Port — -put 3306
Username — — — — — — — — -ex:-admin
Password — — — — — — — ex:- changeme
- For Region, select us-central1 (Iowa).
- For the Encryption Type, select None.
Click Create.
Task 3. Create a one-time migration job
- In the Google Cloud Console, on the Navigation menu (
- ), click Database Migration > Migration jobs.
- Click Create Migration Job.
- For Create a migration job, on the Get Started tab, use the following values:
- Migration job name rds-to-cloudsql
- Migration job ID keep the auto-generated value
- Source database engineAmazon RDS for MySQL
- Destination regionus-central1 (Iowa)
- Migration job typeOne-time
- Leave all other settings as default.
- Click Save & Continue.
Define the source instance
- For source connection profile, select mysql-rds.
- Click Save & Continue.
Create the destination instance
Destination Instance ID mysql-cloudsql
User Root
password — — — — — — — — — — supersecret
Database version Cloud SQL for MySQL 5.7
Zone Any
Connections Public IP
Machine type — — -Standard (1 vCPU, 3.75 GB)
Storage type SSD
Storage capacity 10
- Click Create & Continue.
- When prompted to confirm, click Create Destination & Continue.
Define the connectivity method
- For Connectivity method, select IP allowlist.
When the destination database (Cloud SQL for MySQL) is created, the IP address will be available.
- Copy the Destination outgoing IP address (such as 35.239.140.158) to configure the IP allowlist on the Amazon RDS instance.
- Click Save & Continue.
Task 4. Configure the IP allowlist on source instance
- To modify the IP allowlist on the Amazon RDS instance, run the following command in Cloud Shell:
- Replace
<sg_id>
with the provided value for AWS RDS Database Security Group (such assg-06700713f70076ad8
) on this page, and replace<a.b.c.d>
with the Destination outgoing IP address of your Cloud SQL instance (such as35.239.140.158
).
aws ec2 authorize-security-group-ingress \
--group-id <sg-id> \
--protocol tcp \
--port 3306 \
--cidr <a.b.c.d>/32
Task 5. Test and run a one-time migration job
- Return to the migration job window and review the summary.
- Click Test Job.
- After a successful test, click Create & Start Job.
Task 6. Review status of the one-time migration job in DMS
- In the Google Cloud Console, on the Navigation menu (
- click Database Migration > Migration jobs.
- Click the migration job rds-to-cloudsql to see the details page.
- Review the migration job status.
Task 7. Confirm the data in Cloud SQL for MySQL
Check MySQL databases in Cloud SQL
- In the Google Cloud Console, on the Navigation menu (
- click Databases > SQL.
- Click on the instance ID called mysql-cloudsql.
- In the Primary Instance menu, click Databases.
Notice that the databases called customers_data and sales_data have been migrated to Cloud SQL.
Connect to MySQL database
- In the Primary Instance menu, click Overview.
- In Connect to this instance panel, click on Open cloud shell button.
The command to connect to MySQL will pre-populate in Cloud Shell:
gcloud sql connect mysql-cloudsql --user=root --quiet
- Run the pre-populated command.
If prompted, click Authorize for the API.
- When prompted for a password, which you previously set, enter:
password
Review data in Cloud SQL for MySQL database
- To select the database in the MySQL interactive console, run the following command:
use customers_data;
- Query the number of records in the customers table:
select count(*) from customers;