よろづやアンテナ

ITから生活の参考になる情報を備忘録代わりに残していきます

CentOS7にyum経由でElasticsearch5.xのインストールする手順

CentOS7.4にyum経由でElasticsearch5.xのインストールする手順を紹介します。


最新版はバージョン6ですが、要件的に5が必要だったので、今回は5をインストールしていますが、指定を変えれば6をインストールできます。

ちなみに、以下が公式サイトです。

https://www.elastic.co/guide/en/elasticsearch/reference/current/_installation.html


JAVAの確認。すでにインストールされていたので、スキップ。ちなみに、要件はJava8以降で、Oralce JDKですが、このまま利用。

Elasticsearch requires at least Java 8. Specifically as of this writing, it is recommended that you use the Oracle JDK version 1.8.0_73.

-------------
[root@TestServer ~]# java -version
openjdk version "1.8.0_131"
OpenJDK Runtime Environment (build 1.8.0_131-b12)
OpenJDK 64-Bit Server VM (build 25.131-b12, mixed mode)
-------------

古いOSバージョンで、これより低いバージョンのJavaが入っていた場合は、一旦アンインストールして、再インストールを実行します。


続いて、Elasticsearchのインストールです。

-------------
[root@TestServer ~]# 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
[wq!]で保存。

[root@TestServer ~]# yum install elasticsearch
読み込んだプラグイン:fastestmirror, langpacks
elasticsearch-5.x

~ 中略 ~

Downloading packages:
警告: /var/cache/yum/x86_64/7/elasticsearch-5.x/packages/elasticsearch-5.6.9.rpm: ヘッダー V4 RSA/SHA512 Signature、鍵 ID d88e42b4: NOKEY32 MB 00:00:00 ETA
elasticsearch-5.6.9.rpm の公開鍵がインストールされていません
elasticsearch-5.6.9.rpm | 32 MB 00:00:22
https://artifacts.elastic.co/GPG-KEY-elasticsearch から鍵を取得中です。
Importing GPG key 0xD88E42B4:
Userid : "Elasticsearch (Elasticsearch Signing Key) <dev_ops@elasticsearch.org>"
Fingerprint: 4609 5acc 8548 582c 1a26 99a9 d27d 666c d88e 42b4
From : https://artifacts.elastic.co/GPG-KEY-elasticsearch
上記の処理を行います。よろしいでしょうか? [y/N]y

~ 中略 ~

検証中 : elasticsearch-5.6.9-1.noarch 1/1

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

完了しました!
[root@TestServer ~]#
-------------

依存関係オプションの以下の二つも合わせてインストールします。
・Redis 3.x
・ElasticSearch 5.x (needed when using Full-text search)

-------------
[root@TestServer ~]# /usr/share/elasticsearch/bin/elasticsearch-plugin install analysis-kuromoji
-> Downloading analysis-kuromoji from elastic
[=================================================] 100%??
-> Installed analysis-kuromoji
[root@TestServer ~]# /usr/share/elasticsearch/bin/elasticsearch-plugin install analysis-icu
-> Downloading analysis-icu from elastic
[=================================================] 100%??
-> Installed analysis-icu
[root@TestServer ~]#
-------------

続いてelasticsearchの自動起動設定です。

-------------
[root@TestServer ~]# systemctl start elasticsearch
[root@TestServer ~]# systemctl enable elasticsearch
Created symlink from /etc/systemd/system/multi-user.target.wants/elasticsearch.service to /usr/lib/systemd/system/elasticsearch.service.
[root@TestServer ~]# systemctl list-unit-files | grep elasticsearch
elasticsearch.service enabled
-------------

以上でCentOS7.4にyum経由でElasticsearch5.xのインストール作業は完了です。