Kudu 表數據遷移

使用 Kudu Command Line Tools 將表數據複製到另一個表

這兩個表可在同一個集羣中,也可在不同集羣。但是這兩個表必須具有相同的表模式,可以具有不同的分區模式。該工具可以使用與源表相同的表和分區模式創建新表。

用法:
kudu table copy <master_addresses> <table_name> <dest_master_addresses> [-nocreate_table] [-dst_table=<table>] [-num_threads=<threads>] [-predicates=<predicates>] [-tablets=<tablets>] [-write_type=<type>]

參數:

名稱 描述 類型 默認
master_addresses 以逗號分隔的源 Kudu 主機地址列表,其中每個地址的形式是"hostname:port",也可以使用集羣名 string none
table_name 源表名稱 string none
dest_master_addresses 以逗號分隔的目標 Kudu 主機地址列表,其中每個地址的形式是"hostname:port",也可以使用集羣名 string none
create_table (optional) 如果目標表不存在,是否創建目標表。 bool true
dst_table (optional) 將數據複製到的目標表的名稱。如果爲空字符串,則使用與源表相同的名稱。 string none
num_threads (optional) 要運行的線程數。每個線程運行自己的KuduSession。 int32 2
predicates (optional) 支持三種類型的謂詞,包括"Comparison", “InList” and “IsNull”。 string none
tablets (optional) 如果沒有指定要檢查的 Tablets (以逗號分隔的id列表),則檢查所有的 Tablets。 string none
write_type (optional) 如何將數據複製到目標表。“insert”、"upsert"或空字符串。如果字符串爲空,則不會複製數據(create_table爲true時很有用)。 string insert

使用示例:

Configuration error: Could not connect to the cluster: no leader master found. Client configured with 1 master(s) (192.168.1.101:7051) but cluster indicates it expects 3 master(s) (cdh01:7051,cdh02:7051,cdh03:7051)
注意: master_addresses 需寫全 master 地址。

[root@node01 ~]# kudu table copy node01:7051,node02:7051,node03:7051 my_database.my_table cdh01:7051,cdh02:7051,cdh03:7051 -nocreate_table -dst_table=my_database.my_table -num_threads=8 -write_type=upsert
I0701 13:56:29.095507  1551 table_scanner.cc:532] Scanned count: 1302487
I0701 13:56:34.099725  1551 table_scanner.cc:532] Scanned count: 2425488
I0701 13:56:39.105008  1551 table_scanner.cc:532] Scanned count: 3468528
I0701 13:56:44.109151  1551 table_scanner.cc:532] Scanned count: 4453114
I0701 13:56:49.113626  1551 table_scanner.cc:532] Scanned count: 5425016
I0701 13:56:54.117858  1551 table_scanner.cc:532] Scanned count: 6464445
......
I0701 14:55:03.737257  1551 table_scanner.cc:532] Scanned count: 535158673
I0701 14:55:08.741680  1551 table_scanner.cc:532] Scanned count: 535302695
I0701 14:55:13.745841  1551 table_scanner.cc:532] Scanned count: 535538444
I0701 14:55:18.750126  1551 table_scanner.cc:532] Scanned count: 535752970
I0701 14:55:23.754225  1551 table_scanner.cc:532] Scanned count: 535949697
I0701 14:55:28.758299  1551 table_scanner.cc:532] Scanned count: 536157109
I0701 14:55:33.762697  1551 table_scanner.cc:532] Scanned count: 536302601
I0701 14:55:38.767024  1551 table_scanner.cc:532] Scanned count: 536385095
I0701 14:55:43.771351  1551 table_scanner.cc:532] Scanned count: 536455367
T 76ccd465c1a345a6808a5731da858044 scanned count 53658586 cost 1300.65 seconds
Total count 536573786 cost 3563.88 seconds

參考:
https://kudu.apache.org/docs/command_line_tools_reference.html#remote_replica
https://kudu.apache.org/docs/hive_metastore.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章