取消数据的导入和导出
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
MySQL
| PostgreSQL
| SQL Server
本页面介绍了如何针对 Cloud SQL 实例取消导入和导出数据。此数据包含在 SQL 转储文件或 CSV 文件中。
须知事项
取消导入或导出操作
您可以使用 gcloud
或 REST API 命令取消导入或导出操作。
gcloud
使用 gcloud sql operations cancel
命令可取消操作。
gcloud sql operations cancel operation-ID
将 operation-ID 变量替换为操作的 ID。如需了解详情,请参阅准备工作。
REST v1
在使用任何请求数据之前,请先进行以下替换:
- project-ID:项目 ID。
- operation-ID:导入或导出操作的 ID。如需了解详情,请参阅准备工作。
HTTP 方法和网址:
POST https://sqladmin.googleapis.com/v1/projects/project-ID/operations/operation-ID/cancel
如需发送您的请求,请展开以下选项之一:
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://sqladmin.googleapis.com/v1/projects/project-ID/operations/operation-ID/cancel"
PowerShell (Windows)
执行以下命令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-Uri "https://sqladmin.googleapis.com/v1/projects/project-ID/operations/operation-ID/cancel" | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
此 REST API 调用不会返回任何响应。如需详细了解如何检查导入或导出操作的取消状态,请参阅检查取消状态。
REST v1beta4
在使用任何请求数据之前,请先进行以下替换:
- project-ID:项目 ID。
- operation-ID:导入或导出操作的 ID。如需了解详情,请参阅准备工作。
HTTP 方法和网址:
POST https://sqladmin.googleapis.com/v1beta4/projects/project-ID/operations/operation-ID/cancel
如需发送您的请求,请展开以下选项之一:
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://sqladmin.googleapis.com/v1beta4/projects/project-ID/operations/operation-ID/cancel"
PowerShell (Windows)
执行以下命令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-Uri "https://sqladmin.googleapis.com/v1beta4/projects/project-ID/operations/operation-ID/cancel" | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
此 REST API 调用不会返回任何响应。如需详细了解如何检查导入或导出操作的取消状态,请参阅检查取消状态。
检查已取消的状态
您可以使用 gcloud
或 REST API 命令检查已取消的导入或导出操作的状态。
REST v1
在使用任何请求数据之前,请先进行以下替换:
- project-ID:项目 ID。
- operation-ID:导入或导出操作的 ID。如需了解详情,请参阅准备工作。
HTTP 方法和网址:
GET https://sqladmin.googleapis.com/v1/projects/project-ID/operations/operation-ID
如需发送您的请求,请展开以下选项之一:
curl(Linux、macOS 或 Cloud Shell)
执行以下命令:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://sqladmin.googleapis.com/v1/projects/project-ID/operations/operation-ID"
PowerShell (Windows)
执行以下命令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://sqladmin.googleapis.com/v1/projects/project-ID/operations/operation-ID" | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
响应
{
"kind": "sql#operation",
"targetLink": "https://sqladmin.googleapis.com/v1/projects/project-ID",
"status": "DONE",
"user": "user@example.com",
"insertTime": "2022-11-08T22:12:58.199Z",
"startTime": "2022-11-08T22:13:04.798Z",
"endTime": "2022-11-08T22:13:45.862Z",
"error": {
"kind": "sql#operationErrors",
"errors": [
{
"kind": "sql#operationError",
"code": "CANCEL_SUCCESSFUL",
"message": "Operation successfully cancelled"
}
]
},
"operationType": "EXPORT",
"exportContext": {
"uri": "gs://replica-bucket/source-database.sql",
"kind": "sql#exportContext",
"sqlExportOptions": {
"schemaOnly": false,
"mysqlExportOptions": {
"masterData": 0
}
},
"fileType": "SQL"
},
"name": "operation-ID",
"targetId": "cloud-sql-instance-display-name",
"selfLink": "https://sqladmin.googleapis.com/v1/projects/project-ID/operations/operation-ID",
"targetProject": "project-ID",
"instanceUid": "cloud-sql-instance-ID"
}
REST v1beta4
在使用任何请求数据之前,请先进行以下替换:
- project-ID:项目 ID。
- operation-ID:导入或导出操作的 ID。如需了解详情,请参阅准备工作。
HTTP 方法和网址:
GET https://sqladmin.googleapis.com/v1beta4/projects/project-ID/operations/operation-ID
如需发送您的请求,请展开以下选项之一:
curl(Linux、macOS 或 Cloud Shell)
执行以下命令:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://sqladmin.googleapis.com/v1beta4/projects/project-ID/operations/operation-ID"
PowerShell (Windows)
执行以下命令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://sqladmin.googleapis.com/v1beta4/projects/project-ID/operations/operation-ID" | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
响应
{
"kind": "sql#operation",
"targetLink": "https://sqladmin.googleapis.com/v1beta4/projects/project-ID",
"status": "DONE",
"user": "user@example.com",
"insertTime": "2022-11-08T22:12:58.199Z",
"startTime": "2022-11-08T22:13:04.798Z",
"endTime": "2022-11-08T22:13:45.862Z",
"error": {
"kind": "sql#operationErrors",
"errors": [
{
"kind": "sql#operationError",
"code": "CANCEL_SUCCESSFUL",
"message": "Operation successfully cancelled"
}
]
},
"operationType": "EXPORT",
"exportContext": {
"uri": "gs://replica-bucket/source-database.sql",
"kind": "sql#exportContext",
"sqlExportOptions": {
"schemaOnly": false,
"mysqlExportOptions": {
"masterData": 0
}
},
"fileType": "SQL"
},
"name": "operation-ID",
"targetId": "cloud-sql-instance-display-name",
"selfLink": "https://sqladmin.googleapis.com/v1beta4/projects/project-ID/operations/operation-ID",
"targetProject": "project-ID",
"instanceUid": "cloud-sql-instance-ID"
}
问题排查
问题 |
问题排查 |
错误消息:You can't cancel operation [operation-ID] because
this operation isn't in progress. |
您正尝试取消已完成、失败或取消的导入或导出操作。如果操作正在运行,您可以取消它。
|
错误消息:You can't cancel operation [operation-ID] because
Cloud SQL doesn't support the cancellation of an [operation-type]
operation. |
Cloud SQL 不支持取消操作,因为其操作类型不是 IMPORT 或 EXPORT 。
|
错误消息:The [operation-type] operation isn't cancelled. Wait
and retry in a few seconds. |
Cloud SQL 目前无法取消导入或导出操作。请过几秒后重试。如果问题仍然存在,请与 Google Cloud 支持团队联系。
|
后续步骤
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-02-14。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-02-14。"],[],[]]