在 GCP 帐户之间迁移 MySQL 数据库的最佳方法是什么?

What is the best approach to migrate MySQL database between GCP Accounts?

我需要将一个 GCP 中的 MySQL 数据库克隆到另一个 GCP 帐户。

我能想到的最明显的方法是导出 MySQL 然后将其导入另一个帐户。

还有哪些其他选择?

转到控制台中的 Cloud SQL 页面并选择 migrate data。这里有几个迁移案例,其中有一个符合您的要求:

  • Google Cloud project to Google Cloud project

Move an instance from another Google Cloud project into this one

您可以选择将此只读副本设置为主副本(从而完成迁移),或者您可以保持只读副本的状态,您的克隆将始终是原始项目的映像。这里描述的步骤:

The Cloud SQL Migration Assistant will guide you through the following steps:

  • Providing details on your data source
  • Creating a Cloud SQL read replica
  • Synchronising the read replica with the source
  • Promoting the read replica to your primary instance (optional)

1.将数据导出到源账户中的云存储

选择云存储导出位置、格式

The SQL export process may take a long time (possibly an hour or more for large instances). You will not be able to perform operations on your instance for the entire duration of the export. Once begun, this process cannot be canceled.

2。将导出的转储文件复制到目标帐户

一个。创建一个存储桶

b。编辑存储桶权限

c。添加成员

d。输入邮件来源帐号

e。 Select 角色

将文件从源帐户复制到目标帐户:

gsutil mv gs://source/export gs://destination/export

如果转储文件有大用途:云数据传输

3。 Select云SQL迁移数据

开始迁移

一个。选择数据源详细信息:数据源名称,Public 源 IP 地址,源端口号,MySQL 复制用户名,密码,

b。创建并配置外部主实例的新 Cloud SQL 只读副本。选择只读副本实例 ID、位置、区域、机器类型、存储类型、存储容量、从 Google 云存储

导入 SQL 转储

c。数据同步

d。只读副本升级(可选)