Klustron(原KunlunBase) ClusterManager API
Klustron(原KunlunBase) ClusterManager API
0.使用介绍
KunlunClusterManager 接受 HTTP 协议的请求,并根据请求的类型和参数,执行相应的任务。接口应答模式分为同步和异步模式。 同步模式为客户端在发出请求后,接收到的应答就包含当前接口的执行结果(如果获取集群信息等)。 异步模式通常为执行时间较长的任务。客户端在下发请求后,需要通过 get_status 接口来获取任务的执行状态,指导任务成功或者失败为止。
0.1 下发任务
接口说明
下发集群管理任务。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
version | string | 1 | 自定义协议版本,默认 ‘1.0’ |
job_id | string | 0 | 下发任务,不需要填写 job_id,该 job_id 会由clustermanager 自动生成并通过应答返回。 |
job_type | string | 1 | 任务类型,与具体任务内容相关 |
timestamp | string | 1 | 任务发起的时间戳 |
paras | json | 0 | 自定义参数部分,与任务类型相关。 |
应答参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
version | string | 1 | 自定义协议版本,默认 ‘1.0’ |
error_code | string | 1 | 错误码 |
error_info | string | 1 | 错误信息 |
status | string | 1 | 任务状态,可能的值为 accepted,started, ongoing, done, failed |
job_id | string | 0 | 由clustermanager 自动生成的 job_id, 如果任务类型是异步任务的话,可以通过该 job_id 来查询任务进度和状态。 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"expand_cluster",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"cluster_id":"1",
"dst_shard_id":"2",
"src_shard_id":"1",
"table_list":[
"sbtest.public.test1"
]
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
0.2 获取任务执行状态
接口说明
获取指定 job_id 任务的执行状态。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
version | string | 1 | 自定义协议版本,默认 ‘1.0’ |
job_id | string | 1 | 待查询任务的 id |
job_type | string | 1 | 任务类型,当前接口 'get_status' |
timestamp | string | 1 | 任务发起的时间戳 |
paras | json | 0 | 自定义参数部分,get_status 类型接口不需要填写,其他任务类型可能需要填写。 |
应答参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
version | string | 1 | 自定义协议版本,默认 ‘1.0’ |
error_code | string | 1 | 错误码 |
error_info | string | 1 | 错误信息 |
status | string | 1 | 任务状态,可能的值为 started, ongoing, done, failed |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"expand_cluster",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"cluster_id":"1",
"dst_shard_id":"2",
"src_shard_id":"1",
"table_list":[
"sbtest.public.test1"
]
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
1.设备管理
1.1 上报机器设备
接口说明
将已初始化的服务器设备,注册到系统中。
应答模式
异步。通过 get_status 接口来查询状态。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
job_type | string | 1 | create_machine |
hostaddr | string | 1 | 服务器 IP |
machine_type | string | 1 | 设备类型。 设备类型包括两种 storage 和 computer。 分别代表了存储机型和计算机型。存储机型表示,该设备可以被用来部署 Klustron-storage。相同的,计算机型代表着该设备可以被用来部署 Klustron-server。同一台物理设备,其类型可以是存储设备或者计算设备,也可以既是存储设备,也是计算设备,这种情况下,端口范围需要明确的区分开,确保在同一台设备上安装的计算节点和存储节点不会端口冲突。 |
port_range | string | 1 | 端口分配范围。即新创建的实力端口在该参数指定的范围内分配 |
rack_id | string | 1 | 机架信息 |
datadir | string | 1 | 实例数据目录存放位置 |
logdir | string | 1 | 日志目录存放位置 |
wal_log_dir | string | 1 | wal 日志存放位置 |
comp_datadir | string | 1 | 如果当前设备为计算机型,则该字段标识计算节点的数据目录 |
total_mem | string | 1 | 该机型可用总内存 单位为 MB |
total_cpu_cores | string | 1 | 该机型可用总的逻辑核心数 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"create_machine",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"hostaddr":"192.168.0.135",
"machine_type":"computer",
"port_range":"45000-48000",
"rack_id":"1",
"datadir":"/home/play_ground/run_data",
"logdir":"/home/play_ground/run_data",
"wal_log_dir":"/home/play_ground/run_data",
"comp_datadir":"/home/play_ground/run_data",
"total_mem":"8192",
"total_cpu_cores":"8"
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
#查询接口get_status返回
{
"version":"1.0",
"error_code":"0",
"error_info":"create machine successfully",
"status":"done",
"attachment":{
}
}
1.2 删除设备
接口说明
对已经注册到系统的服务器,执行删除操作。
应答模式
异步。通过 get_status 接口来获取状态。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
job_type | string | 1 | delete_machine |
hostaddr | string | 1 | 机器 ip |
machine_type | string | 1 | 该设备的机型信息 storage 或者 computer |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"delete_machine",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"hostaddr":"127.0.0.1",
"machine_type":"storage"
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
#查询接口get_status返回
{
"version":"1.0",
"error_code":"0",
"error_info":"delete machine successfully",
"status":"done",
"attachment":{
}
}
1.3 设置服务器状态
接口说明
设置指定服务器的状态,如 dead,running,分别表示当前设备处于下线和在线状态,只有在线的设备才能被系统划分到资源池内。
应答模式
异步。通过 get_status 接口来获取状态。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
job_type | string | 1 | delete_machine |
hostaddr | string | 1 | 机器 ip |
node_stats | string | 1 | running, dead |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"set_machine",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"hostaddr":"127.0.0.1",
"node_stats":"running"
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
#查询接口get_status返回
{
"version":"1.0",
"error_code":"0",
"error_info":"set machine success",
"status":"done",
"attachment":{
}
}
2.集群购买与删除
2.1 购买新集群
接口说明
按照指定的参数配置,创建新的 kunlunBase 集群。
应答模式
异步。通过 get_status 接口来获取状态。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
job_type | string | 1 | create_cluster |
nick_name | string | 1 | 业务名称,如‘对账结息数据库’ |
ha_mode | string | 1 | rbr, mgr。标识高可用模式。前者为强同步模式,后者为 mgr 模式。 |
shards | string | 1 | 分片数目 |
nodes | string | 1 | 每个分片的节点数目,至少 3 个节点,组成一主两从的高可用集群 |
comps | string | 1 | 计算节点个数 |
max_storage_size | string | 1 | 最大存储空间 |
max_connections | string | 1 | 最大连接数 |
cpu_cores | string | 1 | 可以使用的最大核数 |
cpu_limit_node | string | 1 | share 标识软隔离模式; quota 标识硬隔离模式; |
innodb_size | string | 1 | Klustron-storage 使用的 innodb_buffer 大小(这个字段innodb_size 单位:M) |
rocksdb_block_cache_size_M | string | 1 | Klustron-storage 设置rocsdb block cache size 单位:M), version >=1.1 |
dbcfg | string | 0 | 设置小内存模式,0和没有这个字段为正常模式,1为小内存模式 取值为 0 或者 1。 |
fullsync_level | string | 1 | 该shard中强同步备机应当个数,该字段值要小于等于备机节点数 |
storage_iplists | Json array | 0 | 为指定安装存储节点机器,如果不指定,默认选择已有机器 |
computer_iplists | Json array | 0 | 为指定安装计算节点机器,如果不指定,默认选择已有机器 |
node_distribution | Json array | 0 | 配置存储节点分布信息 |
comp_distribution | Json array | 0 | 配置计算节点分布信息 |
install_proxysql | string | 0 | 安装集群时是否安装proxysql,如果安装proxysql,则该集群为单shard模式,默认为0 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"create_cluster",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"nick_name":"my_nick_name",
"ha_mode":"mgr",
"shards":"1",
"nodes":"3",
"comps":"1",
"max_storage_size":"20",
"max_connections":"6",
"cpu_cores":"8",
"innodb_size":"1024",
"rocksdb_block_cache_size_M":"1024",
"dbcfg":"1",
"fullsync_level":"1",
"install_proxysql":"0",
"storage_iplists":[
"192.168.0.2",
"192.168.0.3"
],
"computer_iplists":[
"192.168.0.1"
]
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
#查询接口get_status返回
{
"version":"1.0",
"error_code":"0",
"error_info":"create cluster successfully",
"status":"done",
"attachment":{
"cluster_id":"3",
"cluster_name":"cluster_1651903646_000001",
"shards":"1",
"comps":"1"
}
}
2.2 集群内新增分片
接口说明
按照指定的参数配置,在现有集群上,新增分片,可以增加多个。
应答模式
异步。通过 get_status 接口来获取状态。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
job_type | string | 1 | add_shards |
cluster_id | string | 1 | 集群 id |
shards | string | 1 | 新增分片个数 |
nodes | string | 1 | 新增分片中,每个分片的节点个数 |
storage_iplists | Json array | 1 | 为指定安装存储节点机器 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"add_shards",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"cluster_id":"1",
"shards":"2",
"nodes":"3",
"storage_iplists":[
"192.168.0.2",
"192.168.0.3"
]
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
#查询接口get_status返回
{
"version":"1.0",
"error_code":"0",
"error_info":"add shards successfully",
"status":"done",
"attachment":{
"cluster_id":"2",
"cluster_name":"cluster_1651836141_000001",
"shards":"2",
"comps":"1",
"list_shard":[
{
"shard_id":"3",
"shard_name":"shard2"
}
]
}
}
2.3 集群内删除现有分片
接口说明
按照指定的参数配置,在现有集群上,删除分片,只能一个一个删。
应答模式
异步。通过 get_status 接口来获取状态。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
job_type | string | 1 | delete_shards |
cluster_id | string | 1 | 集群 id |
shard_id | string | 1 | 待删除分片 id |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"delete_shard",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"cluster_id":"1",
"shard_id":"1"
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
#查询接口get_status返回
{
"version":"1.0",
"error_code":"0",
"error_info":"delete shard successfully",
"status":"done",
"attachment":{
}
}
2.4 集群内新增计算节点
接口说明
按照指定的参数配置,在现有集群上,新增分片,可以增加多个。
应答模式
异步。通过 get_status 接口来获取状态。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
job_type | string | 1 | add_comps |
cluster_id | string | 1 | 集群 id |
comps | string | 1 | 新增的计算节点的个数 |
computer_iplists | Json array | 1 | 为指定安装计算节点的机器 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"add_comps",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"cluster_id":"1",
"comps":"2",
"computer_iplists":[
"192.168.0.2",
"192.168.0.3"
]
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
#查询接口get_status返回
{
"version":"1.0",
"error_code":"0",
"error_info":"add comps successfully",
"status":"done",
"attachment":{
"cluster_id":"3",
"cluster_name":"cluster_1651903646_000001",
"shards":"1",
"comps":"2",
"list_comp":[
{
"comp_id":"3",
"comp_name":"comp2"
}
]
}
}
2.5 集群内删除计算节点
接口说明
按照指定的参数配置,在现有集群上,删除计算节点,只能一个一个删。
应答模式
异步。通过 get_status 接口来获取状态。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
job_type | string | 1 | delete_shards |
cluster_id | string | 1 | 集群 id |
comp_id | string | 1 | 待删除计算节点 id |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"delete_comp",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"cluster_id":"1",
"comp_id":"1"
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
#查询接口get_status返回
{
"version":"1.0",
"error_code":"0",
"error_info":"delete comp successfully",
"status":"done",
"attachment":{
}
}
2.6 指定集群增加 node 节点
接口说明
按照指定的参数配置,为集群所有分片增加node, 异步,需要查询。
应答模式
异步。通过 get_status 接口来获取状态。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
job_type | string | 1 | add_nodes |
cluster_id | string | 1 | 集群 id |
shard_id | string | 0 | 若指定该字段,则只在该 shard 上增加 node |
nodes | string | 1 | 增加节点的个数 |
storage_iplists | Json array | 1 | 为指定安装存储节点机器 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"add_nodes",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"cluster_id":"1",
"shard_id":"1",
"nodes":"2",
"storage_iplists":[
"192.168.0.2",
"192.168.0.3"
]
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
#查询接口get_status返回
{
"version":"1.0",
"error_code":"0",
"error_info":"add new nodes successfully",
"status":"done",
"attachment":{
"cluster_id":"1",
"cluster_name":"cluster_1651907758_000001",
"shards":"1",
"comps":"1",
"list_shard":[
{
"shard_id":"1",
"shard_name":"shard1",
"nodes":"5",
"list_node":[
{
"hostaddr":"192.168.0.127",
"node_id":"4",
"port":"58509"
},
{
"hostaddr":"192.168.0.127",
"node_id":"5",
"port":"58512"
}
]
}
]
}
}
2.7 指定集群删除 node 节点
接口说明
按照指定的参数配置,为集群指定分片删除指定 node, 异步,需要查询。
应答模式
异步。通过 get_status 接口来获取状态。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
job_type | string | 1 | delete_nodes |
cluster_id | string | 1 | 集群 id |
shard_id | string | 0 | 若指定该字段,则只在该 shard 上增加 node |
hostaddr | string | 1 | 待删除 node 所在的机器 IP |
port | string | 1 | 端口号 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"delete_node",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"cluster_id":"1",
"shard_id":"1",
"hostaddr":"127.0.0.1",
"port":"57338"
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
#查询接口get_status返回
{
"version":"1.0",
"error_code":"0",
"error_info":"delete node successfully",
"status":"done",
"attachment":{
}
}
2.8 重做备机
接口说明
指定重做某个 shard 的备机。
应答模式
异步。通过 get_status 接口来获取状态。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
job_type | string | 1 | delete_nodes |
cluster_id | string | 1 | 集群 id |
shard_id | string | 0 | 若指定该字段,则只在该 shard 上增加 node |
hostaddr | string | 1 | 待删除 node 所在的机器 IP |
port | string | 1 | 端口号 |
need_backup | string | 1 | 是否需要在重做前进行备份 |
hdfs_host | string | 1 | 冷备位置 |
pv_limit | string | 1 | 冷备传输限速 单位是 MB |
allow_pull_from_master | string | 1 | 是否在备机不可用的情况下,使用主机的数据重做备机 |
allow_replica_delay | string | 1 | 备机延迟的最大值,如果备机延迟超过这个值,则认为该备机不适合作为数据源 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"rebuild_node",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"shard_id":"1",
"cluster_id":"1",
"rb_nodes":[
{
"hostaddr":"192.168.0.125",
"port":"57001",
"need_backup":"0",
"hdfs_host":"hdfs",
"pv_limit":"10"
}
],
"allow_pull_from_master":"1",
"allow_replica_delay":"15"
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
#查询接口get_status返回
{
"version":"1.0",
"error_code":"0",
"error_info":"delete node successfully",
"status":"done",
"attachment":{
}
}
2.9 删除指定集群
接口说明
按照指定的参数配置,为集群指定分片删除指定 node, 异步,需要查询。
应答模式
异步。通过 get_status 接口来获取状态。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
job_type | string | 1 | delete_cluster |
cluster_id | string | 1 | 集群 id |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"delete_cluster",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"cluster_id":"1"
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
#查询接口get_status返回
{
"attachment": {
"cluster_id": "43" ,
"cluster_name": "cluster_1665971623_000043" ,
"computer_id": "776" ,
"computer_state": "done" ,
"computer_step": [
{
"cluster_id": "43" ,
"computer_hosts": "192.168.0.132_53704;" ,
"computer_id": "778" ,
"computer_state": "done" ,
"error_code": 0 ,
"error_info": "OK" ,
"rollback_flag": "1"
}
],
"job_steps": "shard,computer" ,
"shard_id": "775" ,
"shard_step": [
{
"cluster_id": "43" ,
"error_code": 0 ,
"error_info": "OK" ,
"rollback_flag": "1" ,
"shard_ids": "83," ,
"storage_hosts": "192.168.0.132_53407;192.168.0.132_53411;" ,
"storage_id": "777" ,
"storage_state": "done"
}
],
"storage_state": "done"
},
"error_code": "0" ,
"error_info": "OK" ,
"job_id": "" ,
"job_type": "" ,
"status": "done" ,
"version": "1.0"
}
2.10 修改实例资源隔离参数
接口说明
按照指定的参数配置,修改 MySQL 或者 PostgreSQL 实例的资源隔离参数,当前只支持 cpu 隔离。
应答模式
异步。通过 get_status 接口来获取状态。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
job_type | string | 1 | update_instance_cgroup |
ip | string | 1 | 实例 ip |
Port | string | 1 | 实例监听端口 |
type | string | 1 | mysql 标识存储节点实例,pg 标识计算节点实例 |
cpu_cores | string | 1 | 分配的 cpu 核数 |
cgroup_mode | string | 1 | cpu 资源限制的模式,默认是quota,可以设置quota或者share,其中 share 标识软隔离,quota 标识硬隔离。 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"update_instance_cgroup",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"ip":"192.168.0.135",
"port":"57001",
"type":"mysql",
"cpu_cores":"5",
"cgroup_mode":"quota"
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
3.集群备份
3.1 手动发起集群备份
接口说明
调用该接口手动发起一次全量备份。cluster_id 为 -1 时,表示备份元数据集群。
应答模式
同步接口。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
cluster_id | string | 1 | 集群 ID |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"manual_backup_cluster",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"cluster_id":"1"
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
4.集群恢复
4.1 集群回档(按时间点恢复集群)
接口说明
按时间点对指定集群进行回档。
应答模式
异步。通过 get_status 接口获取任务进度。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
src_cluster_id | string | 1 | 回档操作的源集群 ID |
dst_cluster_id | string | 1 | 回档操作的目标集群 ID。该集群必须是新买的空集群 |
restore_time | string | 1 | 回档时间点 |
示例
#请求
{
"version":"1.0",
"job_id":"",
"job_type":"cluster_restore",
"timestamp":"1435749309",
"paras":{
"src_cluster_id":"1",
"dst_cluster_id":"2",
"restore_time":"restore_time"
}
} -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
5.集群扩容
5.1 自动获取表搬迁列表
接口说明
获取系统自动选择出来的待搬迁的表列表。
应答模式
同步。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
cluster_id | string | 1 | 集群 ID |
shard_id | string | 1 | 当前集群内待迁出表的源 shard id |
policy | string | 1 | top_hit:选择访问频率最高的表。 top_size:选择数据量最大的表 |
应答参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
attachment->table_list | string | 待迁移表列表 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"get_expand_table_list",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"cluster_id":"3",
"shard_id":"2",
"policy":"top_size"
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":{
"table_list":"kunlundb_super_dba.kunlundb_super_dba_$$_public.test1"
},
"error_code":"0",
"error_info":"",
"job_id":"",
"job_type":"",
"status":"done",
"version":"1.0"
}
5.2 发起表搬迁任务
接口说明
发起表搬迁任务。
应答模式
异步。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
job_type | string | 1 | expand_cluster |
cluster_id | string | 1 | 集群 ID |
src_shard_id | string | 1 | 当前集群内待迁出表的源 shard id |
dst_shard_id | string | 1 | 当前集群内待迁出表的目标 shard id |
table_list | json_array | 1 | 待迁移表列表 |
drop_old_table | string | 0 | 是否保留源表 |
示例
#请求
curl -d '
{
"version": "1.0",
"job_id":"",
"job_type": "expand_cluster",
"timestamp" : "1435749309",
"user_name":"kunlun_test",
"paras": {
"cluster_id": "1",
"dst_shard_id": "5",
"src_shard_id": "6",
"table_list": [
"postgres.public.test2"
]
}
} ' -X POST http://192.168.0.135:8010/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
6. 元数据管理
6.1 获取元数据集群同步模式
接口说明
查询元数据集群同步模式。
应答模式
同步。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
job_type | string | 1 | get_meta_summary |
应答参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
attachment->mode | string | 元数据集群同步模式 no_rep, mgr, rbr 三种类型的结果 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"get_meta_mode",
"timestamp":"1435749309",
"paras":{
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":{
"mode":"mgr"
},
"error_code":"0",
"error_info":"",
"job_id":"",
"job_type":"",
"status":"done",
"version":"1.0"
}
6.2 获取冷备存储服务信息
接口说明
查询冷备存储服务的详细信息。
应答模式
同步。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
job_type | string | 1 | get_backup_storage |
应答参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
hostaddr | string | 备份服务 IP | |
name | string | 备份服务名称 | |
port | string | 备份服务端口 | |
stype | string | 备份服务类型 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"get_backup_storage",
"timestamp":"1435749309",
"paras":{
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":{
"list_backup_storage":[
{
"hostaddr":"192.168.0.135",
"name":"hdfs_backup1",
"port":"9000",
"stype":"HDFS"
}
]
},
"error_code":"0",
"error_info":"",
"job_id":"",
"job_type":"",
"status":"done",
"version":"1.0"
}
6.3 获取机器状态信息
接口说明
查询所有机器状态的详细信息。
应答模式
同步。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
job_type | string | 1 | get_machine_summary |
应答参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
hostaddr | string | 服务器地址 | |
status | string | 服务器状态 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"get_machine_summary",
"timestamp":"1435749309",
"paras":{
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":{
"list_machine":[
{
"hostaddr":"192.168.0.135",
"status":"online"
},
{
"hostaddr":"192.168.0.125",
"status":"online"
}
]
},
"error_code":"0",
"error_info":"",
"job_id":"",
"job_type":"",
"status":"done",
"version":"1.0"
}
6.4 获取集群列表
接口说明
查询所有 kunlunbase 集群列表。
应答模式
同步。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
job_type | string | 1 | get_cluster_summary |
应答参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
name | string | 集群名称 | |
nick_name | string | 业务名称 | |
shards | string | 分片个数 | |
comps | string | 计算节点个数 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"get_machine_summary",
"timestamp":"1435749309",
"paras":{
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":{
"list_machine":[
{
"hostaddr":"192.168.0.135",
"status":"online"
},
{
"hostaddr":"192.168.0.125",
"status":"online"
}
]
},
"error_code":"0",
"error_info":"",
"job_id":"",
"job_type":"",
"status":"done",
"version":"1.0"
}
6.5 获取集群详细信息
接口说明
获取指定集群的详细信息。
应答模式
同步。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
job_type | string | 1 | get_cluster_detail |
cluster_name | string | 1 | 集群名称 |
应答参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
name | string | 集群名称 | |
nick_name | string | 业务名称 | |
shards | string | 分片个数 | |
comps | string | 计算节点个数 | |
comp_name | string | 计算节点名称 | |
hostaddr | string | 计算节点或者存储节点 IP | |
port | string | 计算节点或者存储节点端口 | |
status | string | 当前节点状态 | |
master | string | 当前存储节点是否为主节点 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"get_cluster_detail",
"timestamp":"1435749309",
"paras":{
"cluster_name":"cluster_1659333382_000001"
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":{
"cluster_name":"cluster_1659333382_000001",
"comps":"1",
"list_comp":[
{
"comp_name":"comp_1",
"hostaddr":"192.168.0.135",
"port":"45001",
"status":"online"
}
],
"list_shard":[
{
"list_node":[
{
"hostaddr":"192.168.0.135",
"master":"true",
"port":"55001",
"status":"online"
},
{
"hostaddr":"192.168.0.135",
"master":"false",
"port":"55002",
"status":"online"
},
{
"hostaddr":"192.168.0.135",
"master":"false",
"port":"55003",
"status":"online"
}
],
"nodes":"3",
"shard_name":"shard_1"
}
],
"nick_name":"my_nick_name",
"shards":"1"
},
"error_code":"0",
"error_info":"",
"job_id":"",
"job_type":"",
"status":"done",
"version":"1.0"
}
6.6 获取存储节点系统变量信息
接口说明
查询 Klustron-storage 的某个变量值(如 innodb_buffer_pool_size)。
应答模式
同步。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
job_type | string | 1 | get_variable |
hostaddr | string | 1 | Klustron-storage ip |
port | string | 1 | Klustron-storage port |
variable | string | 1 | 变量名 |
应答参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
result | string | 查询是否成功 | |
value | string | 查询结果 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"get_variable",
"timestamp":"1435749309",
"paras":{
"hostaddr":"192.168.0.135",
"port":"55001",
"variable":"innodb_buffer_pool_size"
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":{
"result":"true",
"value":"5242880"
},
"error_code":"0",
"error_info":"",
"job_id":"",
"job_type":"",
"status":"done",
"version":"1.0"
}
7.表重分布
接口说明
根据用户输入表,将表中数据dump出来导入新表中
应答模式
异步。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
src_cluster_id | string | 1 | 原表所在cluster_id |
dst_shard_id | string | 1 | 目标表重分布到目标的cluster_id |
repartition_tables | string | 1 | 目标表重分布到目标的cluster_id |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"table_repartition",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"src_cluster_id":"3",
"dst_cluster_id":"2",
"repartition_tables":"test_
$$ public.t=>test1 $$
private.t2,test
$$ priv.ta=>test1 $$
_priv1.tb" } } ' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
特别说明:
1.需要预先在目标cluster下建立好database,schema,和table,并且原和目标表表结构一致,这个cluster_mgr会自动校验
2.重分布表任务一次要求做的表必须下同一个database下,原和目标database可以不同
8.表逻辑备份
接口说明
用户发起对某个表逻辑备份,以及设置定时逻辑备份
应答模式
异步。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
cluster_id | string | 1 | 逻辑备份表所在cluster_id |
backup_type | string | 1 | 逻辑备份类型,支持db|schema|table. cluster_mgr版本1.0以上支持 |
db_table | string | 1 | 要逻辑备份的表 |
backup_time | string | 1 | 定时备份时间段 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"logical_backup",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"cluster_id":"1",
"backup_type":"schema",
"backup":[
{
"db_table":"postgres_
$$ public", "backup_time":"01:00:00-02:00:00" }, { "db_table":"postgres $$
_trtest", "backup_time":"01:00:00-02:00:00" } ]
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
特别强调
如果backup_type为db,表示要备份该db下所有schema中表。 在输入backup下 db_table中输入db名
如果backup_type为schema,表示要备份该schema下所有表。 在输入backup下 db_table中输入db_$$_schema
9.表逻辑恢复
接口说明
用户发起对某个逻辑备份表恢复到指定历史时间点
应答模式
异步。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
src_cluster_id | string | 1 | 备份表所在cluster_id |
dst_cluster_id | string | 1 | 逻辑恢复表到的cluster_id |
restore_type | string | 1 | 逻辑恢复类型,支持db|schema|table. cluster_mgr版本1.0以上支持 |
db_table | string | 1 | 要逻辑恢复的表 |
restore_time | string | 1 | 要恢复到的历史时间点 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"logical_restore",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"src_cluster_id":"1",
"dst_cluster_id":"2",
"restore_type":"table",
"restore":[{
"db_table":"postgres_
$$ public.t1", "restore_time":"2022-10-20 19:20:15" },{ "db_table":"postgres $$
_puingblic.t2", "restore_time":"2022-10-20 19:20:15" }]
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
10. 手动触发cluster_mgr主备切换
接口说明
用户发起对当前cluster_mgr集群触发主备切换操作
应答模式
异步。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
task_type | string | 1 | 任务类型,这个地方为transfer_leader |
target_leader | string | 1 | 要切换的目标新主 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"raft_mission",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"task_type":"transfer_leader",
"target_leader":"127.0.0.1:25001"
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
11. 为cluster_mgr添加节点
接口说明
用户发起对当前cluster_mgr集群添加节点操作
应答模式
异步。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
task_type | string | 1 | 任务类型,这个地方为add_peer |
peer | string | 1 | 要添加cluster_mgr节点 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"raft_mission",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"task_type":"add_peer",
"peer":"127.0.0.1:25001"
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
12. 为cluster_mgr删除节点
接口说明
用户发起对当前cluster_mgr集群删除节点操作
应答模式
异步。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
task_type | string | 1 | 任务类型,这个地方为remove_peer |
peer | string | 1 | 要删除的cluster_mgr节点 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"raft_mission",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"task_type":"remove_peer",
"peer":"127.0.0.1:25001"
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
特别强调
为cluster_mgr集群添加/删除节点,需要手动更新cluster_mgr配置文件中raft_group_member_init_config配置项,将添加/删除节点配置更新
Klustron ClusterManager API
0.使用介绍
KlustronClusterManager 接受 HTTP 协议的请求,并根据请求的类型和参数,执行相应的任务。接口应答模式分为同步和异步模式。 同步模式为客户端在发出请求后,接收到的应答就包含当前接口的执行结果(如果获取集群信息等)。 异步模式通常为执行时间较长的任务。客户端在下发请求后,需要通过 get_status 接口来获取任务的执行状态,指导任务成功或者失败为止。
0.1 下发任务
接口说明
下发集群管理任务。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
version | string | 1 | 自定义协议版本,默认 ‘1.0’ |
job_id | string | 0 | 下发任务,不需要填写 job_id,该 job_id 会由clustermanager 自动生成并通过应答返回。 |
job_type | string | 1 | 任务类型,与具体任务内容相关 |
timestamp | string | 1 | 任务发起的时间戳 |
paras | json | 0 | 自定义参数部分,与任务类型相关。 |
应答参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
version | string | 1 | 自定义协议版本,默认 ‘1.0’ |
error_code | string | 1 | 错误码 |
error_info | string | 1 | 错误信息 |
status | string | 1 | 任务状态,可能的值为 accepted,started, ongoing, done, failed |
job_id | string | 0 | 由clustermanager 自动生成的 job_id, 如果任务类型是异步任务的话,可以通过该 job_id 来查询任务进度和状态。 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"expand_cluster",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"cluster_id":"1",
"dst_shard_id":"2",
"src_shard_id":"1",
"table_list":[
"sbtest.public.test1"
]
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
0.2 获取任务执行状态
接口说明
获取指定 job_id 任务的执行状态。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
version | string | 1 | 自定义协议版本,默认 ‘1.0’ |
job_id | string | 1 | 待查询任务的 id |
job_type | string | 1 | 任务类型,当前接口 'get_status' |
timestamp | string | 1 | 任务发起的时间戳 |
paras | json | 0 | 自定义参数部分,get_status 类型接口不需要填写,其他任务类型可能需要填写。 |
应答参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
version | string | 1 | 自定义协议版本,默认 ‘1.0’ |
error_code | string | 1 | 错误码 |
error_info | string | 1 | 错误信息 |
status | string | 1 | 任务状态,可能的值为 started, ongoing, done, failed |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"expand_cluster",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"cluster_id":"1",
"dst_shard_id":"2",
"src_shard_id":"1",
"table_list":[
"sbtest.public.test1"
]
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
1.设备管理
1.1 上报机器设备
接口说明
将已初始化的服务器设备,注册到系统中。
应答模式
异步。通过 get_status 接口来查询状态。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
job_type | string | 1 | create_machine |
hostaddr | string | 1 | 服务器 IP |
machine_type | string | 1 | 设备类型。 设备类型包括两种 storage 和 computer。 分别代表了存储机型和计算机型。存储机型表示,该设备可以被用来部署 Klustron-storage。相同的,计算机型代表着该设备可以被用来部署 Klustron-server。同一台物理设备,其类型可以是存储设备或者计算设备,也可以既是存储设备,也是计算设备,这种情况下,端口范围需要明确的区分开,确保在同一台设备上安装的计算节点和存储节点不会端口冲突。 |
port_range | string | 1 | 端口分配范围。即新创建的实力端口在该参数指定的范围内分配 |
rack_id | string | 1 | 机架信息 |
datadir | string | 1 | 实例数据目录存放位置 |
logdir | string | 1 | 日志目录存放位置 |
wal_log_dir | string | 1 | wal 日志存放位置 |
comp_datadir | string | 1 | 如果当前设备为计算机型,则该字段标识计算节点的数据目录 |
total_mem | string | 1 | 该机型可用总内存 单位为 MB |
total_cpu_cores | string | 1 | 该机型可用总的逻辑核心数 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"create_machine",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"hostaddr":"192.168.0.135",
"machine_type":"computer",
"port_range":"45000-48000",
"rack_id":"1",
"datadir":"/home/play_ground/run_data",
"logdir":"/home/play_ground/run_data",
"wal_log_dir":"/home/play_ground/run_data",
"comp_datadir":"/home/play_ground/run_data",
"total_mem":"8192",
"total_cpu_cores":"8"
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
#查询接口get_status返回
{
"version":"1.0",
"error_code":"0",
"error_info":"create machine successfully",
"status":"done",
"attachment":{
}
}
1.2 删除设备
接口说明
对已经注册到系统的服务器,执行删除操作。
应答模式
异步。通过 get_status 接口来获取状态。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
job_type | string | 1 | delete_machine |
hostaddr | string | 1 | 机器 ip |
machine_type | string | 1 | 该设备的机型信息 storage 或者 computer |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"delete_machine",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"hostaddr":"127.0.0.1",
"machine_type":"storage"
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
#查询接口get_status返回
{
"version":"1.0",
"error_code":"0",
"error_info":"delete machine successfully",
"status":"done",
"attachment":{
}
}
1.3 设置服务器状态
接口说明
设置指定服务器的状态,如 dead,running,分别表示当前设备处于下线和在线状态,只有在线的设备才能被系统划分到资源池内。
应答模式
异步。通过 get_status 接口来获取状态。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
job_type | string | 1 | delete_machine |
hostaddr | string | 1 | 机器 ip |
node_stats | string | 1 | running, dead |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"set_machine",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"hostaddr":"127.0.0.1",
"node_stats":"running"
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
#查询接口get_status返回
{
"version":"1.0",
"error_code":"0",
"error_info":"set machine success",
"status":"done",
"attachment":{
}
}
2.集群购买与删除
2.1 购买新集群
接口说明
按照指定的参数配置,创建新的 Klustron 集群。
应答模式
异步。通过 get_status 接口来获取状态。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
job_type | string | 1 | create_cluster |
nick_name | string | 1 | 业务名称,如‘对账结息数据库’ |
ha_mode | string | 1 | rbr, mgr。标识高可用模式。前者为强同步模式,后者为 mgr 模式。 |
shards | string | 1 | 分片数目 |
nodes | string | 1 | 每个分片的节点数目,至少 3 个节点,组成一主两从的高可用集群 |
comps | string | 1 | 计算节点个数 |
max_storage_size | string | 1 | 最大存储空间 |
data_storage_MB | string | 1 | 数据存储空间,单位:M |
log_storage_MB | string | 1 | 日志存储空间,单位:M |
max_connections | string | 1 | 最大连接数 |
cpu_cores | string | 1 | 可以使用的最大核数 |
cpu_limit_node | string | 1 | share 标识软隔离模式; quota 标识硬隔离模式; |
enable_backup_encrypt | string | 0 | 1 标识开启备份加密;0 标识不开启备份加密 |
backup_encrypt_key | string | 0 | 备份加密 KEY。如果开启了备份加密,那么此选项必填; |
innodb_size | string | 1 | Klustron-storage 使用的 innodb_buffer 大小(这个字段innodb_size 单位:M) |
innodb_page_size | string | 0 | Klustron-storage 使用的 innodb_page_size 大小, 默认为16384 (支持值为4096 |
dbcfg | string | 0 | 设置小内存模式,0和没有这个字段为正常模式,1为小内存模式 取值为 0 或者 1。 |
fullsync_level | string | 1 | 该shard中强同步备机应当个数,该字段值要小于等于备机节点数 |
storage_iplists | Json array | 1 | 为指定安装存储节点机器,如果不指定,默认选择已有机器 |
computer_iplists | Json array | 1 | 为指定安装计算节点机器,如果不指定,默认选择已有机器 |
install_proxysql | string | 0 | 安装集群时是否安装proxysql,如果安装proxysql,则该集群为单shard模式,默认为0 |
增加输入SN和CN节点分布参数 跨city情况,主城指定master_idc/slave_idc
{
"version":"1.0",
"job_id":"",
"job_type":"create_cluster",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"nick_name":"my_nick_name",
"ha_mode":"rbr",
"shards":"1",
"nodes":"3",
"node_distribution":{
"distribution_type":"cross_city",
"master_city":{
"city_name":"cname_11",
"master_idc":{
"idc":"name_11",
"node_num":"2"
},
"slave_idc":[
{
"idc":"name_22",
"node_num":"2"
},
{
"idc":"name_33",
"node_num":"2"
}
]
},
"slave_city":{
"city_name":"cname_22",
"idcs":[
{
"idc":"name_44",
"node_num":"2"
},
{
"idc":"name_55",
"node_num":"2"
}
]
}
},
"comps":"1",
"comp_distribution":[
{
"idc":"name_44",
"node_num":"2"
},
{
"idc":"name_55",
"node_num":"2"
}
],
"max_storage_size":"20",
"max_connections":"6",
"cpu_cores":"8",
"innodb_size":"128",
"dbcfg":"1"
}
}
跨city情况,主城不指定master_idc/slave_idc
{
"version":"1.0",
"job_id":"",
"job_type":"create_cluster",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"nick_name":"my_nick_name",
"ha_mode":"rbr",
"shards":"1",
"nodes":"3",
"node_distribution":{
"distribution_type":"cross_city",
"master_city":{
"city_name":"cname_11",
"idcs":[
{
"idc":"name_22",
"node_num":"2"
},
{
"idc":"name_33",
"node_num":"2"
}
]
},
"slave_city":{
"city_name":"cname_22",
"idcs":[
{
"idc":"name_44",
"node_num":"2"
},
{
"idc":"name_55",
"node_num":"2"
}
]
}
},
"comps":"1",
"comp_distribution":[
{
"idc":"name_44",
"node_num":"2"
},
{
"idc":"name_55",
"node_num":"2"
}
],
"max_storage_size":"20",
"max_connections":"6",
"cpu_cores":"8",
"innodb_size":"128",
"dbcfg":"1"
}
}
同城情况,指定master_idc/slave_idc情况
{
"version":"1.0",
"job_id":"",
"job_type":"create_cluster",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"nick_name":"my_nick_name",
"ha_mode":"rbr",
"shards":"1",
"nodes":"3",
"node_distribution":{
"distribution_type":"same_city",
"master_idc":{
"idc":"name_11",
"node_num":"2"
},
"slave_idc":[
{
"idc":"name_22",
"node_num":"2"
},
{
"idc":"name_33",
"node_num":"2"
}
]
},
"comps":"1",
"comp_distribution":[
{
"idc":"name_44",
"node_num":"2"
},
{
"idc":"name_55",
"node_num":"2"
}
],
"max_storage_size":"20",
"max_connections":"6",
"cpu_cores":"8",
"innodb_size":"128",
"dbcfg":"1"
}
}
同城情况,不指定master_idc/slave_idc情况
{
"version":"1.0",
"job_id":"",
"job_type":"create_cluster",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"nick_name":"my_nick_name",
"ha_mode":"rbr",
"shards":"1",
"nodes":"3",
"node_distribution":{
"distribution_type":"same_city",
"idcs":[
{
"idc":"name_22",
"node_num":"2"
},
{
"idc":"name_33",
"node_num":"2"
}
]
},
"comps":"1",
"comp_distribution":[
{
"idc":"name_44",
"node_num":"2"
},
{
"idc":"name_55",
"node_num":"2"
}
],
"max_storage_size":"20",
"max_connections":"6",
"cpu_cores":"8",
"innodb_size":"128",
"dbcfg":"1"
}
}
不传SN和CN节点分布参数,则和原先接口一致
特别说明: 如果用户输入了storage_iplists和computer_lists,则不允许传node_distribution和comp_distribution nodes数量要等于node_distribution中node_num数量和,comps数量等comp_distribution中node_num数量和 跨城购买时,必须指定主城和备城信息
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"create_cluster",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"nick_name":"my_nick_name",
"ha_mode":"mgr",
"shards":"1",
"nodes":"3",
"comps":"1",
"max_storage_size":"20",
"max_connections":"6",
"cpu_cores":"8",
"innodb_size":"1024",
"dbcfg":"1",
"fullsync_level":"1",
"install_proxysql":"0",
"storage_iplists":[
"192.168.0.2",
"192.168.0.3"
],
"computer_iplists":[
"192.168.0.1"
]
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
#查询接口get_status返回
{
"version":"1.0",
"error_code":"0",
"error_info":"create cluster successfully",
"status":"done",
"attachment":{
"cluster_id":"3",
"cluster_name":"cluster_1651903646_000001",
"shards":"1",
"comps":"1"
}
}
2.2 集群内新增分片
接口说明
按照指定的参数配置,在现有集群上,新增分片,可以增加多个。
应答模式
异步。通过 get_status 接口来获取状态。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
job_type | string | 1 | add_shards |
cluster_id | string | 1 | 集群 id |
shards | string | 1 | 新增分片个数 |
nodes | string | 1 | 新增分片中,每个分片的节点个数 |
storage_iplists | Json array | 1 | 为指定安装存储节点机器 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"add_shards",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"cluster_id":"1",
"shards":"2",
"nodes":"3",
"storage_iplists":[
"192.168.0.2",
"192.168.0.3"
]
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
#查询接口get_status返回
{
"version":"1.0",
"error_code":"0",
"error_info":"add shards successfully",
"status":"done",
"attachment":{
"cluster_id":"2",
"cluster_name":"cluster_1651836141_000001",
"shards":"2",
"comps":"1",
"list_shard":[
{
"shard_id":"3",
"shard_name":"shard2"
}
]
}
}
2.3 集群内删除现有分片
接口说明
按照指定的参数配置,在现有集群上,删除分片,只能一个一个删。
应答模式
异步。通过 get_status 接口来获取状态。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
job_type | string | 1 | delete_shards |
cluster_id | string | 1 | 集群 id |
shard_id | string | 1 | 待删除分片 id |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"delete_shard",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"cluster_id":"1",
"shard_id":"1"
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
#查询接口get_status返回
{
"version":"1.0",
"error_code":"0",
"error_info":"delete shard successfully",
"status":"done",
"attachment":{
}
}
2.4 集群内新增计算节点
接口说明
按照指定的参数配置,在现有集群上,新增分片,可以增加多个。
应答模式
异步。通过 get_status 接口来获取状态。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
job_type | string | 1 | add_comps |
cluster_id | string | 1 | 集群 id |
comps | string | 1 | 新增的计算节点的个数 |
computer_iplists | Json array | 1 | 为指定安装计算节点的机器 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"add_comps",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"cluster_id":"1",
"comps":"2",
"computer_iplists":[
"192.168.0.2",
"192.168.0.3"
]
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
#查询接口get_status返回
{
"version":"1.0",
"error_code":"0",
"error_info":"add comps successfully",
"status":"done",
"attachment":{
"cluster_id":"3",
"cluster_name":"cluster_1651903646_000001",
"shards":"1",
"comps":"2",
"list_comp":[
{
"comp_id":"3",
"comp_name":"comp2"
}
]
}
}
2.5 集群内删除计算节点
接口说明
按照指定的参数配置,在现有集群上,删除计算节点,只能一个一个删。
应答模式
异步。通过 get_status 接口来获取状态。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
job_type | string | 1 | delete_shards |
cluster_id | string | 1 | 集群 id |
comp_id | string | 1 | 待删除计算节点 id |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"delete_comp",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"cluster_id":"1",
"comp_id":"1"
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
#查询接口get_status返回
{
"version":"1.0",
"error_code":"0",
"error_info":"delete comp successfully",
"status":"done",
"attachment":{
}
}
2.6 指定集群增加 node 节点
接口说明
按照指定的参数配置,为集群所有分片增加node, 异步,需要查询。
应答模式
异步。通过 get_status 接口来获取状态。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
job_type | string | 1 | add_nodes |
cluster_id | string | 1 | 集群 id |
shard_id | string | 0 | 若指定该字段,则只在该 shard 上增加 node |
nodes | string | 1 | 增加节点的个数 |
storage_iplists | Json array | 1 | 为指定安装存储节点机器 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"add_nodes",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"cluster_id":"1",
"shard_id":"1",
"nodes":"2",
"storage_iplists":[
"192.168.0.2",
"192.168.0.3"
]
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
#查询接口get_status返回
{
"version":"1.0",
"error_code":"0",
"error_info":"add new nodes successfully",
"status":"done",
"attachment":{
"cluster_id":"1",
"cluster_name":"cluster_1651907758_000001",
"shards":"1",
"comps":"1",
"list_shard":[
{
"shard_id":"1",
"shard_name":"shard1",
"nodes":"5",
"list_node":[
{
"hostaddr":"192.168.0.127",
"node_id":"4",
"port":"58509"
},
{
"hostaddr":"192.168.0.127",
"node_id":"5",
"port":"58512"
}
]
}
]
}
}
2.7 指定集群删除 node 节点
接口说明
按照指定的参数配置,为集群指定分片删除指定 node, 异步,需要查询。
应答模式
异步。通过 get_status 接口来获取状态。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
job_type | string | 1 | delete_nodes |
cluster_id | string | 1 | 集群 id |
shard_id | string | 0 | 若指定该字段,则只在该 shard 上增加 node |
hostaddr | string | 1 | 待删除 node 所在的机器 IP |
port | string | 1 | 端口号 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"delete_node",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"cluster_id":"1",
"shard_id":"1",
"hostaddr":"127.0.0.1",
"port":"57338"
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
#查询接口get_status返回
{
"version":"1.0",
"error_code":"0",
"error_info":"delete node successfully",
"status":"done",
"attachment":{
}
}
2.8 重做备机
接口说明
指定重做某个 shard 的备机。
应答模式
异步。通过 get_status 接口来获取状态。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
job_type | string | 1 | delete_nodes |
cluster_id | string | 1 | 集群 id |
shard_id | string | 0 | 若指定该字段,则只在该 shard 上增加 node |
hostaddr | string | 1 | 待删除 node 所在的机器 IP |
port | string | 1 | 端口号 |
need_backup | string | 1 | 是否需要在重做前进行备份 |
hdfs_host | string | 1 | 冷备位置 |
pv_limit | string | 1 | 冷备传输限速 单位是 MB |
allow_pull_from_master | string | 1 | 是否在备机不可用的情况下,使用主机的数据重做备机 |
allow_replica_delay | string | 1 | 备机延迟的最大值,如果备机延迟超过这个值,则认为该备机不适合作为数据源 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"rebuild_node",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"shard_id":"1",
"cluster_id":"1",
"rb_nodes":[
{
"hostaddr":"192.168.0.125",
"port":"57001",
"need_backup":"0",
"hdfs_host":"hdfs",
"pv_limit":"10"
}
],
"allow_pull_from_master":"1",
"allow_replica_delay":"15"
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
#查询接口get_status返回
{
"version":"1.0",
"error_code":"0",
"error_info":"delete node successfully",
"status":"done",
"attachment":{
}
}
2.9 删除指定集群
接口说明
按照指定的参数配置,为集群指定分片删除指定 node, 异步,需要查询。
应答模式
异步。通过 get_status 接口来获取状态。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
job_type | string | 1 | delete_cluster |
cluster_id | string | 1 | 集群 id |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"delete_cluster",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"cluster_id":"1"
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
#查询接口get_status返回
{
"attachment": {
"cluster_id": "43" ,
"cluster_name": "cluster_1665971623_000043" ,
"computer_id": "776" ,
"computer_state": "done" ,
"computer_step": [
{
"cluster_id": "43" ,
"computer_hosts": "192.168.0.132_53704;" ,
"computer_id": "778" ,
"computer_state": "done" ,
"error_code": 0 ,
"error_info": "OK" ,
"rollback_flag": "1"
}
],
"job_steps": "shard,computer" ,
"shard_id": "775" ,
"shard_step": [
{
"cluster_id": "43" ,
"error_code": 0 ,
"error_info": "OK" ,
"rollback_flag": "1" ,
"shard_ids": "83," ,
"storage_hosts": "192.168.0.132_53407;192.168.0.132_53411;" ,
"storage_id": "777" ,
"storage_state": "done"
}
],
"storage_state": "done"
},
"error_code": "0" ,
"error_info": "OK" ,
"job_id": "" ,
"job_type": "" ,
"status": "done" ,
"version": "1.0"
}
2.10 修改实例资源隔离参数
接口说明
按照指定的参数配置,修改 MySQL 或者 PostgreSQL 实例的资源隔离参数,当前只支持 cpu 隔离。
应答模式
异步。通过 get_status 接口来获取状态。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
job_type | string | 1 | update_instance_cgroup |
ip | string | 1 | 实例 ip |
Port | string | 1 | 实例监听端口 |
type | string | 1 | mysql 标识存储节点实例,pg 标识计算节点实例 |
cpu_cores | string | 1 | 分配的 cpu 核数 |
cgroup_mode | string | 1 | cpu 资源限制的模式,默认是quota,可以设置quota或者share,其中 share 标识软隔离,quota 标识硬隔离。 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"update_instance_cgroup",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"ip":"192.168.0.135",
"port":"57001",
"type":"mysql",
"cpu_cores":"5",
"cgroup_mode":"quota"
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
2.11 重做集群计算节点
接口说明
按照指定的参数,将该集群中所有计算节点重做,即将计算节点中数据清空。
应答模式
异步。通过 get_status 接口来获取状态。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
job_type | string | 1 | rebuild_comps |
cluster_id | string | 1 | 需要重做该集群的所有计算节点 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"rebuild_comps",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"cluster_id":"1"
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
特别说明:
该接口将该集群中所有计算节点中数据清理了。一般再rcr关系断开后,重新建立rcr关系时才需要。
3.集群备份
3.1 手动发起集群备份
接口说明
调用该接口手动发起一次全量备份。cluster_id 为 -1 时,表示备份元数据集群。
应答模式
同步接口。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
cluster_id | string | 1 | 集群 ID |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"manual_backup_cluster",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"cluster_id":"1"
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
4.集群恢复
4.1 集群回档(按时间点恢复集群)
接口说明
按时间点对指定集群进行回档。
应答模式
异步。通过 get_status 接口获取任务进度。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
src_cluster_id | string | 1 | 回档操作的源集群 ID |
dst_cluster_id | string | 1 | 回档操作的目标集群 ID。该集群必须是新买的空集群 |
restore_time | string | 1 | 回档时间点 |
示例
#请求
{
"version":"1.0",
"job_id":"",
"job_type":"cluster_restore",
"timestamp":"1435749309",
"paras":{
"src_cluster_id":"1",
"dst_cluster_id":"2",
"restore_time":"restore_time"
}
} -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
5.集群扩容
5.1 自动获取表搬迁列表
接口说明
获取系统自动选择出来的待搬迁的表列表。
应答模式
同步。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
cluster_id | string | 1 | 集群 ID |
shard_id | string | 1 | 当前集群内待迁出表的源 shard id |
policy | string | 1 | top_hit:选择访问频率最高的表。 top_size:选择数据量最大的表 |
应答参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
attachment->table_list | string | 待迁移表列表 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"get_expand_table_list",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"cluster_id":"3",
"shard_id":"2",
"policy":"top_size"
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":{
"table_list":"kunlundb_super_dba.kunlundb_super_dba_$$_public.test1"
},
"error_code":"0",
"error_info":"",
"job_id":"",
"job_type":"",
"status":"done",
"version":"1.0"
}
5.2 发起表搬迁任务
接口说明
发起表搬迁任务。
应答模式
异步。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
job_type | string | 1 | expand_cluster |
cluster_id | string | 1 | 集群 ID |
src_shard_id | string | 1 | 当前集群内待迁出表的源 shard id |
dst_shard_id | string | 1 | 当前集群内待迁出表的目标 shard id |
table_list | json_array | 1 | 待迁移表列表 |
drop_old_table | string | 0 | 是否保留源表 |
示例
#请求
curl -d '
{
"version": "1.0",
"job_id":"",
"job_type": "expand_cluster",
"timestamp" : "1435749309",
"user_name":"kunlun_test",
"paras": {
"cluster_id": "1",
"dst_shard_id": "5",
"src_shard_id": "6",
"table_list": [
"postgres.public.test2"
]
}
} ' -X POST http://192.168.0.135:8010/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
6. 元数据管理
6.1 获取元数据集群同步模式
接口说明
查询元数据集群同步模式。
应答模式
同步。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
job_type | string | 1 | get_meta_summary |
应答参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
attachment->mode | string | 元数据集群同步模式 no_rep, mgr, rbr 三种类型的结果 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"get_meta_mode",
"timestamp":"1435749309",
"paras":{
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":{
"mode":"mgr"
},
"error_code":"0",
"error_info":"",
"job_id":"",
"job_type":"",
"status":"done",
"version":"1.0"
}
6.2 获取冷备存储服务信息
接口说明
查询冷备存储服务的详细信息。
应答模式
同步。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
job_type | string | 1 | get_backup_storage |
应答参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
hostaddr | string | 备份服务 IP | |
name | string | 备份服务名称 | |
port | string | 备份服务端口 | |
stype | string | 备份服务类型 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"get_backup_storage",
"timestamp":"1435749309",
"paras":{
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":{
"list_backup_storage":[
{
"hostaddr":"192.168.0.135",
"name":"hdfs_backup1",
"port":"9000",
"stype":"HDFS"
}
]
},
"error_code":"0",
"error_info":"",
"job_id":"",
"job_type":"",
"status":"done",
"version":"1.0"
}
6.3 获取机器状态信息
接口说明
查询所有机器状态的详细信息。
应答模式
同步。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
job_type | string | 1 | get_machine_summary |
应答参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
hostaddr | string | 服务器地址 | |
status | string | 服务器状态 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"get_machine_summary",
"timestamp":"1435749309",
"paras":{
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":{
"list_machine":[
{
"hostaddr":"192.168.0.135",
"status":"online"
},
{
"hostaddr":"192.168.0.125",
"status":"online"
}
]
},
"error_code":"0",
"error_info":"",
"job_id":"",
"job_type":"",
"status":"done",
"version":"1.0"
}
6.4 获取集群列表
接口说明
查询所有 Klustron 集群列表。
应答模式
同步。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
job_type | string | 1 | get_cluster_summary |
应答参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
name | string | 集群名称 | |
nick_name | string | 业务名称 | |
shards | string | 分片个数 | |
comps | string | 计算节点个数 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"get_machine_summary",
"timestamp":"1435749309",
"paras":{
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":{
"list_machine":[
{
"hostaddr":"192.168.0.135",
"status":"online"
},
{
"hostaddr":"192.168.0.125",
"status":"online"
}
]
},
"error_code":"0",
"error_info":"",
"job_id":"",
"job_type":"",
"status":"done",
"version":"1.0"
}
6.5 获取集群详细信息
接口说明
获取指定集群的详细信息。
应答模式
同步。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
job_type | string | 1 | get_cluster_detail |
cluster_name | string | 1 | 集群名称 |
应答参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
name | string | 集群名称 | |
nick_name | string | 业务名称 | |
shards | string | 分片个数 | |
comps | string | 计算节点个数 | |
comp_name | string | 计算节点名称 | |
hostaddr | string | 计算节点或者存储节点 IP | |
port | string | 计算节点或者存储节点端口 | |
status | string | 当前节点状态 | |
master | string | 当前存储节点是否为主节点 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"get_cluster_detail",
"timestamp":"1435749309",
"paras":{
"cluster_name":"cluster_1659333382_000001"
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":{
"cluster_name":"cluster_1659333382_000001",
"comps":"1",
"list_comp":[
{
"comp_name":"comp_1",
"hostaddr":"192.168.0.135",
"port":"45001",
"status":"online"
}
],
"list_shard":[
{
"list_node":[
{
"hostaddr":"192.168.0.135",
"master":"true",
"port":"55001",
"status":"online"
},
{
"hostaddr":"192.168.0.135",
"master":"false",
"port":"55002",
"status":"online"
},
{
"hostaddr":"192.168.0.135",
"master":"false",
"port":"55003",
"status":"online"
}
],
"nodes":"3",
"shard_name":"shard_1"
}
],
"nick_name":"my_nick_name",
"shards":"1"
},
"error_code":"0",
"error_info":"",
"job_id":"",
"job_type":"",
"status":"done",
"version":"1.0"
}
6.6 获取存储节点系统变量信息
接口说明
查询 Klustron-storage 的某个变量值(如 innodb_buffer_pool_size)。
应答模式
同步。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
job_type | string | 1 | get_variable |
hostaddr | string | 1 | Klustron-storage ip |
port | string | 1 | Klustron-storage port |
variable | string | 1 | 变量名 |
应答参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
result | string | 查询是否成功 | |
value | string | 查询结果 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"get_variable",
"timestamp":"1435749309",
"paras":{
"hostaddr":"192.168.0.135",
"port":"55001",
"variable":"innodb_buffer_pool_size"
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":{
"result":"true",
"value":"5242880"
},
"error_code":"0",
"error_info":"",
"job_id":"",
"job_type":"",
"status":"done",
"version":"1.0"
}
7.表重分布
接口说明
根据用户输入表,将表中数据dump出来导入新表中
应答模式
异步。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
src_cluster_id | string | 1 | 原表所在cluster_id |
dst_shard_id | string | 1 | 目标表重分布到目标的cluster_id |
repartition_tables | string | 1 | 目标表重分布到目标的cluster_id |
rename_tables | string | 0 | 表重分布完是否需要将目标表reanme成源表名 |
del_src_table | string | 0 | 表重分布成功后,是否需要自动删除源表 |
del_resv_day | string | 0 | del_src_table=0,则需要设置保留多少天,默认为7天 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"repartition_tables",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"src_cluster_id":"3",
"dst_cluster_id":"2",
"repartition_tables":"test_
$$ public.t=>test1 $$
private.t2,test
$$ priv.ta=>test1 $$
_priv1.tb" } } ' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
特别说明:
1.需要预先在目标cluster下建立好database,schema,和table,并且原和目标表表结构一致,这个cluster_mgr会自动校验
2.重分布表任务一次要求做的表必须下同一个database下,原和目标database可以不同
8.表逻辑备份
接口说明
用户发起对某个表逻辑备份,以及设置定时逻辑备份
应答模式
异步。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
cluster_id | string | 1 | 逻辑备份表所在cluster_id |
backup_type | string | 0 | 逻辑备份类型,目前支持db,schema,table。如果输入db,则备份该db下所有表 |
db_table | string | 1 | 要逻辑备份的表 |
backup_time | string | 1 | 定时备份时间段 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"logical_backup",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"cluster_id":"1",
"backup_type":"table",
"backup":[
{
"db_table":"postgres_
$$ public.t1", "backup_time":"01:00:00-02:00:00" }, { "db_table":"postgres $$
_puinblic.t2", "backup_time":"01:00:00-02:00:00" } ]
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
9.表逻辑恢复
接口说明
用户发起对某个逻辑备份表恢复到指定历史时间点
应答模式
异步。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
src_cluster_id | string | 1 | 备份表所在cluster_id |
dst_cluster_id | string | 1 | 逻辑恢复表到的cluster_id |
restore_type | string | 0 | 逻辑恢复类型,目前支持db,schema,table,如果输入db,则从源cluster中将该db下所有表恢复到目标cluster |
db_table | string | 1 | 要逻辑恢复的表 |
restore_time | string | 1 | 要恢复到的历史时间点 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"logical_restore",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"src_cluster_id":"1",
"dst_cluster_id":"2",
"restore_type":"table",
"restore":[{
"db_table":"postgres_
$$ public.t1", "restore_time":"2022-10-20 19:20:15" },{ "db_table":"postgres $$
_publgic.t2", "restore_time":"2022-10-20 19:20:15" }] } } ' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
10. 手动触发cluster_mgr主备切换
接口说明
用户发起对当前cluster_mgr集群触发主备切换操作
应答模式
异步。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
task_type | string | 1 | 任务类型,这个地方为transfer_leader |
target_leader | string | 1 | 要切换的目标新主 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"raft_mission",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"task_type":"transfer_leader",
"target_leader":"127.0.0.1:25001"
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
11. 为cluster_mgr添加节点
接口说明
用户发起对当前cluster_mgr集群添加节点操作
应答模式
异步。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
task_type | string | 1 | 任务类型,这个地方为add_peer |
peer | string | 1 | 要添加cluster_mgr节点 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"raft_mission",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"task_type":"add_peer",
"peer":"127.0.0.1:25001"
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
12. 为cluster_mgr删除节点
接口说明
用户发起对当前cluster_mgr集群删除节点操作
应答模式
异步。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
task_type | string | 1 | 任务类型,这个地方为remove_peer |
peer | string | 1 | 要删除的cluster_mgr节点 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"raft_mission",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"task_type":"remove_peer",
"peer":"127.0.0.1:25001"
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
特别强调
为cluster_mgr集群添加/删除节点,需要手动更新cluster_mgr配置文件中raft_group_member_init_config配置项,将添加/删除节点配置更新
13. 手动跨idc主备切换
接口说明
用户发起对某个cluster进行跨idc切换操作
应答模式
异步。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
cluster_id | string | 1 | 要切换的集群id |
target_idc | string | 1 | 要切换到的目标idc |
need_rollback | string | 0 | 切换失败是否回滚切换成功的shard |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"manual_idcsw",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"cluster_id":"1",
"target_idc":"abc"
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
14. 强制跨城切换
接口说明
用户发起对某个cluster进行跨城切换操作
应答模式
异步。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
cluster_id | string | 1 | 要切换的集群id |
target_city | string | 1 | 要切换到的目标city |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"force_citysw",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"cluster_id":"1",
"target_city":"abc"
}
}
' -X POST http://192.168.0.135:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
特别强调
该操作为强制切换,不能保证数据一致性。
15. 建立rcr数据同步
接口说明
用户发起对两个cluster建立rcr数据同步
应答模式
异步。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
master_info | Json_Array | 1 | 主rcr参数,meta_db和cluster_id |
cluster_id | string | 1 | 备rcr cluster的id |
ignore_db | string | 0 | 默认值为0, 如果传入1,备集群中数据将会清理重新从主集群拉取,存储节点和计算节点数据都被清理 |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"create_rcr",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"master_info":{
"meta_db":"127.0.0.1:57001,127.0.0.2:57001,127.0.0.3:57001",
"cluster_id":"1"
},
"cluster_id":"2",
"ignore_db":"0"
}
}
' -X POST http://127.0.0.1:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
16. 删除rcr数据同步
接口说明
用户发起取消两个cluster rcr数据同步
应答模式
异步。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
master_info | Json_Array | 1 | 主rcr参数,meta_db和cluster_id |
cluster_id | string | 1 | 备rcr cluster的id |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"delete_rcr",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"master_info":{
"meta_db":127.0.0.1:57001,127.0.0.2:57002",
"cluster_id":"1"
},
"cluster_id":"2"
}
}
' -X POST http://127.0.0.1:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
17. 手动rcr切换
接口说明
用户发起对手动切换rcr同步
应答模式
异步。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
master_info | Json_Array | 1 | 主rcr参数,meta_db和cluster_id |
cluster_id | string | 1 | 备rcr cluster的id |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"manualsw_rcr",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"master_info":{
"meta_db":127.0.0.1:57001,127.0.0.2:57002",
"cluster_id":"1"
},
"cluster_id":"2"
}
}
' -X POST http://127.0.0.1:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
17. 配置rcr数据同步参数
接口说明
用户发起对rcr数据同步参数调整
应答模式
异步。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
master_info | Json_Array | 1 | 主rcr参数,meta_db和cluster_id |
work_mode | string | 1 | 修改参数类型,目前支持modify_sync_delay |
sync_delay | string | 0 | 当work_mode=modify_sync_delay时,设置延迟时间,单位为s |
cluster_id | string | 1 | 备rcr cluster的id |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"modify_rcr",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"master_info":{
"meta_db":127.0.0.1:57001,127.0.0.2:57002",
"cluster_id":"1"
},
"work_mode":"start_rcr",
"cluster_id":"2"
}
}
' -X POST http://127.0.0.1:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
18. 设置自动物理备份时间段
接口说明
用户发起对物理自动备份时间段调整
应答模式
异步。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
cluster_id | string | 1 | cluster的id |
time_period_str | string | 1 | 备份时间段,格式为“08:00:00-24:00:00” |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"update_cluster_coldback_time_period",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"cluster_id":"2",
"time_period_str":"08:00:00-24:00:00"
}
}
' -X POST http://127.0.0.1:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
19. 对集群中存储节点或计算节点操作
接口说明
用户发起对集群中存储节点或者计算节点操作
应答模式
异步。
请求参数
参数名称 | 参数类型 | 是否必填 | 备注 |
---|---|---|---|
control | string | 1 | 操作类型,start |
hostaddr | string | 1 | 要操作实例的机器ip |
port | string | 1 | 要操作实例的机器端口 |
machine_type | string | 1 | 要操作实例类型,storage |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"control_instance",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
"control":"start",
"hostaddr":"127.0.0.1",
"port":"27001",
"machine_type":"storage"
}
}
' -X POST http://127.0.0.1:35001/HttpService/Emit
#应答
{
"attachment":null,
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
20. 获取当前元数据集群主节点
接口说明
用户同发起任务,获取当前元数据集群主节点
应答模式
同步。
请求参数
| 参数名称 | 参数类型 | 是否必填 | 备注 |
| ----------- | ---------- | -------- | ------------------------------------------------------ |
示例
#请求
curl -d '
{
"version":"1.0",
"job_id":"",
"job_type":"get_meta_master",
"timestamp":"1435749309",
"user_name":"kunlun_test",
"paras":{
}
}
' -X POST http://127.0.0.1:35001/HttpService/Emit
#应答
{
"attachment":{"master_host":"127.0.0.1:23301"},
"error_code":"0",
"error_info":"",
"job_id":"35",
"status":"accept",
"version":"1.0"
}
END
33542df8d527d8698510020e4f1eed55588fb013:cluster_mgr_api.md