#################
主要是用於sql文件和csv文件的導入
最好還是tiup安裝:
root@shell>> tiup install tidb-lightning
一、下載安裝:
地址:https://docs.pingcap.com/zh/tidb/dev/download-ecosystem-tools#tidb-lightning
#下載地址格式約定為:https://download.pingcap.org/tidb-toolkit-{version}-linux-amd64.tar.gz
# 其中version格式為v5.2.1形式的格式,舉例如下:
shell>> curl -o tidb-toolkit-v5.2.1-linux-amd64.tar.gz https://download.pingcap.org/tidb-toolkit-v5.2.1-linux-amd64.tar.gz
# 解壓后可得: shell>> tar -xzvf tidb-toolkit-v5.2.1-linux-amd64.tar.gz
二、配置導入:
現在,需要將10.10.10.40機器上/home/work/sql_dir目錄中大量的sql文件導入到tidb地址為10.10.10.10:4000的集群中 目標集群信息: tidb:
10.10.10.10:4000 10.10.10.11:4000
pd:
10.10.10.20:2379
10.10.10.21:2379
10.10.10.22:2379
tikv:
10.10.10.30:20160
10.10.10.31:20160
10.10.10.32:20160
[work@10.10.10.40 bin]$ cat tidb-lightning.toml [lightning] # 日志 level = "info" file = "tidb-lightning.log" [tikv-importer] # 選擇使用的 local 后端;使用 TiDB-backend,則使用backend = "tidb" backend = "tidb" # 設置排序的鍵值對的臨時存放地址,目標路徑需要是一個空目錄,弄一個空的臨時目錄即可 # sorted-kv-dir = "/home/work/tmp/sorted-kv-dir" [mydumper] # 源數據目錄,這就是你的sql文件或csv文件所在目錄。 data-source-dir = "/home/work/sql_dir/" # 配置通配符規則,默認規則會過濾 mysql、sys、INFORMATION_SCHEMA、PERFORMANCE_SCHEMA、METRICS_SCHEMA、INSPECTION_SCHEMA 系統數據庫下的所有表 # 若不配置該項,導入系統表時會出現“找不到 schema”的異常 # filter = ['*.*', '!mysql.*', '!sys.*', '!INFORMATION_SCHEMA.*', '!PERFORMANCE_SCHEMA.*', '!METRICS_SCHEMA.*', '!INSPECTION_SCHEMA.*'] [tidb] # 集群中tidb組件中的入口地址:ip、port、user、password四大基本信息 host = "10.10.10.10" port = 4000 user = "root" password = "123456" # 表架構信息在從 TiDB 的“狀態端口”獲取。 #status-port = 10080 # 集群中任意一個pd實例的地址,當然也可以填寫多個pd地址 pd-addr = "10.10.10.20:2379"
三、導入數據:
work@shell>> ./tidb-lightning -config tidb-lightning.toml --check-requirements=false
問題:
1)v5.1.0版本的tiup-lightning因為出現了檢查不通過,因此提示給出了:--check-requirement=false ,實際上需要寫成:--check-requirements=false
+---+-------------------------------------------------------------------------------------------+-------------+--------+ | # | CHECK ITEM | TYPE | PASSED | +---+-------------------------------------------------------------------------------------------+-------------+--------+ | 1 | Cluster is available | critical | true | +---+-------------------------------------------------------------------------------------------+-------------+--------+ | 2 | Cluster has no other loads | performance | true | +---+-------------------------------------------------------------------------------------------+-------------+--------+ | 3 | Lightning has the correct storage permission | critical | true | +---+-------------------------------------------------------------------------------------------+-------------+--------+ | 4 | Cluster resources are rich for this import task | critical | true | +---+-------------------------------------------------------------------------------------------+-------------+--------+ | 5 | large csv: event.event.000000000.sql file exists and it will slow down import performance | performance | false | +---+-------------------------------------------------------------------------------------------+-------------+--------+ | 6 | checkpoints are valid | critical | true | +---+-------------------------------------------------------------------------------------------+-------------+--------+ | 7 | table schemas are valid | critical | true | +---+-------------------------------------------------------------------------------------------+-------------+--------+ 1 performance check failed Error: lightning pre check failed.please fix the check item and make check passed or set --check-requirement=false to avoid this check tidb lightning encountered error: lightning pre check failed.please fix the check item and make check passed or set --check-requirement=false to avoid this check
參考:https://githubmemory.com/repo/pingcap/tiup/issues/1474
################
####################