elasticsearch:2.3.1html
hive:0.12java
2.1 首先獲取elasticsearc-hadoop的jar包node
連接地址:http://jcenter.bintray.com/org/elasticsearch/elasticsearch-hadoop/2.3.1/elasticsearch-hadoop-2.3.1.jar,下載便可。須要說明的是你的elasticsearch什麼版本,那麼elasticsearch-hadoop的jar包就什麼版本,不然後果難料elasticsearch
2.2 hive集成elasticsearchide
將elasticsearch-hadoop-2.3.1.jar拷貝到hive的默認lib目錄便可。個人目錄是:$HIVE_HOME/auxlib目錄oop
啓動hive,查看效果:ui
/home/q/java/default/bin/java -Xmx256m -Djava.net.preferIPv4Stack=true *** -hiveconf hive.aux.jars.path=file:///home/q/hive/hive-0.12.0-bin/auxlib/elasticsearch-hadoop-2.0.1.jar
只要包含了上面的紅色部分說明集成成功url
3.1 創建數據表spa
3.1.1 創建view表.net
CREATE EXTERNAL TABLE user (id INT, name STRING) STORED BY 'org.elasticsearch.hadoop.hive.EsStorageHandler' TBLPROPERTIES('es.resource' = 'radiott/artiststt','es.index.auto.create' = 'true','es.nodes' = 'elastisticsearch.*.qunar.com','es.port' = '9222');
有幾個參數,es.nodes是配置的es的url地址,默認是localhost。es.port是端口號碼,默認是9200
3.1.2 創建數據表
CREATE TABLE user_source (id INT, name STRING) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',';
3.2 加載數據
3.2.1 加載基礎數據
數據示例,我放在/tmp/user_source.log
1,medcl 2,lcdem 3,tom 4,jack
加載到user_source表,命令以下:LOAD DATA LOCAL INPATH '/tmp/user_source.log' OVERWRITE INTO TABLE user_source;
3.2.2 加載到es
INSERT OVERWRITE TABLE user SELECT s.id, s.name FROM user_source s;
查看效果:
http://blog.csdn.net/sunflower_cao/article/details/39896189
https://www.elastic.co/guide/en/elasticsearch/hadoop/current/configuration.html#_essential_settings