设置 Spanner 迁移工具

本文档介绍了如何在 Cloud Shell 上安装和运行 Spanner 迁移工具 (SMT)。如需详细了解 SMT,请参阅 Spanner 迁移工具

准备工作

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  3. Verify that billing is enabled for your Google Cloud project.

  4. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  5. Verify that billing is enabled for your Google Cloud project.

  6. 安装 Google Cloud CLI。
  7. 如需初始化 Google Cloud CLI,请运行 gcloud init 命令。
  8. 安装 Spanner 迁移工具

    您可以使用 Linux shell 命令或 Google Cloud CLI 安装 SMT:

    Linux shell

    如需安装 SMT,请运行以下命令:

      sudo apt-get install google-cloud-sdk-spanner-migration-tool
    

    gcloud

    您可以使用 gcloud components install 命令安装 SMT:

      gcloud components install spanner-migration-tool
    

    如需详细了解如何安装 SMT,请参阅安装 Spanner 迁移工具

    访问 Spanner 迁移工具

    您可以使用 gcloud alpha spanner migrate 命令访问和使用 SMT。

    如需启动 SMT Web 界面,您可以运行以下命令:

      gcloud alpha spanner migrate web
    

    您需要提供 Google Cloud 凭证,以允许 SMT 访问资源。点击上述命令的响应中的 http://localhost:8080,打开 Web 界面。

    连接到 Spanner

    如需使用 SMT Web 界面连接到 Spanner,请执行以下操作:

    1. 点击修改按钮以配置与 Spanner 的连接。

    2. 指定以下信息以连接到 Spanner:

      • 项目 ID:Spanner 实例所在的项目 ID。
      • 实例 ID:Spanner 实例 ID。
    3. 点击保存

    连接到源数据库

    您需要使用 SMT Web 界面通过提供以下信息连接到源数据库:

    • 数据库引擎:指定源数据库是 MySQL、SQL Server、Oracle 还是 PostgreSQL。
    • 主机名:源数据库的 IP 地址。
    • 端口:源数据库可访问的端口。
    • 用户名:源数据库的用户名。
    • 密码:源数据库的密码。
    • Spanner 方言:指定您要使用 GoogleSQL 还是 PostgreSQL

    输入信息后,您可以点击测试连接,然后点击连接,以连接到源数据库。

    后续步骤