2
2

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 3 years have passed since last update.

格安VPS上にElasticSearchを構築してみた

Last updated at Posted at 2021-07-29

環境

Indigo KVM Instance 4 CPU 4 GB
CentOS 7.5.1804 (Core)
ElasticSearch 7.13.4
kibana 7.13.4
Python 2.7.5

ElasticSearchをインストール

ElasticSearchのDLに必要なキーをインポート

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

##ElasticSearchのリポジトリを追加
enabled=0にしておくと、他のインストールには影響しません

$ sudo vi /etc/yum.repos.d/elasticsearch.repo

[elasticsearch]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=0
autorefresh=1
type=rpm-md

##ElasticSearchをインストール
先ほど作成したリポジトリを指定して、ElasticSearchをインストールする

sudo yum install --enablerepo=elasticsearch elasticsearch

##OS起動時に起動するように設定

sudo chkconfig --add elasticsearch

##アクセス設定及びクラスタ設定
AWSやVPSなどではグローバルIPにアクセスする
nodeの設定をしないと起動時にエラーになるので注意が必要

$ sudo vi /etc/elasticsearch/elasticsearch.yml

# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
- # node.name: node-1
+ node.name: node-1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ---------------------------------- Network -----------------------------------
#
# By default Elasticsearch is only accessible on localhost. Set a different
# address here to expose this node on the network:
#
- # network.host: 192.168.0.1
+ network.host: 0.0.0.0
#
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
#
#http.port: 9200
#
# For more information, consult the network module documentation.
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.seed_hosts: ["host1", "host2"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
- # cluster.initial_master_nodes: ["node-1", "node-2"]
+ cluster.initial_master_nodes: ["node-1"]
#
# For more information, consult the discovery and cluster formation module documentation.

##SELinux無効

$ sudo vi /etc/selinux/config

- # SELINUX=enforce
+ SELINUX=disabled

##ElasticSearch起動

sudo systemctl start elasticsearch

##稼働確認
http://xxx.xxx.xxx.xxx:9200 にアクセス

アクセスできない場合は、iptablesfirewalldが入っている可能性があります

Kibanaをインストール

##Kibanaをインストール

sudo yum install --enablerepo=elasticsearch kibana

##OS起動時に起動するように設定

sudo chkconfig --add kibana

##アクセス設定
AWSやVPSなどではグローバルIPにアクセスする

$ sudo vi /etc/kibana/kibana.yml

# ------------------------------------ Node ------------------------------------
#
# Specifies the address to which the Kibana server will bind. IP addresses and host names are both valid values.
# The default is 'localhost', which usually means remote machines will not be able to connect.
# To allow connections from remote users, set this parameter to a non-loopback address.
- #server.host: localhost
+ server.host: 0.0.0.0

##kibana起動

sudo systemctl start kibana

##稼働確認
http://xxx.xxx.xxx.xxx:5601 にアクセス
少し時間が掛かるかもしれません。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?