概览
在本页中,您将学习如何使用 Database Migration Service API 管理 PostgreSQL 源数据库的迁移作业。
您可以通过两种方式使用 Database Migration Service API。您可以进行 REST API 调用,也可以使用 Google Cloud CLI (CLI)。
如需查看有关使用 gcloud
管理 Database Migration Service 迁移作业的概要信息,请点击此处。
创建迁移作业的草稿
以下示例展示了在草稿模式下创建迁移作业的请求。这样,您无需一次性创建迁移作业。您可以创建其一部分,然后使用 PATCH
操作对其进行更新。
例如,如果您想创建迁移作业,但没有目标数据库或网络连接方法,则可以使用以下代码:
在使用任何请求数据之前,请先进行以下替换:
- project-id:项目 ID
- region:项目区域
- migration-job-id:迁移作业 ID
- migration-job-name:迁移作业名称
- source-connection-profile-id:来源连接配置文件 ID
- destination-connection-profile-id:目标连接配置文件 ID
- provider:与来源数据库的分类类型关联的提供方。
- 对于独立 PostgreSQL 实例,请使用
DATABASE_PROVIDER_UNSPECIFIED
,因为此值与本地数据库相关联。 - 对于 Cloud SQL for PostgreSQL 实例,请使用
CLOUDSQL
。 - 对于任何托管式数据库服务,请使用其对应的
ENUM
值。请参阅DatabaseProvider
对象引用。
- 对于独立 PostgreSQL 实例,请使用
HTTP 方法和网址:
POST https://datamigration.googleapis.com/v1/projects/project-id /locations/region /migrationJobs?migrationJobId=migration-job-id
请求 JSON 正文:
{ "displayName": "migration-job-name ", "state": "DRAFT", "type": "CONTINUOUS", "source": "projects/project-id /locations/region /connectionProfiles/source-connection-profile-id ", //"destination":"projects/project-id /locations/region /connectionProfiles/destination-connection-profile-id ", "sourceDatabase": { "engine": "POSTGRESQL", "provider": "provider " }, //"vpcPeeringConnectivity": { //"vpc": "default" //} }
如需发送您的请求,请展开以下选项之一:
curl(Linux、macOS 或 Cloud Shell)
将请求正文保存在名为 request.json
的文件中,然后执行以下命令:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://datamigration.googleapis.com/v1/projects/project-id /locations/region /migrationJobs?migrationJobId=migration-job-id "
PowerShell (Windows)
将请求正文保存在名为 request.json
的文件中,然后执行以下命令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://datamigration.googleapis.com/v1/projects/project-id /locations/region /migrationJobs?migrationJobId=migration-job-id " | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
{ "name": "projects/project-id /locations/region /operations/operation-1591975557292-5a7e4b195623c-e350e3da-713dee7d", "metadata": { "@type": "type.googleapis.com/google.cloud.clouddms.v1.OperationMetadata", "createTime": "2020-06-12T15:25:57.430715421Z", "target": "projects/project-id /locations/region /migrationJobs/migration-job-id ", "verb": "create", "requestedCancellation": false, "apiVersion": "v1" }, "done": false }
创建具有 VPC 对等互连的持续迁移作业
以下示例展示了一个请求,该请求用于创建一个持续迁移作业,以便使用 VPC 对等互连连接将 PostgreSQL 数据库(在 Google Compute Engine 虚拟机上运行)迁移到 Cloud SQL for PostgreSQL。
在使用任何请求数据之前,请先进行以下替换:
- project-id:项目 ID
- region:项目区域
- migration-job-id:迁移作业 ID
- migration-job-name:迁移作业名称
- source-connection-profile-id:来源连接配置文件 ID
- destination-connection-profile-id:目标连接配置文件 ID
- provider:与来源数据库的分类类型关联的提供方。
- 对于独立 PostgreSQL 实例,请使用
DATABASE_PROVIDER_UNSPECIFIED
,因为此值与本地数据库相关联。 - 对于 Cloud SQL for PostgreSQL 实例,请使用
CLOUDSQL
。 - 对于任何托管式数据库服务,请使用其对应的
ENUM
值。请参阅DatabaseProvider
对象引用。
- 对于独立 PostgreSQL 实例,请使用
HTTP 方法和网址:
POST https://datamigration.googleapis.com/v1/projects/project-id /locations/region /migrationJobs?migrationJobId=migration-job-id
请求 JSON 正文:
{ "displayName": "migration-job-name ", "state": "NOT_STARTED", "type": "CONTINUOUS", "source": "projects/project-id /locations/region /connectionProfiles/source-connection-profile-id ", "destination":"projects/project-id /locations/region /connectionProfiles/destination-connection-profile-id ", "sourceDatabase": { "engine": "POSTGRESQL", "provider": "provider " }, "vpcPeeringConnectivity": { "vpc": "default" } }
如需发送您的请求,请展开以下选项之一:
curl(Linux、macOS 或 Cloud Shell)
将请求正文保存在名为 request.json
的文件中,然后执行以下命令:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://datamigration.googleapis.com/v1/projects/project-id /locations/region /migrationJobs?migrationJobId=migration-job-id "
PowerShell (Windows)
将请求正文保存在名为 request.json
的文件中,然后执行以下命令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://datamigration.googleapis.com/v1/projects/project-id /locations/region /migrationJobs?migrationJobId=migration-job-id " | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
{ "name": "projects/project-id /locations/region /operations/operation-1591975557292-5a7e4b195623c-e350e3da-713dee7d", "metadata": { "@type": "type.googleapis.com/google.cloud.clouddms.v1.OperationMetadata", "createTime": "2020-06-12T15:25:57.430715421Z", "target": "projects/project-id /locations/region /migrationJobs/migration-job-id ", "verb": "create", "requestedCancellation": false, "apiVersion": "v1" }, "done": false }
如需详细了解如何使用 gcloud
创建 Database Migration Service 迁移作业,请点击此处。
创建具有反向 SSH 连接的持续迁移作业
以下示例展示了一个请求,该请求用于创建一个持续运行的迁移作业,以便使用反向 SSH 连接将 Amazon RDS PostgreSQL 数据库迁移到 Cloud SQL for PostgreSQL。
在使用任何请求数据之前,请先进行以下替换:
- project-id:项目 ID
- region:项目区域
- migration-job-id:迁移作业 ID
- migration-job-name:迁移作业名称
- source-connection-profile-id:来源连接配置文件 ID
- destination-connection-profile-id:目标连接配置文件 ID
- vm-name:SSH 虚拟机的名称。例如,dms-ssh-bastion。
- vm-ip-address:SSH 虚拟机的 IP 地址。例如:11.22.33.44。
- vm-port:SSH 虚拟机的连接端口。例如,3306。
- vpc-name:VPC 网络名称。例如,projects/project-id/global/networks/test-network。
- provider:与来源数据库的分类类型关联的提供方。
- 对于独立 PostgreSQL 实例,请使用
DATABASE_PROVIDER_UNSPECIFIED
,因为此值与本地数据库相关联。 - 对于 Cloud SQL for PostgreSQL 实例,请使用
CLOUDSQL
。 - 对于任何托管式数据库服务,请使用其对应的
ENUM
值。请参阅DatabaseProvider
对象引用。
- 对于独立 PostgreSQL 实例,请使用
HTTP 方法和网址:
POST https://datamigration.googleapis.com/v1/projects/project-id /locations/region /migrationJobs?migrationJobId=migration-job-id
请求 JSON 正文:
{ "displayName": "migration-job-name ", "state": "NOT_STARTED", "type": "CONTINUOUS", "source": "projects/project-id /locations/region /connectionProfiles/source-connection-profile-id ", "destination":"projects/project-id /locations/region /connectionProfiles/destination-connection-profile-id ", "sourceDatabase": { "engine": "POSTGRESQL", "provider": "provider " }, "reverseSshConnectivity": { "vm": "vm-name ", "vm_ip": "vm-ip-address ", "vm_port":vm-port , "vpc": "vpc-name " } }
如需发送您的请求,请展开以下选项之一:
curl(Linux、macOS 或 Cloud Shell)
将请求正文保存在名为 request.json
的文件中,然后执行以下命令:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://datamigration.googleapis.com/v1/projects/project-id /locations/region /migrationJobs?migrationJobId=migration-job-id "
PowerShell (Windows)
将请求正文保存在名为 request.json
的文件中,然后执行以下命令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://datamigration.googleapis.com/v1/projects/project-id /locations/region /migrationJobs?migrationJobId=migration-job-id " | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
{ "name": "projects/project-id /locations/region /operations/operation-1591973161667-5a7e422cb0ba4-3004980d-2ae97165", "metadata": { "@type": "type.googleapis.com/google.cloud.clouddms.v1.OperationMetadata", "createTime": "2020-06-12T14:46:01.744267779Z", "target": "projects/project-id /locations/region /migrationJobs/migration-job-id ", "verb": "create", "requestedCancellation": false, "apiVersion": "v1" }, "done": false }
如需详细了解如何使用 gcloud
创建 Database Migration Service 迁移作业,请点击此处。
创建使用 IP 许可名单连接的迁移作业
以下示例展示了创建迁移作业的请求,该请求使用 IP 许可名单将独立 PostgreSQL 实例或托管式数据库服务迁移到 Cloud SQL for PostgreSQL 数据库。
在使用任何请求数据之前,请先进行以下替换:
- project-id:项目 ID
- region:项目区域
- migration-job-id:迁移作业 ID
- migration-job-name:迁移作业名称
- source-connection-profile-id:来源连接配置文件 ID
- destination-connection-profile-id:目标连接配置文件 ID
- provider:与来源数据库的分类类型关联的提供方。
- 对于独立 PostgreSQL 实例,请使用
DATABASE_PROVIDER_UNSPECIFIED
,因为此值与本地数据库相关联。 - 对于 Cloud SQL for PostgreSQL 实例,请使用
CLOUDSQL
。 - 对于任何托管式数据库服务,请使用其对应的
ENUM
值。请参阅DatabaseProvider
对象引用。
- 对于独立 PostgreSQL 实例,请使用
HTTP 方法和网址:
POST https://datamigration.googleapis.com/v1/projects/project-id /locations/region /migrationJobs?migrationJobId=migration-job-id
请求 JSON 正文:
{ "displayName": "migration-job-name ", "state": "NOT_STARTED", "type": "CONTINUOUS", "source": "projects/project-id /locations/region /connectionProfiles/source-connection-profile-id ", "destination":"projects/project-id /locations/region /connectionProfiles/destination-connection-profile-id ", "sourceDatabase": { "engine": "POSTGRESQL", "provider": "provider " }, "staticIpConnectivity": {} }
如需发送您的请求,请展开以下选项之一:
curl(Linux、macOS 或 Cloud Shell)
将请求正文保存在名为 request.json
的文件中,然后执行以下命令:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://datamigration.googleapis.com/v1/projects/project-id /locations/region /migrationJobs?migrationJobId=migration-job-id "
PowerShell (Windows)
将请求正文保存在名为 request.json
的文件中,然后执行以下命令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://datamigration.googleapis.com/v1/projects/project-id /locations/region /migrationJobs?migrationJobId=migration-job-id " | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
{ "name": "projects/project-id /locations/region /operations/operation-1591973161667-5a7e422cb0ba4-3004980d-2ae97165", "metadata": { "@type": "type.googleapis.com/google.cloud.clouddms.v1.OperationMetadata", "createTime": "2020-06-12T14:46:01.744267779Z", "target": "projects/project-id /locations/region /migrationJobs/migration-job-id ", "verb": "create", "requestedCancellation": false, "apiVersion": "v1" }, "done": false }
如需详细了解如何使用 gcloud
创建 Database Migration Service 迁移作业,请点击此处。
获取迁移作业相关信息
在使用任何请求数据之前,请先进行以下替换:
- project-id:项目 ID
- region:项目区域
- migration-job-id:迁移作业 ID
HTTP 方法和网址:
GET https://datamigration.googleapis.com/v1/projects/project-id /locations/region /migrationJobs/migration-job-id
如需发送您的请求,请展开以下选项之一:
curl(Linux、macOS 或 Cloud Shell)
执行以下命令:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://datamigration.googleapis.com/v1/projects/project-id /locations/region /migrationJobs/migration-job-id "
PowerShell (Windows)
执行以下命令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://datamigration.googleapis.com/v1/projects/project-id /locations/region /migrationJobs/migration-job-id " | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
{ "name": "projects/project-id /locations/region /migrationJobs/one-time-vpc-job", "createTime": "2020-06-12T15:48:39.666093835Z", "updateTime": "2020-06-12T15:48:39.666093835Z", "displayName": "migration-job-display-name ", "state": "CREATING", "type": "CONTINUOUS", "source": "projects/project-id /locations/region /connectionProfiles/connection-profile-id ", "destination": "projects/project-id /locations/region /connectionProfiles/connection-profile-id ", "sourceDatabase": { "engine": "POSTGRESQL" }, "destinationDatabase": { "provider": "CLOUDSQL" }, "vpcPeeringConnectivity": { "vpc": "default" } }
如需详细了解如何使用 gcloud
检索迁移作业的相关信息,请点击此处。
列出迁移作业
在使用任何请求数据之前,请先进行以下替换:
- project-id:项目 ID
- region:项目区域
orderBy:
使用此过滤条件可按字母顺序检索特定区域的所有迁移作业的列表。例如,orderBy=name
过滤条件会按名称按字母顺序返回所有迁移作业。-
pageSize:
使用此过滤条件可指定 Database Migration Service 在页面上检索和显示的迁移作业的数量上限。例如,通过设置pageSize=10
,Database Migration Service 最多会针对网页返回 10 个迁移作业。
如果有超过 10 项迁移作业,则它们会显示在其他页面上。每个页面底部都会显示一个 nextPageToken
参数和一个唯一标识符(例如 oasndfoasdnoasun1241243ojsandf
)。您可以使用该标识符检索下一个页面上的迁移作业列表。在最终页面上,nextPageToken
参数和唯一标识符不会显示。
HTTP 方法和网址:
GET https://datamigration.googleapis.com/v1/projects/project-id /locations/region /migrationJobs
如需发送您的请求,请展开以下选项之一:
curl(Linux、macOS 或 Cloud Shell)
执行以下命令:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://datamigration.googleapis.com/v1/projects/project-id /locations/region /migrationJobs"
PowerShell (Windows)
执行以下命令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://datamigration.googleapis.com/v1/projects/project-id /locations/region /migrationJobs" | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
{ "migrationJobs": [ { "name": "projects/project-id /locations/region /migrationJobs/name-of-first-migration-job ", "createTime": "2020-06-12T15:48:39.666093835Z", "updateTime": "2020-06-12T15:48:39.666093835Z", "displayName": "display-name-of-first-migration-job ", "state": "NOT_STARTED", "type": "CONTINUOUS", "source": "projects/project-id /locations/region /connectionProfiles/connection-profile-id ", "destination": "projects/project-id /locations/region /connectionProfiles/connection-profile-id ", "sourceDatabase": { "engine": "POSTGRESQL" }, "destinationDatabase": { "provider": "CLOUDSQL" }, "vpcPeeringConnectivity": { "vpc": "default" } } { "name": "projects/project-id /locations/region /migrationJobs/name-of-second-migration-job ", "createTime": "2021-02-13T11:59:39.104613835Z", "updateTime": "2021-02-13T12:01:38.666093835Z", "displayName": "display-name-of-second-migration-job ", "state": "RUNNING", "type": "CONTINUOUS", "source": "projects/project-id /locations/region /connectionProfiles/connection-profile-id ", "destination": "projects/project-id /locations/region /connectionProfiles/connection-profile-id ", "sourceDatabase": { "engine": "POSTGRESQL" }, "destinationDatabase": { "provider": "CLOUDSQL" }, "staticIpConnectivity": {} "vpc": "default" } ], "nextPageToken": "unique-identifier " }
如需详细了解如何使用 gcloud
检索所有迁移作业的相关信息,请点击此处。
为迁移作业生成 SSH 隧道配置脚本
在使用任何请求数据之前,请先进行以下替换:
- project-id:项目 ID
- region:项目区域
- migration-job-id:迁移作业 ID
HTTP 方法和网址:
POST https://datamigration.googleapis.com/v1/projects/project-id /locations/region /migrationJobs/migration-job-id :generateSshScript
请求 JSON 正文:
{ "vm":"vm-name ", "vmCreationConfig":{ "vmMachineType":"machine-type ", "subnet":"subnet-name " } }
如需发送您的请求,请展开以下选项之一:
curl(Linux、macOS 或 Cloud Shell)
将请求正文保存在名为 request.json
的文件中,然后执行以下命令:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://datamigration.googleapis.com/v1/projects/project-id /locations/region /migrationJobs/migration-job-id :generateSshScript"
PowerShell (Windows)
将请求正文保存在名为 request.json
的文件中,然后执行以下命令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://datamigration.googleapis.com/v1/projects/project-id /locations/region /migrationJobs/migration-job-id :generateSshScript" | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
{ "name": "projects/project-id /locations/region /operations/operation-1591973161667-5a7e422cb0ba4-3004980d-2ae97165", "metadata": { "@type": "type.googleapis.com/google.cloud.clouddms.v1.OperationMetadata", "createTime": "2020-06-12T14:46:01.744267779Z", "target": "projects/project-id /locations/region /migrationJobs/migration-job-id ", "verb": "generate", "requestedCancellation": false, "apiVersion": "v1" }, "done": false }
如需详细了解如何使用 gcloud
为迁移作业生成 SSH 脚本,请点击此处。
验证迁移作业
以下是用于验证迁移作业的请求。通过验证迁移作业,您可以确保作业能够成功启动和运行。
在使用任何请求数据之前,请先进行以下替换:
- project-id:项目 ID
- region:项目区域
- migration-job-id:迁移作业 ID
HTTP 方法和网址:
POST https://datamigration.googleapis.com/v1/projects/project-id /locations/region /migrationJobs/migration-job-id :verify
如需发送您的请求,请展开以下选项之一:
curl(Linux、macOS 或 Cloud Shell)
执行以下命令:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d "" \
"https://datamigration.googleapis.com/v1/projects/project-id /locations/region /migrationJobs/migration-job-id :verify"
PowerShell (Windows)
执行以下命令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-Uri "https://datamigration.googleapis.com/v1/projects/project-id /locations/region /migrationJobs/migration-job-id :verify" | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
{ "name": "projects/project-id /locations/region /operations/operation-1591973161667-5a7e422cb0ba4-3004980d-2ae97165", "metadata": { "@type": "type.googleapis.com/google.cloud.clouddms.v1.OperationMetadata", "createTime": "2020-06-12T14:46:01.744267779Z", "target": "projects/project-id /locations/region /migrationJobs/migration-job-id ", "verb": "verify", "requestedCancellation": false, "apiVersion": "v1" }, "done": false }
如需详细了解如何使用 gcloud
验证迁移作业,请点击此处。
更新迁移作业
以下显示了用于更新现有迁移作业的显示名称的请求。通过在请求中使用 updateMask
参数,使只有这些字段需要包含在请求正文中。
在使用任何请求数据之前,请先进行以下替换:
- project-id:项目 ID
- region:项目区域
- migration-job-id:迁移作业 ID
HTTP 方法和网址:
PATCH https://datamigration.googleapis.com/v1/projects/project-id /locations/region /connectionProfiles/connection-profile-id ?updateMask=displayName
请求 JSON 正文:
{ "displayName": "updated-display-name ", }
如需发送您的请求,请展开以下选项之一:
curl(Linux、macOS 或 Cloud Shell)
将请求正文保存在名为 request.json
的文件中,然后执行以下命令:
curl -X PATCH \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://datamigration.googleapis.com/v1/projects/project-id /locations/region /connectionProfiles/connection-profile-id ?updateMask=displayName"
PowerShell (Windows)
将请求正文保存在名为 request.json
的文件中,然后执行以下命令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method PATCH `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://datamigration.googleapis.com/v1/projects/project-id /locations/region /connectionProfiles/connection-profile-id ?updateMask=displayName" | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
{ "name": "projects/project-id /locations/region /operations/operation-1591973161667-5a7e422cb0ba4-3004980d-2ae97165", "metadata": { "@type": "type.googleapis.com/google.cloud.clouddms.v1.OperationMetadata", "createTime": "2020-06-12T14:46:01.744267779Z", "target": "projects/project-id /locations/region /migrationJobs/migration-job-id ", "verb": "update", "requestedCancellation": false, "apiVersion": "v1" }, "done": false }
如需详细了解如何使用 gcloud
更新迁移作业,请点击此处。
启动迁移作业
以下示例展示了启动迁移作业的请求。
在使用任何请求数据之前,请先进行以下替换:
- project-id:项目 ID
- region:项目区域
- migration-job-id:迁移作业 ID
HTTP 方法和网址:
POST https://datamigration.googleapis.com/v1/projects/project-id /locations/region /migrationJobs/migration-job-id :start
如需发送您的请求,请展开以下选项之一:
curl(Linux、macOS 或 Cloud Shell)
执行以下命令:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d "" \
"https://datamigration.googleapis.com/v1/projects/project-id /locations/region /migrationJobs/migration-job-id :start"
PowerShell (Windows)
执行以下命令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-Uri "https://datamigration.googleapis.com/v1/projects/project-id /locations/region /migrationJobs/migration-job-id :start" | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
{ "name": "projects/project-id /locations/region /operations/operation-1591973161667-5a7e422cb0ba4-3004980d-2ae97165", "metadata": { "@type": "type.googleapis.com/google.cloud.clouddms.v1.OperationMetadata", "createTime": "2020-06-12T14:46:01.744267779Z", "target": "projects/project-id /locations/region /migrationJobs/migration-job-id ", "verb": "start", "requestedCancellation": false, "apiVersion": "v1" }, "done": false }
如需详细了解如何使用 gcloud
启动迁移作业,请点击此处。
重启失败的迁移作业
以下示例显示了重启迁移作业的请求。如果迁移失败且无法恢复,或者在完整转储期间停止,则可以从头开始重新启动迁移作业。
在使用任何请求数据之前,请先进行以下替换:
- project-id:项目 ID
- region:项目区域
- migration-job-id:迁移作业 ID
HTTP 方法和网址:
POST https://datamigration.googleapis.com/v1/projects/project-id /locations/region /migrationJobs/migration-job-id :restart
如需发送您的请求,请展开以下选项之一:
curl(Linux、macOS 或 Cloud Shell)
执行以下命令:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d "" \
"https://datamigration.googleapis.com/v1/projects/project-id /locations/region /migrationJobs/migration-job-id :restart"
PowerShell (Windows)
执行以下命令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-Uri "https://datamigration.googleapis.com/v1/projects/project-id /locations/region /migrationJobs/migration-job-id :restart" | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
{ "name": "projects/project-id /locations/region /operations/operation-1591973161667-5a7e422cb0ba4-3004980d-2ae97165", "metadata": { "@type": "type.googleapis.com/google.cloud.clouddms.v1.OperationMetadata", "createTime": "2020-06-12T14:46:01.744267779Z", "target": "projects/project-id /locations/region /migrationJobs/migration-job-id ", "verb": "restart", "requestedCancellation": false, "apiVersion": "v1" }, "done": false }
如需详细了解如何使用 gcloud
重启迁移作业,请点击此处。
停止迁移作业
以下示例展示了停止迁移作业的请求。
在使用任何请求数据之前,请先进行以下替换:
- project-id:项目 ID
- region:项目区域
- migration-job-id:迁移作业 ID
HTTP 方法和网址:
POST https://datamigration.googleapis.com/v1/projects/project-id /locations/region /migrationJobs/migration-job-id :stop
如需发送您的请求,请展开以下选项之一:
curl(Linux、macOS 或 Cloud Shell)
执行以下命令:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d "" \
"https://datamigration.googleapis.com/v1/projects/project-id /locations/region /migrationJobs/migration-job-id :stop"
PowerShell (Windows)
执行以下命令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-Uri "https://datamigration.googleapis.com/v1/projects/project-id /locations/region /migrationJobs/migration-job-id :stop" | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
{ "name": "projects/project-id /locations/region /operations/operation-1591973161667-5a7e422cb0ba4-3004980d-2ae97165", "metadata": { "@type": "type.googleapis.com/google.cloud.clouddms.v1.OperationMetadata", "createTime": "2020-06-12T14:46:01.744267779Z", "target": "projects/project-id /locations/region /migrationJobs/migration-job-id ", "verb": "stop", "requestedCancellation": false, "apiVersion": "v1" }, "done": false }
如需详细了解如何使用 gcloud
停止迁移作业,请点击此处。
继续执行迁移作业
以下示例显示了继续执行迁移作业的请求。
在使用任何请求数据之前,请先进行以下替换:
- project-id:项目 ID
- region:项目区域
- migration-job-id:迁移作业 ID
HTTP 方法和网址:
POST https://datamigration.googleapis.com/v1/projects/project-id /locations/region /migrationJobs/migration-job-id :resume
如需发送您的请求,请展开以下选项之一:
curl(Linux、macOS 或 Cloud Shell)
执行以下命令:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d "" \
"https://datamigration.googleapis.com/v1/projects/project-id /locations/region /migrationJobs/migration-job-id :resume"
PowerShell (Windows)
执行以下命令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-Uri "https://datamigration.googleapis.com/v1/projects/project-id /locations/region /migrationJobs/migration-job-id :resume" | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
{ "name": "projects/project-id /locations/region /operations/operation-1591973161667-5a7e422cb0ba4-3004980d-2ae97165", "metadata": { "@type": "type.googleapis.com/google.cloud.clouddms.v1.OperationMetadata", "createTime": "2020-06-12T14:46:01.744267779Z", "target": "projects/project-id /locations/region /migrationJobs/migration-job-id ", "verb": "resume", "requestedCancellation": false, "apiVersion": "v1" }, "done": false }
如需详细了解如何使用 gcloud
恢复迁移作业,请点击此处。
提升迁移作业
以下示例展示了提升迁移作业的请求。
在使用任何请求数据之前,请先进行以下替换:
- project-id:项目 ID
- region:项目区域
- migration-job-id:迁移作业 ID
HTTP 方法和网址:
POST https://datamigration.googleapis.com/v1/projects/project-id /locations/region /migrationJobs/migration-job-id :promote
如需发送您的请求,请展开以下选项之一:
curl(Linux、macOS 或 Cloud Shell)
执行以下命令:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d "" \
"https://datamigration.googleapis.com/v1/projects/project-id /locations/region /migrationJobs/migration-job-id :promote"
PowerShell (Windows)
执行以下命令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-Uri "https://datamigration.googleapis.com/v1/projects/project-id /locations/region /migrationJobs/migration-job-id :promote" | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
{ "name": "projects/project-id /locations/region /operations/operation-1591973161667-5a7e422cb0ba4-3004980d-2ae97165", "metadata": { "@type": "type.googleapis.com/google.cloud.clouddms.v1.OperationMetadata", "createTime": "2020-06-12T14:46:01.744267779Z", "target": "projects/project-id /locations/region /migrationJobs/migration-job-id ", "verb": "promote", "requestedCancellation": false, "apiVersion": "v1" }, "done": false }
如需详细了解如何使用 gcloud
提升迁移作业,请点击此处。
删除迁移作业
以下示例显示了删除迁移作业的请求。
在使用任何请求数据之前,请先进行以下替换:
- project-id:项目 ID
- region:项目区域
- migration-job-id:迁移作业 ID
HTTP 方法和网址:
DELETE https://datamigration.googleapis.com/v1/projects/project-id /locations/region /migrationJobs/migration-job-id
如需发送您的请求,请展开以下选项之一:
curl(Linux、macOS 或 Cloud Shell)
执行以下命令:
curl -X DELETE \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://datamigration.googleapis.com/v1/projects/project-id /locations/region /migrationJobs/migration-job-id "
PowerShell (Windows)
执行以下命令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method DELETE `
-Headers $headers `
-Uri "https://datamigration.googleapis.com/v1/projects/project-id /locations/region /migrationJobs/migration-job-id " | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
{ "name": "projects/project-id /locations/region /operations/operation-1591973161667-5a7e422cb0ba4-3004980d-2ae97165", "metadata": { "@type": "type.googleapis.com/google.cloud.clouddms.v1.OperationMetadata", "createTime": "2020-06-12T14:46:01.744267779Z", "target": "projects/project-id /locations/region /migrationJobs/migration-job-id ", "verb": "delete", "requestedCancellation": false, "apiVersion": "v1" }, "done": false }
如需详细了解如何使用 gcloud
删除迁移作业,请点击此处。