序言:
首先說說es2.2在yarn上跑的好處和不足,在hadoop上跑可以統一使用yarn資源,不用單獨給es搞物理機了。
這裏要注意es並沒有使用hdfs,網上資料說可以使用hdfs來管理es備份文件,本人費很大勁沒有找到成功安裝方式。
參考網址:
https://github.com/elastic/elasticsearch-hadoop 源碼地址
https://www.elastic.co/guide/en/elasticsearch/hadoop/current/es-yarn.html 官方文檔
https://www.elastic.co/downloads/elasticsearch 下載包地址
安裝需要:
這裏需要一個jar(elasticsearch-yarn-2.2.0.jar)和一個zip(elasticsearch-2.2.0.zip)
jar從私服下載,zip從官網下載就可以了
開始安裝:
1.使用hadoop運行jar輸出幫助文檔
$ hadoop jar elasticsearch-yarn-2.2.0.jar
No command specified
Usage:
-download-es : Downloads Elasticsearch.zip
-install : Installs/Provisions Elasticsearch-YARN into HDFS
-install-es : Installs/Provisions Elasticsearch into HDFS
-start : Starts provisioned Elasticsearch in YARN
-status : Reports status of Elasticsearch in YARN
-stop : Stops Elasticsearch in YARN
-help : Prints this help
Configuration options can be specified _after_ each command; see the documentation for more information.
2.按照官網執行 $ hadoop jar elasticsearch-yarn-2.2.0 -download-es
下載了n次
不行啊,看看原來沒地址吧 https://download.elastic.co/elasticsearch/elasticsearch/
試了試好像下載不了
自己找地址手工下載吧
https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/zip/elasticsearch/2.2.0/elasticsearch-2.2.0.zip
放在
hadoop的app/downloads 中吧,爲什麼放這裏的,因爲官方文檔說從命令行執行的 .downloads中獲取zip
這樣就算下載完了。
下一步安裝命令:
hadoop jar elasticsearch-yarn-2.2.0.jar
-install-es
hadoop jar elasticsearch-yarn-2.2.0.jar -install
不錯,兩個執行都上傳成功了
文件放在了 hdfs://cluster1:8020/apps/elasticsearch/ 目錄下
啓動一下試一試吧:
hadoop jar /app/elasticsearch-hadoop-2.2.0/dist/elasticsearch-yarn-2.2.0.jar -start
提示 16/02/18 09:37:24 INFO impl.YarnClientImpl: Submitted application application_1455675371242_0002
Launched a 1 node Elasticsearch-YARN cluster [application_1455675371242_0002@http://host218:9026/proxy/application_1455675371242_0002/] at Thu Feb 18 09:37:23 CST 2016
查看一下狀態:
hadoop jar elasticsearch-yarn-2.2.0.jar -status
提示如下
Id State Status Start Time Finish Time Tracking URL
application_1455675371242_0002 FINISHED FAILED 2/18/16 9:37 AM 2/18/16 9:37 AM http://host218:9026/proxy/ap
官網提示應該是這樣
Id State Status Start Time Finish Time Tracking URL
application_1415921358606_0007 RUNNING UNDEFINED 11/14/14 19:34 PM N/A
這裏使用yarn命令查看一下日誌發現,是root權限不讓啓動,這樣我們就使用一個參數強制使用root啓動吧。
命令如下:
hadoop jar elasticsearch-yarn-2.2.0.jar -start sys.prop.es.insecure.allow.root=true containers=5
解釋一下啊,第一個參數是允許root啓動(其他參數參考官網),第二個參數是使用多少個datanode節點。終於啓動成功可以正常使用過了。
這裏說一下,這個zip可以減壓修改配置文件,也可以安裝head等插件。
以下是一些優化及其配置供參考:
#node名稱爲主機名稱
node.name: ${HOSTNAME}
使用eth0網卡
network.host: _eth0_
單播發現nodes集合
discovery.zen.ping.unicast.hosts: ["host213", "host217", "host221", "host231","host236","host233","host235"]
cluster.name: ehl_elasticsearch
path.data: /data/elasticsearch/indexdata
path.work: /data/elasticsearch/work
path.logs: /data/elasticsearch/logs
#允許鎖定內存
bootstrap.mlockall: true
ES_MIN_MEM: 4g
ES_MAX_MEM: 4g
#不允許動態生成索引配置
index.mapper.dynamic: false
修改linux允許所內存
echo 'ulimit -l unlimited' >> /etc/profile
. /etc/profile