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