How to install elasticsearch on ubuntu and centos

Elasticsearch is highly-scalable search and analytics tool which can store,search data in realtime.

Let us see, How to install elasticsearch on Linux machines either Ubuntu or Centos.
 

Open Terminal and type "sudo su" [HIT Enter], login as root user, so you don't want to use sudo everytime when you use an administrative commands. 


Ubuntu:
Before proceeding to install Elasticsearch, we must confirm that we are up-to-date on apt repository and all dependencies,

Run the below command:
  • apt update
  • apt upgrade && apt dist-upgrade
Once, Completed,Follow the simple steps below: copy and paste one by one
 
JAVA Installation - Dependency for Elasticsearch 
Verify, JAVA is installed on the machine, by the below command:
  •  java -version
 If not installed, Type the below command to install JAVA
  • apt install openjdk-8-jre-headless
Install Elasticsearch
  • wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
Based on your Elasticsearch Version Requirement(am choosing 6 here):
  • echo "deb https://artifacts.elastic.co/packages/5.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-5.x.list
  • echo "deb https://artifacts.elastic.co/packages/6.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-6.x.list
  • echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-7.x.list
After adding your required version apt sources:
  • apt update
  • apt install elasticsearch
  • systemctl enable elasticsearch 
  • systemctl daemon-reload
  • systemctl start elasticsearch
  • systemctl status elasticsearch
 

 
Now, Inorder to make Listen elasticsearch on public - Common Settings for Ubuntu/CentOS:
 
Goto /etc/elasticsearch/elasticsearch.yml file using your fav text editor, i use nano here and edit
network.host = 0.0.0.0
network.port=9200
  • nano /etc/elasticsearch/elasticsearch.yml 
 

 
 Save(CTRL + O) and close (CTRL + X)
 
Restart Elasticsearch: 
  •  systemctl restart elasticsearch   
wait for some 20 to 30 seconds for elasticsearch service to bootup and type the below command to verify elasticsearch running on port 9200.
  • netstat -plunt


  Elasticsearch is installed now - Use Curl or browser to verify the version:
  • curl localhost:9200 

  • On Chrome or Firefox - Type the server ip on which elasticsearch installed http://IP:9200
 
Elasticsearch installation completed on Ubuntu. 

Cent OS:

Before proceeding to install Elasticsearch, we must confirm that we are up-to-date on yum repository and all dependencies,


Run the below command:
  • yum update
Once, Completed,Follow the simple steps below: copy and paste one by one.
 
JAVA Installation - Dependency for Elasticsearch 
Verify, JAVA is installed on the machine, by the below command:
  •  java -version
 If not installed, Type the below command to install JAVA
  • yum install java-1.8.0-openjdk.x86_64 -y

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

Based on your Elasticsearch Version Requirement(am choosing 6 here):
    
  Create the elasticsearch repo using nano or vi text editor:(Change 6.x to any required version ex:7.x)
  • nano /etc/yum.repos.d/elasticsearch.repo
          [elasticsearch] 
          name=Elasticsearch repository for 6.x packages 
          baseurl=https://artifacts.elastic.co/packages/6.x/yum 
          gpgcheck=1 
          gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch 
          enabled=0 
          autorefresh=1 
          type=rpm-md
 
After adding your required version-yum repo sources:
  • yum update
  • yum install --enablerepo=elasticsearch elasticsearch    
  • systemctl daemon-reload
  • systemctl enable elasticsearch 
  • systemctl start elasticsearch
  • systemctl status elasticsearch 



wait for some 20 to 30 seconds for elasticsearch service to bootup and type the below command to verify elasticsearch running on port 9200.

  • netstat -plunt

 

  Elasticsearch is installed now - Use Curl or browser to verify the version:
  • curl localhost:9200 
  • On Chrome or Firefox - Type the server ip on which elasticsearch installed http://IP:9200
Elasticsearch installation completed on CentOS.


No comments: