大数据方兴未艾,Hive在业界,是大数据的标配了。因此hive数据添加到ES的应用场景还是比较常见的。
学习ES官方的es-hadoop, 有从hive导数据到ES. 实验可行。
hive的版本: hive-1.1.0-cdh5.9.0
具体的步骤如下:
step1 将elasticsearch-hadoop-hive-version.jar添加到hive
wget https://artifacts.elastic.co/downloads/elasticsearch-hadoop/elasticsearch-hadoop-6.3.0.zip
unzip elasticsearch-hadoop-6.3.0.zip
hdfs dfs -mkdir /user/test/es_hadoop/
hdfs dfs -put elasticsearch-hadoop-hive-6.3.0.jar /user/test/es_hadoop/
ADD JAR hdfs://test/user/test/es_hadoop/elasticsearch-hadoop-hive-6.3.0.jar;
step2 创建Hive表:
CREATE EXTERNAL TABLE elastic_table(
uuid string,
key1 int,
key2 int,
day string
)
STORED BY 'org.elasticsearch.hadoop.hive.EsStorageHandler'
TBLPROPERTIES('es.resource'='index/type',
'es.nodes'='serverIP:port',
'es.index.auto.create'='TRU