LoginSignup
33

More than 5 years have passed since last update.

MacにElasticsearchとelasticsearch-headをインストール

Posted at

Elasticsearchを使ったRailsサンプルアプリの作成をMac環境でやろうと思ったのですが、セットアップに手間取ってしまったのでその過程を残しておきます。

環境

  • OS X Yosemite

Elasticsearchのインストール

$ brew update
$ brew install elasticsearch

インストールが終わったら自動起動の設定をします。

$ ln -sfv /usr/local/opt/elasticsearch/*.plist ~/Library/LaunchAgents
$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.elasticsearch.plist

PATHを通す

このままではpluginコマンドが使えないので、パスを通します。人によってelasticsearchのバージョンが違うかもしれないので、注意してください(brew info elasticsearchで確認できるplugin scriptを参考にするといいと思います)。

$ brew info elasticsearch
elasticsearch: stable 2.2.0, HEAD
Distributed search & analytics engine
https://www.elastic.co/products/elasticsearch
/usr/local/Cellar/elasticsearch/2.2.0_1 (211 files, 38.0M) *
  Built from source
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/elasticsearch.rb
==> Caveats
Data:    /usr/local/var/elasticsearch/elasticsearch_yuki/
Logs:    /usr/local/var/log/elasticsearch/elasticsearch_yuki.log
Plugins: /usr/local/Cellar/elasticsearch/2.2.0_1/libexec/plugins/
Config:  /usr/local/etc/elasticsearch/
plugin script: /usr/local/Cellar/elasticsearch/2.2.0_1/libexec/bin/plugin

To reload elasticsearch after an upgrade:
  launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.elasticsearch.plist
  launchctl load ~/Library/LaunchAgents/homebrew.mxcl.elasticsearch.plist
Or, if you don't want/need launchctl, you can just run:

今回の場合だとplugin script: /usr/local/Cellar/elasticsearch/2.2.0_1/libexec/bin/pluginの部分を参考に.bash_profileとかにPATHの記述をすることになります。

.bash_profileとか
export ELASTICPATH=/usr/local/Cellar/elasticsearch/2.2.0_1/libexec/bin
export PATH=$PATH:$ELASTICPATH
$ exec $SHELL -l

必ずしもPATHは通す必要はありませんが、今後pluginコマンドを多用する場合はパスを通していないと面倒かと思います。

elasticsearch-headのインストール

$ plugin install mobz/elasticsearch-head

http://localhost:9200/_plugin/head/を確認すると、それっぽい画面が表示されていると思います。

以上です。

参考

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
33