placement rule产生过多副本

【版本】 v5.2.2
集群设置5副本。label设置了3个层级:city,zone,host,其中city设置了3个:xx1 2个tikv,xx2 3个tikv, bj1 3个tikv。目前region 副本分布如下:
image
region 51 副本分布xx1:1个, xx2:2个 ,bj1: 2个


现在想要设置region副本分布为 xx1:2个 ,xx2:2个 ,bj1:1个。参考placement rule官方文档增加了如下规则。
[
{
“group_id”: “test”,
“id”: “xx1”,
“start_key”: “”,
“end_key”: “”,
“role”: “voter”,
“count”: 2,
“label_constraints”: [
{“key”: “zone”, “op”: “in”, “values”: [“xx1”]}
],
“location_labels”: [ “city”,“zone”,“host”]
},
{
“group_id”: “test”,
“id”: “xx2”,
“start_key”: “”,
“end_key”: “”,
“role”: “voter”,
“count”: 2,
“label_constraints”: [
{“key”: “zone”, “op”: “in”, “values”: [“xx2”]}
],
“location_labels”: [ “city”,“zone”,“host”]
},
{
“group_id”: “test”,
“id”: “bj1”,
“start_key”: “”,
“end_key”: “”,
“role”: “voter”,
“count”: 1,
“label_constraints”: [
{“key”: “zone”, “op”: “in”, “values”: [“bj1”]}
],
“location_labels”: [ “city”,“zone”,“host”]
}
]
增加placement rule后,副本数增至8个(总tikv数量),每个zone内增加了1个副本
image

想要达到副本分布为 xx1:2个 ,xx2:2个 ,bj1:1个 该如何设置placement-rule?
设置的总副本数是5为什么在上述步骤增加placement-rule后副本数增加至8个?

  1. 麻烦帮忙反馈下 region id 51 的 规则
pd-ctl config placement-rules show --region=51
  1. 如果可以的话,也反馈下 所有规则
pd-ctl config placement-rules show
  1. max-replicas 可以注意下文档
    https://docs.pingcap.com/zh/tidb/v4.0/configure-placement-rules#placement-rules-使用文档

新初始化的集群,做其他测试已经destroy了, placement-rule show 还能看见些会话记录信息
» config placement show config
[
{
“group_id”: “pd”,
“id”: “default”,
“start_key”: “”,
“end_key”: “”,
“role”: “voter”,
“count”: 5,
“location_labels”: [
“city”,
“zone”,
“host”
]
},
{
“group_id”: “test”,
“id”: “bj1”,
“start_key”: “”,
“end_key”: “”,
“role”: “voter”,
“count”: 1,
“label_constraints”: [
{
“key”: “zone”,
“op”: “in”,
“values”: [
“bj1”
]
}
],
“location_labels”: [
“city”,
“zone”,
“host”
]
},
{
“group_id”: “test”,
“id”: “xx1”,
“start_key”: “”,
“end_key”: “”,
“role”: “voter”,
“count”: 2,
“label_constraints”: [
{
“key”: “zone”,
“op”: “in”,
“values”: [
“xx1”
]
}
],
“location_labels”: [
“city”,
“zone”,
“host”
]
},
{
“group_id”: “test”,
“id”: “xx2”,
“start_key”: “”,
“end_key”: “”,
“role”: “voter”,
“count”: 2,
“label_constraints”: [
{
“key”: “zone”,
“op”: “in”,
“values”: [
“xx2”
]
}
],
“location_labels”: [
“city”,
“zone”,
“host”
]
}
]

你这个总共是需要 10 个副本,5+1+2+2 =10 , pd 是个名称,不是指的pd的副本数。 只有 8 个是因为 tikv 只有 8 个吧

默认default策略是5个,我试过删除报错,我想5副本设置为2+2+1,另外max_repicas参数设置是5.为什么能超过5呢

需要使用 group override 的设置,不然规则是叠加起来的,可以看官方文档最上面的图理解一下。

明白了,那这个最大副本数max_replicas不是一个硬限制吗

你一次回答的贴图看一下吧

不好意思,光注意看下边了

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