Eddi Alim
Eddi Alim
  • 1
  • 5 908
MySQL AWS RDS replication to Google Cloud SQL
MySQL AWS RDS Replication to Google Cloud SQL
Here is a simple howto guide for how to replicate from AWS RDS to Google Cloud SQL.
To setup replication on Google Cloud SQL, we need a static IP address but RDS does not have a static IP address. So for that reason, we need the proxy to forward the traffic from master to slave. There are many different kinds of solutions out there which Bill Schneider already wrote in his blog post.
I will go with socat for this test example:
socat: e.g., socat TCP-LISTEN,[port],fork,reuseaddr TCP:[hostname]:[port].
Let's get it on!
So here is the recipe for our cooking session:
Instances:
- AWS RDS (Master)
- EC2 Instance (Proxy)
- Google Cloud SQL (Slave)
Before we can start with the replication we need to make the following changes on the RDS Master instance:
- Enable backup
Backup needs to be enabled for binlog to be enabled or have 1 replication rds instance running.
- Setup a new Parameter Group for your RDS Master.
We need to enable enforce_gtid_consistency & gtid_mode = ON
A reboot is required for this.
Now, lets set up a small VM for forwarding a static IP to an RDS hostname.
Use a static Elastic IP for making sure that the IP will not change during a reboot
Adjust Security Group to make port 3306 wide open. (You can adjust it later to make it more secure)
Once you have the instance running you only need to install socat and run following command:
$ socat -v TCP-LISTEN:3306,fork TCP:rds-master.c3u5ki2hnnys.eu-central-1.rds.amazonaws.com:3306
That's it! nothing more to do here.
Now let us have look on the Google Cloud Replication.
Instead of creating a new instance we need to use the migration wizard of google in order to make replication work.
Only 3 steps are needed for this procedure:
Install the Google Cli SDK on your VM or local machine
Create a Google Storage bucket to upload the mysqldump
Make a mysqldump of the database and upload it to the storage
Then let's run the mysqldump from their master and upload it directly to the Google Storage Bucket:
$ mysqldump \
-h3.122.54.17 -P -urdsmaster -p \
- databases aws-rds-master-db \
- hex-blob - skip-triggers - master-data=1 \
- order-by-primary - compact - no-autocommit \
- default-character-set=utf8mb4 - ignore-table \
- single-transaction - set-gtid-purged=on | gzip | gsutil cp - gs://rdsmaster/hq-master1.sql.gz
You will find more pieces of information about Google Cloud SQL external replication here.
Once this is done we basically only have to go through the Google Cloud SQL Migration process and use the Elastic IP of the EC2 Proxy and the MySQL credentials!
มุมมอง: 5 909

วีดีโอ

ความคิดเห็น

  • @giyeolim1031
    @giyeolim1031 2 ปีที่แล้ว

    knock knock~ I have Question. Nowaday, Use this tech??

  • @udaygovindarajula1655
    @udaygovindarajula1655 4 ปีที่แล้ว

    Wil this work in case of migrating from RDS to Cloudsql Postgres?

  • @harshitverma9298
    @harshitverma9298 4 ปีที่แล้ว

    Hey Eddi, I have a problem! I want to transfer my all aws mariadb database to google studio. How can I do this???

  • @singleunit
    @singleunit 5 ปีที่แล้ว

    and also edit the Parameter Cluster Group binlog_format to anything other than OFF

  • @singleunit
    @singleunit 5 ปีที่แล้ว

    Great video, Thank you. A couple of points that need to be clarified. this will not work for a Aurora MySQL cluster as is. you will need to make sure the cluster is on ver 2.04 or higher of Aurora and you create Parameter Cluster Group instead of DB group. Plus for those that don't know (this was me until recently) the mysql dump command should be run within google cloud shell

  • @jamiedowns7189
    @jamiedowns7189 5 ปีที่แล้ว

    Hi Erdal, great video thanks for posting. I was wondering if you have an email address or other means I can contact you by? Thanks.

  • @Davidlavieri
    @Davidlavieri 5 ปีที่แล้ว

    Nice and simple great video! I wanted to do backups every 6h from rds and send them to gcloud bucket, but this seems better! Thanks