1、下载elasticsearch-hadoop-2.2.0beta1.jar,拷贝到hive的lib目录中,然后以如下方式打开hive命令窗口:
bin/hive -hiveconf hive.aux.jars.path=/root/hive/lib/elasticsearch-hadoop- 2.2.0 beta1.jar这个也可以写在hive的配置文件中,<property><name>hive.aux.jars.path</name><value>hdfs://ns/path/elasticsearch-hadoop.jar</value><description>A comma separated list (with no spaces) of the jar files</description></property>
2、创建表
CREATE TABLE es(location STRING, url STRING)STORED BY 'org.elasticsearch.hadoop.hive.EsStorageHandler'TBLPROPERTIES('es.resource' = 'test/share','es.index.auto.create' = 'true','es.nodes'='customercenter1,customercenter2,customercenter3,customercenter4','es.port'='9200');
由于在
Elasticsearch for hive搭建时,
Elasticsearch使用的是官方最新版本,而
Elasticsearch for
hadoop的
插件包版本更新不及时,导致在环境搭建的时候出现了问题
Elasticsearch for Apache Hadoop 2.1.0版本及前版本不支持最新的
Elasticsearch2.1.0导致遇到兼容性问题如下:
而
Elasticsearch for Apache Hadoop
2.1.1版本开始做了版本限制,详情如下:
Elasticsearch for Apache Hadoop
2.2.0
beta1开始对
Elasticsearch2.x版本做了兼容
在使用
Elasticsearch for Apache Hadoop
2.2.0
beta1过程中一直遇到以下问题:
经过修改源码打印日志发现是rest API返回结果变了
Elasticsearch1.7的
/_nodes/transport
rest API返回结果
Elasticsearch2.1
的
/_nodes/transport
rest API返回结果