本文說明如何在 Cloud Shell 中安裝及執行 Spanner 遷移工具 (SMT)。如要進一步瞭解 SMT,請參閱 Spanner 遷移工具。
事前準備
- 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.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator
(
roles/resourcemanager.projectCreator
), which contains theresourcemanager.projects.create
permission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator
(
roles/resourcemanager.projectCreator
), which contains theresourcemanager.projects.create
permission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
- 安裝 Google Cloud CLI。
-
如要初始化 Google Cloud CLI,請執行
gcloud init
指令。 按一下編輯按鈕,設定與 Spanner 的連線。
指定下列資訊,連線至 Spanner:
- 專案 ID:Spanner 執行個體所在的專案 ID。
- 執行個體 ID:Spanner 執行個體 ID。
按一下 [儲存]。
- 資料庫引擎:指定來源資料庫是 MySQL、SQL Server、Oracle 還是 PostgreSQL。
- 主機名稱:來源資料庫的 IP 位址。
- 通訊埠:可存取來源資料庫的通訊埠。
- 使用者名稱:來源資料庫的使用者名稱。
- 「Password」(密碼):來源資料庫的密碼。
- Spanner 方言:指定要使用 GoogleSQL 或 PostgreSQL。
安裝 Spanner 遷移工具
您可以使用 Linux 殼層指令或 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 網頁 UI,請執行下列指令:
gcloud alpha spanner migrate web
您必須提供 Google Cloud 憑證,才能允許 SMT 存取資源。按一下先前指令的回應中的 http://localhost:8080
,開啟網頁 UI。
連線至 Spanner
如要使用 SMT 網頁介面連線至 Spanner,請按照下列步驟操作:
連線至來源資料庫
您需要使用 SMT 網頁介面連線至來源資料庫,並提供下列資訊:
輸入資訊後,按一下「測試連線」,然後按一下「連線」,即可連線至來源資料庫。