Help us understand the problem. What is going on with this article?

Elasticsearch+Kibanaを設定してみる(CentOS7.4編)

More than 1 year has passed since last update.

ElasticsearchとKibanaの構築検証をしたのでメモ

CentOSバージョン

CentOS Linux release 7.4.1708

必要なもの

javaが必要なようです。

javaのインストール

# yum install java-1.8.0-openjdk.x86_64

# rpm -qa | grep java

java -version
# openjdk version "1.8.0_151"
OpenJDK Runtime Environment (build 1.8.0_151-b12)
OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)

Elasticseach のインストール(RPM)

インストール方法は何種類かあります。今回はRPMでインストールします。
詳細はURLを参照してください。
https://www.elastic.co/guide/en/elasticsearch/reference/current/install-elasticsearch.html#install-elasticsearch

RPMのインストール方法
https://www.elastic.co/guide/en/elasticsearch/reference/current/rpm.html

パッケージのダウンロード
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.1.1.rpm

Shaのダウンロード
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.1.1.rpm.sha512

ダウンロードしたパッケージの正当性確認

sha512sum -c elasticsearch-6.1.1.rpm.sha512
elasticsearch-6.1.1.rpm: 完了

インストール

# rpm --install elasticsearch-6.1.1.rpm
警告: elasticsearch-6.1.1.rpm: ヘッダー V4 RSA/SHA512 Signature、鍵 ID d88e42b4: NOKEY
Creating elasticsearch group... OK
Creating elasticsearch user... OK
### 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

自動起動の有効化

# systemctl daemon-reload
# systemctl enable elasticsearch.service
Created symlink from /etc/systemd/system/multi-user.target.wants/elasticsearch.service to /usr/lib/systemd/system/elasticsearch.service.

サービスの起動
# systemctl start elasticsearch.service

接続確認

# curl http://localhost:9200
{
  "name" : "UME_kvt",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "_xxxxxxxxxxxxxx",
  "version" : {
    "number" : "6.1.1",
    "build_hash" : "bd11x7x",
    "build_date" : "2017-12-17T20:23:25.338Z",
    "build_snapshot" : false,
    "lucene_version" : "7.1.0",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

定義ファイルのバックアップ

# cp -p /etc/elasticsearch/elasticsearch.yml /etc/elasticsearch/elasticsearch.yml.org`

# diff /etc/elasticsearch/elasticsearch.yml /etc/elasticsearch/elasticsearch.yml.org`

定義ファイルの修正

# vi /etc/elasticsearch/elasticsearch.yml

~ 50行目付近 ~
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
#network.host: 192.168.0.1
network.host: 0.0.0.0 ←全接続許可しちゃいます

#
# Set a custom port for HTTP:
#
#http.port: 9200
#
# For more information, consult the network module documentation.
#

修正内容の確認

# diff /etc/elasticsearch/elasticsearch.yml /etc/elasticsearch/elasticsearch.yml.org
56d55
< network.host: 0.0.0.0

サービス再起動
# systemctl restart elasticsearch

IPアドレスに対してcurl確認

# curl http:// IPアドレス :9200
{
  "name" : "UME_kvt",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "_xxxxxxxxxxxxxx",
  "version" : {
    "number" : "6.1.1",
    "build_hash" : "bd11x7x",
    "build_date" : "2017-12-17T20:23:25.338Z",
    "build_snapshot" : false,
    "lucene_version" : "7.1.0",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

Kibanaのインストール(RPM)

公式URL
https://www.elastic.co/guide/en/kibana/current/install.html

RPMのインストール方法
https://www.elastic.co/guide/en/kibana/current/rpm.html

パッケージのダウンロード
# wget https://artifacts.elastic.co/downloads/kibana/kibana-6.1.1-x86_64.rpm

こちらは公式SHAがエラーでちゃうので、パッケージのチェックはせず

インストール

# rpm --install kibana-6.1.1-x86_64.rpm
警告: kibana-6.1.1-x86_64.rpm: ヘッダー V4 RSA/SHA512 Signature、鍵 ID d88e42b4: NOKEY

自動起動有効化

# systemctl daemon-reload
# systemctl enable kibana.service
Created symlink from /etc/systemd/system/multi-user.target.wants/kibana.service to /etc/systemd/system/kibana.service.

サービス起動
# systemctl start kibana.service

ローカル接続確認

# curl http://localhost:5601
<script>var hashRoute = '/app/kibana';
var defaultRoute = '/app/kibana';

var hash = window.location.hash;
if (hash.length) {
  window.location = hashRoute + hash;
} else {
  window.location = defaultRoute;

定義のバックアップ

# cp -p /etc/kibana/kibana.yml /etc/kibana/kibana.yml.org
# diff /etc/kibana/kibana.yml /etc/kibana/kibana.yml.org

定義ファイルの修正

vi /etc/kibana/kibana.yml

~ 7行目付近 ~
# Specifies the address to which the Kibana server will bind. IP addresses and h
ost names are both valid values.
# The default is 'localhost', which usually means remote machines will not be ab
le to connect.
# To allow connections from remote users, set this parameter to a non-loopback a
ddress.
#server.host: "localhost"
server.host: "0.0.0.0" 

~ 20行目付近 ~

# The URL of the Elasticsearch instance to use for all your queries.
#elasticsearch.url: "http://localhost:9200"
elasticsearch.url: "http:// IPアドレス :9200"

修正内容の確認

# diff /etc/kibana/kibana.yml /etc/kibana/kibana.yml.org
8d7
< server.host: "0.0.0.0"
23d21
< elasticsearch.url: "http:// IPアドレス :9200"

サービス再起動
# systemctl restart kibana.service

接続確認

# curl http:// IPアドレス :5601
<script>var hashRoute = '/app/kibana';
var defaultRoute = '/app/kibana';

var hash = window.location.hash;
if (hash.length) {
  window.location = hashRoute + hash;
} else {
  window.location = defaultRoute;

ファイアウォールの設定

ホスト外からの通信を許可します。

事前確認
# firewall-cmd --list-ports --zone=public

Elasticsearchのポートを許可します。

# firewall-cmd --permanent --add-port=9200/tcp --zone=public
success

Kibanaのポートを許可します。

# firewall-cmd --permanent --add-port=5601/tcp --zone=public
success

ファイアウォール定義の再読み込み

# firewall-cmd --reload
success

ポート許可の再確認

# firewall-cmd --list-ports --zone=public
9200/tcp 5601/tcp

一応ファイアウォールの再起動しての確認

# systemctl restart firewalld

# firewall-cmd --list-ports --zone=public
9200/tcp 5601/tcp

外部ホストからのブラウザ接続

ブラウザから下記のURLにアクセスします。
http:// IPアドレス :5601

画像のようなページが出れば大丈夫です。

image.png

使い方

使い方は専門家にお任せ
インフラ屋さんはセットアップで満足です。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした