# TiDB Binlog 的使用 - Drainer 启动

```
./bin/drainer -config drainer.toml -initial-commit-st {initial-commit-ts}

# Drainer Configuration.

addr = "192.168.0.13:8249"
data-dir = "data.drainer"
pd-urls = "http://192.168.0.16:2379,http://192.168.0.15:2379,http://192.168.0.14:2379"
log-file = "drainer.log"
db-type = "mysql"
[syncer.to]
host = "192.168.0.13"
user = "root"
password = ""
port = 3306
```
-------------------------------------------------------------
我们可以通过如下命令启动 Drainer 节点:
./bin/drainer -config drainer.toml -initial-commit-ts {initial-commit-ts}
注意:
1. 如果下游为 MySQL/TiDB,为了保证数据的完整性,在 Drainer 初次启动前需要获取 initial-commit-ts 的值,并进行全量数据的备份与恢复。
2. 其中的 drainer.toml 配置文件主要指定了 Drainer 的地址,数据保存位置,查询 Pump 在线的时间间隔和下游数据库的地址等,例如:

# Drainer Configuration.

# Drainer 提供服务的地址("192.168.0.13:8249")
addr = "192.168.0.13:8249"

# Drainer 对外提供服务的地址
advertise-addr = "192.168.0.13:8249"

# 向 PD 查询在线 Pump 的时间间隔 (默认 10,单位 秒)
detect-interval = 10

# Drainer 数据存储位置路径 (默认 "data.drainer")
data-dir = "data.drainer"

# PD 集群节点的地址 (英文逗号分割,中间不加空格)
pd-urls = "http://192.168.0.16:2379,http://192.168.0.15:2379,http://192.168.0.14:2379"

# log 文件路径
log-file = "drainer.log"

# Drainer 下游服务类型（默认为 mysql）
# 参数有效值为 "mysql","tidb","file","kafka"
db-type = "mysql"

# db-type 设置为 mysql 时,下游数据库服务器参数
[syncer.to]
host = "192.168.0.13"
user = "root"
password = ""
# 使用 `./binlogctl -cmd encrypt -text string` 加密的密码
# encrypted_password 非空时 password 会被忽略
encrypted_password = ""
port = 3306

详细的配置请参考:https://docs.pingcap.com/zh/tidb/dev/deploy-tidb-binlog