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

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