Skip to content

Commit

Permalink
Merge pull request #795 from pingcap/binlog_kafka
Browse files Browse the repository at this point in the history
add about db-type=kafka
  • Loading branch information
zhengwanbo committed Jul 9, 2018
2 parents e5f9e4b + b9c659e commit 8ac9b4a
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions tools/tidb-binlog-kafka.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,15 @@ cd tidb-binlog-latest-linux-amd64
#### 注意

* 需要为一个 TiDB 集群中的每台 TiDB server 部署一个 Pump,目前 TiDB server 只支持以 unix socket 的方式输出 Binlog。

* 手动部署时,启动优先级为:Pump > TiDB;停止优先级为 TiDB > Pump。

设置 TiDB 启动参数 `binlog-socket` 为对应的 Pump 参数 `socket` 所指定的 unix socket 文件路径,最终部署结构如下图所示:

![TiDB pump 模块部署结构](../media/tidb-pump-deployment.png)

* Drainer 不支持对 ignore schemas(在过滤列表中的 schemas)的 table 进行 rename DDL 操作。

* 在已有的 TiDB 集群中启动 Drainer,一般需要全量备份并且获取 savepoint,然后导入全量备份,最后启动 Drainer 从 savepoint 开始同步;

为了保证数据的完整性,在 Pump 运行 10 分钟左右后按顺序进行如下操作:
Expand All @@ -78,7 +80,7 @@ cd tidb-binlog-latest-linux-amd64
* 全量导入备份到目标系统
* Kafka 版本 Drainer 启动的 savepoint 默认保存在下游 database tidb_binlog 下的 checkpoint 表中,如果 checkpoint 表中没有效的数据,可以通过设置 `initial-commit-ts` 启动 Drainer 从指定位置开始消费 - `bin/drainer --config=conf/drainer.toml --initial-commit-ts=${position}`

* Drainer 输出的 pb,要在配置文件中设置如下参数:
* Drainer 输出为 pb,要在配置文件中设置如下参数:

```
[syncer]
Expand All @@ -89,6 +91,20 @@ cd tidb-binlog-latest-linux-amd64
dir = "/path/pb-dir"
```

* Drainer 输出为 kafka,要在配置文件中设置如下参数:

```
[syncer]
db-type = "kafka"
# when db-type is kafka, you can uncomment this to config the down stream kafka, or it will be the same kafka addrs where drainer pull binlog from.
#[syncer.to]
# kafka-addrs = "127.0.0.1:9092"
# kafka-version = "0.8.2.0"
```

输出到 kafka 的数据为按 ts 排好序的 protobuf 定义 binlog 格式,可以参考 [driver](https://github.com/pingcap/tidb-tools/tree/master/tidb_binlog/driver) 获取数据同步到下游。

* Kafka 和 ZooKeeper 集群需要在部署 TiDB-Binlog 之前部署好。Kafka 需要 0.9 及以上版本。

#### Kafka 集群配置推荐
Expand Down Expand Up @@ -206,7 +222,7 @@ ZK3="192.168.0.11"

# Pump 向 PD 发送心跳的间隔 (单位 秒)
heartbeat-interval = 3

# PD 集群节点的地址
pd-urls = "http://192.168.0.16:2379,http://192.168.0.15:2379,http://192.168.0.14:2379"

Expand Down

0 comments on commit 8ac9b4a

Please sign in to comment.