Install elasticsearch on CentOS 7

To install elasticsearch, first install java

yum -y install java-1.8.0-openjdk

Import key

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

Create file

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

Paste following

[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

Install elasticsearch

yum install --enablerepo=elasticsearch elasticsearch

Set elastic search to start on boot

systemctl enable elasticsearch

To start/stop/status

systemctl stop elasticsearch.service
systemctl start elasticsearch.service
systemctl status elasticsearch.service

To see logs

tail -f /var/log/elasticsearch/elasticsearch.log

ElasticSearch runs on port 9200

[root@server ~]# netstat -lntp | grep java
tcp6       0      0 127.0.0.1:9200          :::*                    LISTEN      1289/java           
tcp6       0      0 ::1:9200                :::*                    LISTEN      1289/java           
tcp6       0      0 127.0.0.1:9300          :::*                    LISTEN      1289/java           
tcp6       0      0 ::1:9300                :::*                    LISTEN      1289/java           
[root@server ~]# 

If you get error starting elasticsearch, check Elasticsearch failed to start on CentOS 7

If you have a previous installation, make sure you delete left over files before you install differnt version of elasticsearch. I removed following files/folders when i had to downgrade elasticsearch.

/etc/sysconfig/elasticsearch.rpmsave
/var/lib/elasticsearch
/var/log/elasticsearch

See elasticsearch

Need help with Linux Server or WordPress? We can help!

Leave a Reply

Your email address will not be published. Required fields are marked *