brew tapを用いてElasticsearch2.4とelasticsearch-headをMacにインストール

前提

  • OS
  • Homebrewのバージョン
    • 1.1.9

概要

Elasticsearchをbrewでインストールすると、デフォルトでバージョン5がインストールされたが、
https://github.com/mobz/elasticsearch-headを確認すると、

for Elasticsearch 5.x: site plugins are not supported. Run as a standalone server

とのことなので、
brew tapを用いて過去のバージョンの2.4とelasticsearch-headをインストールする。

手順

1. Elasticsearch2.4のインストール

brew tap homebrew/versions
brew search elasticsearch

elasticsearch                                  elasticsearch@1.7                              elasticsearch@2.4

過去のelasticsearchのパッケージが確認出来るので、

brew install elasticsearch@2.4

でElasticsearch2.4をインストールする。
次に、

ln -sfv /usr/local/opt/elasticsearch\@2.4/homebrew.mxcl.elasticsearch\@2.4.plist
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.elasticsearch\@2.4.plist

自動起動の設定を行う。

2. PATHの設定

brew info elasticsearch@2.4

を実行すると

Data:    /usr/local/var/elasticsearch/elasticsearch_HirofumiYamamoto/
Logs:    /usr/local/var/log/elasticsearch/elasticsearch_HirofumiYamamoto.log
Plugins: /usr/local/opt/elasticsearch@2.4/libexec/plugins/
Config:  /usr/local/etc/elasticsearch/
plugin script: /usr/local/opt/elasticsearch@2.4/libexec/bin/plugin

と記述されている部分が見つかるのでこれを参考にPATHを通しておく。
今回はpluginコマンドでelasticsearch-headをインストールするので、

echo 'export PATH="/usr/local/opt/elasticsearch@2.4/libexec/bin:$PATH"' >> ~/.bash_profile

で.bash_profileを更新しPATHを通す。

source ~/.bash_profile

で.bash_profileを再度読み込みしておく。

3. elasticsearch-headのインストール

plugin install mobz/elasticsearch-head

でelasticsearch-headをインストールする。

4. ブラウザで確認

elasticsearch

でelasticsearchを起動し、
http://localhost:9200/_plugin/head/を開き、

f:id:poustel:20170204184016p:plain

が表示されていればOK。

参考リンク

qiita.com