Skip to content

Commit e48c88b

Browse files
TomShawnyikekelilin90
authored
lightning: add docs for local backend (pingcap#3660)
* lightning: add docs for local backend * Update tidb-lightning-faq.md * refine headings * Apply suggestions from code review Co-authored-by: Keke Yi <[email protected]> * Update tidb-lightning/deploy-tidb-lightning.md * add back mistakenly deleted content * Apply suggestions from code review Co-authored-by: Keke Yi <[email protected]> * change "import modes" to "backend" * Update tidb-lightning-backends.md * move "what backend can do" * Apply suggestions from code review Co-authored-by: Keke Yi <[email protected]> Co-authored-by: Keke Yi <[email protected]> Co-authored-by: Lilian Lee <[email protected]>
1 parent 9e728a0 commit e48c88b

17 files changed

+562
-431
lines changed

TOC.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@
187187
+ [Checkpoints](/tidb-lightning/tidb-lightning-checkpoints.md)
188188
+ [Table Filter](/table-filter.md)
189189
+ [CSV Support](/tidb-lightning/migrate-from-csv-using-tidb-lightning.md)
190-
+ [TiDB-backend](/tidb-lightning/tidb-lightning-tidb-backend.md)
190+
+ [Backends](/tidb-lightning/tidb-lightning-backends.md)
191191
+ [Web Interface](/tidb-lightning/tidb-lightning-web-interface.md)
192192
+ [Monitor](/tidb-lightning/monitor-tidb-lightning.md)
193193
+ [Troubleshoot](/troubleshoot-tidb-lightning.md)

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,4 @@ The steps to manually modify the GC time are as follows:
8383

8484
## Restore data into TiDB
8585

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).
86+
To restore data into TiDB, use TiDB Lightning to import the exported data. See [TiDB Lightning Tutorial](/tidb-lightning/tidb-lightning-backends.md).

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,4 @@ Then execute two more commands:
9393

9494
## Restore data into TiDB
9595

96-
To restore data into TiDB, use TiDB Lightning to import the exported data. See [TiDB Lightning Tutorial](/tidb-lightning/tidb-lightning-tidb-backend.md).
96+
To restore data into TiDB, use TiDB Lightning to import the exported data. See [TiDB Lightning Tutorial](/tidb-lightning/tidb-lightning-backends.md).

dumpling-overview.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ The above command exports all the tables in the `employees` database and the `Wo
123123
Dumpling can also export specific databases with the `-B` option or specific tables with the `-T` option.
124124

125125
> **Note:**
126-
>
126+
>
127127
> - The `--filter` option and the `-T` option cannot be used at the same time.
128128
> - The `-T` option can only accept a complete form of inputs like `database-name.table-name`, and inputs with only the table name are not accepted. Example: Dumpling cannot recognize `-T WorkOrder`.
129129
@@ -210,7 +210,7 @@ After your operation is completed, set the GC time back (the default value is `1
210210
update mysql.tidb set VARIABLE_VALUE = '10m' where VARIABLE_NAME = 'tikv_gc_life_time';
211211
```
212212

213-
Finally, all the exported data can be imported back to TiDB using [Lightning](/tidb-lightning/tidb-lightning-tidb-backend.md).
213+
Finally, all the exported data can be imported back to TiDB using [Lightning](/tidb-lightning/tidb-lightning-backends.md).
214214

215215
## Option list of Dumpling
216216

ecosystem-tool-user-guide.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ aliases: ['/docs/dev/ecosystem-tool-user-guide/','/docs/dev/reference/tools/user
77

88
This document introduces the functionalities of TiDB ecosystem tools and their relationship.
99

10-
## Full data export
10+
## Full data export
1111

1212
[Dumpling](/dumpling-overview.md) is a tool for the logical full data export from MySQL or TiDB.
1313

@@ -22,10 +22,11 @@ The following are the basics of Dumpling:
2222

2323
[TiDB Lightning](/tidb-lightning/tidb-lightning-overview.md) (Lightning) is a tool used for the full import of large amounts of data into a TiDB cluster. Currently, TiDB Lightning supports reading SQL dump exported via Dumpling or CSV data source.
2424

25-
TiDB Lightning supports two modes:
25+
TiDB Lightning supports three modes:
2626

27-
- `importer`: This mode uses tikv-importer as the backend, which is usually for importing a large amount of data (at the TB level). During the import, the cluster cannot provide services.
28-
- `tidb`: This mode uses TiDB/MySQL as the backend, which is slower than the `importer` mode but can be performed online. It also supports importing data to MySQL.
27+
- `local`: TiDB Lightning parses data into ordered key-value pairs and directly imports them into TiKV. This mode is usually for importing a large amount of data (at the TB level) to a new cluster. During the import, the cluster cannot provide services.
28+
- `importer`: This mode is similar to the `local` mode. To use this mode, you need to deploy an additional component `tikv-importer` to help import key-value pairs. If the target cluster is in v4.0 or later versions, it is recommended to use the `local` mode.
29+
- `tidb`: This mode uses TiDB/MySQL as the backend, which is slower than the `local` mode and `importer` mode but can be performed online. It also supports importing data to MySQL.
2930

3031
The following are the basics of TiDB Lightning:
3132

@@ -37,7 +38,7 @@ The following are the basics of TiDB Lightning:
3738

3839
> **Note:**
3940
>
40-
> The Loader tool is no longer maintained. For scenarios related to Loader, it is recommended that you use the `tidb` mode of TiDB Lighting instead.
41+
> The Loader tool is no longer maintained. For scenarios related to Loader, it is recommended that you use the `tidb` mode of TiDB Lighting instead. For details, see [TiDB Lightning TiDB backends](/tidb-lightning/tidb-lightning-backends.md#migrating-from-loader-to-tidb-lightning-tidb-backend).
4142
4243
## Backup and restore
4344

get-started-with-tidb-lightning.md

+36-48
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,11 @@ aliases: ['/docs/dev/get-started-with-tidb-lightning/','/docs/dev/how-to/get-sta
1111
+ Import **large amounts** of **new** data **quickly**
1212
+ Back up and restore all the data
1313

14-
The TiDB Lightning tool set consists of two components:
15-
16-
- **`tidb-lightning`** (the "front end") reads the data source and imports the database structure into the TiDB cluster, and also transforms the data into Key-Value (KV) pairs and sends them to `tikv-importer`.
17-
18-
- **`tikv-importer`** (the "back end") combines and sorts the KV pairs and then imports these sorted pairs as a whole into the TiKV cluster.
19-
2014
![Architecture of TiDB Lightning tool set](/media/tidb-lightning-architecture.png)
2115

2216
## Prerequisites
2317

24-
This tutorial assumes you use several new and clean CentOS 7 instances. You can use VMware, VirtualBox or other tools to deploy a virtual machine locally or a small cloud virtual machine on a vendor-supplied platform. Because TiDB Lightning consumes a large amount of computer resources, it is recommended that you allocate at least 4 GB memory for running it.
18+
This tutorial assumes you use several new and clean CentOS 7 instances. You can use VMware, VirtualBox or other tools to deploy a virtual machine locally or a small cloud virtual machine on a vendor-supplied platform. Because TiDB Lightning consumes a large amount of computer resources, it is recommended that you allocate at least 16 GB memory and CPU of 32 cores for running it with the best performance.
2519

2620
> **Warning:**
2721
>
@@ -51,69 +45,63 @@ After executing this command, the full backup data is exported to the `/data/my_
5145

5246
### Step 1: Deploy TiDB cluster
5347

54-
Before the data import, you need to deploy a TiDB cluster (later than v2.0.9). In this tutorial, TiDB v3.0.4 is used. For the deployment method, refer to [TiDB Introduction](/overview.md).
48+
Before the data import, you need to deploy a TiDB cluster (later than v2.0.9). In this tutorial, TiDB v4.0.3 is used. For the deployment method, refer to [TiDB Introduction](/overview.md).
5549

5650
### Step 2: Download TiDB Lightning installation package
5751

5852
Download the TiDB Lightning installation package from the following link:
5953

60-
- **v3.0.4**: [tidb-toolkit-v3.0.4-linux-amd64.tar.gz](https://download.pingcap.org/tidb-toolkit-v3.0.0-linux-amd64.tar.gz)
54+
- **v4.0.3**: [tidb-toolkit-v4.0.3-linux-amd64.tar.gz](https://download.pingcap.org/tidb-toolkit-v4.0.3-linux-amd64.tar.gz)
6155

6256
> **Note:**
6357
>
6458
> Choose the same version of TiDB Lightning as that of the TiDB cluster.
6559
66-
### Step 3: Start `tikv-importer`
67-
68-
1. Upload `bin/tikv-importer` in the package to the server where TiDB Lightning is deployed.
60+
### Step 3: Start `tidb-lightning`
6961

70-
2. Configure `tikv-importer.toml`.
62+
1. Upload `bin/tidb-lightning` and `bin/tidb-lightning-ctl` in the package to the server where TiDB Lightning is deployed.
63+
2. Upload the [prepared data source](#prepare-full-backup-data) to the server.
64+
3. Configure `tidb-lightning.toml` as follows:
7165

7266
```toml
73-
# The template of the tikv-importer configuration file
74-
75-
# Log file
76-
log-file = "tikv-importer.log"
77-
# Log level: "trace", "debug", "info", "warn", "error" or "off"
78-
log-level = "info"
79-
80-
[server]
81-
# The listening address of tikv-importer. tidb-lightning connects to this address for data write.
82-
addr = "192.168.20.10:8287"
83-
84-
[import]
85-
# The directory of the engine file.
86-
import-dir = "/mnt/ssd/data.import/"
67+
[lightning]
68+
# logging
69+
level = "info"
70+
file = "tidb-lightning.log"
71+
72+
[tikv-importer]
73+
# Uses the Local-backend
74+
backend = "local"
75+
# Sets the directory for temporarily storing the sorted key-value pairs.
76+
# The target directory must be empty.
77+
"sorted-kv-dir" = "/mnt/ssd/sorted-kv-dir"
78+
79+
[mydumper]
80+
# Mydumper local source data directory
81+
data-source-dir = "/data/my_datasource/"
82+
83+
[tidb]
84+
# Information of the target cluster
85+
host = "172.16.31.2"
86+
port = 4000
87+
user = "root"
88+
password = "rootroot"
89+
# Table schema information is fetched from TiDB via this status-port.
90+
status-port = 10080
91+
# The PD address of the cluster
92+
pd-addr = "172.16.31.3:2379"
8793
```
8894

89-
3. Run `tikv-importer`:
90-
91-
{{< copyable "shell-regular" >}}
92-
93-
```sh
94-
nohup ./tikv-importer -C tikv-importer.toml > nohup.out &
95-
```
96-
97-
### Step 4: Start `tidb-lightning`
98-
99-
1. Upload `bin/tidb-lightning` and `bin/tidb-lightning-ctl` in the installation package to the server where TiDB Lightning is deployed.
100-
2. Upload the [prepared data source](#prepare-full-backup-data) to the server.
101-
3. After configuring the parameters properly, use a `nohup` command to start the `tidb-lightning` process. If you directly run the command in the command-line, the process might exit because of the SIGHUP signal received. Instead, it's preferable to run a bash script that contains the `nohup` command:
95+
4. After configuring the parameters properly, use a `nohup` command to start the `tidb-lightning` process. If you directly run the command in the command-line, the process might exit because of the SIGHUP signal received. Instead, it's preferable to run a bash script that contains the `nohup` command:
10296

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

10599
```sh
106100
#!/bin/bash
107-
nohup ./tidb-lightning \
108-
--importer 172.16.31.10:8287 \
109-
-d /data/my_database/ \
110-
--tidb-host 172.16.31.2 \
111-
--tidb-user root \
112-
--log-file tidb-lightning.log \
113-
> nohup.out &
101+
nohup ./tidb-lightning -config tidb-lightning.toml > nohup.out &
114102
```
115103

116-
### Step 5: Check data integrity
104+
### Step 4: Check data integrity
117105

118106
After the import is completed, TiDB Lightning exits automatically. If the import is successful, you can find `tidb lightning exit` in the last line of the log file.
119107

loader-overview.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ aliases: ['/docs/dev/loader-overview/','/docs/dev/reference/tools/loader/','/doc
88

99
> **Warning:**
1010
>
11-
> Loader is no longer maintained. Its features are completely superseded by [TiDB Lightning TiDB-backend](/tidb-lightning/tidb-lightning-tidb-backend.md). It is strongly recommend to use TiDB Lightning instead.
11+
> Loader is no longer maintained. Its features are completely superseded by [TiDB Lightning TiDB-backend](/tidb-lightning/tidb-lightning-backends.md#tidb-lightning-tidb-backend). It is strongly recommend to use TiDB Lightning instead.
1212
1313
## What is Loader?
1414

media/tidb-lightning-architecture.png

7.22 KB
Loading

migrate-from-mysql-mydumper-files.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ Before you start the migration, [deploy TiDB Lightning](/tidb-lightning/deploy-t
1616

1717
> **Note:**
1818
>
19-
> - If you choose the Importer-backend to import data, you need to deploy `tikv-importer` along with TiDB Lightning. During the import process, the TiDB cluster cannot provide services. This mode imports data quickly, which is suitable for importing a large amount of data (above the TB level).
20-
> - If you choose the TiDB-backend, deploy TiDB Lightning only. The cluster can provide services normally during the import.
21-
> - For detailed differences between the two backend mode, see [TiDB Lightning Backend](/tidb-lightning/tidb-lightning-tidb-backend.md).
19+
> - If you choose the Local-backend to import data, the TiDB cluster cannot provide services during the import process. This mode imports data quickly, which is suitable for importing a large amount of data (above the TB level).
20+
> - If you choose the TiDB-backend, the cluster can provide services normally during the import, at a slower import speed.
21+
> - For detailed differences between the two backend modes, see [TiDB Lightning Backends](/tidb-lightning/tidb-lightning-backends.md).
2222
2323
## Step 2: Configure data source of TiDB Lightning
2424

0 commit comments

Comments
 (0)