12
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AWS EC2上にElasticSearchをインストール

Posted at

概要

ElasticSearchの検証のため、AWS EC2のt2.nano上にElasticSearchをインストールしたときの忘備録です

yumのアップデート

EC2インスタンスを作った時のお決まり

$ sudo yum update

Java8のインストール

$ sudo yum install java-1.8.0-openjdk.x86_64

すでにJava7が入っているため、デフォルト設定をJava8に変更します

$ sudo alternatives --config java

> There are 2 programs which provide 'java'.
>   Selection    Command
> -----------------------------------------------
> *+ 1           /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java
>    2           /usr/lib/jvm/jre-1.8.0-openjdk.x86_64/bin/java

Enter to keep the current selection[+], or type selection number:2 

ElasticSearchのインストール

$ mkdir ~/src
$ cd ~/src
$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.7.rpm
$ sha1sum elasticsearch-5.6.7.rpm
$ sudo rpm --install elasticsearch-5.6.7.rpm

t2.nanoのメモリが0.5GBしかないのにデフォルトで2GBに設定されているため、JVMの設定を256MBに設定します。
これをしないとElasticSearchの起動に失敗します。

$ sudo su
$ vim /etc/elasticsearch/jvm.options
/etc/elasticsearch/jvm.options
#-Xms2g
#-Xmx2g
-Xms256m
-Xmx256m

外部からのアクセスを受け付けるため、elasticsearch.ymlに以下を追記

$ vim /etc/elasticsearch/elasticsearch.yml
/etc/elasticsearch/elasticsearch.yml
・・・
network.host: ec2-xxx-xxx-xxx-xxx.ap-northeast-x.compute.amazonaws.com
transport.host: localhost

自動起動設定を追加

$ sudo chkconfig --add elasticsearch

起動

$ sudo -i service elasticsearch start

確認
ElasticSearchのデフォルトポートは9200
ブラウザから以下にアクセス

http://ec2-XX-XXX-XX-XX.ap-northeast-1.compute.amazonaws.com:9200/

↓のようなJSONが返ってきたらセットアップ成功!

{
  "name" : "DznLRHS",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "WodF7ptTR-K7F6LRYBbAQw",
  "version" : {
    "number" : "5.5.0",
    "build_hash" : "260387d",
    "build_date" : "2017-06-30T23:16:05.735Z",
    "build_snapshot" : false,
    "lucene_version" : "6.6.0"
  },
  "tagline" : "You Know, for Search"
}
12
12
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
12
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?