hive 数据导入 es

es-hadoop插件

上传es-hadoop插件到集群

准备hive数据

-- 连接hive
beeline -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;

file

file

file

海汼部落原创文章,原文链接:http://www.hainiubl.com/topics/75637

  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值