Skip to content

Commit 0ad1a6a

Browse files
yikekelichunzhulilin90
authored
add dumpling into tidb tools (pingcap#3453)
* align the structure of pingcap/docs-cn#3800 * revert * Update dumpling-overview.md * Update dumpling-overview.md * update backup-and-restore-using-dumpling-lightning.md * ADD summary * fix an anchor * Update dumpling-overview.md Co-authored-by: Chunzhu Li <[email protected]> * Apply suggestions from code review * Apply suggestions from code review Co-authored-by: Chunzhu Li <[email protected]> * Update dumpling-overview.md Co-authored-by: Chunzhu Li <[email protected]> * Apply suggestions from code review Co-authored-by: Chunzhu Li <[email protected]> * Apply suggestions from code review * Update dumpling-overview.md * parameter -> option * Update note format and add inline code format * fix 2 dead links from upstream Co-authored-by: Chunzhu Li <[email protected]> Co-authored-by: Lilian Lee <[email protected]>
1 parent a8b465d commit 0ad1a6a

13 files changed

+382
-199
lines changed

TOC.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@
6262
+ [Use TiDB Ansible](/scale-tidb-using-ansible.md)
6363
+ [Use TiDB Operator](https://docs.pingcap.com/tidb-in-kubernetes/v1.1/scale-a-tidb-cluster)
6464
+ Backup and Restore
65-
+ [Use Mydumper and TiDB Lightning](/backup-and-restore-using-mydumper-lightning.md)
66-
+ [Use Dumpling for Export or Backup](/export-or-backup-using-dumpling.md)
67-
+ Use BR Tool
65+
+ Use BR Tool (Recommended)
6866
+ [Use BR Tool](/br/backup-and-restore-tool.md)
6967
+ [BR Use Cases](/br/backup-and-restore-use-cases.md)
7068
+ [BR storages](/br/backup-and-restore-storages.md)
69+
+ [Use Dumpling and TiDB Lightning (Recommended)](/backup-and-restore-using-dumpling-lightning.md)
70+
+ [Use Mydumper and TiDB Lightning](/backup-and-restore-using-mydumper-lightning.md)
7171
+ [Read Historical Data](/read-historical-data.md)
7272
+ [Configure Time Zone](/configure-time-zone.md)
7373
+ [Daily Checklist](/daily-check.md)
@@ -186,6 +186,7 @@
186186
+ [FAQ](/tidb-lightning/tidb-lightning-faq.md)
187187
+ [Glossary](/tidb-lightning/tidb-lightning-glossary.md)
188188
+ [TiCDC](/ticdc/ticdc-overview.md)
189+
+ [Dumpling](/dumpling-overview.md)
189190
+ sync-diff-inspector
190191
+ [Overview](/sync-diff-inspector/sync-diff-inspector-overview.md)
191192
+ [Data Check for Tables with Different Schema/Table Names](/sync-diff-inspector/route-diff.md)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
---
2+
title: Use Dumpling and TiDB Lightning for Data Backup and Restoration
3+
summary: Introduce how to use Dumpling and TiDB Lightning to backup and restore full data of TiDB.
4+
aliases: ['/docs-cn/dev/export-or-backup-using-dumpling/','/zh/tidb/dev/export-or-backup-using-dumpling']
5+
---
6+
7+
# Use Dumpling and TiDB Lightning for Data Backup and Restoration
8+
9+
This document introduces in detail how to use Dumpling and TiDB Lightning to backup and restore full data of TiDB. For incremental backup and replication to downstream, refer to [TiDB Binlog](/tidb-binlog/tidb-binlog-overview.md).
10+
11+
Suppose that the TiDB server information is as follows:
12+
13+
|Server Name|Server Address|Port|User|Password|
14+
|----|-------|----|----|--------|
15+
|TiDB|127.0.0.1|4000|root|*|
16+
17+
Use the following tools for data backup and restoration:
18+
19+
- [Dumpling](/dumpling-overview.md): to export data from TiDB
20+
- [TiDB Lightning](/tidb-lightning/tidb-lightning-overview.md): to import data into TiDB
21+
22+
## Best practices for full backup and restoration using Dumpling/TiDB Lightning
23+
24+
To quickly backup and restore data (especially large amounts of data), refer to the following recommendations:
25+
26+
* Keep the exported data file as small as possible. It is recommended to use the `-F` option of Dumpling to set the file size. If you use TiDB Lightning to restore data, it is recommended that you set the value of `-F` to `256m`.
27+
* If some of the exported tables have many rows, you can enable concurrency in the table by setting the `-r` option.
28+
29+
## Backup data from TiDB
30+
31+
Use the following `dumpling` command to backup data from TiDB.
32+
33+
{{< copyable "shell-regular" >}}
34+
35+
```bash
36+
./bin/dumpling -h 127.0.0.1 -P 4000 -u root -t 32 -F 256m -T test.t1 -T test.t2 -o ./var/test
37+
```
38+
39+
In this command:
40+
41+
- `-T test.t1 -T test.t2` means that only the two tables `test`.`t1` and `test`.`t2` are exported. For more methods to filter exported data, refer to [Filter exported data](/dumpling-overview.md#filter-the-exported-data).
42+
- `-t 32` means that 32 threads are used to export the data.
43+
- `-F 256m` means that a table is partitioned into chunks, and one chunk is 256MB.
44+
45+
Starting from v4.0.0, Dumpling can automatically extends the GC time if it can access the PD address of the TiDB cluster. But for TiDB earlier than v4.0.0, you need to manually modify the GC time. Otherwise, you might bump into the following error:
46+
47+
```log
48+
Could not read data from testSchema.testTable: GC life time is shorter than transaction duration, transaction starts at 2019-08-05 21:10:01.451 +0800 CST, GC safe point is 2019-08-05 21:14:53.801 +0800 CST
49+
```
50+
51+
The steps to manually modify the GC time are as follows:
52+
53+
1. Before executing the `dumpling` command, query the [GC](/garbage-collection-overview.md) value of the TiDB cluster and execute the following statement in the MySQL client to adjust it to a suitable value:
54+
55+
{{< copyable "sql" >}}
56+
57+
```sql
58+
SELECT * FROM mysql.tidb WHERE VARIABLE_NAME = 'tikv_gc_life_time';
59+
```
60+
61+
```sql
62+
+-----------------------+------------------------------------------------------------------------------------------------+
63+
| VARIABLE_NAME | VARIABLE_VALUE |
64+
+-----------------------+------------------------------------------------------------------------------------------------+
65+
| tikv_gc_life_time | 10m0s |
66+
+-----------------------+------------------------------------------------------------------------------------------------+
67+
1 rows in set (0.02 sec)
68+
```
69+
70+
{{< copyable "sql" >}}
71+
72+
```sql
73+
update mysql.tidb set VARIABLE_VALUE = '720h' where VARIABLE_NAME = 'tikv_gc_life_time';
74+
```
75+
76+
2. After executing the `dumpling` command, restore the GC value of the TiDB cluster to the initial value in step 1:
77+
78+
{{< copyable "sql" >}}
79+
80+
```sql
81+
update mysql.tidb set VARIABLE_VALUE = '10m' where VARIABLE_NAME = 'tikv_gc_life_time';
82+
```
83+
84+
## Restore data into TiDB
85+
86+
To restore data into TiDB, use TiDB Lightning to import the exported data. See [TiDB Lightning Tutorial](/tidb-lightning/tidb-lightning-tidb-backend.md).

backup-and-restore-using-mydumper-lightning.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ aliases: ['/docs/dev/backup-and-restore-using-mydumper-lightning/','/docs/dev/ho
77

88
This document describes how to perform full backup and restoration of the TiDB data using Mydumper and TiDB Lightning. For incremental backup and restoration, refer to [TiDB Binlog](/tidb-binlog/tidb-binlog-overview.md).
99

10-
Suppose that the TiDB service information is as follows:
10+
Suppose that the TiDB server information is as follows:
1111

12-
|Name|Address|Port|User|Password|
12+
|Server Name|Server Address|Port|User|Password|
1313
|:----|:-------|:----|:----|:--------|
1414
|TiDB|127.0.0.1|4000|root|*|
1515

@@ -32,25 +32,25 @@ Use [Mydumper](/mydumper-overview.md) to export data from TiDB and use [TiDB Lig
3232

3333
To quickly backup and restore data (especially large amounts of data), refer to the following recommendations:
3434

35-
* Keep the exported data file as small as possible. It is recommended to use the `-F` parameter to set the file size. If you use TiDB Lightning to restore data, it is recommended that you set the value of `-F` to `256` (MB). If you use `loader` for restoration, it is recommended to set the value to `64` (MB).
35+
* Keep the exported data file as small as possible. It is recommended to use the `-F` option of Mydumper to set the file size. If you use TiDB Lightning to restore data, it is recommended that you set the value of `-F` to `256` (MB). If you use `loader` for restoration, it is recommended to set the value to `64` (MB).
3636

3737
## Backup data from TiDB
3838

39-
Use `mydumper` to backup data from TiDB.
39+
Use the following `mydumper` command to backup data from TiDB:
4040

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

4343
```bash
4444
./bin/mydumper -h 127.0.0.1 -P 4000 -u root -t 32 -F 256 -B test -T t1,t2 --skip-tz-utc -o ./var/test
4545
```
4646

47-
In this command,
47+
In this command:
4848

49-
`-B test` means that the data is exported from the `test` database.
50-
`-T t1,t2` means that only the `t1` and `t2` tables are exported.
51-
`-t 32` means that 32 threads are used to export the data.
52-
`-F 256` means that a table is partitioned into chunks, and one chunk is 256MB.
53-
`--skip-tz-utc` means to ignore the inconsistency of time zone setting between MySQL and the data exporting machine and to disable automatic conversion.
49+
- `-B test` means that the data is exported from the `test` database.
50+
- `-T t1,t2` means that only the `t1` and `t2` tables are exported.
51+
- `-t 32` means that 32 threads are used to export the data.
52+
- `-F 256` means that a table is partitioned into chunks, and one chunk is 256MB.
53+
- `--skip-tz-utc` means to ignore the inconsistency of time zone setting between MySQL and the data exporting machine and to disable automatic conversion.
5454

5555
If `mydumper` returns the following error:
5656

br/backup-and-restore-tool.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ aliases: ['/docs/dev/br/backup-and-restore-tool/','/docs/dev/reference/tools/br/
66

77
# Use BR to Back up and Restore Data
88

9-
[Backup & Restore](http://github.com/pingcap/br) (BR) is a command-line tool for distributed backup and restoration of the TiDB cluster data. Compared with [`dumpling`](/export-or-backup-using-dumpling.md) and [`mydumper`/`loader`](/backup-and-restore-using-mydumper-lightning.md), BR is more suitable for scenarios of huge data volume. This document describes the BR command line, detailed use examples, best practices, restrictions, and introduces the implementation principles of BR.
9+
[Backup & Restore](http://github.com/pingcap/br) (BR) is a command-line tool for distributed backup and restoration of the TiDB cluster data. Compared with [`dumpling`](/backup-and-restore-using-dumpling-lightning.md) and [`mydumper`/`loader`](/backup-and-restore-using-mydumper-lightning.md), BR is more suitable for scenarios of huge data volume. This document describes the BR command line, detailed use examples, best practices, restrictions, and introduces the implementation principles of BR.
1010

1111
## Usage restrictions
1212

download-ecosystem-tools.md

+14
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,20 @@ Download [DM](https://docs.pingcap.com/tidb-data-migration/v1.0/overview) by usi
5959
>
6060
> `{version}` in the above download link indicates the version number of DM. For example, the download link for `v1.0.1` is `https://download.pingcap.org/dm-v1.0.1-linux-amd64.tar.gz`. You can check the published DM versions in the [DM Release](https://github.com/pingcap/dm/releases) page.
6161
62+
## Dumpling
63+
64+
Download [Dumpling](/dumpling-overview.md) from the links below:
65+
66+
| Installation package | Operating system | Architecture | SHA256 checksum |
67+
|:---|:---|:---|:---|
68+
| `https://download.pingcap.org/tidb-toolkit-{version}-linux-amd64.tar.gz` | Linux | amd64 | `https://download.pingcap.org/tidb-toolkit-{version}-linux-amd64.sha256` |
69+
70+
> **Note:**
71+
>
72+
> The `{version}` in the download link is the version number of Dumpling. For example, the link for downloading the `v4.0.2` version of Dumpling is `https://download.pingcap.org/tidb-toolkit-v4.0.2-linux-amd64.tar.gz`. You can view the currently released versions in [Dumpling Releases](https://github.com/pingcap/dumpling/releases).
73+
>
74+
> Dumpling supports arm64 linux. You can replace `amd64` in the download link with `arm64`, which means the `arm64` version of Dumpling.
75+
6276
## Syncer, Loader, and Mydumper
6377

6478
If you want to download the latest version of [Syncer](/syncer-overview.md), [Loader](/loader-overview.md), or [Mydumper](/mydumper-overview.md), directly download the tidb-enterprise-tools package, because all these tools are included in this package.

0 commit comments

Comments
 (0)