【问题标题】:Migration from Google cloud datastore to Google cloud sql从谷歌云数据存储迁移到谷歌云 sql
【发布时间】:2018-10-11 08:09:34
【问题描述】:

我们将 Google Cloud Datastore 用于我们的 Google App Engine (GAE) 应用程序。在我们的项目改造期间,我们希望将我们的数据库从 Datastore 迁移到 Google Cloud SQL。

我们在 Datastore 中有大约 1 TB 的数据,不包括索引。

如何从 Datastore 迁移到 Cloud SQL,是否有任何现有的开源解决方案可用于此。

我检查了以下一项 https://cloud.google.com/datastore/docs/export-import-entities,不利于datastore和sql之间的数据迁移

谢谢

【问题讨论】:

    标签: google-cloud-platform google-cloud-datastore google-cloud-sql


    【解决方案1】:

    您可以使用Cloud Datastore to JSON dataflow template 导出到 JSON 文件,然后运行脚本将 JSON 文件读入云 sql。

    【讨论】:

      【解决方案2】:

      有不同的方法来管理这个,我认为最简单的方法是按照 Jim Morrison 所说的,使用 Cloud Datastore to JSON Dataflow 模板。这种方法也有不同的可能性:

      首先使用该命令将公共模板下载到本地:

       gsutil cp gs://dataflow-templates/latest/Datastore_to_GCS_Text .
      

      (注意不要删除最后一个.,你可以换到你要下载的目录)

      然后,正如 Jim Morrison 在他的回答中向您解释的那样,编辑下载的文件并使用您自己的 [1] 更改模板参数。

      完成后,将其再次上传到您拥有的存储桶中。例如:

      gsutil cp Datastore_to_GCS_Text gs://datastore_to_cloudsql/template/
      

      然后您可以使用 GCP Console 运行作业(通过使用自定义模板从模板创建作业)[2]

      当您拥有 JSON 文件后,将其转换为 CSV 并将其导入云 SQL [3]。另外,也许您想添加一个函数,因为模板参数允许[1] 直接将导出的数据转换为 CSV 格式而不是 JSON 文件。

      提供的 JSON 格式是一个文档,其中填充了类似这样的行,我对其进行了格式化以使其更清晰:

      {
        "key":{"partitionId":{"projectId":"MY_PROJECT_ID"},
        "path":[{"kind":"MY_KIND_NAME","id":"4814888656437248"}]},
        "properties":{
          "MY_FIRST_COLUMN":{"integerValue_FOR_EXAMPLE":"3_INT_VALUE_EXAMPLE"},
          "SECOND_COLUMN":{"stringValue_FOR_EXAMPLE":"foobarfoobarfoobar_FOR_EXAMPLE"},
          "THIRD_COLUMN":{"stringValue_FOR_EXAMPLE":"foobar_FOR_EXAMPLE"}
        }
      }
      

      1:https://cloud.google.com/dataflow/docs/templates/provided-templates#cloud-datastore-to-cloud-storage-text

      2:https://cloud.google.com/dataflow/docs/templates/executing-templates#using-the-gcp-console

      3:https://cloud.google.com/sql/docs/mysql/import-export/importing#importing_csv_files_to_title_short

      【讨论】:

        猜你喜欢
        • 2012-11-16
        • 2017-05-11
        • 2015-02-03
        • 2015-07-17
        • 1970-01-01
        • 2020-09-10
        • 1970-01-01
        • 2022-12-23
        • 1970-01-01
        相关资源
        最近更新 更多