-
Notifications
You must be signed in to change notification settings - Fork 1.2k
doc: add witness related docs #12628
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
Draft
ethercflow
wants to merge
106
commits into
pingcap:master
Choose a base branch
from
ethercflow:witness
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+151
−0
Draft
Changes from all commits
Commits
Show all changes
106 commits
Select commit
Hold shift + click to select a range
6606f99
doc: add witness related docs
ethercflow 36335bd
doc: fix lints
ethercflow 96d7634
address comments
ethercflow 0252bf1
Update configure-placement-rules.md
ethercflow 0273ad7
Update pd-configuration-file.md
ethercflow aaf9894
Update configure-placement-rules.md
ethercflow e0fec37
Update configure-placement-rules.md
ethercflow 49b895c
Update pd-configuration-file.md
ethercflow e15c865
Update witness.md
ethercflow 6d54a02
Update witness.md
ethercflow d01296b
Update pd-control.md
ethercflow 195e6bc
Update witness.md
ethercflow 6c6a088
Update witness.md
ethercflow 0489858
Update witness.md
ethercflow 6c67b28
Update witness.md
ethercflow ff891c4
Update pd-configuration-file.md
ethercflow 3ff85b9
Update pd-configuration-file.md
ethercflow fc77dca
Update witness.md
ethercflow a85325c
Update witness.md
ethercflow d8c7709
Update witness.md
ethercflow 7afb007
Update witness.md
ethercflow d3c043f
Update witness.md
ethercflow c75adc9
Update pd-configuration-file.md
ethercflow fa38766
Update witness.md
ethercflow b1f4eb6
Update witness.md
ethercflow da381d7
Update witness.md
ethercflow 1d438a7
docs: address comments
ethercflow 6eb9e67
docs: fix broken extern link
ethercflow 0ab358e
Update use-witness-to-speed-up-failover.md
ethercflow 0e0b61e
Update use-witness-to-speed-up-failover.md
ethercflow 01af00d
Update use-witness-to-save-costs.md
ethercflow 02cd9eb
Update TOC.md
ethercflow 08e073b
Update use-witness-to-speed-up-failover.md
ethercflow 05cf9b4
Update use-witness-to-save-costs.md
ethercflow ff5cd26
Update glossary.md
ethercflow 449f8d5
Update pd-configuration-file.md
ethercflow 12bb30b
Update pd-configuration-file.md
ethercflow 50ed9f6
docs: address comments
ethercflow 61c278d
docs: revert media
ethercflow 36c2fa0
Update pd-control.md
ethercflow 4686b22
Update use-witness-to-save-costs.md
ethercflow bdd061e
Update use-witness-to-save-costs.md
ethercflow d220274
Update use-witness-to-save-costs.md
ethercflow 3fb7e3b
Update use-witness-to-speed-up-failover.md
ethercflow e0e4f3c
Update use-witness-to-speed-up-failover.md
ethercflow 8479816
Update use-witness-to-speed-up-failover.md
ethercflow 7463f2d
Update glossary.md
ethercflow 72bbf3a
Update pd-configuration-file.md
ethercflow f98a79f
Update use-witness-to-save-costs.md
ethercflow a88ca41
Update use-witness-to-save-costs.md
ethercflow 64c0ab6
Update use-witness-to-save-costs.md
ethercflow f901caf
Update use-witness-to-speed-up-failover.md
ethercflow 290e953
Update use-witness-to-speed-up-failover.md
ethercflow a83ebe5
docs: revert media
ethercflow 7395ec2
Update use-witness-to-save-costs.md
ethercflow 92ab97c
Update use-witness-to-save-costs.md
ethercflow 9383992
Update pd-configuration-file.md
ethercflow 460539b
Update pd-control.md
ethercflow f87abe8
Update pd-configuration-file.md
ethercflow 3b3eda5
Update use-witness-to-save-costs.md
ethercflow c71e8b2
Update pd-configuration-file.md
ethercflow e0ac575
Update use-witness-to-save-costs.md
ethercflow 3da7d54
Update use-witness-to-save-costs.md
ethercflow 538c1d7
Update use-witness-to-speed-up-failover.md
ethercflow c7720a4
Update use-witness-to-speed-up-failover.md
ethercflow 242ddcb
Update use-witness-to-speed-up-failover.md
ethercflow b2eaafb
Update configure-placement-rules.md
ethercflow 9c131d1
Update configure-placement-rules.md
ethercflow 2f030d6
Update pd-configuration-file.md
ethercflow 788e197
docs: address comments
ethercflow c09b88e
docs: address comments
ethercflow b690402
Update use-witness-to-save-costs.md
ethercflow f9cddff
Update use-witness-to-save-costs.md
ethercflow 1686cac
Update use-witness-to-save-costs.md
ethercflow 2603d97
Update use-witness-to-speed-up-failover.md
ethercflow b4f6e0f
Update use-witness-to-speed-up-failover.md
ethercflow 98e984e
Update use-witness-to-save-costs.md
ethercflow c5a35dc
Update use-witness-to-speed-up-failover.md
ethercflow c344f1e
docs: address comments
ethercflow 16c952d
Update use-witness-to-save-costs.md
ethercflow fa9b7d2
doc: address comments
ethercflow e5ea5db
Update glossary.md
ethercflow f0a78ec
Update pd-control.md
ethercflow 4e5d73e
Update use-witness-to-save-costs.md
ethercflow 33caa36
Update use-witness-to-save-costs.md
ethercflow c342c89
Apply suggestions from code review
Oreoxmt ac01317
Update use-witness-to-save-costs.md
ethercflow 38d1d0e
docs: address comments
ethercflow f24ef29
remove blank lines
Oreoxmt 9c9f8de
Update TOC.md
ethercflow d31e190
Update TOC.md
ethercflow 215638a
Update configure-placement-rules.md
ethercflow 5c01d55
Update configure-placement-rules.md
ethercflow ab9c16a
Update glossary.md
ethercflow 2c09781
Update pd-configuration-file.md
ethercflow eacb582
Update pd-configuration-file.md
ethercflow 5d93335
Update pd-configuration-file.md
ethercflow 3ed6a7b
Update pd-control.md
ethercflow 3a3f858
Update pd-control.md
ethercflow c044823
Update use-witness-to-save-costs.md
ethercflow a16a623
Update use-witness-to-save-costs.md
ethercflow 043787f
Update use-witness-to-save-costs.md
ethercflow c552bc8
Update use-witness-to-save-costs.md
ethercflow ee9a5b9
Apply suggestions from code review
ethercflow 59ee7bf
fix format
Oreoxmt 7a6184b
Apply suggestions from code review
Oreoxmt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
title: 使用 Witness 副本节约成本 | ||
summary: 了解如何使用 Witness 副本在高可靠的存储环境中节约成本。 | ||
--- | ||
|
||
# 使用 Witness 副本节约成本 | ||
|
||
本文介绍如何在高可靠存储环境中使用 Witness 副本节约成本。如果需要使用 Witness 副本提高 TiKV Down 场景下的持久性,请参考[使用 Witness 副本来加速恢复](/use-witness-to-speed-up-failover.md)。 | ||
|
||
## 功能说明 | ||
|
||
在云环境中,推荐使用持久性为 99.8%~99.9% 的 Amazon Elastic Block Store (EBS) 或持久性为 99.99%~99.999% 的 Google Cloud Platform (GCP) 的 Persistent Disk 作为 TiKV 单节点存储。此时,TiKV 使用 3 个 Raft 副本虽然可行,但并不必要。为了降低成本,TiKV 引入了 Witness 副本功能,即 2 Replicas With 1 Log Only 机制。其中 1 Log Only 副本仅存储 Raft 日志但不进行数据 apply,依然可以通过 Raft 协议保证数据一致性。与标准的 3 副本架构相比,Witness 副本可以节省存储资源及 CPU 使用率。 | ||
|
||
> **警告:** | ||
> | ||
> Witness 副本功能自 v7.0.0 开始引入,与低版本不兼容,因此不支持降级。 | ||
|
||
ethercflow marked this conversation as resolved.
Show resolved
Hide resolved
|
||
## 适用场景 | ||
|
||
高可靠的存储环境 (99.8%~99.9%),例如使用 Amazon EBS 或 GCP Persistent Disk 时,可以开启并配置 Witness 副本来节约成本。 | ||
|
||
## 使用步骤 | ||
|
||
### 第 1 步:开启 Witness | ||
|
||
使用 PD Control 执行 `config set enable-witness true` 命令开启 Witness: | ||
|
||
```bash | ||
pd-ctl config set enable-witness true | ||
``` | ||
|
||
命令输出 `Success` 表示开启成功。如果 Placement Rules 没有配置 Witness 副本,则默认不会有 Witness 产生。只有出现 TiKV Down 后,才会立刻添加一个 Witness 节点,后续系统将其转换为普通的 Voter。 | ||
|
||
### 第 2 步:配置 Witness 副本 | ||
|
||
以三副本为例,修改 `rule.json` 为[场景六:在高可靠的存储环境下配置 Witness 副本](/configure-placement-rules.md#场景六在高可靠的存储环境下配置-witness-副本)中的配置。 | ||
|
||
编辑完文件后,使用下面的命令将配置保存至 PD 服务器: | ||
|
||
```bash | ||
pd-ctl config placement-rules save --in=rule.json | ||
``` | ||
|
||
## 注意事项 | ||
|
||
- 建议只在高可靠的存储环境中设置 Witness 副本。例如,使用持久性为 99.8%~99.9% 的 Amazon EBS 或持久性为 99.99%~99.999% 的 GCP Persistent Disk 作为单节点存储。 | ||
- 由于 Witness 副本没有应用 Raft 日志,因此无法对外提供读写服务。当 Leader Down 后且剩余的 Voter 没有最新的 Raft 日志时,Raft 会选举 Witness 副本临时成为 Leader。Witness 副本当选后,会向 Voter 补发 Raft 日志后 transfer leader 给 Voter。若无法及时 transfer leader,当客户端 Backoff 超时后,应用可能收到 `IsWitness` 错误。 | ||
- 当系统存在 Pending Voter 时,为防止 Witness 积攒过多的 Raft 日志,导致占满整个磁盘空间,系统会将 Witness 晋升为普通 Voter。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
title: 使用 Witness 副本加速恢复 | ||
summary: 了解如何使用 Witness 副本来加速恢复。 | ||
--- | ||
|
||
# 使用 Witness 副本加速恢复 | ||
|
||
本文介绍如何使用 Witness 副本提高 TiKV Down 场景下的持久性。如果需要在高可靠存储环境中使用 Witness 副本节约成本,请参考[使用 Witness 副本节约成本](/use-witness-to-save-costs.md)。 | ||
|
||
## 功能说明 | ||
|
||
Witness 副本功能可用于快速恢复 (failover),以提高系统的可用性和数据持久性。例如在 3 缺 1 的情况下,虽然满足多数派要求,但是系统很脆弱,而完整恢复一个新成员的时间通常很长(需要先拷贝 snapshot 然后 apply 最新的日志),特别是 Region snapshot 比较大时,恢复的时间会更长。而且,拷贝副本的过程可能会对不健康的 Group member 造成更多的压力。因此,先添加一个 Witness 副本可以快速移除不健康的节点,降低在恢复一个新成员的过程中,又一个节点挂掉导致 Raft Group 不可用的风险(Learner 无法参与选举和提交),从而保证恢复数据过程中日志的安全性。 | ||
|
||
> **警告:** | ||
> | ||
> Witness 副本功能自 v7.0.0 开始引入,与低版本不兼容,因此不支持降级。 | ||
|
||
ethercflow marked this conversation as resolved.
Show resolved
Hide resolved
|
||
## 适用场景 | ||
|
||
在快速恢复以提高持久性的场景下,可以开启 Witness 功能但不配置 Witness 副本。 | ||
|
||
## 使用方法 | ||
|
||
使用 PD Control 执行 `config set enable-witness true` 命令开启 Witness: | ||
|
||
```bash | ||
pd-ctl config set enable-witness true | ||
``` | ||
|
||
命令输出 `Success` 表示开启成功。如果没有按照[使用 Witness 节约成本](/use-witness-to-save-costs.md)配置 Witness 副本,则集群正常状态下不会有 Witness 副本产生。只有出现 TiKV Down 后,才会立刻添加一个 Witness 节点,后续系统会将其转换为普通的 Voter。 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.