Popular blog tags

How To Install and uninstall reinstall Elasticsearch 7.x on Ubuntu 18.04(aliyun)


Table of content

1.Install Elasticsearch with Debian Packageedit

2.Download and install the Debian package manually


Install Elasticsearch with Debian Package



Install Elasticsearch 7.4.2 on Ubuntu 18.04(aliyun)

step 1:import the Elasticsearch public GPG key into APT
curl -fsSL https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -

step 2:add the Elastic source list to the sources.list.d directory, where APT will look for new sources
echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list

step 3:update your package lists so APT will read the new Elastic source
sudo apt update

step 4:install Elasticsearch
sudo apt install elasticsearch
sudo apt-get install elasticsearch=7.4.2

step 5:Start the Elasticsearch service
sudo systemctl start elasticsearch #Start the Elasticsearch service

step 6:Checking that Elasticsearch is running
curl -X GET "localhost:9200/"
wget http://localhost:9200

step 7:enable Elasticsearch to start up every time your server boots
sudo systemctl enable elasticsearch #enable Elasticsearch to start up every time your server boots

Elasticsearch is now installed.


step 2:Checking that Elasticsearch is running

wget http://localhost:9200


curl -X GET "localhost:9200/"


  "name" : "iZuf6hn15mpmrtypv9ltogZ",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "9MRok0MvR62qtdbi8X3PBQ",
  "version" : {
    "number" : "7.4.2",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "2f90bbf7b93631e52bafb59b3b049cb44ec25e96",
    "build_date" : "2019-10-28T20:40:44.881551Z",
    "build_snapshot" : false,
    "lucene_version" : "8.2.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  "tagline" : "You Know, for Search"



sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable elasticsearch.service

sudo systemctl start elasticsearch.service
sudo systemctl stop elasticsearch.service

sudo systemctl restart elasticsearch.service

sudo systemctl status elasticsearch.service


see the messages logged by the Elasticsearch service you can use the command below:

sudo journalctl -fu elasticsearch.service --since today
sudo journalctl -xe



Directory layout of Debian package

The Debian package places config files, logs, and the data directory in the appropriate locations for a Debian-based system:


Directory structure  on  Ubuntu.

Configuration files:


Download and install the Debian package manually

The Debian package for Elasticsearch  can be downloaded from the website and installed as follows:

Elasticsearch v7.4.2

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.4.2-amd64.deb
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.4.2-amd64.deb.sha512
shasum -a 512 -c elasticsearch-7.4.2-amd64.deb.sha512 
sudo dpkg -i elasticsearch-7.4.2-amd64.deb

Elasticsearch v7.10.0

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.10.0-amd64.deb
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.10.0-amd64.deb.sha512
shasum -a 512 -c elasticsearch-7.10.0-amd64.deb.sha512 
sudo dpkg -i elasticsearch-7.10.0-amd64.deb



Uninstall  Elasticsearch on Ubuntu 18.04(aliyun)

sudo apt-get --purge autoremove elasticsearch
sudo rm -rf /var/lib/elasticsearch/  #completely remove it from the system also delete its directory if there is any
sudo rm -rf /etc/elasticsearch


Reinstall Elasticsearch

sudo apt-get install elasticsearch #because the repo is still on your system. 


You can also install it by directly downloading the Elasticseasrch.DEB file from its official website



Useful links