-
Notifications
You must be signed in to change notification settings - Fork 1.2k
how-to: add placement rules guide #2246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| { | ||
| "group_id": "tiflash", | ||
| "id": "learner-replica-table-03", | ||
| "start_key": "748000000000000003", // start key of table 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的key要encode下不
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我从之前那个文章里 copy 过来的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
之前那个简单化过,主要是为了好理解。。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
全部改成 6E 和 6D 了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不行呀,都改成 6E 6D 的话,跟文字说明的“某个table"不匹配
how-to/configure/placement-rules.md
Outdated
| "count": 2, | ||
| "label_constraints": [ | ||
| {"key": "zone", "op": "in", "values": ["bj1", "bj2"]}, | ||
| {"key", "disk", "op": "notIn", "values": ["hdd"]} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| {"key", "disk", "op": "notIn", "values": ["hdd"]} | |
| {"key": "disk", "op": "notIn", "values": ["hdd"]} |
how-to/configure/placement-rules.md
Outdated
| >> config set enable-placement-rules true | ||
| ``` | ||
|
|
||
| 开启后会根据之前的副本配置默认生成一条规则,下面的生成的规则对应于之前版本的 `max-replicas=3,location-labels=[zone,rack,host]` 配置: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
之前版本具体是哪个版本之前的呢?
| 开启后会根据之前的副本配置默认生成一条规则,下面的生成的规则对应于之前版本的 `max-replicas=3,location-labels=[zone,rack,host]` 配置: | |
| 开启后会根据之前的副本配置默认生成一条规则。下面的生成的规则对应之前版本的 `max-replicas=3,location-labels=[zone,rack,host]` 配置: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rleungx 请明确一下之前版本。
how-to/configure/placement-rules.md
Outdated
|
|
||
| ### group_id | ||
|
|
||
| 标识规则的创建者,不同创建者之间互不影响 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这部分改为列表形式是否更好?每一个字段为一个列表项目。+ group_id:标识规则的创建者。不同创建者之间互不影响。
| 标识规则的创建者,不同创建者之间互不影响 | |
| 标识规则的创建者。不同创建者之间互不影响。 |
how-to/configure/placement-rules.md
Outdated
|
|
||
| *注意* 由于不同的 Rule 调度时单独计算,只能保证 default 规则的 3 副本按照 `location-labels` 隔离,meta 规则的 2 副本也隔离,而不能防止 default 规则的副本和 meta 规则的副本被调度在一起。 | ||
|
|
||
| 可以通过 default 规则的范围拆分成 2 个,key range 分别为 `["", "6D")` 和 `["6E", "")`,然后把 meta 规则的 `count` 调整为 5,让 meta 数据只适配一条 5 副本的规则,实现 `location-label` 的隔离。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 可以通过 default 规则的范围拆分成 2 个,key range 分别为 `["", "6D")` 和 `["6E", "")`,然后把 meta 规则的 `count` 调整为 5,让 meta 数据只适配一条 5 副本的规则,实现 `location-label` 的隔离。 | |
| 可以通过 default 规则的范围拆分成 2 个 key range,分别为 `["", "6D")` 和 `["6E", "")`,然后把 meta 规则的 `count` 调整为 `5`,让 meta 数据只适配一条 5 副本的规则,实现 `location-label` 的隔离。 |
how-to/configure/placement-rules.md
Outdated
| } | ||
| ``` | ||
|
|
||
| ### 场景二:5 副本按 2-2-1 的比例放置在 3 个数据中心,且第 3 个中心不调度 Leader |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ### 场景二:5 副本按 2-2-1 的比例放置在 3 个数据中心,且第 3 个中心不调度 Leader | |
| ### 场景二 | |
| 场景描述:5 副本按 2:2:1 的比例放置在 3 个数据中心,且第 3 个中心不调度 Leader。 |
how-to/configure/placement-rules.md
Outdated
|
|
||
| 每个数据中心对应一条规则,通过 `count` 设置副本数,通过 `role` 标识副本角色(是否需要 `leader`)。由于每个规则对应的副本都使用 `label_constraints` 约束在单个数据中心内了,`location_labels` 只需配置 `rack`,`host` 两级。 | ||
|
|
||
| ### 场景三:为某个 table 添加 2 个 TiFlash 副本 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ### 场景三:为某个 table 添加 2 个 TiFlash 副本 | |
| ### 场景三 | |
| 场景描述:为某个 table 添加 2 个 TiFlash 副本。 |
how-to/configure/placement-rules.md
Outdated
| } | ||
| ``` | ||
|
|
||
| 该规则指定添加的角色为 `learner`,并且通过 `label_constraints` 被用于筛选 `engine` 的类型,指定 `engine` 类型为 `tiflash`。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 该规则指定添加的角色为 `learner`,并且通过 `label_constraints` 被用于筛选 `engine` 的类型,指定 `engine` 类型为 `tiflash`。 | |
| 该规则指定添加的角色为 `learner`,并且通过 `label_constraints` 筛选 `engine` 的类型,指定 `engine` 类型为 `tiflash`。 |
how-to/configure/placement-rules.md
Outdated
|
|
||
| 该规则指定添加的角色为 `learner`,并且通过 `label_constraints` 被用于筛选 `engine` 的类型,指定 `engine` 类型为 `tiflash`。 | ||
|
|
||
| ### 场景四:为某个 table 在有高性能磁盘的北京节点添加 2 个 Follower 副本 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ### 场景四:为某个 table 在有高性能磁盘的北京节点添加 2 个 Follower 副本 | |
| ### 场景四 | |
| 场景描述:为某张表在有高性能磁盘的北京节点添加 2 个 Follower 副本。 |
|
LGTM |
how-to/configure/placement-rules.md
Outdated
| {{< copyable "shell-regular" >}} | ||
|
|
||
| ```bash | ||
| >> config set enable-placement-rules true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| >> config set enable-placement-rules true | |
| config set enable-placement-rules true |
how-to/configure/placement-rules.md
Outdated
|
|
||
| ## 开启 Placement Rules | ||
|
|
||
| 可通过 pd-ctl 设置 `enable-placement-rules` 为 `true` 开启 Placement Rules。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pd-ctl 使用文档 link 一下?
|
|
||
| {{< copyable "" >}} | ||
|
|
||
| ```json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我运行后我没看到这条规则, 怎么看?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
使用 pd-ctl 的 config show 没有看到相关配置
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
使用 curl 通过 GET 命令才看到
|
|
||
| 以下部分介绍添加 Placement Rules 的典型场景。 | ||
|
|
||
| ### 场景一 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
典型场景能不能把之行的命令直接贴一下,要不我还要自己转换 json 。。。
how-to/configure/placement-rules.md
Outdated
| "start_key": "6D", | ||
| "end_key": "6E", | ||
| "role": "voter", | ||
| "count": "2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[root@4 bin]# curl -X POST -H "Content-Type: application/json" --data @data.json http://172.16.5.204:2379/pd/api/v1/config/rule
{
"code": "input",
"msg": "json: cannot unmarshal string into Go struct field Rule.count of type int",
"data": {
"Value": "string",
"Type": {},
"Offset": 101,
"Struct": "Rule",
"Field": "count"
}
}
how-to/configure/placement-rules.md
Outdated
| { | ||
| "group_id": "pd", | ||
| "id": "meta", | ||
| "start_key": "6D", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"start key should be encoded in table mode: insufficient bytes to decode value"
Signed-off-by: Ryan Leung <rleungx@gmail.com>
This reverts commit 922e368.
Signed-off-by: Ryan Leung <rleungx@gmail.com>
Signed-off-by: Ryan Leung <rleungx@gmail.com>
Signed-off-by: Ryan Leung <rleungx@gmail.com>
Signed-off-by: Ryan Leung <rleungx@gmail.com>
110ccaf to
42674e4
Compare
|
@rleungx It seems that some comments haven't been resolved yet. |
|
@GregoryIan @disksing PTAL again, thanks! |
|
还有两个建议
|
|
@disksing PTAL |
|
No body is satisfied with this document. Closing it, I'll write it later. |

What is changed, added or deleted?
This PR adds the Placement Rules related document.
What is the related PR or file link(s)?
N/A
Which TiDB version(s) does your changes apply to?
3.1/dev