一、环境说明
Elasticsearch 7.10.0
Hive 3.1.2
Hadoop 3.X
二、操作步骤
- 下载ES-Hadoop安装包,其版本需要与Elasticsearch实例保持一致,下载地址:https://www.elastic.co/cn/downloads/
本文中下载的是 :elasticsearch-hadoop-7.10.0.zip
- 解压已下载的
elasticsearch-hadoop-7.10.0.zip
,并将elasticsearch-hadoop-hive-7.10.0.jar
上传至大数据集群
比如我将jar包上传至hdfs的/user/hive/elastic/目录下:
#创建目录:
hdfs dfs -mkdir /user/hive/elastic
#上传jar包
hdfs dfs -put elasticsearch-hadoop-hive-7.10.0.jar /user/hive/elastic/
#查看
hdfs dfs -ls /user/hive/elastic
- hive添加jar 引用
hive>add jar hdfs://cluster/user/hive/elastic/elasticsearch-hadoop-hive-7.10.0.jar;
- 创建外部表
CREATE TABLE ods.ods_es_hive_da (
id bigint ,
createdtime bigint,
customerdrugname string,
customerhciname string,
drugname string