Skip to content

Set up Elasticsearch and Kibana on CentOS 7

jyomaj edited this page May 30, 2017 · 3 revisions

Elevate to root user:

sudo -s

Install java 1.8:

yum install java-1.8.0-openjdk.x86_64

Check java version:

java -version 

e.g. output:

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)

Import the Elasticsearch PGP key

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

Create elasticsearch repo file

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

and fill with:

[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

Install Elasticsearch:

yum install elasticsearch 

Take a backup of the jvm.options

cp -p /etc/elasticsearch/jvm.options /etc/elasticsearch/jvm.options.bak

Edit jvm.options file

vi /etc/elasticsearch/jvm.options

and change the java initial size of total heap space and maximum size of total heap space as appropriate (50% of physical RAM). They will default to:

-Xms2g
-Xmx2g

Reload systemd

systemctl daemon-reload

Enable Elasticsearch for startup

systemctl enable elasticsearch.service

Take a backup of elasticsearch.yml

cp -p /etc/elasticsearch/elasticsearch.yml  /etc/elasticsearch/elasticsearch.yml.bak

Edit elasticsearch.yml

vi /etc/elasticsearch/elasticsearch.yml

and add the following:

node.name:    ${HOSTNAME}
network.host: 0.0.0.0
http.cors.enabled: true
http.cors.allow-origin: /.*/  
http.cors.allow-credentials: true
node.max_local_storage_nodes: 1
gateway.expected_nodes: 1

Take a backup of limits.conf

cp -p /etc/security/limits.conf /etc/security/limits.conf.bak

Edit limits.conf file

vi /etc/security/limits.conf

and add the following to set maximum number of open files for the elasticsearch user:

elasticsearch  -  nofile  65536

Take a backup of the elasticsearch sysconfig

cp -p /etc/sysconfig/elasticsearch /etc/sysconfig/elasticsearch.bak

Modify elasticsearch sysconfig

vi /etc/sysconfig/elasticsearch

to uncomment:

MAX_LOCKED_MEMORY=unlimited

Take a backup of elasticsearch.service

cp -p /usr/lib/systemd/system/elasticsearch.service /usr/lib/systemd/system/elasticsearch.service.bak

Assuming you have used the 'bootstrap.memory.lock: true' option in elasticsearch.yml and 'MAX_LOCKED_MEMORY=unlimited' in /etc/sysconfig/elasticsearch , modify elasticsearch sysconfig

vi /usr/lib/systemd/system/elasticsearch.service

to uncomment

LimitMEMLOCK=infinity

Reload systemd

systemctl daemon-reload

Start Elasticsearch

systemctl start elasticsearch.service

Check the status of Elasticsearch

systemctl status elasticsearch.service

You can also check /var/log/elasticsearch/elasticsearch.log

Note about ports: Port 9200 is needed to do queries against elasticsearch, port 5601 is needed for Kibana and port 9100 is needed if you want to use the head plugin

Create kibana repo file

vi /etc/yum.repos.d/kibana.repo

and fill with

[kibana-5.x]
name=Kibana 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

Install Kibana

yum install kibana

Reload systemd

systemctl daemon-reload

Enable Kibana for startup

systemctl enable kibana.service

Modify kibana.yml

vi /etc/kibana/kibana.yml

and add the following so you can connect to it from other machines:

server.host: "0.0.0.0"

Start Kibana

systemctl start kibana.service

Check the status of Kibana

systemctl status kibana.service
Clone this wiki locally
You can’t perform that action at this time.