是否有将一表所有region leader批量均分至所有store的方法?

【 TiDB 使用环境】生产环境 /测试/ Poc
【 TiDB 版本】6.5.0
【复现路径】做过哪些操作出现的问题
新建表后,使用split region预分配100个region,发现所有region都位于一个store上,虽然pd调度均衡了所有store的region总数,但新表的region没有分散开来,是否有如题操作,可以像pd add transfer leader这样手动将leader分散到各个store?



文档上这么写的

这个说的是split region的行为,不是split之后region放在哪里

目前没有这种操作,想你说的这种情况,如果打散某个表的leader分布,那其他表的也分布也会受影响啊,默认是总体均衡。

1 个赞

了解了,不过我们的场景实际是新建表,刚刚有老师说可以用pre split region建表,这样建完leader就是均衡的,但不知为何我这样建表后表只有一个region

发现原因是pre split 只能和 SHARD_ROW_ID_BITS 一起用

https://docs.pingcap.com/zh/tidb/stable/pd-control/#operator-check--show--add--remove

>> operator show                                        // 显示所有的 operators
>> operator show admin                                  // 显示所有的 admin operators
>> operator show leader                                 // 显示所有的 leader operators
>> operator show region                                 // 显示所有的 Region operators
>> operator add add-peer 1 2                            // 在 store 2 上新增 Region 1 的一个副本
>> operator add add-learner 1 2                         // 在 store 2 上新增 Region 1 的一个 learner 副本
>> operator add remove-peer 1 2                         // 移除 store 2 上的 Region 1 的一个副本
>> operator add transfer-leader 1 2                     // 把 Region 1 的 leader 调度到 store 2
>> operator add transfer-region 1 2 3 4                 // 把 Region 1 调度到 store 2,3,4
>> operator add transfer-peer 1 2 3                     // 把 Region 1 在 store 2 上的副本调度到 store 3
>> operator add merge-region 1 2                        // 将 Region 1 与 Region 2 合并
>> operator add split-region 1 --policy=approximate     // 将 Region 1 对半拆分成两个 Region,基于粗略估计值
>> operator add split-region 1 --policy=scan            // 将 Region 1 对半拆分成两个 Region,基于精确扫描值
>> operator remove 1                                    // 把 Region 1 的调度操作删掉
>> operator check 1                                     // 查看 Region 1 相关 operator 的状态
1 个赞

region 和 store,还有个控制的点,通过标签调度
比较麻烦,可以尝试下
https://docs.pingcap.com/zh/tidb/stable/multi-data-centers-in-one-city-deployment#tikv-labels-样例规划

TiDB http api 有这个操作

15.Scatter regions of the specified table, add a
 scatter-range scheduler for the PD and the range is same as the table range.
curl http://{TiDBIP}:10080/tables/{db}/{table}/scatter
Hint: On a partitioned table, use the table(partition) pattern as the table name, test(p1) for example.
Note: The scatter-range scheduler may conflict with the global scheduler, do not use it for long periods on the larger table.
16.Stop scatter the regions, disable the
 scatter-range scheduler for the specified table.
curl http://{TiDBIP}:10080/tables/{db}/{table}/stop-scatter
Hint: On a partitioned table, use the table(partition) pattern as the table name, test(p1) for example.
1 个赞

这个停止 scatter 有时候不太好用,可以 pd-ctl 清理对应调度停止

这个的流程上是把每个store加个label,然后拿placement rule限制?

对,固定一些 region 在一些 tikv 节点上

当 tikv 节点足够多的时候,想要控制 region 的分布,想让分布更加合理
比如,按照物理节点拆分,按照机架拆分,按照网络拆分等等,不同的方式来规划这个

1 个赞

感觉可以,不过确实代价有点大 :joy:

如果有足够的时间,可以尝试一下

亲测可用,就是他这个描述有点让人不敢用…在大表上面用的话会有什么后果么

此话题已在最后回复的 60 天后被自动关闭。不再允许新回复。