TiDB Lightning Command Line Flags

You can configure TiDB Lightning either using the configuration file or in command line. This document describes the command line flags of TiDB Lightning.

Command line flags

tidb-lightning

You can configure the following parameters using tidb-lightning:

ParameterDescriptionCorresponding configuration item
--config <file>Read the global configuration from the file. If this parameter is not specified, TiDB Lightning uses the default configuration.
-VPrint the program version.
-d <directory>Local directory or external storage URI of data files.mydumper.data-source-dir
-L <level>Log level: debug, info, warn, error, or fatal. info by default.lightning.level
-f <rule>Table filter rules. Can be specified multiple times.mydumper.filter
--backend <backend>Select an import mode. local refers to physical import mode; tidb refers to logical import mode.tikv-importer.backend
--log-file <file>Log file path. By default, it is /tmp/lightning.log.{timestamp}. If set to '-', it means that the log files will be output to stdout.lightning.log-file
--status-addr <ip:port>Listening address of the TiDB Lightning serverlightning.status-port
--pd-urls <host1:port1,host2:port2,...,hostn:portn>PD endpoint address. Starting from v7.6.0, TiDB supports setting multiple PD addresses.tidb.pd-addr
--tidb-host <host>TiDB server hosttidb.host
--tidb-port <port>TiDB server port (default = 4000)tidb.port
--tidb-status <port>TiDB status port (default = 10080)tidb.status-port
--tidb-user <user>User name to connect to TiDBtidb.user
--tidb-password <password>Password to connect to TiDB. The password can either be plaintext or Base64 encoded.tidb.password
--enable-checkpoint <bool>Whether to enable checkpoints (default = true)checkpoint.enable
--analyze <level>Analyze tables after importing. Available values are "required", "optional" (default value), and "off".post-restore.analyze
--checksum <level>Compare checksum after importing. Available values are "required" (default value), "optional", and "off".post-restore.checksum
--check-requirements <bool>Check cluster version compatibility before starting the task, and check whether TiKV has more than 10% free space left during running time. (default = true)lightning.check-requirements
--ca <file>CA certificate path for TLS connectionsecurity.ca-path
--cert <file>Certificate path for TLS connectionsecurity.cert-path
--key <file>Private key path for TLS connectionsecurity.key-path
--server-modeStart TiDB Lightning in server modelightning.server-mode

If you specify both a command line parameter and the corresponding setting in the configuration file, the command line parameter takes precedence. For example, running ./tidb-lightning -L debug --config cfg.toml would always set the log level to "debug" regardless of the content of cfg.toml.

tidb-lightning-ctl

All parameters of tidb-lightning apply to tidb-lightning-ctl. In addition, you can also configure the following parameters using tidb-lightning-ctl:

ParameterDescription
--compactPerform a full compaction.
--switch-mode <mode>Switch every TiKV store to the given mode: normal or import.
--fetch-modePrint the current mode of every TiKV store.
--import-engine <uuid>Import the closed engine file from TiKV Importer into the TiKV cluster.
--cleanup-engine <uuid>Delete the engine file from TiKV Importer.
--checkpoint-dump <folder>Dump current checkpoint as CSVs into the folder.
--checkpoint-error-destroy <table_name>Remove the checkpoint. If it causes an error, drop the table.
--checkpoint-error-ignore <table_name>Ignore any error recorded in the checkpoint involving the given table.
--checkpoint-remove <table_name>Unconditionally remove the checkpoint of the table.

The <table_name> must either be a qualified table name in the form `db`.`tbl` (including the backquotes), or the keyword all.