Skip to content

Commit

Permalink
ticdc: add 4 docs for data replication scenarios (pingcap#10276)
Browse files Browse the repository at this point in the history
  • Loading branch information
shichun-0415 authored Jul 7, 2022
1 parent fb48720 commit 9d231a0
Show file tree
Hide file tree
Showing 29 changed files with 709 additions and 328 deletions.
10 changes: 7 additions & 3 deletions TOC.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
- [用 Sysbench 测试 TiDB](/benchmark/benchmark-tidb-using-sysbench.md)
- [对 TiDB 进行 TPC-C 测试](/benchmark/benchmark-tidb-using-tpcc.md)
- 数据迁移
- [数据迁移综述](/migration-overview.md)
- [数据迁移概述](/migration-overview.md)
- [迁移工具](/migration-tools.md)
- 数据迁移场景
- [从 Aurora 迁移数据到 TiDB](/migrate-aurora-to-tidb.md)
Expand All @@ -108,12 +108,17 @@
- [从 CSV 文件迁移数据到 TiDB](/migrate-from-csv-files-to-tidb.md)
- [从 SQL 文件迁移数据到 TiDB](/migrate-from-sql-files-to-tidb.md)
- [从 TiDB 集群迁移数据至另一 TiDB 集群](/migrate-from-tidb-to-tidb.md)
- [从 TiDB 同步数据至 Apache Kafka](/replicate-data-to-kafka.md)
- [从 TiDB 集群迁移数据至兼容 MySQL 的数据库](/migrate-from-tidb-to-mysql.md)
- 复杂迁移场景
- [上游使用 pt/gh-ost 工具的持续同步场景](/migrate-with-pt-ghost.md)
- [下游存在更多列的迁移场景](/migrate-with-more-columns-downstream.md)
- [如何根据类型或 DDL 内容过滤 binlog 事件](/filter-binlog-event.md)
- [如何通过 SQL 表达式过滤 DML binlog 事件](/filter-dml-event.md)
- 数据集成
- [数据集成概述](/integration-overview.md)
- 数据集成场景
- [与 Confluent Cloud 进行数据集成](/ticdc/integrate-confluent-using-ticdc.md)
- [与 Apache Kafka 和 Apache Flink 进行数据集成](/replicate-data-to-kafka.md)
- 运维操作
- 升级 TiDB 版本
- [使用 TiUP 升级(推荐)](/upgrade-tidb-using-tiup.md)
Expand Down Expand Up @@ -495,7 +500,6 @@
- [TiCDC Open Protocol](/ticdc/ticdc-open-protocol.md)
- [TiCDC Avro Protocol](/ticdc/ticdc-avro-protocol.md)
- [TiCDC Canal-JSON Protocol](/ticdc/ticdc-canal-json.md)
- [将 TiDB 集成到 Confluent Platform](/ticdc/integrate-confluent-using-ticdc.md)
- [常见问题解答](/ticdc/ticdc-faq.md)
- [术语表](/ticdc/ticdc-glossary.md)
- TiUniManager
Expand Down
2 changes: 1 addition & 1 deletion backup-and-restore-using-dumpling-lightning.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ SELECT table_name,table_schema,SUM(data_length)/1024/1024 AS data_length,SUM(ind

2. 运行 `tidb-lightning`。如果直接在命令行中启动程序,可能会因为 `SIGHUP` 信号而退出,建议配合 `nohup``screen` 等工具,如:

若从 S3 导入,则需将有权限访问该 Amazon S3 后端存储的账号的 SecretKey 和 AccessKey 作为环境变量传入 Lightning 节点。同时还支持从 `~/.aws/credentials` 读取凭证文件。
若从 Amazon S3 导入,则需将有权限访问该 S3 后端存储的账号的 SecretKey 和 AccessKey 作为环境变量传入 Lightning 节点。同时还支持从 `~/.aws/credentials` 读取凭证文件。

```shell
export AWS_ACCESS_KEY_ID=${access_key}
Expand Down
2 changes: 1 addition & 1 deletion dm/migrate-data-using-dm.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ tiup dmctl --master-addr 172.16.10.71:8261 stop-task test

如果使用 TiUP 部署 DM 集群时,正确部署了 Prometheus、Alertmanager 与 Grafana,且其地址均为 `172.16.10.71`。可在浏览器中打开 <http://172.16.10.71:9093> 进入 Alertmanager 查看 DM 告警信息;可在浏览器中打开 <http://172.16.10.71:3000> 进入 Grafana,选择 DM 的 dashboard 查看 DM 相关监控项。

DM 在运行过程中,DM-worker, DM-master 及 dmctl 都会通过日志输出相关信息。各组件的日志目录如下:
DM 在运行过程中,DM-workerDM-master 及 dmctl 都会通过日志输出相关信息。各组件的日志目录如下:

- DM-master 日志目录:通过 DM-master 进程参数 `--log-file` 设置。如果使用 TiUP 部署 DM,则日志目录位于 `{log_dir}`。
- DM-worker 日志目录:通过 DM-worker 进程参数 `--log-file` 设置。如果使用 TiUP 部署 DM,则日志目录位于 `{log_dir}`。
16 changes: 16 additions & 0 deletions integration-overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
title: 数据集成概述
summary: 了解使用 TiCDC 进行数据集成的具体场景。
---

# 数据集成概述

数据集成一般是指数据在各个独立的数据源之间流动、转换和汇集。随着数据量的爆炸式增长和数据价值被深度挖掘,对数据集成的需求越来越普遍和迫切。为了避免 TiDB 成为数据孤岛,顺利与各个数据系统进行集成,TiCDC 提供将 TiDB 增量数据变更日志实时同步到其他数据系统的能力。本文介绍一些常用的数据集成场景,你可以依据这些场景选择最适合自己的数据集成方案。

## 与 Confluent Cloud 进行数据集成

你可以使用 TiCDC 将 TiDB 的增量数据同步到 Confluent Cloud,并借助 Confluent Cloud 的能力最终将数据分别同步到 ksqlDB、Snowflake、SQL Server。参见[与 Confluent Cloud 进行数据集成](/ticdc/integrate-confluent-using-ticdc.md)

## 与 Apache Kafka 和 Apache Flink 进行数据集成

你可以使用 TiCDC 将 TiDB 的增量数据同步到 Apache Kafka,并使用 Apache Flink 消费 Kafka 中的数据。参见[与 Apache Kafka 和 Apache Flink 进行数据集成](/replicate-data-to-kafka.md)
Binary file added media/integrate/add-snowflake-sink-connector.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/integrate/authentication.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/integrate/configuration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/integrate/confluent-topics.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/integrate/credentials.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/integrate/data-preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/integrate/results.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/integrate/select-from-orders.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/integrate/sql-query-result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/integrate/topic-selection.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 22 additions & 22 deletions migrate-aurora-to-tidb.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ aliases: ['/zh/tidb/dev/migrate-from-aurora-using-lightning/','/docs-cn/dev/migr

## 导入全量数据到 TiDB

### 第 1 步: 导出 Aurora 快照文件到 Amazon S3
### 第 1 步:导出 Aurora 快照文件到 Amazon S3

1. 在 Aurora 上,执行以下命令,查询并记录当前 binlog 位置:

Expand Down Expand Up @@ -47,7 +47,7 @@ aliases: ['/zh/tidb/dev/migrate-from-aurora-using-lightning/','/docs-cn/dev/migr
- 创建快照点时,Aurora binlog 的名称及位置。
- 快照文件的 S3 路径,以及具有访问权限的 SecretKey 和 AccessKey。

### 第 2 步: 导出 schema
### 第 2 步:导出 schema

因为 Aurora 生成的快照文件并不包含建表语句文件,所以你需要使用 Dumpling 自行导出 schema 并使用 Lightning 在下游创建 schema。你也可以跳过此步骤,并以手动方式在下游自行创建 schema。

Expand Down Expand Up @@ -76,9 +76,9 @@ tiup dumpling --host ${host} --port 3306 --user root --password ${password} --fi
|-d 或 --no-data |不导出数据,仅导出 schema|
|-f 或 --filter |导出能匹配模式的表,不可用 -T 一起使用,语法可参考[table filter](/table-filter.md)|

### 第 3 步: 编写 Lightning 配置文件
### 第 3 步:编写 Lightning 配置文件

根据以下内容创建`tidb-lightning.toml` 配置文件:
根据以下内容创建 `tidb-lightning.toml` 配置文件:

{{< copyable "shell-regular" >}}

Expand Down Expand Up @@ -121,7 +121,7 @@ type = '$3'

如果需要在 TiDB 开启 TLS ,请参考 [TiDB Lightning Configuration](/tidb-lightning/tidb-lightning-configuration.md)。

### 第 4 步: 导入全量数据到 TiDB
### 第 4 步:导入全量数据到 TiDB

1. 使用 Lightning 在下游 TiDB 建表:

Expand All @@ -131,7 +131,7 @@ type = '$3'
tiup tidb-lightning -config tidb-lightning.toml -d 's3://my-bucket/schema-backup?region=us-west-2'
```

2. 运行 `tidb-lightning`。如果直接在命令行中启动程序,可能会因为 `SIGHUP` 信号而退出,建议配合`nohup``screen`等工具,如:
2. 运行 `tidb-lightning`。如果直接在命令行中启动程序,可能会因为 `SIGHUP` 信号而退出,建议配合 `nohup``screen` 等工具,如:

将有权限访问该 Amazon S3 后端存储的账号的 SecretKey 和 AccessKey 作为环境变量传入 Lightning 节点。同时还支持从 `~/.aws/credentials` 读取凭证文件。

Expand All @@ -145,11 +145,11 @@ type = '$3'

3. 导入开始后,可以采用以下任意方式查看进度:

- 通过 `grep` 日志关键字 `progress` 查看进度,默认 5 分钟更新一次。
- 通过监控面板查看进度,请参考 [TiDB Lightning 监控](/tidb-lightning/monitor-tidb-lightning.md)。
- 通过 Web 页面查看进度,请参考 [Web 界面](/tidb-lightning/tidb-lightning-web-interface.md)。
- 通过 `grep` 日志关键字 `progress` 查看进度,默认 5 分钟更新一次。
- 通过监控面板查看进度,请参考 [TiDB Lightning 监控](/tidb-lightning/monitor-tidb-lightning.md)。
- 通过 Web 页面查看进度,请参考 [Web 界面](/tidb-lightning/tidb-lightning-web-interface.md)。

4. 导入完毕后,TiDB Lightning 会自动退出。查看日志的最后 5 行中会有 `the whole procedure completed`,则表示导入成功
4. 导入完毕后,TiDB Lightning 会自动退出。查看 `tidb-lightning.log` 日志末尾是否有 `the whole procedure completed` 信息,如果有,表示导入成功。如果没有,则表示导入遇到了问题,可根据日志中的 error 提示解决遇到的问题

> **注意:**
>
Expand All @@ -164,9 +164,9 @@ type = '$3'
- [安装 DM 集群](/dm/deploy-a-dm-cluster-using-tiup.md)
- [获取 DM 所需上下游数据库权限](/dm/dm-worker-intro.md)

### 第 1 步: 创建数据源
### 第 1 步:创建数据源

1. 新建`source1.yaml`文件, 写入以下内容:
1. 新建 `source1.yaml` 文件, 写入以下内容:

{{< copyable "" >}}

Expand Down Expand Up @@ -194,12 +194,12 @@ type = '$3'

该命令中的参数描述如下:

|参数 |描述|
|- |-|
|`--master-addr` |dmctl 要连接的集群的任意 DM-master 节点的 {advertise-addr},例如:172.16.10.71:8261|
|`operate-source create`|向 DM 集群加载数据源|
| 参数 | 描述 |
| - | - |
| `--master-addr` | dmctl 要连接的集群的任意 DM-master 节点的 `{advertise-addr}`,例如:172.16.10.71:8261 |
| `operate-source create` |向 DM 集群加载数据源 |

### 第 2 步: 创建迁移任务
### 第 2 步:创建迁移任务

新建 `task1.yaml` 文件, 写入以下内容:

Expand Down Expand Up @@ -247,7 +247,7 @@ mysql-instances:

以上内容为执行迁移的最小任务配置。关于任务的更多配置项,可以参考 [DM 任务完整配置文件介绍](/dm/task-configuration-file-full.md)

### 第 3 步: 启动任务
### 第 3 步:启动任务

在你启动数据迁移任务之前,建议使用 `check-task` 命令检查配置是否符合 DM 的配置要求,以降低后期报错的概率:

Expand All @@ -269,12 +269,12 @@ tiup dmctl --master-addr ${advertise-addr} start-task task.yaml

|参数|描述|
|-|-|
|`--master-addr`|dmctl 要连接的集群的任意 DM-master 节点的 {advertise-addr},例如: 172.16.10.71:8261|
|`--master-addr`|dmctl 要连接的集群的任意 DM-master 节点的 `{advertise-addr}`,例如:172.16.10.71:8261|
|`start-task`|命令用于创建数据迁移任务|

如果任务启动失败,可根据返回结果的提示进行配置变更后,再次执行上述命令,重新启动任务。遇到问题请参考[故障及处理方法](/dm/dm-error-handling.md)以及[常见问题](/dm/dm-faq.md)。

### 第 4 步: 查看任务状态
### 第 4 步:查看任务状态

如需了解 DM 集群中是否存在正在运行的迁移任务及任务状态等信息,可使用 `tiup dmctl` 执行 `query-status` 命令进行查询:

Expand All @@ -286,13 +286,13 @@ tiup dmctl --master-addr ${advertise-addr} query-status ${task-name}

关于查询结果的详细解读,请参考[查询状态](/dm/dm-query-status.md)。

### 第 5 步: 监控任务与查看日志
### 第 5 步:监控任务与查看日志

要查看迁移任务的历史状态以及更多的内部运行指标,可参考以下步骤。

如果使用 TiUP 部署 DM 集群时,正确部署了 Prometheus、Alertmanager 与 Grafana,则使用部署时填写的 IP 及端口进入 Grafana,选择 DM 的 dashboard 查看 DM 相关监控项。

DM 在运行过程中,DM-worker, DM-master 及 dmctl 都会通过日志输出相关信息。各组件的日志目录如下:
DM 在运行过程中,DM-workerDM-master 及 dmctl 都会通过日志输出相关信息。各组件的日志目录如下:

- DM-master 日志目录:通过 DM-master 进程参数 `--log-file` 设置。如果使用 TiUP 部署 DM,则日志目录默认位于 `/dm-deploy/dm-master-8261/log/`
- DM-worker 日志目录:通过 DM-worker 进程参数 `--log-file` 设置。如果使用 TiUP 部署 DM,则日志目录默认位于 `/dm-deploy/dm-worker-8262/log/`
Expand Down
12 changes: 6 additions & 6 deletions migrate-from-csv-files-to-tidb.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ TiDB Lightning 支持读取 CSV 格式的文件,以及其他定界符格式,
- [安装 TiDB Lightning](/migration-tools.md)
- [获取 Lightning 所需下游数据库权限](/tidb-lightning/tidb-lightning-faq.md#tidb-lightning-对下游数据库的账号权限要求是怎样的)

## 第 1 步: 准备 CSV 文件
## 第 1 步:准备 CSV 文件

将所有要导入的 CSV 文件放在同一目录下,若要 TiDB Lightning 识别所有 CSV 文件,文件名必须满足以下格式:

- 包含整张表数据的 CSV 文件,需命名为 `${db_name}.${table_name}.csv`
- 如果一张表分布于多个 CSV 文件,这些 CSV 文件命名需加上文件编号的后缀,如 `${db_name}.${table_name}.003.csv`。数字部分不需要连续,但必须递增,并且需要用零填充数字部分,保证后缀为同样长度。

## 第 2 步: 创建目标表结构
## 第 2 步:创建目标表结构

CSV 文件自身未包含表结构信息。要将 CSV 数据导入 TiDB,就必须为数据提供表结构。可以通过以下任一方法创建表结构:

Expand All @@ -34,7 +34,7 @@ CSV 文件自身未包含表结构信息。要将 CSV 数据导入 TiDB,就必

* **方法二**:手动在下游 TiDB 建库和表。

## 第 3 步: 编写配置文件
## 第 3 步:编写配置文件

新建文件 `tidb-lightning.toml`,包含以下内容:

Expand Down Expand Up @@ -89,7 +89,7 @@ pd-addr = "${ip}:${port}" # 集群 PD 的地址,Lightning 通过 PD 获取

关于配置文件更多信息,可参阅 [TiDB Lightning 配置参数](/tidb-lightning/tidb-lightning-configuration.md)

## 第 4 步: 导入性能优化(可选)
## 第 4 步:导入性能优化(可选)

导入文件的大小统一约为 256 MiB 时,TiDB Lightning 可达到最佳工作状态。如果导入单个 CSV 大文件,TiDB Lightning 在默认配置下只能使用一个线程来处理,这会降低导入速度。

Expand All @@ -111,7 +111,7 @@ pd-addr = "${ip}:${port}" # 集群 PD 的地址,Lightning 通过 PD 获取
strict-format = true
```

## 第 5 步: 执行导入
## 第 5 步:执行导入

运行 `tidb-lightning`。如果直接在命令行中启动程序,可能会因为 `SIGHUP` 信号而退出,建议配合 `nohup``screen` 等工具,如:

Expand All @@ -127,7 +127,7 @@ nohup tiup tidb-lightning -config tidb-lightning.toml > nohup.out 2>&1 &
- 通过监控面板查看进度,请参考 [TiDB Lightning 监控](/tidb-lightning/monitor-tidb-lightning.md)
- 通过 Web 页面查看进度,请参考 [Web 界面](/tidb-lightning/tidb-lightning-web-interface.md)

导入完毕后,TiDB Lightning 会自动退出。查看日志的最后 5 行中会有 `the whole procedure completed`,则表示导入成功
导入完毕后,TiDB Lightning 会自动退出。查看 `tidb-lightning.log` 日志末尾是否有 `the whole procedure completed` 信息,如果有,表示导入成功。如果没有,则表示导入遇到了问题,可根据日志中的 error 提示解决遇到的问题

> **注意:**
>
Expand Down
4 changes: 2 additions & 2 deletions migrate-from-sql-files-to-tidb.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pd-addr = "${ip}:${port}" # 集群 PD 的地址,Lightning 通过 PD 获取

运行 `tidb-lightning`。如果直接在命令行中启动程序,可能会因为 `SIGHUP` 信号而退出,建议配合 `nohup``screen` 等工具。

若从 S3 导入,则需将有权限访问该 Amazon S3 后端存储的账号的 SecretKey 和 AccessKey 作为环境变量传入 Lightning 节点。
若从 Amazon S3 导入,则需将有权限访问该 S3 后端存储的账号的 SecretKey 和 AccessKey 作为环境变量传入 Lightning 节点。

{{< copyable "shell-regular" >}}

Expand All @@ -89,7 +89,7 @@ nohup tiup tidb-lightning -config tidb-lightning.toml > nohup.out 2>&1 &
- 通过监控面板查看进度,请参考 [TiDB Lightning 监控](/tidb-lightning/monitor-tidb-lightning.md)
- 通过 Web 页面查看进度,请参考 [Web 界面](/tidb-lightning/tidb-lightning-web-interface.md)

导入完毕后,TiDB Lightning 会自动退出。查看日志的最后 5 行中会有 `the whole procedure completed`,则表示导入成功
导入完毕后,TiDB Lightning 会自动退出。查看 `tidb-lightning.log` 日志末尾是否有 `the whole procedure completed` 信息,如果有,表示导入成功。如果没有,则表示导入遇到了问题,可根据日志中的 error 提示解决遇到的问题

> **注意:**
>
Expand Down
Loading

0 comments on commit 9d231a0

Please sign in to comment.