tidb 冷热隔离 创建表 默认不指定存放策略,数据会存在什么地方

现在default的placement-rule没办法通过Placement rule in SQL的方式来直接修改,只能通过原始的pd-ctl来修改。原理可以参考下面这个文章。
https://docs.pingcap.com/zh/tidb/stable/configure-placement-rules#配置规则操作步骤

我给你贴下大概的执行步骤吧:

  1. 查看当前的default规则
tiup ctl:v6.5.3 pd config placement-rules show --group=pd --id=default

正常来说,返回值应该是

{
  "group_id": "pd",
  "id": "default",
  "start_key": "",
  "end_key": "",
  "role": "voter",
  "is_witness": false,
  "count": 3,
  "location_labels": [
    "zone",
    "dc",
    "host",
    "disk"
  ]
}

  1. 手动加一个基于lable的label_constraints,将需要排除的label加进去,例子如下
{
  "group_id": "pd",
  "id": "default",
  "start_key": "",
  "end_key": "",
  "role": "voter",
  "is_witness": false,
  "count": 3,
  "label_constraints": [
    {
      "key": "disk",
      "op": "notIn",
      "values": [
        "sata",
        "sata-new"
      ]
    }
  ],
  "location_labels": [
    "zone",
    "dc",
    "host"
  ]
}
  1. 将配置应用到pd中
tiup ctl:v6.5.3 pd config placement save --in=rules.json
1 个赞