Hive數據導入Elasticsearch
阿新 • • 發佈:2019-05-05
fields png txt ring 數據表 inf ESS handler def Loading data to table default.test1
OK
一、準備jar包:可以去mvn倉庫下載
elasticsearch-hadoop-6.3.1.jar
二、 進入hive添加jar
hive>add jar /mnt/elasticsearch-hadoop-6.3.1.jar
三、準備數據
[[email protected] mnt]# cat test.txt 111,aaa 222,bbb 333,ccc
四、創建與Elasticsearch對接test外部表
create table test(key string,value string) STORED BY ‘org.elasticsearch.hadoop.hive.EsStorageHandler‘ TBLPROPERTIES(‘es.resource‘ = ‘test/user‘, ‘es.nodes‘=‘192.168.200.100‘, ‘es.port‘=‘9200‘, ‘es.nodes.wan.only‘=‘true‘);
創建源數據表test1
hive> CREATE TABLE test1(key string,value string) row format delimited fields terminated by ‘,‘ stored as textfile; OK Time taken: 0.266 seconds
hive> load data local inpath ‘/mnt/test.txt‘ into table test1;
OK
加載MR結果到HIVE
查看結果:
Hive數據導入Elasticsearch