文档平台 API 中心 云数据库 MySQL 任务相关接口 查询云数据库实例任务列表

查询云数据库实例任务列表

最近更新时间:2018-10-26 15:05:01

1. 接口描述

接口请求域名: cdb.tencentcloudapi.com 。

本接口(DescribeTasks)用于查询云数据库实例任务列表。

默认接口请求频率限制:100次/秒。

注意:本接口支持金融区地域。由于金融区和非金融区是隔离不互通的,因此当公共参数 Region 为金融区地域(例如 ap-shanghai-fsi)时,需要同时指定带金融区地域的域名,最好和 Region 的地域保持一致,例如:cdb.ap-shanghai-fsi.tencentcloudapi.com 。

2. 输入参数

以下请求参数列表仅列出了接口请求参数和部分公共参数,完整公共参数列表见公共请求参数

参数名称 必选 类型 描述
Action String 公共参数,本接口取值:DescribeTasks
Version String 公共参数,本接口取值:2017-03-20
Region String 公共参数,详见产品支持的地域列表
InstanceId String 实例ID,格式如:cdb-c1nl9rpv,与云数据库控制台页面中显示的实例ID相同,可使用查询实例列表 接口获取,其值为输出参数中字段 InstanceId 的值
AsyncRequestId String 异步任务请求ID,执行 CDB 相关操作返回的 AsyncRequestId
TaskTypes.N Array of Integer 任务类型,不传值则查询所有任务类型,可能的值:1-数据库回档;2-SQL操作;3-数据导入;5-参数设置;6-初始化;7-重启;8-开启GTID;9-只读实例升级;10-数据库批量回档;11-主实例升级;12-删除库表;13-切换为主实例;
TaskStatus.N Array of Integer 任务状态,不传值则查询所有任务状态,可能的值:-1-未定义;0-初始化; 1-运行中;2-执行成功;3-执行失败;4-已终止;5-已删除;6-已暂停;
StartTimeBegin String 第一个任务的开始时间,用于范围查询,时间格式如:2017-12-31 10:40:01
StartTimeEnd String 最后一个任务的开始时间,用于范围查询,时间格式如:2017-12-31 10:40:01
Offset Integer 记录偏移量,默认值为0
Limit Integer 单次请求返回的数量,默认值为20,最大值为100

3. 输出参数

参数名称 类型 描述
TotalCount Integer 符合查询条件的实例总数
Items Array of String 返回的实例任务信息
RequestId String 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。

4. 示例

示例1 查询云数据库实例任务列表

输入示例

https://cdb.tencentcloudapi.com/?Action=DescribeTasks
&InstanceIds.0=cdb-eb2w7dto
&<公共请求参数>

输出示例

{
  "Response": {
    "Items": [
      {
        "Code": 0,
        "Data": [
          {
            "Character_set_server": "utf8",
            "InstanceId": "cdb-gt70m8aa",
            "Lower_case_table_names": "0",
            "Vport": 3306
          }
        ],
        "EndTime": "2017-06-27 15:06:36",
        "JobId": 15964,
        "Message": "初始化实例成功",
        "Progress": 100,
        "StartTime": "2017-06-27 15:05:33",
        "Status": 2,
        "Type": 6
      },
      {
        "Code": -5003,
        "Data": [
          {
            "Code": 3,
            "Databases": [
              {
                "Code": 3,
                "Database": "clear_test",
                "Message": "dial tcp :0: connection refused"
              }
            ],
            "EndTime": "2017-07-21 17:19:31",
            "InstanceId": "cdb-atjl8gns",
            "Message": "dial tcp :0: connection refused",
            "StartTime": "2017-07-21 17:19:30"
          }
        ],
        "EndTime": "2017-07-21 17:19:31",
        "JobId": 51788,
        "Message": "",
        "Progress": 0,
        "StartTime": "2017-07-21 17:19:30",
        "Status": 3,
        "Type": 2
      },
      {
        "Code": 0,
        "Data": [
          {
            "After": {
              "CdbType": "CUSTOM",
              "DeployMode": "",
              "EngineVersion": "5.6",
              "MasterZone": 160002,
              "Memory": 2000,
              "ProtectMode": "",
              "SlaveZoneFirst": 160002,
              "SlaveZoneSecond": "",
              "Volume": 100
            },
            "Before": {
              "CdbType": "CUSTOM",
              "DeployMode": "",
              "EngineVersion": "5.6",
              "MasterZone": 160002,
              "Memory": 1000,
              "ProtectMode": "",
              "SlaveZoneFirst": 160002,
              "SlaveZoneSecond": "",
              "Volume": 50
            },
            "DealName": "20170627160000060843141595228010",
            "InstanceId": "cdb-gt70m8aa"
          }
        ],
        "EndTime": "2017-06-27 15:16:57",
        "JobId": 15967,
        "Message": "实例升级任务完成",
        "Progress": 100,
        "StartTime": "2017-06-27 15:13:52",
        "Status": 2,
        "Type": 11
      },
      {
        "Code": 0,
        "Data": [
          {
            "InstanceId": "",
            "Parameters": [
              {
                "Code": 0,
                "CurrentValue": "2",
                "Message": "ok",
                "Name": "back_log",
                "OldValue": "210"
              }
            ]
          }
        ],
        "EndTime": "2017-06-27 16:34:25",
        "JobId": 15969,
        "Message": "设置参数成功",
        "Progress": 100,
        "StartTime": "2017-06-27 16:33:40",
        "Status": 2,
        "Type": 5
      },
      {
        "Code": 3,
        "Data": [
          {
            "CostTime": 0,
            "Database": "test",
            "FileName": "skyler.sql",
            "FileSize": "12",
            "InstanceId": ""
          }
        ],
        "EndTime": "2017-06-27 16:47:23",
        "JobId": 15970,
        "Message": "Warning: Using a password on the command line interface can be insecure.?ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'joell=skyler' at line 1?dumper err?",
        "Progress": 5,
        "StartTime": "2017-06-27 16:46:52",
        "Status": 3,
        "Type": 3
      },
      {
        "Code": 3,
        "Data": [
          {
            "CostTime": 0,
            "Database": "test",
            "FileName": "joellwang_1_4.sql",
            "FileSize": "5857113",
            "InstanceId": ""
          }
        ],
        "EndTime": "2017-06-27 16:49:44",
        "JobId": 15971,
        "Message": "Warning: Using a password on the command line interface can be insecure.?ERROR 2006 (HY000) at line 1: MySQL server has gone away?dumper err?",
        "Progress": 5,
        "StartTime": "2017-06-27 16:49:13",
        "Status": 3,
        "Type": 3
      },
      {
        "Code": 0,
        "Data": [
          {
            "CostTime": 19,
            "Database": "test",
            "FileName": "LearningSQLExample.sql",
            "FileSize": "28384",
            "InstanceId": ""
          }
        ],
        "EndTime": "2017-06-27 17:03:00",
        "JobId": 15972,
        "Message": "success",
        "Progress": 100,
        "StartTime": "2017-06-27 17:02:29",
        "Status": 2,
        "Type": 3
      },
      {
        "Code": 0,
        "Data": [
          {
            "After": {
              "CdbType": "CUSTOM",
              "DeployMode": "",
              "EngineVersion": "5.6",
              "MasterZone": 160002,
              "Memory": 8000,
              "ProtectMode": "",
              "SlaveZoneFirst": 160002,
              "SlaveZoneSecond": "",
              "Volume": 100
            },
            "Before": {
              "CdbType": "CUSTOM",
              "DeployMode": "",
              "EngineVersion": "5.6",
              "MasterZone": 160002,
              "Memory": 8000,
              "ProtectMode": "",
              "SlaveZoneFirst": 160002,
              "SlaveZoneSecond": "",
              "Volume": 50
            },
            "DealName": "20170627160000060849699827143219",
            "InstanceId": "cdb-o8cacfkg"
          }
        ],
        "EndTime": "2017-06-27 18:08:25",
        "JobId": 15974,
        "Message": "实例升级任务完成",
        "Progress": 100,
        "StartTime": "2017-06-27 18:04:19",
        "Status": 2,
        "Type": 11
      },
      {
        "Code": 0,
        "Data": [
          {
            "Character_set_server": "utf8",
            "InstanceId": "cdb-7262qp3q",
            "Lower_case_table_names": "0",
            "Vport": 3306
          }
        ],
        "EndTime": "2017-06-27 19:19:34",
        "JobId": 15976,
        "Message": "初始化实例成功",
        "Progress": 100,
        "StartTime": "2017-06-27 19:18:31",
        "Status": 2,
        "Type": 6
      },
      {
        "Code": 0,
        "Data": [
          {
            "Code": 0,
            "DatabaseTables": [
              {
                "Database": "monitor_master",
                "Tables": [
                  {
                    "NewTableName": "monitor_alarm_bak_1",
                    "TableName": "monitor_alarm"
                  }
                ]
              }
            ],
            "Databases": [
              {
                "DatabaseName": "test",
                "NewDatabaseName": "test_bak"
              }
            ],
            "InstanceId": "cdb-ewgjla5w",
            "Message": "回档成功",
            "Progress": 100,
            "RollbackTime": "2017-04-06 16:00:00",
            "Status": 2
          }
        ],
        "EndTime": "2017-04-06 20:45:03",
        "JobId": 51695,
        "Message": "所有实例回档成功",
        "Progress": 100,
        "StartTime": "2017-04-06 20:42:59",
        "Status": 2,
        "Type": 10
      }
    ],
    "RequestId": "6EF60BEC-0242-43AF-BB20-270359FB54A7",
    "TotalCount": 13
  }
}

5. 开发者资源

API Explorer

该工具提供了在线调用、签名验证、SDK 代码生成和快速检索接口等能力,能显著降低使用云 API 的难度,推荐使用。

SDK

云 API 3.0 提供了配套的开发工具集(SDK),支持多种编程语言,能更方便的调用 API。

命令行工具

6. 错误码

以下仅列出了接口业务逻辑相关的错误码,其他错误码详见公共错误码

错误码 描述
CdbError 后端错误或者流程错误。
InternalError.DatabaseAccessError 数据库内部错误。
InternalError.DesError 系统内部错误。
InvalidParameter 参数错误。
InvalidParameter.InstanceNotFound 实例不存在。
OperationDenied 不允许进行操作。
OperationDenied.WrongStatus 后端任务状态非法。