批量获取数据库参数
功能介绍
在进行数据库迁移时,为了确保迁移成功后业务应用的使用不受影响,数据复制服务提供了参数对比功能帮助您进行源库和目标库参数一致性对比,此接口可以获取源库和目标库的数据库参数。
调试
您可以在API Explorer中调试该接口,支持自动认证鉴权。API Explorer可以自动生成SDK代码示例,并提供SDK代码示例调试功能。
接口约束
- 目前仅MySQL迁移和MySQL灾备支持参数对比的功能。
- job_direction为up时才能调用,任务状态为CONFIGURATION才能调用。
- 双主灾备时父任务不支持。
- 对于上述参数“innodb_buffer_pool_size”,参数对比功能对应用到目标数据库的值做了内控,最大不会超过目标数据库总内存的70%。所以有时候是无法完全和源数据库该参数取值一致,这是为了避免目标数据库设置过大,而导致数据库无法启动,如果您觉得上述最大值偏小,可以在数据库中通过执行命令手动设置更大的值,具体可参考参数对比详细介绍 。
URI
POST /v3/{project_id}/jobs/batch-get-params
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
project_id |
是 |
String |
租户在某一Region下的Project ID。 获取方法请参见获取项目ID。 |
请求参数
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
Content-Type |
是 |
String |
指定类型为application/json。 缺省值:application/json |
X-Auth-Token |
是 |
String |
从IAM服务获取的用户Token。 |
X-Language |
否 |
String |
请求语言类型。 缺省值:en-us 取值:
|
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
jobs |
是 |
Array of strings |
批量查询任务请求体。 |
refresh |
是 |
String |
是否重新获取数据库参数,1代表是,0代表否(从缓存中获取),第一次调用时请设置为1。 |
响应参数
状态码: 202
参数 |
参数类型 |
描述 |
---|---|---|
params_list |
Array of objects |
查询数据库参数响应体。 详情请参见表5。 |
count |
Integer |
总数。 |
参数 |
参数类型 |
描述 |
---|---|---|
compare_result |
String |
参数对比结果。取值:
|
data_type |
String |
参数类型 |
group |
String |
分组。取值:
|
key |
String |
参数名。 |
need_restart |
String |
是否需要重启。取值:
|
source_value |
String |
源数据库参数值。 |
target_value |
String |
目标数据库参数值。 |
value_range |
String |
参数范围。 |
error_code |
String |
错误码。 |
error_message |
String |
错误信息。 |
请求示例
批量获取数据库参数请求体示例:
https://{endpoint}/v3/054ba152d480d55b2f5dc0069e7ddef0/jobs/batch-get-params { "jobs" : [ "140b5236-88ad-43c8-811c-1268453jb101" ], "refresh": 1 }
响应示例
状态码: 202
Accepted
{ "count" : 1, "params_list" : [ { "params" : [ { "group" : "performance", "key" : "binlog_cache_size", "source_value" : "16384", "target_value" : "32768", "compare_result" : "false", "data_type" : "figure", "value_range" : "4096-16777216", "need_restart" : "false" }, { "group" : "performance", "key" : "binlog_stmt_cache_size", "source_value" : "32768", "target_value" : "32768", "compare_result" : "true", "data_type" : "figure", "value_range" : "4096-16777216", "need_restart" : "false" }, { "group" : "performance", "key" : "bulk_insert_buffer_size", "source_value" : "8388608", "target_value" : "8388608", "compare_result" : "true", "data_type" : "figure", "value_range" : "0-18446744073709551615", "need_restart" : "false" }, { "group" : "common", "key" : "character_set_server", "source_value" : "utf8", "target_value" : "utf8", "compare_result" : "true", "data_type" : null, "value_range" : "utf8|latin1|gbk|utf8mb4", "need_restart" : "true" }, { "group" : "common", "key" : "collation_server", "source_value" : "utf8_general_ci", "target_value" : "utf8_general_ci", "compare_result" : "true", "data_type" : null, "value_range" : "latin1_german1_ci|latin1_swedish_ci|latin1_danish_ci|latin1_german2_ci|latin1_bin|latin1_general_ci|latin1_general_cs|latin1_spanish_ci|gbk_chinese_ci|gbk_bin|utf8_general_ci|utf8_bin|utf8_unicode_ci|utf8_icelandic_ci|utf8_latvian_ci|utf8_romanian_ci|utf8_slovenian_ci|utf8_polish_ci|utf8_estonian_ci|utf8_spanish_ci|utf8_swedish_ci|utf8_turkish_ci|utf8_czech_ci|utf8_danish_ci|utf8_lithuanian_ci|utf8_slovak_ci|utf8_spanish2_ci|utf8_roman_ci|utf8_persian_ci|utf8_esperanto_ci|utf8_hungarian_ci|utf8_sinhala_ci|utf8mb4_general_ci|utf8mb4_bin|utf8mb4_unicode_ci|utf8mb4_icelandic_ci|utf8mb4_latvian_ci|utf8mb4_romanian_ci|utf8mb4_slovenian_ci|utf8mb4_polish_ci|utf8mb4_estonian_ci|utf8mb4_spanish_ci|utf8mb4_swedish_ci|utf8mb4_turkish_ci|utf8mb4_czech_ci|utf8mb4_danish_ci|utf8mb4_lithuanian_ci|utf8mb4_slovak_ci|utf8mb4_spanish2_ci|utf8mb4_roman_ci|utf8mb4_persian_ci|utf8mb4_esperanto_ci|utf8mb4_hungarian_ci|utf8mb4_sinhala_ci", "need_restart" : "true" }, { "group" : "common", "key" : "connect_timeout", "source_value" : "10", "target_value" : "10", "compare_result" : "true", "data_type" : null, "value_range" : "2-31536000", "need_restart" : "false" }, { "group" : "common", "key" : "explicit_defaults_for_timestamp", "source_value" : "OFF", "target_value" : "OFF", "compare_result" : "true", "data_type" : null, "value_range" : "ON|OFF", "need_restart" : "true" }, { "group" : "performance", "key" : "innodb_buffer_pool_size", "source_value" : "536870912", "target_value" : "536870912", "compare_result" : "true", "data_type" : "figure", "value_range" : "5242880-2147483648", "need_restart" : "true" }, { "group" : "common", "key" : "innodb_flush_log_at_trx_commit", "source_value" : "1", "target_value" : "1", "compare_result" : "true", "data_type" : null, "value_range" : "0|1|2", "need_restart" : "false" }, { "group" : "common", "key" : "innodb_lock_wait_timeout", "source_value" : "50", "target_value" : "50", "compare_result" : "true", "data_type" : null, "value_range" : "1-1073741824", "need_restart" : "false" }, { "group" : "performance", "key" : "key_buffer_size", "source_value" : "16777216", "target_value" : "16777216", "compare_result" : "true", "data_type" : "figure", "value_range" : "8-9223372036854771712", "need_restart" : "false" }, { "group" : "performance", "key" : "long_query_time", "source_value" : "1.000000", "target_value" : "1.000000", "compare_result" : "true", "data_type" : "figure", "value_range" : "0.03-3600", "need_restart" : "false" }, { "group" : "common", "key" : "max_connections", "source_value" : "800", "target_value" : "800", "compare_result" : "true", "data_type" : null, "value_range" : "1-100000", "need_restart" : "false" }, { "group" : "common", "key" : "net_read_timeout", "source_value" : "30", "target_value" : "30", "compare_result" : "true", "data_type" : null, "value_range" : "1-31536000", "need_restart" : "false" }, { "group" : "common", "key" : "net_write_timeout", "source_value" : "60", "target_value" : "60", "compare_result" : "true", "data_type" : null, "value_range" : "1-31536000", "need_restart" : "false" }, { "group" : "performance", "key" : "read_buffer_size", "source_value" : "262144", "target_value" : "262144", "compare_result" : "true", "data_type" : "figure", "value_range" : "8192-2147479552", "need_restart" : "false" }, { "group" : "performance", "key" : "read_rnd_buffer_size", "source_value" : "524288", "target_value" : "524288", "compare_result" : "true", "data_type" : "figure", "value_range" : "1-2147483647", "need_restart" : "false" }, { "group" : "performance", "key" : "sort_buffer_size", "source_value" : "262144", "target_value" : "262144", "compare_result" : "true", "data_type" : "figure", "value_range" : "32768-18446744073709551615", "need_restart" : "false" }, { "group" : "performance", "key" : "sync_binlog", "source_value" : "1", "target_value" : "1", "compare_result" : "true", "data_type" : "figure", "value_range" : "0-4294967295", "need_restart" : "false" }, { "group" : "common", "key" : "tx_isolation", "source_value" : "REPEATABLE-READ", "target_value" : "REPEATABLE-READ", "compare_result" : "true", "data_type" : null, "value_range" : "READ-UNCOMMITTED|READ-COMMITTED|REPEATABLE-READ|SERIALIZABLE", "need_restart" : "false" } ] } ] }
状态码
状态码 |
描述 |
---|---|
202 |
Accepted |
400 |
Bad Request |
错误码
请参见错误码。