【 TiDB 使用环境】生产环境
【 TiDB 版本】v6.4.0
【复现路径】做过哪些操作出现的问题
单机部署1tidb server 3tikv 1pd 实例,tikv数据实例达到磁盘100%,需要扩容。由于磁盘规划格式化问题,需要协助集群,重装。先利用tiup dumpling导出已有的数据到本地,后来发现参考网上导出命令时,误用了output-filename-template参数。运行命令如下(ip等信息已隐):
tiup dumpling -u root -P 4000 -h 10.xx.xx.xxx -o /opt/ccc/data/export/ -r 200000 -t 16 --filetype sql --compress gzip --database db1,test -F 256MiB --output-filename-template ‘tidb-test.{{.Index}}’
导出完之后,便将tidb集群数据清理和卸载了,然后调整拓扑文件之后,重新部署了集群,现使用tiup lighting工具导入数据时,没报错,但是没导入数据。命令如下:
nohup tiup tidb-lightning -no-schema -config tidb-lightning.toml > nohup.out &
运行结果日志:
[2023/03/24 12:53:34.938 +08:00] [WARN] [config.go:827] [“currently only per-task configuration can be applied, global configuration changes can only be made on startup”] [“global config changes”=“[lightning.level,lightning.file]”]
[2023/03/24 12:53:34.939 +08:00] [INFO] [lightning.go:382] [cfg] [cfg=“{"id":1679633614939008092,"lightning":{"table-concurrency":6,"index-concurrency":2,"region-concurrency":88,"io-concurrency":5,"check-requirements":true,"meta-schema-name":"lightning_metadata","max-error":{"type":0},"task-info-schema-name":"lightning_task_info"},"tidb":{"host":"10.xx.xx.xx","port":4000,"user":"root","status-port":10080,"pd-addr":"10.xx.xx.xx:2379","sql-mode":"ONLY_FULL_GROUP_BY,NO_AUTO_CREATE_USER","tls":"false","security":{"ca-path":"","cert-path":"","key-path":"","redact-info-log":false},"max-allowed-packet":67108864,"distsql-scan-concurrency":15,"build-stats-concurrency":20,"index-serial-scan-concurrency":20,"checksum-table-concurrency":2,"vars":null},"checkpoint":{"schema":"tidb_lightning_checkpoint","driver":"file","enable":true,"keep-after-success":"remove"},"mydumper":{"read-block-size":65536,"batch-size":0,"batch-import-ratio":0,"source-id":"","data-source-dir":"file:///opt/ccc/data1/export","character-set":"auto","csv":{"separator":",","delimiter":"\"","terminator":"","null":"\\N","header":true,"trim-last-separator":false,"not-null":false,"backslash-escape":true},"max-region-size":268435456,"filter":["!mysql.","!sys.","!INFORMATION_SCHEMA.","!PERFORMANCE_SCHEMA.","!METRICS_SCHEMA.","!INSPECTION_SCHEMA."],"files":null,"no-schema":true,"case-sensitive":false,"strict-format":false,"default-file-rules":true,"ignore-data-columns":null,"data-character-set":"binary","data-invalid-char-replace":"�"},"tikv-importer":{"addr":"","backend":"local","on-duplicate":"replace","max-kv-pairs":4096,"send-kv-pairs":32768,"region-split-size":0,"region-split-keys":0,"sorted-kv-dir":"/opt/ccc/data/sorted-kv-dir","disk-quota":9223372036854775807,"range-concurrency":16,"duplicate-resolution":"none","incremental-import":false,"engine-mem-cache-size":536870912,"local-writer-mem-cache-size":134217728,"store-write-bwlimit":0},"post-restore":{"checksum":"required","analyze":"optional","level-1-compact":false,"post-process-at-last":true,"compact":false},"cron":{"switch-mode":"5m0s","log-progress":"5m0s","check-disk-quota":"1m0s"},"routes":null,"security":{"ca-path":"","cert-path":"","key-path":"","redact-info-log":false},"black-white-list":{"do-tables":null,"do-dbs":null,"ignore-tables":null,"ignore-dbs":null}}”]
[2023/03/24 12:53:34.959 +08:00] [INFO] [lightning.go:483] [“load data source start”]
[2023/03/24 12:53:34.974 +08:00] [INFO] [loader.go:450] [“[loader] file is filtered by file router”] [path=metadata]
[2023/03/24 12:53:35.546 +08:00] [INFO] [lightning.go:486] [“load data source completed”] [takeTime=587.32434ms] []
[2023/03/24 12:53:35.546 +08:00] [INFO] [checkpoints.go:1014] [“open checkpoint file failed, going to create a new one”] [path=/tmp/tidb_lightning_checkpoint.pb] []
[2023/03/24 12:53:35.554 +08:00] [INFO] [local.go:578] [“multi ingest support”]
[2023/03/24 12:53:35.554 +08:00] [INFO] [restore.go:448] [“the whole procedure start”]
[2023/03/24 12:53:35.556 +08:00] [INFO] [restore.go:1995] [new_collation_enabled] [enabled=true]
[2023/03/24 12:53:35.556 +08:00] [INFO] [restore.go:756] [“restore all schema start”]
[2023/03/24 12:53:35.556 +08:00] [INFO] [restore.go:772] [“restore all schema completed”] [takeTime=82.701µs] []
[2023/03/24 12:53:35.562 +08:00] [INFO] [version.go:398] [“detect server version”] [type=TiDB] [version=6.4.0]
[2023/03/24 12:53:35.563 +08:00] [INFO] [version.go:398] [“detect server version”] [type=TiDB] [version=6.4.0]
[2023/03/24 12:53:35.567 +08:00] [INFO] [restore.go:1424] [“restore all tables data start”]
[2023/03/24 12:53:35.569 +08:00] [INFO] [restore.go:1309] [“cancel periodic actions”] [do=true]
[2023/03/24 12:53:35.569 +08:00] [INFO] [restore.go:1869] [“switch import mode”] [mode=Import]
[2023/03/24 12:53:35.569 +08:00] [INFO] [restore.go:1869] [“switch import mode”] [mode=Normal]
[2023/03/24 12:53:35.592 +08:00] [INFO] [restore.go:1532] [“restore all tables data completed”] [takeTime=24.970574ms] []
[2023/03/24 12:53:35.592 +08:00] [INFO] [restore.go:1535] [“cleanup task metas”]
[2023/03/24 12:53:35.592 +08:00] [INFO] [restore.go:1829] [“skip full compaction”]
[2023/03/24 12:53:35.592 +08:00] [INFO] [restore.go:1171] [“everything imported, stopping periodic actions”]
[2023/03/24 12:53:35.592 +08:00] [INFO] [restore.go:2018] [“clean checkpoints start”] [keepAfterSuccess=remove] [taskID=1679633614939008092]
[2023/03/24 12:53:35.592 +08:00] [INFO] [restore.go:2026] [“clean checkpoints completed”] [keepAfterSuccess=remove] [taskID=1679633614939008092] [takeTime=41.754µs] []
[2023/03/24 12:53:35.592 +08:00] [INFO] [restore.go:476] [“the whole procedure completed”] [takeTime=37.750328ms] []
[2023/03/24 12:53:35.593 +08:00] [INFO] [main.go:106] [“tidb lightning exit”] [finished=true]
tidb-lightning.toml 内容如下:
[lightning]
日志
level = “info”
file = “tidb-lightning.log”
[tikv-importer]
选择使用的导入模式
backend = “local”
设置排序的键值对的临时存放地址,目标路径需要是一个空目录
sorted-kv-dir = “/opt/ccc/data/sorted-kv-dir”
[mydumper]
源数据目录。
data-source-dir = “/opt/ccc/data1/export/”
配置通配符规则,默认规则会过滤 mysql、sys、INFORMATION_SCHEMA、PERFORMANCE_SCHEMA、METRICS_SCHEMA、INSPECTION_SCHEMA 系统数据库下的所有表
若不配置该项,导入系统表时会出现“找不到 schema”的异常
#filter = [‘.’, ‘!mysql.', '!sys.’, ‘!INFORMATION_SCHEMA.', '!PERFORMANCE_SCHEMA.’, ‘!METRICS_SCHEMA.', '!INSPECTION_SCHEMA.’]
filter = [‘!mysql.', '!sys.’, ‘!INFORMATION_SCHEMA.', '!PERFORMANCE_SCHEMA.’, ‘!METRICS_SCHEMA.', '!INSPECTION_SCHEMA.’]
[tidb]
目标集群的信息
host = “10.xx.xx.xx”
port = 4000
user = “root”
password = “xxx”
表架构信息在从 TiDB 的“状态端口”获取。
status-port = 10080
集群 pd 的地址
pd-addr = “10.xx.xx.xx:2379”
【遇到的问题:问题现象及影响】
dumpling语句,误加了参数,导致导出数据格式异常,在lighting阶段无法被识别。请问该如何处理,以正常加载到数据库中?
tiup dumpling -u root -P 4000 -h 10.xx.xx.xxx -o /opt/ccc/data/export/ -r 200000 -t 16 --filetype sql --compress gzip --database db1,test -F 256MiB --output-filename-template ‘tidb-test.{{.Index}}’
【资源配置】
【附件:截图/日志/监控】