github / gh-ost

GitHub's Online Schema-migration Tool for MySQL
MIT License
12.15k stars 1.24k forks source link

Running on Google Cloud SQL #770

Open ekirkland opened 4 years ago

ekirkland commented 4 years ago

We have been successfully using gh-ost with RDS for a few years and now we'd like to use it with an instance that is going to be running in Google Cloud SQL. The problem we're facing is that we can't find out if it's possible to enable binary logging on the replica, and we have had problems in the past in RDS when trying to migrate on master.

I did some searching on here and didn't find too much conversation on using gh-ost with GCP other than the --gcp flag. Could I get some more insight into what this does? Does it allow us to still use the replica even without the binary logging enabled?

zmoazeni commented 4 years ago

I haven't run gh-ost on Google Cloud SQL, but I can help with the --gcp flag.

It currently just changes the way the connection is validated because GCP sets the port to NULL:

https://github.com/github/gh-ost/blob/b38814f90ebfd429bd1bdf0ebd258472e5bb3965/go/base/utils.go#L77-L86

What trouble are you seeing with enabling the binary logging on the replica? Is that option disabled?

https://cloud.google.com/sql/docs/mysql/backup-recovery/restoring#enablingpitr

If their interface (and gcloud route) prohibits it, a (costly) alternative would be to daisy chain a replica maybe?

master -> replica1 -> replica2
          ^^ run gh-ost against this server

As far as I know, ~GCP~ Google Cloud SQL doesn't prohibit that sort of topology (but I could be totally wrong!). And to support it, replica1 would have to enable binary logging.

sunkaiqin commented 4 years ago

Here are some tips from GCP CloudSQL doc, see this link: https://cloud.google.com/sql/docs/mysql/replication/tips

So I suspect GCP may not allow the binary logging on the replica.

zmoazeni commented 4 years ago

Thanks @sunkaiqin TIL!

Skimming that doc this popped out to me: https://cloud.google.com/sql/docs/mysql/replication/tips#external-replica

It looks like you could run a replica on non-CloudSQL that replicates from CloudSQL? It may be annoying to set up a replica elsewhere, but the reliability requirements of that server may be much lower if nothing is operationally depending on it. And you could have gh-ost run against that replica?

sunkaiqin commented 4 years ago

@zmoazeni Happy to work with gh-ost and it is such an amazing tool 👍

Yeah, external replica could be a way to go. As you mentioned we lose the convenience of the managed services from GCP.

Maybe GCP team has more insight regarding replica binlog enablement. Or they could provide this option for us to utilize gh-ost on GCP easily 😄

Thanks anyway for the information.

tedchang77 commented 2 years ago

looks like you can now enable binary logging on read replicas: https://cloud.google.com/sql/docs/mysql/replication#bin-log-replica