元数据分片管理

获取当前设备上所有分片信息

curl -v "http://192.168.2.160:15220/getPartitions" | python -m json.tool

响应示例

{
    "code": 200,
    "data": {
        "1": {
            "ForbidWriteOpOfProtoVer0": true,
            "end": 4194304,
            "freeze": false,
            "partition_id": 1,
            "partition_type": 0,
            "peers": [
                {
                    "addr": "192.168.2.160:15210",
                    "id": 5
                },
                {
                    "addr": "192.168.2.161:15210",
                    "id": 6
                },
                {
                    "addr": "192.168.2.185:15210",
                    "id": 7
                }
            ],
            "start": 0,
            "ver_seq": 0,
            "vol_name": "udbtovol"
        }
    },
    "msg": "OK"
}

获取指定分片ID的当前状态信息

获取指定分片id的当前状态信息,包含当前分片组的raft leader地址,raft组成员,inode分配游标等信息

curl -v "http://192.168.2.160:15220/getPartitionById?pid=2" | python -m json.tool

参数说明

参数 类型 描述
pid 整型 元数据分片的ID

响应示例

{
    "code": 200,
    "data": {
        "cursor": 4194305,
        "end": 8388608,
        "leaderAddr": "192.168.2.161:15210",
        "leader_term": 1,
        "nodeId": 5,
        "partition_id": 2,
        "partition_type": 0,
        "peers": [
            {
                "addr": "192.168.2.160:15210",
                "id": 5
            },
            {
                "addr": "192.168.2.161:15210",
                "id": 6
            },
            {
                "addr": "192.168.2.185:15210",
                "id": 7
            }
        ],
        "start": 4194305,
        "vol_name": "udbtovol"
    },
    "msg": "OK"
}

创建

批量创建元数据分区

curl -v "http://192.168.2.160:15010/metaPartition/create?count=10&name=udbtovol"

参数列表

参数 类型 描述
name string 卷的名字
count uint64 新增的mp数目

查询

展示元数据分片的详细信息,包括分片ID,分片的起始范围等等。

curl -v "http://192.168.2.160:15010/metaPartition/get?id=1" | python -m json.tool

参数列表

参数 类型 描述
id uint64 元数据分片ID

响应示例

{
    "PartitionID": 1,
    "Start": 0,
    "End": 9223372036854776000,
    "MaxNodeID": 1,
    "VolName": "test",
    "Replicas": {},
    "ReplicaNum": 3,
    "Status": 2,
    "IsRecover": true,
    "Hosts": {},
    "Peers": {},
    "Zones": {},
    "MissNodes": {},
    "LoadResponse": {}
}

下线副本

下线元数据分片的某个副本,并且创建一个新的副本。

curl -v "http://192.168.2.160:15010/metaPartition/decommission?id=13&addr=192.168.2.161:15210"

参数列表

参数 类型 描述
id uint64 元数据分片ID
addr string 要下线副本的地址

比对副本

发送比对副本任务到各个副本,然后检查各个副本的Crc是否一致。

curl -v "http://192.168.2.160:15010/metaPartition/load?id=1"

参数列表

参数 类型 描述
id uint64 元数据分片ID