Skip to main content

KlustronDB  ClusterManager API

KlustronDBAbout 37 min

KlustronDB  ClusterManager API

0. Introduction to Use

KunlunClusterManager accepts requests via the HTTP protocol and executes corresponding tasks based on the type and parameters of the request. The interface response modes are divided into synchronous and asynchronous modes. In synchronous mode, after the client sends a request, the received response contains the execution result of the current interface (for example, when obtaining cluster information). Asynchronous mode is usually for tasks that take a longer time to execute. After sending a request, the client needs to use the get_status interface to obtain the execution status of the task, until the task succeeds or fails.

0.1 Assign Tasks

Interface Description

Assign cluster management tasks.

Request parameters

Parameter NameParameter TypeRequiredRemarks
versionstring1Custom protocol version, default '1.0'
job_idstring0For issuing tasks, no need to fill in job_id. This job_id will be automatically generated by clustermanager and returned in the response.
job_typestring1Task type, related to the specific task content
timestampstring1Timestamp when the task is initiated
parasjson0Custom parameter section, related to the task type

Response Parameters

Parameter NameParameter TypeRequiredRemarks
versionstring1Custom protocol version, default '1.0'
error_codestring1Error code
error_infostring1Error information
statusstring1Task status, possible values are accepted, started, ongoing, done, failed
job_idstring0job_id automatically generated by clustermanager. If the task type is an asynchronous task, the task progress and status can be queried using this job_id.

Example

#请求
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 Get Task Execution Status

Interface Description

Get the execution status of the specified job_id task.

Request parameters

Parameter NameParameter TypeRequiredRemarks
versionstring1Custom protocol version, default '1.0'
job_idstring1ID of the task to be queried
job_typestring1Task type, current interface 'get_status'
timestampstring1Timestamp when the task was initiated
parasjson0Custom parameter section, not required for get_status type interface, may be required for other task types.

Response Parameters

Parameter NameParameter TypeRequiredRemarks
versionstring1Custom protocol version, default '1.0'
error_codestring1Error code
error_infostring1Error information
statusstring1Task status, possible values are started, ongoing, done, failed

Example

#请求
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. Equipment Management

1.1 Reporting Machinery and Equipment

Interface Description

Register the initialized server device into the system.

Response mode

Asynchronous. Use the get_status interface to check the status.

Request parameters

参数名称参数类型是否必填备注
job_typestring1create_machine
hostaddrstring1服务器 IP
machine_typestring1设备类型。 设备类型包括两种 storage 和 computer。 分别代表了存储机型和计算机型。存储机型表示,该设备可以被用来部署  KlustronDB_storage。相同的,计算机型代表着该设备可以被用来部署  KlustronDB_server。同一台物理设备,其类型可以是存储设备或者计算设备,也可以既是存储设备,也是计算设备,这种情况下,端口范围需要明确的区分开,确保在同一台设备上安装的计算节点和存储节点不会端口冲突。
port_rangestring1端口分配范围。即新创建的实力端口在该参数指定的范围内分配
rack_idstring1机架信息
datadirstring1实例数据目录存放位置
logdirstring1日志目录存放位置
wal_log_dirstring1wal 日志存放位置
comp_datadirstring1如果当前设备为计算机型,则该字段标识计算节点的数据目录
total_memstring1该机型可用总内存 单位为 MB
total_cpu_coresstring1该机型可用总的逻辑核心数

Example

#请求
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 Remove Device

Interface Description

Perform the delete operation on servers that have already been registered in the system.

Response mode

Asynchronous. Use the get_status interface to obtain the status.

Request parameters

Parameter NameParameter TypeRequiredRemarks
job_typestring1delete_machine
hostaddrstring1Machine IP
machine_typestring1The device model information: storage or computer

Example

#请求
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 Set Server Status

Interface Description

Set the status of a specified server, such as dead or running, which indicate that the current device is offline or online, respectively. Only online devices can be assigned to the resource pool by the system.

Response mode

Asynchronous. Use the get_status interface to obtain the status.

Request parameters

Parameter NameParameter TypeRequiredRemarks
job_typestring1delete_machine
hostaddrstring1Machine IP
node_statsstring1running, dead

Example

#请求
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. Cluster Purchase and Deletion

2.1 Purchase a New Cluster

Interface Description

Create a new kunlunBase cluster according to the specified parameter configuration.

Response mode

Asynchronous. Use the get_status interface to obtain the status.

Request parameters

Parameter NameParameter TypeRequiredNotes
job_typestringYescreate_cluster
nick_namestringYesBusiness name, e.g., 'Reconciliation and Interest Settlement Database'
ha_modestringYesrbr, mgr. Indicates high-availability mode. The former is in strong synchronization mode, while the latter is in mgr mode.
shardsstring1Number of shards
nodesstring1Number of nodes in each shard. At least three nodes, high-availability clusters that form 1 master and slave
compsstring1Number of compute nodes
max_storage_sizestring1Maximum storage space
max_connectionsstring1Maximum number of connections
cpu_coresstring1Maximum number of cores that can be used
cpu_limit \isolation_nodesoft stringshot1
innodb_sizestring1KlustronDB the innodb_buffer size used by _storage (this field innodb_size unit: M)
dbcfgstring0sets the small memory mode, 0 and without this field for normal mode, 1 for small memory mode takes the value 0 or 1.
fullsync_levelstring1The required number of strongly synchronized standby nodes in this shard. This value must be less than or equal to the number of standby nodes.
storage_iplistsJson array0Specifies the hosts on which to install the storage nodes. If not specified, existing hosts will be used by default.
computer_iplistsJson array0Specifies the hosts on which to install the compute nodes. If not specified, existing hosts will be used by default.
node_distributionJson array0Configures the distribution information for storage nodes.
comp_distributionJson array0Configures the distribution information for compute nodes.
install_proxysqlstring0Whether to install ProxySQL during cluster deployment. If ProxySQL is installed, the cluster will be in single-shard mode. The default value is 0.

Example

#请求
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 Adding New Shards Within the Cluster

Interface Description

According to the specified parameter configuration, on the existing cluster, new shards can be added, and multiple shards can be added.

Response mode

Asynchronous. Use the get_status interface to obtain the status.

Request parameters

Parameter NameParameter TypeRequiredNotes
job_typestring1add_shards
cluster_idstring1Cluster ID
shardsstring1Number of shards to add
nodesstring1Number of nodes per shard
storage_iplistsJson array1Machines specified for installing storage nodes

Example

#请求
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 Delete existing shards within the cluster

Interface Description

According to the specified parameter configuration, on the existing cluster, shards can only be deleted one by one.

Response mode

Asynchronous. Use the get_status interface to obtain the status.

Request parameters

Parameter NameParameter TypeRequiredRemarks
job_typestring1delete_shards
cluster_idstring1Cluster ID
shard_idstring1ID of the shard to be deleted

Example

#请求
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 Adding New Compute Nodes within the Cluster

Interface Description

According to the specified parameter configuration, on the existing cluster, new shards can be added, and multiple shards can be added.

Response mode

Asynchronous. Use the get_status interface to obtain the status.

Request parameters

Parameter NameParameter TypeRequiredRemarks
job_typestring1add_comps
cluster_idstring1Cluster ID
compsstring1Number of new compute nodes
computer_iplistsJson array1Machines for installing specified compute nodes

Example

#请求
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 Deleting compute nodes within the cluster

Interface Description

According to the specified parameter configuration, on the existing cluster, deleting compute nodes can only be done one by one.

Response mode

Asynchronous. Use the get_status interface to obtain the status.

Request parameters

Parameter NameParameter TypeRequiredRemarks
job_typestring1delete_shards
cluster_idstring1Cluster id
comp_idstring1ID of the computing node to be deleted

Example

#请求
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 Specify cluster to add node

Interface Description

Add nodes to all shards of the cluster according to the specified parameter configuration, asynchronously, requires querying.

Response mode

Asynchronous. Use the get_status interface to obtain the status.

Request parameters

Parameter NameParameter TypeRequiredNotes
job_typestring1add_nodes
cluster_idstring1Cluster ID
shard_idstring0If this field is specified, nodes will be added only to this shard
nodesstring1Number of nodes to add
storage_iplistsJSON array1Machines designated for installing storage nodes

Example

#请求
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 Specify cluster to delete node

Interface Description

According to the specified parameter configuration, delete the specified node from the cluster's designated shard asynchronously, query needed.

Response mode

Asynchronous. Use the get_status interface to obtain the status.

Request parameters

Parameter NameParameter TypeRequiredRemarks
job_typestring1delete_nodes
cluster_idstring1Cluster ID
shard_idstring0If this field is specified, nodes will only be added to this shard
hostaddrstring1IP of the machine where the node to be deleted is located
portstring1Port number

Example

#请求
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 Redo the backup machine

Interface Description

Designate a backup machine to redo a certain shard.

Response mode

Asynchronous. Use the get_status interface to obtain the status.

Request parameters

Parameter NameParameter TypeRequiredNotes
job_typestringYesdelete_nodes
cluster_idstringYesCluster ID
shard_idstringNoIf specified, nodes will be added only to this shard
hostaddrstringYesIP address of the machine where the node to be deleted resides
portstringYesPort number
need_backupstringYesWhether a backup is required before redoing
hdfs_hoststringYesCold backup location
pv_limitstringYesCold backup transfer rate limit, in MB
allow_pull_from_masterstringYesWhether to use data from the primary node to redo the standby node if the standby is unavailable
allow_replica_delaystringYesMaximum allowable delay for the standby node; if the delay exceeds this value, the standby node will be considered unsuitable as a data source

Example

#请求
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 Remove the specified cluster

Interface Description

According to the specified parameter configuration, delete the specified node from the cluster's designated shard, asynchronously, requires querying.

Response mode

Asynchronous. Use the get_status interface to obtain the status.

Request parameters

Parameter NameParameter TypeRequiredRemarks
job_typestring1delete_cluster
cluster_idstring1Cluster ID

Example

#请求
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 Modify instance resource isolation parameters

Interface Description

According to the specified parameter configuration, modify the resource isolation parameters of the MySQL or PostgreSQL instance. Currently, only CPU isolation is supported.

Response mode

Asynchronous. Use the get_status interface to obtain the status.

Request parameters

Parameter NameParameter TypeRequiredNotes
job_typestringYesupdate_instance_cgroup
ipstringYesInstance IP address
PortstringYesInstance listening port
typestringYes“mysql” indicates a storage node instance; “pg” indicates a compute node instance
cpu_coresstringYesNumber of CPU cores allocated
cgroup_modestringYesCPU resource limitation mode; the default is “quota”. It can be set to either “quota” or “share”, where “share” represents soft isolation and “quota” represents hard isolation.

Example

#请求
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. Cluster Backup

3.1 Manually Initiate Cluster Backup

Interface Description

Call this interface to manually initiate a full backup. When cluster_id is -1, it indicates backing up the metashard.

Response mode

Synchronous interface.

Request parameters

Parameter NameParameter TypeRequiredRemarks
cluster_idstring1Cluster ID

Example

#请求
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. Cluster Recovery

4.1 Cluster Rollback (Restore Cluster by Time Point)

Interface Description

Perform a rollback on the specified cluster according to the point in time.

Response mode

Asynchronous. Obtain task progress through the get_status interface.

Request parameters

Parameter NameParameter TypeRequiredRemarks
src_cluster_idstringYesID of the source cluster for the rollback operation
dst_cluster_idstringYesID of the target cluster for the rollback operation. This cluster must be a newly purchased empty cluster
restore_timestringYesRollback time point

Example

Request

{ "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

Response

5. Cluster Expansion

5.1 Automatically Obtain Table Migration List

Interface Description

Get the list of tables automatically selected by the system for migration.

Response mode

Synchronize.

Request parameters

Parameter NameParameter TypeRequiredRemarks
cluster_idstring1Cluster ID
shard_idstring1Source shard ID of the table to be migrated within the current cluster
policystring1top_hit: select the table with the highest access frequency. top_size: select the table with the largest data volume

Response Parameters

Parameter NameParameter TypeRequiredRemarks
attachment->table_liststringList of tables to be migrated

Example

Request

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

Response

{ "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 Initiate Table Migration Task

Interface Description

Initiate table migration task.

Response mode

Asynchronous.

Request parameters

Parameter NameParameter TypeRequiredRemarks
job_typestring1expand_cluster
cluster_idstring1Cluster ID
src_shard_idstring1Source shard ID of the table to be migrated in the current cluster
dst_shard_idstring1Target shard ID of the table to be migrated in the current cluster
table_listjson_array1List of tables to be migrated
drop_old_tablestring0Whether to retain the source table

Example

Request

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

Response

6. Metadata Management

6.1 Obtaining metashard Synchronization Mode

Interface Description

Query the metashard synchronization mode.

Response mode

Synchronize.

Request parameters

Parameter NameParameter TypeRequiredRemarks
job_typestring1get_meta_summary

Response Parameters

Parameter NameParameter TypeRequiredNotes
attachment->modestring
metashard synchronization mode. Three types of results: no_rep, mgr, rbr

Example

Request

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

Response

{ "attachment":{ "mode":"mgr" }, "error_code":"0", "error_info":"", "job_id":"", "job_type":"", "status":"done", "version":"1.0" }

6.2 Obtaining Cold Backup Storage Service Information

Interface Description

Inquire about the detailed information of cold backup storage services.

Response mode

Synchronize.

Request parameters

Parameter NameParameter TypeRequiredRemarks
job_typestring1get_backup_storage

Response Parameters

Parameter NameParameter TypeRequiredNotes
hostaddrstring
Backup service IP
namestring
Backup service name
portstring
Backup service port
stypestring
Backup service type

Example

Request

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

Response

{ "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 Obtaining Machine Status Information

Interface Description

Query detailed information of all machine statuses.

Response mode

Synchronize.

Request parameters

Parameter NameParameter TypeRequiredRemarks
job_typestring1get_machine_summary

Response Parameters

Parameter NameParameter TypeRequiredRemarks
hostaddrstring
Server Address
statusstring
Server Status

Example

Request

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

Response

{ "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 Get Cluster List

Interface Description

Query the list of all kunlunbase clusters.

Response mode

Synchronize.

Request parameters

Parameter NameParameter TypeRequiredRemarks
job_typestring1get_cluster_summary

Response Parameters

Parameter NameParameter TypeRequiredRemarks
namestringCluster Name
nick_namestringBusiness Name
shardsstringNumber of Shards
compsstringNumber of Compute Nodes

Example

Request

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

Response

{ "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 Getting Cluster Details

Interface Description

Get detailed information of the specified cluster.

Response mode

Synchronize.

Request parameters

Parameter NameParameter TypeRequiredRemarks
job_typestring1get_cluster_detail
cluster_namestring1Cluster Name

Response Parameters

Parameter NameParameter TypeRequiredRemarks
namestringCluster name
nick_namestringBusiness name
shardsstringNumber of shards
compsstringNumber of compute nodes
comp_namestringCompute node name
hostaddrstringIP of compute or storage node
portstringPort of compute or storage node
statusstringCurrent node status
masterstringWhether the current storage node is the master node

Example

Request

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

Response

{ "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 Obtaining Storage Node System Variable Information

Interface Description

Query the value of a certain variable in KlustronDB_storage (such as innodb_buffer_pool_size).

Response mode

Synchronize.

Request parameters

Parameter NameParameter TypeRequiredRemarks
job_typestring1get_variable
hostaddrstring1KlustronDB_storage IP
portstring1KlustronDB_storage port
variablestring1Variable name

Response Parameters

Parameter NameParameter TypeRequiredRemarks
resultstring
Query success or not
valuestring
Query result

Example

Request

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

Response

{ "attachment":{ "result":"true", "value":"5242880" }, "error_code":"0", "error_info":"", "job_id":"", "job_type":"", "status":"done", "version":"1.0" }

7. Table Redistribution

Interface Description

Based on the user input table, dump the data from the table and import it into a new table

Response mode

Asynchronous.

Request parameters

Parameter NameParameter TypeRequiredRemarks
src_cluster_idstring1The cluster_id where the original table is located
dst_shard_idstring1The cluster_id to which the target table is redistributed
repartition_tablesstring1The target tables are redistributed to the target cluster_id

Example

Request

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

Response

Special Note:

1.It is necessary to pre-create the database, schema, and table in the target cluster, and the structure of the original and target tables must be consistent. This cluster_mgr will automatically perform the verification. 2.For the redistribution table task, the tables that need to be done at one time must be under the same database, but the source and target databases can be different.

8. Table Logical Backup

Interface Description

The user initiates a logical backup of a specific table and sets up scheduled logical backups.

Response mode

Asynchronous.

Request parameters

Parameter NameParameter TypeRequiredNotes
cluster_idstring1The cluster_id where the logical backup table is located
backup_typestring1Logical backup type, supports db
db_tablestring1Table to be logically backed up
backup_timestring1Scheduled backup time period

Example

Request

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

Response

Special emphasis

If backup_type is db, it means that all tables in all schemas under that db need to be backed up. Enter the db name in db_table under backup.

If backup_type is schema, it means that all tables under that schema need to be backed up. In the backup input, enter db_$$_schema under db_table.

9. Table Logical Recovery

Interface Description

The user initiates the restoration of a certain logical backup table to a specified historical point in time

Response mode

Asynchronous.

Request parameters

Parameter NameParameter TypeRequiredRemarks
src_cluster_idstring1The cluster_id where the backup table is located
dst_cluster_idstring1The cluster_id to which the table will be logically restored
restore_typestring1Logical restore type, supports db
db_tablestring1The table to be logically restored
restore_timestring1The historical point in time to restore to

Example

Request

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

Response

10. Manually trigger cluster_mgr primary-standby switch

Interface Description

The user initiates a master-slave switch operation on the current cluster_mgr cluster

Response mode

Asynchronous.

Request parameters

Parameter NameParameter TypeRequiredRemarks
task_typestring1Task type, here it is transfer_leader
target_leaderstring1The target new leader to switch to

Example

Request

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

Response

11. Add nodes to cluster_mgr

Interface Description

User initiates the operation to add nodes to the current cluster_mgr cluster

Response mode

Asynchronous.

Request parameters

Parameter NameParameter TypeRequiredRemarks
task_typestring1Task type, here it is add_peer
peerstring1The cluster_mgr node to add

Example

Request

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

Response

12. Delete nodes for cluster_mgr

Interface Description

The user initiates the operation to delete a node from the current cluster_mgr cluster

Response mode

Asynchronous.

Request parameters

Parameter NameParameter TypeRequiredRemarks
task_typestring1Task type, here it is remove_peer
peerstring1The cluster_mgr node to be deleted

Example

Request

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

Response

Special emphasis

To add/delete nodes to the cluster_mgr cluster, you need to manually update the raft_group_member_init_config configuration item in the cluster_mgr configuration file and update the configuration for adding/deleting nodes =============================================================================================================================

KlustronDB ClusterManager API

0. Introduction to Use

KlustronDB ClusterManager accepts requests via the HTTP protocol and performs corresponding tasks based on the type and parameters of the request. The interface response modes are divided into synchronous and asynchronous modes. In synchronous mode, the client receives a response that contains the execution result of the current interface after making a request (for example, when obtaining cluster information). Asynchronous mode is usually used for tasks that take a long time to execute. After issuing a request, the client needs to use the get_status interface to obtain the task's execution status until the task is completed successfully or fails.

0.1 Assign Tasks

Interface Description

Assign cluster management tasks.

Request parameters

Parameter NameParameter TypeRequiredRemarks
versionstring1Custom protocol version, default '1.0'
job_idstring0For issuing tasks, no need to fill in job_id. This job_id will be automatically generated by clustermanager and returned in the response.
job_typestring1Task type, related to the specific task content
timestampstring1Timestamp when the task is initiated
parasjson0Custom parameter section, related to the task type

Response Parameters

Parameter NameParameter TypeRequiredRemarks
versionstring1Custom protocol version, default '1.0'
error_codestring1Error code
error_infostring1Error information
statusstring1Task status, possible values are accepted, started, ongoing, done, failed
job_idstring0job_id automatically generated by clustermanager. If the task type is an asynchronous task, the task progress and status can be queried using this job_id.

Example

Request

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

Response

0.2 Get Task Execution Status

Interface Description

Get the execution status of the specified job_id task.

Request parameters

Parameter NameParameter TypeRequiredRemarks
versionstring1Custom protocol version, default '1.0'
job_idstring1ID of the task to be queried
job_typestring1Task type, current interface 'get_status'
timestampstring1Timestamp when the task was initiated
parasjson0Custom parameter section, not required for get_status type interface, may be required for other task types.

Response Parameters

Parameter NameParameter TypeRequiredRemarks
versionstring1Custom protocol version, default '1.0'
error_codestring1Error code
error_infostring1Error information
statusstring1Task status, possible values are started, ongoing, done, failed

Example

Request

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

Response

1. Equipment Management

1.1 Reporting Machinery and Equipment

Interface Description

Register the initialized server device into the system.

Response mode

Asynchronous. Use the get_status interface to check the status.

Request parameters

参数名称参数类型是否必填备注
job_typestring1create_machine
hostaddrstring1服务器 IP
machine_typestring1设备类型。 设备类型包括两种 storage 和 computer。 分别代表了存储机型和计算机型。存储机型表示,该设备可以被用来部署  KlustronDB_storage。相同的,计算机型代表着该设备可以被用来部署  KlustronDB_server。同一台物理设备,其类型可以是存储设备或者计算设备,也可以既是存储设备,也是计算设备,这种情况下,端口范围需要明确的区分开,确保在同一台设备上安装的计算节点和存储节点不会端口冲突。
port_rangestring1端口分配范围。即新创建的实力端口在该参数指定的范围内分配
rack_idstring1机架信息
datadirstring1实例数据目录存放位置
logdirstring1日志目录存放位置
wal_log_dirstring1wal 日志存放位置
comp_datadirstring1如果当前设备为计算机型,则该字段标识计算节点的数据目录
total_memstring1该机型可用总内存 单位为 MB
total_cpu_coresstring1该机型可用总的逻辑核心数

Example

Request

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

Response

The query interface get_status returns

{ "version":"1.0", "error_code":"0", "error_info":"create machine successfully", "status":"done", "attachment":{

} }

1.2 Remove Device

Interface Description

Perform the delete operation on servers that have already been registered in the system.

Response mode

Asynchronous. Use the get_status interface to obtain the status.

Request parameters

Parameter NameParameter TypeRequiredRemarks
job_typestring1delete_machine
hostaddrstring1Machine IP
machine_typestring1The device model information: storage or computer

Example

Request

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

Response

The query interface get_status returns

{ "version":"1.0", "error_code":"0", "error_info":"delete machine successfully", "status":"done", "attachment":{

} }

1.3 Set Server Status

Interface Description

Set the status of a specified server, such as dead or running, which indicate that the current device is offline or online, respectively. Only online devices can be assigned to the resource pool by the system.

Response mode

Asynchronous. Use the get_status interface to obtain the status.

Request parameters

Parameter NameParameter TypeRequiredRemarks
job_typestring1delete_machine
hostaddrstring1Machine IP
node_statsstring1running, dead

Example

Request

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

Response

The query interface get_status returns

{ "version":"1.0", "error_code":"0", "error_info":"set machine success", "status":"done", "attachment":{

} }

2. Cluster Purchase and Deletion

2.1 Purchase a New Cluster

Interface Description

Create a new KlustronDB cluster according to the specified parameter configuration.

Response mode

Asynchronous. Use the get_status interface to obtain the status.

Request parameters

Parameter NameParameter TypeRequiredNotes
job_typestringYescreate_cluster
nick_namestringYesBusiness name, e.g., 'Reconciliation and Interest Settlement Database'
ha_modestringYesrbr, mgr. Indicates high-availability mode. The former is in strong synchronization mode, while the latter is in mgr mode.
shardsstring1Number of shards
nodesstring1Number of nodes per shard, with at least 3 nodes forming a highly available cluster consisting of one primary node and two secondary nodes
compsstring1Number of compute nodes
max_storage_sizestring1Maximum storage space
data_storage_MBstring1Data storage space, in MB
log_storage_MBstring1Log storage space, in MB
max_connectionsstring1Maximum number of connections
cpu_coresstring1Maximum number of cores that can be used
cpu_limit_nodestring1share indicates soft isolation mode; quota indicates hard isolation mode;
enable_backup_encryptstring01 indicates enabling backup encryption; 0 indicates disabling backup encryption
backup_encrypt_keystring0Backup encryption key. If backup encryption is enabled, this option is required;
innodb_sizestring1KlustronDB the innodb_buffer size used by storage (this field innodb_size unit: M)
innodb_page_sizestring0KlustronDB the innodb_page_size used by storage, the default is 16384 (supported values are 4096
dbcfgstring0Set the small memory mode, 0 and without this field for normal mode, 1 for small memory mode is 0 or 1.
fullsync_levelstring1The desired number of strongly synchronized standby nodes in this shard. This value must be less than or equal to the total number of standby nodes.
storage_iplistsJSON array1Specifies the hosts on which to install the storage nodes. If not specified, the system will default to using existing hosts.
compute_iplistsJSON array1Specifies the hosts on which to install the compute nodes. If not specified, the system will default to using existing hosts.
install_proxysqlstring0Whether to install ProxySQL when setting up the cluster. If ProxySQL is installed, the cluster will operate in single-shard mode. The default value is 0.

Add input SN and CN node distribution parameters. In cross-city situations, specify master_idc/slave_idc for the main city.

{
    "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"
    }
}

In cross-city situations, the main city does not specify 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"
    }
}

Local situation, specified master_idc/slave_idc situation

{
    "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"
    }
}

Same-city situation, without specifying master_idc/slave_idc situation

{
    "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"
    }
}

If the SN and CN node distribution parameters are not provided, it will be consistent with the original interface.

Special Note: If the user inputs storage_iplists and computer_lists, passing node_distribution and comp_distribution is not allowed. The number of nodes must equal the total of node_num in node_distribution, and the number of comps must equal the total of node_num in comp_distribution. When purchasing across cities, the information of the primary city and backup city must be specified.

Example

Request

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

Response

The query interface get_status returns

{ "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 Adding New Shards Within the Cluster

Interface Description

According to the specified parameter configuration, on the existing cluster, new shards can be added, and multiple shards can be added.

Response mode

Asynchronous. Use the get_status interface to obtain the status.

Request parameters

Parameter NameParameter TypeRequiredNotes
job_typestring1add_shards
cluster_idstring1Cluster ID
shardsstring1Number of shards to add
nodesstring1Number of nodes per shard
storage_iplistsJson array1Machines specified for installing storage nodes

Example

Request

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

Response

The query interface get_status returns

{ "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 Delete existing shards within the cluster

Interface Description

According to the specified parameter configuration, on the existing cluster, shards can only be deleted one by one.

Response mode

Asynchronous. Use the get_status interface to obtain the status.

Request parameters

Parameter NameParameter TypeRequiredRemarks
job_typestring1delete_shards
cluster_idstring1Cluster ID
shard_idstring1ID of the shard to be deleted

Example

Request

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

Response

The query interface get_status returns

{ "version":"1.0", "error_code":"0", "error_info":"delete shard successfully", "status":"done", "attachment":{

} }

2.4 Adding New Compute Nodes within the Cluster

Interface Description

According to the specified parameter configuration, on the existing cluster, new shards can be added, and multiple shards can be added.

Response mode

Asynchronous. Use the get_status interface to obtain the status.

Request parameters

Parameter NameParameter TypeRequiredRemarks
job_typestring1add_comps
cluster_idstring1Cluster id
compsstring1Number of added compute nodes
computer_iplistsJson array1Machines where the compute nodes will be installed

Example

Request

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

Response

The query interface get_status returns

{ "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 Deleting Compute Nodes within the Cluster

Interface Description

According to the specified parameter configuration, on the existing cluster, deleting compute nodes can only be done one by one.

Response mode

Asynchronous. Use the get_status interface to obtain the status.

Request parameters

Parameter NameParameter TypeRequiredRemarks
job_typestring1delete_shards
cluster_idstring1Cluster id
comp_idstring1ID of the computing node to be deleted

Example

Request

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

Response

The query interface get_status returns

{ "version":"1.0", "error_code":"0", "error_info":"delete comp successfully", "status":"done", "attachment":{

} }

2.6 Specify cluster to add node

Interface Description

Add nodes to all shards of the cluster according to the specified parameter configuration, asynchronously, requires querying.

Response mode

Asynchronous. Use the get_status interface to obtain the status.

Request parameters

Parameter NameParameter TypeRequiredRemarks
job_typestring1add_nodes
cluster_idstring1Cluster ID
shard_idstring0If this field is specified, nodes are added only on this shard
nodesstring1Number of nodes to add
storage_iplistsJSON array1Machines designated for installing storage nodes
rebuild_sync_limitstring0Data synchronization speed pulled from the master node, default value is 10 (unit: MB)

Example

Request

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

Response

The query interface get_status returns

{ "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 Specify cluster to delete node

Interface Description

According to the specified parameter configuration, delete the specified node from the cluster's designated shard asynchronously, query needed.

Response mode

Asynchronous. Use the get_status interface to obtain the status.

Request parameters

Parameter NameParameter TypeRequiredRemarks
job_typestring1delete_nodes
cluster_idstring1Cluster ID
shard_idstring0If this field is specified, nodes will only be added to this shard
hostaddrstring1IP of the machine where the node to be deleted is located
portstring1Port number

Example

Request

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

Response

The query interface get_status returns

{ "version":"1.0", "error_code":"0", "error_info":"delete node successfully", "status":"done", "attachment":{

} }

2.8 Redo the backup machine

Interface Description

Designate a backup machine to redo a certain shard.

Response mode

Asynchronous. Use the get_status interface to obtain the status.

Request parameters

Parameter NameParameter TypeRequiredNotes
job_typestringYesdelete_nodes
cluster_idstringYesCluster ID
shard_idstringNoIf specified, nodes will be added only to this shard
hostaddrstringYesIP address of the machine where the node to be deleted resides
portstringYesPort number
need_backupstringYesWhether a backup is required before redoing
hdfs_hoststringYesCold backup location
pv_limitstringYesCold backup transfer rate limit, in MB
allow_pull_from_masterstringYesWhether to use data from the primary node to redo the standby node if the standby is unavailable
allow_replica_delaystringYesMaximum allowable delay for the standby node; if the delay exceeds this value, the standby node will be considered unsuitable as a data source

Example

Request

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

Response

The query interface get_status returns

{ "version":"1.0", "error_code":"0", "error_info":"delete node successfully", "status":"done", "attachment":{

} }

2.9 Remove the specified cluster

Interface Description

According to the specified parameter configuration, delete the specified node from the cluster's specified shard asynchronously, query needed.

Response mode

Asynchronous. Use the get_status interface to obtain the status.

Request parameters

Parameter NameParameter TypeRequiredRemarks
job_typestring1delete_cluster
cluster_idstring1Cluster ID

Example

Request

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

Response

The query interface get_status returns

{ "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 Modify instance resource isolation parameters

Interface Description

According to the specified parameter configuration, modify the resource isolation parameters of the MySQL or PostgreSQL instance. Currently, only CPU isolation is supported.

Response mode

Asynchronous. Use the get_status interface to obtain the status.

Request parameters

Parameter NameParameter TypeRequiredNotes
job_typestringYesupdate_instance_cgroup
ipstringYesInstance IP address
PortstringYesInstance listening port
typestringYes“mysql” indicates a storage node instance; “pg” indicates a compute node instance
cpu_coresstringYesNumber of CPU cores allocated
cgroup_modestringYesCPU resource limitation mode; the default is “quota”. It can be set to either “quota” or “share”, where “share” represents soft isolation and “quota” represents hard isolation.

Example

Request

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

Response

2.11 Redo Cluster Computing Nodes

Interface Description

According to the specified parameters, redo all computing nodes in the cluster, that is, clear the data in the computing nodes.

Response mode

Asynchronous. Use the get_status interface to obtain the status.

Request parameters

Parameter NameParameter TypeRequiredRemarks
job_typestring1rebuild_comps
cluster_idstring1Need to redo all compute nodes of this cluster

Example

Request

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

Response

Special Note:

This interface clears data on all computing nodes in the cluster. Generally, it is only needed when re-establishing the RCR relationship after the RCR relationship is disconnected.

3. Cluster Backup

3.1 Manually Initiate Cluster Backup

Interface Description

Call this interface to manually initiate a full backup. When cluster_id is -1, it indicates backing up the metashard.

Response mode

Synchronous interface.

Request parameters

Parameter NameParameter TypeRequiredRemarks
cluster_idstring1Cluster ID

Example

Request

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

Response

4. Cluster Recovery

4.1 Cluster Rollback (Restore Cluster by Time Point)

Interface Description

Perform a rollback on the specified cluster according to the point in time.

Response mode

Asynchronous. Obtain task progress through the get_status interface.

Request parameters

Parameter NameParameter TypeRequiredRemarks
src_cluster_idstringYesSource cluster ID for the rollback operation
dst_cluster_idstringYesTarget cluster ID for the rollback operation. This cluster must be a newly purchased empty cluster
restore_timestringYesRollback point in time

Example

Request

{ "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

Response

5. Cluster Expansion

5.1 Automatically Obtain Table Migration List

Interface Description

Get the list of tables automatically selected by the system for migration.

Response mode

Synchronize.

Request parameters

Parameter NameParameter TypeRequiredRemarks
cluster_idstring1Cluster ID
shard_idstring1Source shard ID of the table to be migrated within the current cluster
policystring1top_hit: select the table with the highest access frequency. top_size: select the table with the largest data volume

Response Parameters

Parameter NameParameter TypeRequiredRemarks
attachment->table_liststring
List of tables to be migrated

Example

Request

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

Response

{ "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 Initiate Table Migration Task

Interface Description

Initiate table migration task.

Response mode

Asynchronous.

Request parameters

Parameter NameParameter TypeRequiredRemarks
job_typestring1expand_cluster
cluster_idstring1Cluster ID
src_shard_idstring1Source shard ID of the table to be migrated in the current cluster
dst_shard_idstring1Target shard ID of the table to be migrated in the current cluster
table_listjson_array1List of tables to be migrated
drop_old_tablestring0Whether to retain the source table

Example

#请求
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. Metadata Management

6.1 Obtaining metashard Synchronization Mode

Interface Description

Query the metashard synchronization mode.

Response mode

Synchronize.

Request parameters

Parameter NameParameter TypeRequiredRemarks
job_typestring1get_meta_summary

Response Parameters

Parameter NameParameter TypeRequiredNotes
attachment->modestring
metashard synchronization mode. Three types of results: no_rep, mgr, rbr

Example

Request

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

Response

{ "attachment":{ "mode":"mgr" }, "error_code":"0", "error_info":"", "job_id":"", "job_type":"", "status":"done", "version":"1.0" }

6.2 Obtaining Cold Backup Storage Service Information

Interface Description

Inquire about the detailed information of cold backup storage services.

Response mode

Synchronize.

Request parameters

Parameter NameParameter TypeRequiredRemarks
job_typestring1get_backup_storage

Response Parameters

Parameter NameParameter TypeRequiredNotes
hostaddrstringBackup service IP
namestringBackup service name
portstringBackup service port
stypestringBackup service type

Example

Request

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

Response

{ "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 Obtaining Machine Status Information

Interface Description

Query detailed information of all machine statuses.

Response mode

Synchronize.

Request parameters

Parameter NameParameter TypeRequiredRemarks
job_typestring1get_machine_summary

Response Parameters

Parameter NameParameter TypeRequiredRemarks
hostaddrstring
Server Address
statusstring
Server Status

Example

Request

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

Response

{ "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 Get Cluster List

Interface Description

Query the list of all KlustronDB clusters.

Response mode

Synchronize.

Request parameters

Parameter NameParameter TypeRequiredRemarks
job_typestring1get_cluster_summary

Response Parameters

Parameter NameParameter TypeRequiredRemarks
namestringCluster Name
nick_namestringBusiness Name
shardsstringNumber of Shards
compsstringNumber of Compute Nodes

Example

Request

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

Response

{ "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 Get Cluster Details

Interface Description

Get detailed information of the specified cluster.

Response mode

Synchronize.

Request parameters

Parameter NameParameter TypeRequiredRemarks
job_typestring1get_cluster_detail
cluster_namestring1Cluster Name

Response Parameters

Parameter NameParameter TypeRequiredRemarks
namestringCluster name
nick_namestringBusiness name
shardsstringNumber of shards
compsstringNumber of compute nodes
comp_namestringCompute node name
hostaddrstringIP of compute or storage node
portstringPort of compute or storage node
statusstringCurrent node status
masterstringWhether the current storage node is the master node

Example

Request

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

Response

{ "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 Obtaining Storage Node System Variable Information

Interface Description

Query the value of a certain variable in KlustronDB_storage (such as innodb_buffer_pool_size).

Response mode

Synchronize.

Request parameters

Parameter NameParameter TypeRequiredRemarks
job_typestring1get_variable
hostaddrstring1KlustronDB_storage IP
portstring1KlustronDB_storage port
variablestring1Variable name

Response Parameters

Parameter NameParameter TypeRequiredRemarks
resultstring
Query success
valuestring
Query result

Example

Request

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

Response

{ "attachment":{ "result":"true", "value":"5242880" }, "error_code":"0", "error_info":"", "job_id":"", "job_type":"", "status":"done", "version":"1.0" }

7. Table Redistribution

Interface Description

Based on the user input table, dump the data from the table and import it into a new table

Response mode

Asynchronous.

Request parameters

Parameter NameParameter TypeRequiredRemarks
src_cluster_idstring1The cluster_id where the source table is located
dst_shard_idstring1The cluster_id to which the target table is redistributed
repartition_tablesstring1The target table to be redistributed to the target cluster_id
rename_tablesstring0Whether to rename the target table to the source table name after redistribution
del_src_tablestring0Whether to automatically delete the source table after successful redistribution
del_resv_daystring0If del_src_table=0, specify how many days to retain, default is 7 days

Example

Request

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

Response

Special Note:

1.It is necessary to pre-create the database, schema, and table in the target cluster, and the structure of the source and target tables must be consistent. This cluster_mgr will automatically perform the verification. 2.For the redistribution table task, the tables that need to be done at one time must be under the same database, but the source and target databases can be different.

8. Table Logical Backup

Interface Description

The user initiates a logical backup of a specific table and sets up scheduled logical backups.

Response mode

Asynchronous.

Request parameters

Parameter NameParameter TypeRequiredNotes
cluster_idstring1The cluster_id where the logical backup tables are located
backup_typestring0Type of logical backup, currently supports db, schema, table. If db is entered, all tables under that db will be backed up
db_tablestring1The table to be backed up logically
backup_timestring1Scheduled backup time period

Example

Request

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

Response

9. Table Logical Recovery

Interface Description

The user initiates the restoration of a certain logical backup table to a specified historical point in time

Response mode

Asynchronous.

Request parameters

Parameter NameParameter TypeRequiredNotes
src_cluster_idstring1The cluster_id where the backup table is located
dst_cluster_idstring1The cluster_id to which the table will be logically restored
restore_typestring0Type of logical restoration, currently supports db, schema, table. If 'db' is entered, all tables under that db in the source cluster will be restored to the target cluster
db_tablestring1The table to be logically restored
restore_timestring1The historical time point to restore to

Example

Request

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

Response

10. Manually trigger cluster_mgr primary-standby switch

Interface Description

The user initiates a master-slave switch operation on the current cluster_mgr cluster

Response mode

Asynchronous.

Request parameters

Parameter NameParameter TypeRequiredRemarks
task_typestring1Task type, here it is transfer_leader
target_leaderstring1The target new leader to switch to

Example

Request

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

Response

11. Add nodes to cluster_mgr

Interface Description

The user initiates the operation to add nodes to the current cluster_mgr cluster

Response mode

Asynchronous.

Request parameters

Parameter NameParameter TypeRequiredRemarks
task_typestring1Task type, here it is add_peer
peerstring1The cluster_mgr node to add

Example

Request

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

Response

12. Delete nodes for cluster_mgr

Interface Description

The user initiates the operation to remove a node from the current cluster_mgr cluster

Response mode

Asynchronous.

Request parameters

Parameter NameParameter TypeRequiredRemarks
task_typestring1Task type, here it is remove_peer
peerstring1The cluster_mgr node to be deleted

Example

Request

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

Response

Special emphasis

To add/remove nodes to/from the cluster_mgr cluster, you need to manually update the raft_group_member_init_config configuration item in the cluster_mgr configuration file and update the configuration for adding/removing nodes.

13. Manual cross-IDC primary-standby switch

Interface Description

The user initiates an operation to switch a certain cluster across IDCs

Response mode

Asynchronous.

Request parameters

Parameter NameParameter TypeRequiredRemarks
cluster_idstring1The cluster ID to switch to
target_idcstring1The target IDC to switch to
need_rollbackstring0Whether to roll back the successfully switched shard if the switch fails

Example

Request

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

Response

14. Forced Cross-City Switching

Interface Description

The user initiates a cross-city switch operation for a certain cluster

Response mode

Asynchronous.

Request parameters

Parameter NameParameter TypeRequiredRemarks
cluster_idstring1The cluster id to switch
target_citystring1The target city to switch to

Example

Request

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

Response

Special emphasis

This operation is a forced switch and cannot guarantee data consistency.

15. Establish RCR data synchronization

Interface Description

The user initiated RCR data synchronization between two clusters

Response mode

Asynchronous.

Request parameters

Parameter NameParameter TypeRequiredRemarks
master_infoJson_Array1Main RCR parameter, meta_db and cluster_id
cluster_idstring1ID of the backup RCR cluster
ignore_dbstring0Default is 0. If 1 is passed, data in the backup cluster will be cleared and re-pulled from the main cluster; both storage and compute node data will be cleared
rebuild_pv_limitstring0Maximum sync speed when pulling data from the main cluster. Default is 10 MB
parallel_rebuildstring0Default is 0. If 1 is passed, redo backup cluster shard nodes in parallel
skip_sync_rolesstring0When establishing sync relationships, whether to skip certain roles not present in the backup cluster. Format: ba,cd,ef

Example

Request

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

Response

16. Delete rcr data synchronization

Interface Description

The user initiated the cancellation of RCR data synchronization for two clusters

Response mode

Asynchronous.

Request parameters

Parameter NameParameter TypeRequiredRemarks
master_infoJson_Array1Main rcr parameter, meta_db and cluster_id
cluster_idstring1Backup rcr cluster id

Example

Request

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

Response

17. Manual RCR Switching

Interface Description

User initiates manual switching of RCR synchronization

Response mode

Asynchronous.

Request parameters

Parameter NameParameter TypeRequiredRemarks
master_infoJson_Array1Main rcr parameter, meta_db and cluster_id
cluster_idstring1Backup rcr cluster id

Example

Request

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

Response

17. Configure RCR data synchronization parameters

Interface Description

The user initiates an adjustment to the RCR data synchronization parameters

Response mode

Asynchronous.

Request parameters

Parameter NameParameter TypeRequiredRemark
master_infoJson_Array1Main rcr parameter, meta_db and cluster_id
work_modestring1Modify parameter type, currently supports modify_sync_delay
sync_delaystring0When work_mode=modify_sync_delay, set delay time in seconds
cluster_idstring1Backup rcr cluster id

Example

Request

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

Response

18. Set the automatic physical backup time period

Interface Description

User initiates adjustment of the physical automatic backup time period

Response mode

Asynchronous.

Request parameters

Parameter NameParameter TypeRequiredRemarks
cluster_idstring1ID of the cluster
time_period_strstring1Backup time period, format is “08:00:00-24:00:00”

Example

Request

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

Response

19. Operations on storage nodes or compute nodes in the cluster

Interface Description

The user initiates operations on storage nodes or compute nodes in the cluster

Response mode

Asynchronous.

Request parameters

Parameter NameParameter TypeRequiredRemarks
controlstring1Operation type, start
hostaddrstring1IP of the machine of the instance to operate
portstring1Port of the machine of the instance to operate
machine_typestring1Type of instance to operate, storage

Example

Request

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

Response

20. Get the current metashard master node

Interface Description

User initiates a task and obtains the current metashard master node

Response mode

Synchronize.

Request parameters

Parameter NameParameter TypeRequiredRemarks

Example

Request

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

Response

{ "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