使用 DM binary 部署 DM 集群

本文将介绍如何使用 DM binary 快速部署 DM 集群。

下载 DM 安装包

DM 安装包位于 TiDB 离线工具包中。下载方式,请参考 TiDB 工具下载

使用样例

假设在五台服务器上部署两个 DM-worker 实例和三个 DM-master 实例。各个节点的信息如下:

实例服务器地址端口
DM-master1192.168.0.48261
DM-master2192.168.0.58261
DM-master3192.168.0.68261
DM-worker1192.168.0.78262
DM-worker2192.168.0.88262

下面以此为例,说明如何部署 DM。

部署 DM-master

DM-master 提供命令行参数配置文件两种配置方式。

使用命令行参数部署 DM-master

DM-master 的命令行参数说明:

./dm-master --help
Usage of dm-master: -L string log level: debug, info, warn, error, fatal (default "info") -V prints version and exit -advertise-addr string advertise address for client traffic (default "${master-addr}") -advertise-peer-urls string advertise URLs for peer traffic (default "${peer-urls}") -config string path to config file -data-dir string path to the data directory (default "default.${name}") -initial-cluster string initial cluster configuration for bootstrapping, e.g. dm-master=http://127.0.0.1:8291 -join string join to an existing cluster (usage: cluster's "${master-addr}" list, e.g. "127.0.0.1:8261,127.0.0.1:18261" -log-file string log file path -master-addr string master API server and status addr -name string human-readable name for this DM-master member -peer-urls string URLs for peer traffic (default "http://127.0.0.1:8291") -print-sample-config print sample config file of dm-worker

使用配置文件部署 DM-master

推荐使用配置文件,把以下配置文件内容写入到 conf/dm-master1.toml 中。

DM-master 的配置文件:

# Master Configuration. name = "master1" # 日志配置 log-level = "info" log-file = "dm-master.log" # DM-master 监听地址 master-addr = "192.168.0.4:8261" # DM-master 节点的对等 URL peer-urls = "192.168.0.4:8291" # 初始集群中所有 DM-master 的 advertise-peer-urls 的值 initial-cluster = "master1=http://192.168.0.4:8291,master2=http://192.168.0.5:8291,master3=http://192.168.0.6:8291"

在终端中使用下面的命令运行 DM-master:

./dm-master -config conf/dm-master1.toml

对于 DM-master2 和 DM-master3,修改配置文件中的 namemaster2master3,并将 peer-urls 的值改为 192.168.0.5:8291192.168.0.6:8291 即可。

部署 DM-worker

DM-worker 提供命令行参数配置文件两种配置方式。

使用命令行参数部署 DM-worker

查看 DM-worker 的命令行参数说明:

./dm-worker --help
Usage of worker: -L string log level: debug, info, warn, error, fatal (default "info") -V prints version and exit -advertise-addr string advertise address for client traffic (default "${worker-addr}") -config string path to config file -join string join to an existing cluster (usage: dm-master cluster's "${master-addr}") -keepalive-ttl int dm-worker's TTL for keepalive with etcd (in seconds) (default 10) -log-file string log file path -name string human-readable name for DM-worker member -print-sample-config print sample config file of dm-worker -worker-addr string listen address for client traffic

使用配置文件部署 DM-worker

推荐使用配置文件来配置 DM-worker,把以下配置文件内容写入到 conf/dm-worker1.toml 中。

DM-worker 的配置文件:

# Worker Configuration. name = "worker1" # 日志配置 log-level = "info" log-file = "dm-worker.log" # DM-worker 的地址 worker-addr = ":8262" # 对应集群中 DM-master 配置中的 master-addr join = "192.168.0.4:8261,192.168.0.5:8261,192.168.0.6:8261"

在终端中使用下面的命令运行 DM-worker:

./dm-worker -config conf/dm-worker1.toml

对于 DM-worker2,修改配置文件中的 nameworker2 即可。

这样,DM 集群就部署成功了。