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 1 commit
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
Prev Previous commit
Next Next commit
Apply suggestions from code review
Co-Authored-By: Ian <ArGregoryIan@gmail.com>
  • Loading branch information
july2993 and IANTHEREAL authored Feb 10, 2020
commit e2eeafe5db438312774255c2304578e66e785011
12 changes: 7 additions & 5 deletions dev/reference/tidb-binlog/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -621,13 +621,15 @@ Drainer="192.168.0.13"

# 关于 Relay log

drainer 会拆分上游的事务并发写下游,极端情况下上游集群不可用后并且 drainer 异常退出后没法再同步到一个一致的状态
drainer 会拆分上游的事务并发写下游,在极端情况上游集群不可用并且 drainer 异常退出后,同步的下游集群(MySQL/TiDB)可能处于数据不一致的中间状态

下游集群达到一个时间戳为 `ts` 的一致的状态的定义为
下游集群达到一致的状态的定义为

* 下游集群为上游设置 _tidb_snapshot = ts_ 的快照
* 下游集群的数据等同于设置了 _tidb_snapshot = ts_ 的快照上游 TiDB 集群的数据

当开启 Relay log 后每个 binlog 会先写对应的日志到磁盘上再写下游,如果上游集群不可用,我们总是可以通过这些日志来把集群恢复到一个一致的状态,只要不会同时丢失这部分日志。 已经同步到下游的 relay log 会尽可能快的删除,所以不会占很多空间。
当 drainer 开启 relay log 后会先将 binlog event 写到磁盘上,然后再同步给下游集群。如果上游集群不可用,我们总是可以通过 relay log 把集群恢复到一个一致的状态。除非同时丢失 relay log 数据,不过这是概率极小的事件。此外可以使用 nfs 等网络文件系统来保证 relay log 的数据安全。

relay log 会尽可能快的删除已经同步到下游的 binlog event,所以不会占很多磁盘空间。

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

Expand All @@ -640,7 +642,7 @@ mysql> select * from tidb_binlog.checkpoint;
+---------------------+--------------------------------------------------------+
```

当 drainer 启动时发现 status 为 1 并且连接不上 PD, 会尝试读取 relay log 恢复下游到一个一致的状态再退出,如果正常恢复退出,可以看到 status 更新为 0
当 drainer 启动时连接不上上游集群的 PD 并且探测到 checkpoint 的 status 为 1 , 会尝试读取 relay log 将下游集群恢复到一个一致的状态,然后 drainer 进程将 checkpoint 的 status 设置为 0 后主动退出

## 配置

Expand Down