LoginSignup
0
2

More than 5 years have passed since last update.

elasticsearchをVMにインストールする

Last updated at Posted at 2017-01-07

About

なんだかんだでちゃんと触ったことがなかったので試す。

環境

  • vagrantで立てたbento/centos-7.2
    • 7.3はなぞのエラーに見舞われたのでパス

インストール

基本的に公式のガイドに従うだけ。rpmで入れたほうが便利そうなので、rpmで導入する。

JREをインストール

Javaの実行環境が必要なのでopenjdkを導入。

$ sudo yum install java-1.8.0-openjdk
$ java -version
openjdk version "1.8.0_111"
OpenJDK Runtime Environment (build 1.8.0_111-b15)
OpenJDK 64-Bit Server VM (build 25.111-b15, mixed mode)

GPGキーをインポート

$ sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch

elasticsearchのリポジトリを手で追加してインストール

$ sudo vi /etc/yum.repos.d/elasticsearch.repo
[elasticsearch-5.x]
name=Elasticsearch repository for 5.x packages
baseurl=https://artifacts.elastic.co/packages/5.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
$ sudo yum install elasticsearch -y
### NOT starting on installation, please execute the following statements to configure elasticsearch service to start automatically using systemd
 sudo systemctl daemon-reload
 sudo systemctl enable elasticsearch.service
### You can start elasticsearch service by executing
 sudo systemctl start elasticsearch.service
  検証中                  : elasticsearch-5.1.1-1.noarch                   1/1

インストール:
  elasticsearch.noarch 0:5.1.1-1

完了しました!

ってなってたので、とりあえずsystemdで起動。

$ sudo systemctl start elasticsearch
$ sudo systemctl status elasticsearch

エラーが…

Jan 07 11:40:52 localhost.localdomain elasticsearch[3409]: OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N
Jan 07 11:40:52 localhost.localdomain elasticsearch[3409]: OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error='Cannot allocate memory' (errno=12)
Jan 07 11:40:52 localhost.localdomain elasticsearch[3409]: #
Jan 07 11:40:52 localhost.localdomain elasticsearch[3409]: # There is insufficient memory for the Java Runtime Environment to continue.
Jan 07 11:40:52 localhost.localdomain elasticsearch[3409]: # Native memory allocation (mmap) failed to map 2060255232 bytes for committing reserved memory.
Jan 07 11:40:52 localhost.localdomain elasticsearch[3409]: # An error report file with more information is saved as:
Jan 07 11:40:52 localhost.localdomain elasticsearch[3409]: # /tmp/hs_err_pid3409.log
Jan 07 11:40:52 localhost.localdomain systemd[1]: elasticsearch.service: main process exited, code=exited, status=1/FAILURE

メモリーが足りないとのこと。(VMのメモリーは512MBだった。さすがに小さいかなと思ってあとで1GBにした)

デフォルトだと2GB近く必要らしい。

メモリーサイズを変更する

設定を変更するには下記ファイルを修正

/etc/elasticsearch/jvm.options
# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space

#-Xms2g
#-Xmx2g
-Xms1g 
-Xmx1g

これで起動を試みると

$ sudo systemctl start elasticsearch
$ sudo systemctl status elasticsearch
[vagrant@localhost etc]$ sudo systemctl status elasticsearch
● elasticsearch.service - Elasticsearch
   Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; disabled; vendor preset: disabled)
   Active: active (running) since 土 2017-01-07 11:53:24 UTC; 44s ago

起動した!インストール完

参考

0
2
0

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
0
2