Elasticsearch

環境 [#ca0e749f]

CentOS6

事前準備 [#qf119905]

 # yum install java

1.yumでインストール [#gd6e6516]

yumでのインストールは公式でサポートされています。

 # rpm --import https://packages.elastic.co/GPG-KEY-elasticsearch
 # cd /etc/yum.repos.d/
 # vim elasticsearch.repo
 [elasticsearch-2.x]
 name=Elasticsearch repository for 2.x packages
 baseurl=http://packages.elastic.co/elasticsearch/2.x/centos
 gpgcheck=1
 gpgkey=http://packages.elastic.co/GPG-KEY-elasticsearch
 enabled=1
 
 # yum install elasticsearch
 # yum list installed | grep elasticsearch
 elasticsearch.noarch                 2.2.0-1                           @elasticsearch-2.x
 # chkconfig --add elasticsearch
 # chkconfig elasticsearch --list
 elasticsearch  	0:off	1:off	2:on	3:on	4:on	5:on	6:off
 # /etc/init.d/elasticsearch start
 # curl -XGET http://127.0.0.1:9200
 {
  "name" : "Wilbur Day",
  "cluster_name" : "elasticsearch",
  "version" : {
    "number" : "2.2.0",
    "build_hash" : "8ff36d139e16f8720f2947ef62c8167a888992fe",
    "build_timestamp" : "2016-01-27T13:32:39Z",
    "build_snapshot" : false,
    "lucene_version" : "5.4.1"
  },
  "tagline" : "You Know, for Search"
 }

インストールディレクトリ [#rf4d831e]

 # find /usr/ -name "elasticsearch"
 /usr/share/elasticsearch
 /usr/share/elasticsearch/bin/elasticsearch
 /usr/local/src/elasticsearch-2.2.0/bin/elasticsearch

2.ソースからインストール [#ua803e4e]

 # yum install java
 # cd /usr/local/src
 # wget https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.0.0/elasticsearch-2.0.0.tar.gz
 # tar xfvz elasticsearch-2.0.0.tar.gz
 # mv elasticsearch-2.0.0 /usr/local/
 # cd /usr/local/
 # ln -s elasticsearch-2.0.0 elasticsearch
 # cd elasticsearch
 # ./bin/elasticsearch  

rootで実行すると以下エラーで起動できない [#tbf300f1]

 Exception in thread "main" java.lang.RuntimeException: don't run elasticsearch as root.
 	at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:92)
 	at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:138)
 	at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:270)
 	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
 Refer to the log for complete error details.

一般ユーザーで起動 [#kd584298]

 $ ./bin/elasticsearch &
 $ pgrep -fl elasticsearch
 1914 /usr/bin/java -Xms256m -Xmx1g -Djava.awt.headless=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError -XX:+DisableExplicitGC -Dfile.encoding=UTF-8 -Djna.nosys=true -Des.path.home=/usr/local/elasticsearch -cp /usr/local/elasticsearch/lib/elasticsearch-2.0.0.jar:/usr/local/elasticsearch/lib/* org.elasticsearch.bootstrap.Elasticsearch start