数据迁移工具概览
TiDB 提供了丰富的数据迁移相关的工具,用于全量迁移、增量迁移、备份恢复、数据同步等多种场景。
本文介绍了使用这些工具的场景、支持的上下游、优势和相关限制等信息。请根据你的需求选择合适的工具。
TiDB Data Migration (DM)
| 使用场景 | 用于将数据从与 MySQL 协议兼容的数据库迁移到 TiDB | 
|---|---|
| 上游 | MySQL,MariaDB,Aurora | 
| 下游 | TiDB | 
| 主要优势 | 
  | 
| 使用限制 | 数据导入速度与 TiDB Lightning 的 Logical Import Mode 大致相同,而比TiDB Lightning 的 Physical Import Mode 低很多。建议用于 1 TB 以内的存量数据迁移。 | 
TiDB Lightning
| 使用场景 | 用于将数据全量导入到 TiDB | 
|---|---|
| 上游(输入源文件) | 
  | 
| 下游 | TiDB | 
| 主要优势 | 
  | 
| 使用限制 | 
  | 
Dumpling
| 使用场景 | 用于将数据从 MySQL/TiDB 进行全量导出 | 
|---|---|
| 上游 | MySQL,TiDB | 
| 下游(输出文件) | SQL,CSV | 
| 主要优势 | 
  | 
| 使用限制 | 
  | 
TiCDC
| 使用场景 | 通过拉取 TiKV 变更日志实现的 TiDB 增量数据同步工具,具有将数据还原到与上游任意 TSO 一致状态的能力,支持其他系统订阅数据变更 | 
|---|---|
| 上游 | TiDB | 
| 下游 | TiDB,MySQL,Kafka,Confluent | 
| 主要优势 | 提供开放数据协议 (TiCDC Open Protocol)。 | 
| 使用限制 | TiCDC 只能同步至少存在一个有效索引的表。暂不支持以下场景:
  | 
Backup & Restore (BR)
| 使用场景 | 通过对大数据量的 TiDB 集群进行数据备份和恢复,实现数据迁移 | 
|---|---|
| 上游 | TiDB | 
| 下游(输出文件) | SST,backup.meta 文件,backup.lock 文件 | 
| 主要优势 | 
  | 
| 使用限制 | 
  | 
sync-diff-inspector
| 使用场景 | 用于校验 MySQL/TiDB 中两份数据的一致性 | 
|---|---|
| 上游 | TiDB,MySQL | 
| 下游 | TiDB,MySQL | 
| 主要优势 | 提供了修复数据的功能,适用于修复少量不一致的数据。 | 
| 使用限制 | 
  | 
使用 TiUP 快速安装
从 TiDB 4.0 开始,TiUP 作为软件包管理器,帮助你轻松管理 TiDB 生态系统中的不同集群组件。现在你可以只用一个 TiUP 命令行来管理任何组件。
第 1 步:安装 TiUP
curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
重新声明全局环境变量:
source ~/.bash_profile
第 2 步:安装组件
你可以通过以下命令查看所有可用组件:
tiup list
以下输出为所有可用组件:
Available components:
Name            Owner    Description
----            -----    -----------
bench           pingcap  Benchmark database with different workloads
br              pingcap  TiDB/TiKV cluster backup restore tool
cdc             pingcap  CDC is a change data capture tool for TiDB
client          pingcap  Client to connect playground
cluster         pingcap  Deploy a TiDB cluster for production
ctl             pingcap  TiDB controller suite
dm              pingcap  Data Migration Platform manager
dmctl           pingcap  dmctl component of Data Migration Platform
errdoc          pingcap  Document about TiDB errors
pd-recover      pingcap  PD Recover is a disaster recovery tool of PD, used to recover the PD cluster which cannot start or provide services normally
playground      pingcap  Bootstrap a local TiDB cluster for fun
tidb            pingcap  TiDB is an open source distributed HTAP database compatible with the MySQL protocol
tidb-lightning  pingcap  TiDB Lightning is a tool used for fast full import of large amounts of data into a TiDB cluster
tiup            pingcap  TiUP is a command-line component management tool that can help to download and install TiDB platform components to the local system
选择所需要的组件进行安装
tiup install dumpling tidb-lightning
第 3 步: 更新 TiUP 及组件 (可选)
建议先查看新版本的更新日志及兼容性说明:
tiup update --self && tiup update dm