Skip to content
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

reference/tidb-binlog: add docs about relay log #2224

Merged
merged 27 commits into from
Feb 19, 2020
Merged
Changes from 4 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
0dc57be
Add docs about relay log
july2993 Feb 10, 2020
8c5893b
Merge branch 'master' into relay_doc
IANTHEREAL Feb 10, 2020
aaa1418
Address comment
july2993 Feb 10, 2020
552c3c1
Merge remote-tracking branch 'july2993/relay_doc' into relay_doc
july2993 Feb 10, 2020
e2eeafe
Apply suggestions from code review
july2993 Feb 10, 2020
fbab790
Remove trailing space
july2993 Feb 10, 2020
42cca9d
Update dev/reference/tidb-binlog/deploy.md
july2993 Feb 12, 2020
161a7ea
Add GC strategy
july2993 Feb 12, 2020
7571cdb
rename status as consistent
july2993 Feb 12, 2020
c05dccd
Merge branch 'master' into relay_doc
july2993 Feb 12, 2020
7b00bc7
refine document of binlog relay
IANTHEREAL Feb 13, 2020
973a764
add relay
IANTHEREAL Feb 13, 2020
6efa7d8
refine relay log description
IANTHEREAL Feb 13, 2020
c8c1b25
format document
IANTHEREAL Feb 13, 2020
6b51e21
Merge branch 'master' into relay_doc
IANTHEREAL Feb 13, 2020
2cf96a6
Apply suggestions from code review
july2993 Feb 17, 2020
ed58dc7
Address comment
july2993 Feb 17, 2020
d04d1c5
Merge branch 'master' into relay_doc
july2993 Feb 17, 2020
968eda6
Address comment
july2993 Feb 18, 2020
ad905b4
Merge branch 'master' into relay_doc
july2993 Feb 18, 2020
0172889
Merge branch 'master' into relay_doc
IANTHEREAL Feb 18, 2020
68cac7b
reference/tidb-binlog: fix typos, add aliases, add toc
TomShawn Feb 18, 2020
7d83c3d
Merge branch 'master' into relay_doc
july2993 Feb 19, 2020
45b561a
align other versions
july2993 Feb 19, 2020
c590bd3
Update v3.1/reference/tidb-binlog/relay-log.md
july2993 Feb 19, 2020
80f90d8
Update v3.0/reference/tidb-binlog/relay-log.md
july2993 Feb 19, 2020
60f569b
Merge branch 'master' into relay_doc
july2993 Feb 19, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions dev/reference/tidb-binlog/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,13 @@ Drainer="192.168.0.13"

# replicate-do-db = ["~^b.*","s1"]

# [syncer.relay]
# 保存 relay log 的目录,空值表示不开启。
# 只有下游是 TiDB/MySQL 配置才有意义。
july2993 marked this conversation as resolved.
Show resolved Hide resolved
# log-dir = ""
# 每个文件的最大大小
july2993 marked this conversation as resolved.
Show resolved Hide resolved
# max-file-size = 10485760

# [[syncer.replicate-do-table]]
# db-name ="test"
# tbl-name = "log"
Expand Down Expand Up @@ -612,6 +619,40 @@ Drainer="192.168.0.13"

如果命令行参数与配置文件中的参数重合,则使用命令行设置的参数的值。

# 关于 Relay log

drainer 会拆分上游的事务并发写下游,极端情况下上游集群不可用后并且 drainer 异常退出后没法再同步到一个一致的状态。
july2993 marked this conversation as resolved.
Show resolved Hide resolved

下游集群达到一个时间戳为 `ts` 的一致的状态的定义为:
july2993 marked this conversation as resolved.
Show resolved Hide resolved

* 下游集群为上游设置 _tidb_snapshot = ts_ 的快照
july2993 marked this conversation as resolved.
Show resolved Hide resolved

当开启 Relay log 后每个 binlog 会先写对应的日志到磁盘上再写下游,如果上游集群不可用,我们总是可以通过这些日志来把集群恢复到一个一致的状态,只要不会同时丢失这部分日志。 已经同步到下游的 relay log 会尽可能快的删除,所以不会占很多空间。
july2993 marked this conversation as resolved.
Show resolved Hide resolved

下游报存的 checkpoint 可以看到 status 状态, 0 表示达到一致的状态。drainer 运行时会是 1,正常退出后会更新为 0。
july2993 marked this conversation as resolved.
Show resolved Hide resolved

```
mysql> select * from tidb_binlog.checkpoint;
+---------------------+--------------------------------------------------------+
| clusterID | checkPoint |
+---------------------+--------------------------------------------------------+
| 6791641053252586769 | {"status":0,"commitTS":414529105591271429,"ts-map":{}} |
+---------------------+--------------------------------------------------------+
```

july2993 marked this conversation as resolved.
Show resolved Hide resolved
当 drainer 启动时发现 status 为 1 并且连接不上 PD, 会尝试读取 relay log 恢复下游到一个一致的状态再退出,如果正常恢复退出,可以看到 status 更新为 0。
july2993 marked this conversation as resolved.
Show resolved Hide resolved

## 配置

开启 relay log 功能只需要在 drainer 添加如下配置:

```
[syncer.relay]
july2993 marked this conversation as resolved.
Show resolved Hide resolved
# 保存 relay log 的目录,空值表示不开启。
# 只有下游是 TiDB/MySQL 配置才有意意义。
log-dir = "/dir/to/save/log"
```

> **注意:**
>
> - 在运行 TiDB 时,需要保证至少一个 Pump 正常运行。
Expand Down