元数据节点管理

新增

Restful API:

curl -v "http://192.168.2.160:15010/metaNode/add?addr=192.168.2.162:15210"

参数说明

参数 类型 描述
addr string 元数据节点和master的交互地址

响应示例

{"code":0,"msg":"success","data":14}

命令行查看结果:

./udbto-cli metanode list

[Meta nodes]
ID        ADDRESS                                                              WRITABLE    ACTIVE      MEDIA        ForbidWriteOpOfProtoVer0
5         192.168.2.160:15210(localhost.localdomain:15210)                     Yes         Active      N/A          notForbid   
6         192.168.2.161:15210(udb64:15210)                                     Yes         Active      N/A          notForbid   
7         192.168.2.185:15210                                                  Yes         Active      N/A          notForbid   
13        192.168.2.162:15210                                                  No          Inactive    N/A          notForbid (新节点未安装)

查询

查询返回元数据节点的详细信息,包括地址、总的内存大小、已使用内存大小等等。

curl -v "http://192.168.2.160:15010/metaNode/get?addr=192.168.2.161:15210"  | python -m json.tool

参数说明

参数 类型 描述
addr string 元数据节点和master的交互地址

响应示例

{
    "ID": 3,
    "Addr": "10.196.59.202:15210",
    "IsActive": true,
    "Zone": "zone1",
    "MaxMemAvailWeight": 66556215048,
    "TotalWeight": 67132641280,
    "UsedWeight": 576426232,
    "Ratio": 0.008586377967698518,
    "SelectCount": 0,
    "Carry": 0.6645600532184904,
    "Threshold": 0.75,
    "ReportTime": "2018-12-05T17:26:28.29309577+08:00",
    "MetaPartitionCount": 1,
    "NodeSetID": 2,
    "PersistenceMetaPartitions": {}
}

下线节点

下线前,查看节点信息:

./udbto-cli metanode list

用命令行下线:

./udbto-cli metanode decommission 192.168.2.162:15210
Decommission meta node successfully

用Restful API下线:

curl -v "http://192.168.2.160:15010/metaNode/decommission?addr=192.168.2.162:15210"

响应示例

{"code":0,"msg":"success","data":"decommissionMetaNode metaNode [192.168.2.162:15210] limit 0 has offline successfully"}

推荐

为了避免下线node时其被写入新数据,可以先进行设置节点状态,再从集群中下线某个元数据节点,该节点上的所有元数据分片都会被异步的迁移到集群中其它可用的元数据节点,分为普通模式和严格模式。

设置阈值

如果某元数据节点内存使用率达到这个阈值,则该节点上所有的元数据分片都会被设置为只读。

命令行:

./udbto-cli cluster threshold 0.8

MetaNode threshold is set to 0.8!

查看结果:

./udbto-cli metanode info 192.168.2.160:15210

[Meta node info]
  ID                  : 5
  Address             : 192.168.2.160:15210(localhost.localdomain:15210)
  Threshold           : 0.8
  MaxMemAvailWeight   : 3.25 GB
  Allocated           : 184.86 MB
  Total               : 3.43 GB
  Zone                : default
  Status              : Active
  Rdonly              : false
  Report time         : 2025-09-10 15:31:44
  Partition count     : 15
  Persist partitions  : [13 14 15 1 2 3 4 5 6 7 8 9 12 10 11]
  Can alloc partition : true
  Max partition count : 300
  CpuUtil             : 3.1%

Restful API:

curl -v "http://192.168.2.160:15010/threshold/set?threshold=0.75"

参数说明

参数 类型 描述
threshold float64 元数据节点能使用本机内存的最大比率

响应示例

{"code":0,"msg":"success","data":"set threshold to 0.75 successfully"}

迁移

从源元数据节点迁移指定个数元数据分区至目标元数据节点。

curl -v "http://192.168.2.160:15010/metaNode/migrate?srcAddr=192.168.2.160:15210&targetAddr=192.168.2.161:15210&count=3"

参数列表

| — | — | —- | | srcAddr | string | 迁出元数据节点地址 | | targetAddr | string | 迁入元数据节点地址 | | count | int | 迁移元数据分区的个数,非必填,默认50个 |

响应示例

{"code":0,"msg":"success","data":"migrateMetaNodeHandler from src [192.168.0.143:15210] to targaet[192.168.0.183:15210] has migrate successfully"}