Hive數據導入Elasticsearch


一、准備jar包:可以去mvn倉庫下載

elasticsearch-hadoop-6.3.1.jar

二、 進入hive添加jar

hive>add jar /mnt/elasticsearch-hadoop-6.3.1.jar

三、准備數據

[root@master 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;
Loading data to table default.test1
OK

加載MR結果到HIVE

 

查看結果:

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM