受欢迎的博客标签

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

Published

Table of content

1.Install Elasticsearch with Debian Packageedit

2.Download and install the Debian package manually

 

Install Elasticsearch with Debian Package

https://www.elastic.co/guide/en/elasticsearch/reference/current/deb.html#deb

 

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
or
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/"
or
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

or

curl -X GET "localhost:9200/"

output:

{
  "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:

/etc/elasticsearch/elasticsearch.yml
/etc/elasticsearch/jvm.options

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

https://www.elastic.co/guide/en/elasticsearch/reference/current/deb.html#install-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. 

or

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

https://www.cnblogs.com/ExMan/p/11351296.html

 

Useful links

https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-elasticsearch-on-ubuntu-18-04