-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: ti-srebot <[email protected]>
- Loading branch information
Showing
4 changed files
with
202 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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,135 @@ | ||
--- | ||
title: binlogctl 工具 | ||
summary: 介绍 binlogctl 的使用方法。 | ||
aliases: ['/docs-cn/dev/tidb-binlog/binlog-control/'] | ||
--- | ||
|
||
# binlogctl 工具 | ||
|
||
Binlog Control(以下简称 binlogctl)是 TiDB Binlog 的命令行工具,用于管理 TiDB Binlog 集群。 | ||
|
||
binlogctl 支持如下这些功能: | ||
|
||
* 查看 Pump/Drainer 状态 | ||
* 暂停/下线 Pump/Drainer | ||
* Pump/Drainer 异常状态处理 | ||
|
||
使用 binlogctl 的场景: | ||
|
||
* 同步出现故障/检查运行情况,需要查看 Pump/Drainer 的状态 | ||
* 维护集群,需要暂停/下线 Pump/Drainer | ||
* Pump/Drainer 异常退出,状态没有更新,或者状态不符合预期,对业务造成影响 | ||
|
||
## binlogctl 下载 | ||
|
||
> **注意:** | ||
> | ||
> 建议使用的 Control 工具版本与集群版本保持一致。 | ||
binlogctl 下载链接: | ||
|
||
{{< copyable "shell-regular" >}} | ||
|
||
```bash | ||
wget https://download.pingcap.org/tidb-{version}-linux-amd64.tar.gz && | ||
wget https://download.pingcap.org/tidb-{version}-linux-amd64.sha256 | ||
``` | ||
|
||
检查文件完整性,返回 ok 则正确: | ||
|
||
{{< copyable "shell-regular" >}} | ||
|
||
```bash | ||
sha256sum -c tidb-{version}-linux-amd64.sha256 | ||
``` | ||
|
||
检查文件完整性,返回 ok 则正确: | ||
|
||
{{< copyable "shell-regular" >}} | ||
|
||
```bash | ||
sha256sum -c tidb-enterprise-tools-latest-linux-amd64.sha256 | ||
``` | ||
|
||
## binlogctl 使用说明 | ||
|
||
命令行参数: | ||
|
||
```bash | ||
Usage of binlogctl: | ||
-V | ||
输出 binlogctl 的版本信息 | ||
-cmd string | ||
命令模式,包括 "generate_meta"(已废弃), "pumps", "drainers", "update-pump" ,"update-drainer", "pause-pump", "pause-drainer", "offline-pump", "offline-drainer" | ||
-data-dir string | ||
保存 Drainer 的 checkpoint 的文件的路径 (默认 "binlog_position")(已废弃) | ||
-node-id string | ||
Pump/Drainer 的 ID | ||
-pd-urls string | ||
PD 的地址,如果有多个,则用"," 连接 (默认 "http://127.0.0.1:2379") | ||
-ssl-ca string | ||
SSL CAs 文件的路径 | ||
-ssl-cert string | ||
PEM 格式的 X509 认证文件的路径 | ||
-ssl-key string | ||
PEM 格式的 X509 key 文件的路径 | ||
-time-zone string | ||
如果设置时区,在 "generate_meta" 模式下会打印出获取到的 tso 对应的时间。例如 "Asia/Shanghai" 为 CST 时区,"Local" 为本地时区 | ||
-show-offline-nodes | ||
在用 `-cmd pumps` 或 `-cmd drainers` 命令时使用,这两个命令默认不显示 offline 的节点,仅当明确指定 `-show-offline-nodes` 时会显示 | ||
``` | ||
|
||
命令示例: | ||
|
||
- 查询所有的 Pump/Drainer 的状态: | ||
|
||
设置 `cmd` 为 `pumps` 或者 `drainers` 来查看所有 Pump 或者 Drainer 的状态。例如: | ||
|
||
{{< copyable "shell-regular" >}} | ||
|
||
```bash | ||
bin/binlogctl -pd-urls=http://127.0.0.1:2379 -cmd pumps | ||
``` | ||
|
||
``` | ||
[2019/04/28 09:29:59.016 +00:00] [INFO] [nodes.go:48] ["query node"] [type=pump] [node="{NodeID: 1.1.1.1:8250, Addr: pump:8250, State: online, MaxCommitTS: 408012403141509121, UpdateTime: 2019-04-28 09:29:57 +0000 UTC}"] | ||
``` | ||
|
||
{{< copyable "shell-regular" >}} | ||
|
||
```bash | ||
bin/binlogctl -pd-urls=http://127.0.0.1:2379 -cmd drainers | ||
``` | ||
|
||
``` | ||
[2019/04/28 09:29:59.016 +00:00] [INFO] [nodes.go:48] ["query node"] [type=drainer] [node="{NodeID: 1.1.1.1:8249, Addr: 1.1.1.1:8249, State: online, MaxCommitTS: 408012403141509121, UpdateTime: 2019-04-28 09:29:57 +0000 UTC}"] | ||
``` | ||
|
||
- 暂停/下线 Pump/Drainer | ||
|
||
binlogctl 提供以下命令暂停/下线服务: | ||
|
||
| cmd | 说明 | 示例 | | ||
| --------------- | ------------- | ------------------------------------------------------------------------------------------------| | ||
| pause-pump | 暂停 Pump | `bin/binlogctl -pd-urls=http://127.0.0.1:2379 -cmd pause-pump -node-id ip-127-0-0-1:8250` | | ||
| pause-drainer | 暂停 Drainer | `bin/binlogctl -pd-urls=http://127.0.0.1:2379 -cmd pause-drainer -node-id ip-127-0-0-1:8249` | | ||
| offline-pump | 下线 Pump | `bin/binlogctl -pd-urls=http://127.0.0.1:2379 -cmd offline-pump -node-id ip-127-0-0-1:8250` | | ||
| offline-drainer | 下线 Drainer | `bin/binlogctl -pd-urls=http://127.0.0.1:2379 -cmd offline-drainer -node-id ip-127-0-0-1:8249` | | ||
|
||
binlogctl 会发送 HTTP 请求给 Pump/Drainer,Pump/Drainer 收到命令后会主动执行对应的退出流程。 | ||
|
||
- 异常情况下修改 Pump/Drainer 的状态 | ||
|
||
在服务正常运行以及符合流程的暂停、下线过程中,Pump/Drainer 的状态都是可以正确的。但是在一些异常情况下 Pump/Drainer 无法正确维护自己的状态,可能会影响数据同步任务,在这种情况下需要使用 binlogctl 修复状态信息。 | ||
|
||
设置 `cmd` 为 `update-pump` 或者 `update-drainer` 来更新 Pump 或者 Drainer 的状态。Pump 和 Drainer 的状态可以为 paused 或者 offline。例如: | ||
|
||
{{< copyable "shell-regular" >}} | ||
|
||
```bash | ||
bin/binlogctl -pd-urls=http://127.0.0.1:2379 -cmd update-pump -node-id ip-127-0-0-1:8250 -state paused | ||
``` | ||
|
||
> **注意:** | ||
> | ||
> Pump/Drainer 在正常运行过程中会定期在 PD 中更新自己的状态,而这条命令是直接去修改 Pump/Drainer 保存在 PD 中的状态,所以在 Pump/Drainer 服务正常的情况下使用这些命令是没有意义的。仅在 Pump/Drainer 服务异常的情况下使用,具体哪些场景下使用这条命令可以参考 FAQ。 |
This file contains 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 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