龙空技术网

hive 数据导入 es

青牛老师 297

前言:

眼前你们对“hive从本地导入数据”可能比较注重,小伙伴们都想要了解一些“hive从本地导入数据”的相关知识。那么小编也在网络上收集了一些关于“hive从本地导入数据””的相关文章,希望咱们能喜欢,大家一起来学习一下吧!

es-hadoop插件

上传es-hadoop插件到集群

准备hive数据

-- 连接hivebeeline -u "jdbc:hive2://worker-1:10000/;principal=hive/worker-1@HAINIU.COM"-- 创建临时表create table if not exists xiniu.hivetable(    pk string,    col1 int,    col2 boolean,    col3 timestamp,    col4 string)comment 'hive表'row format delimited fields terminated by '\t';-- 加载数据load data inpath '/eslib/testfile' into table xiniu.hivetable;

导入hive数据到es

上传es-hadoop jar包

hadoop fs -put /opt/elasticsearch-hadoop-7.13.1.jar /eslib/
加载es-hadoop jar包
add jar hdfs:///eslib/elasticsearch-hadoop-7.13.1.jar
创建es的hive外表
CREATE EXTERNAL TABLE xiniu.hive2es(pk string,col1 string,col2 string,col3 string,col4 string)STORED BY 'org.elasticsearch.hadoop.hive.EsStorageHandler'TBLPROPERTIES('es.resource'='hivemappinges/_doc','es.nodes'='worker-1:9200,worker-2:9200,worker-3:9200','es.index.auto.create'='TRUE','es.index.refresh_interval' = '-1','es.index.number_of_replicas' = '0','es.batch.write.retry.count' = '6','es.batch.write.retry.wait' = '60s','es.mapping.name' = 'pk:pk,col1:col1,col2:col2,col3:col3,col4:col4');
插入数据到es的hive外表
INSERT OVERWRITE TABLE xiniu.hive2es SELECT pk,col1,col2,col3,col4 FROM xiniu.hivetable;

海汼部落原创文章,原文链接:()

标签: #hive从本地导入数据 #hive导入数据的四种方式