Installing ElasticSearch 7 on Ubuntu 22.04 Server

ES7 is a requirement for Magento 2.4+, however it is widely used in many other applications and has a broad set of use cases beyond that.

Since Ubuntu 22.04 we moved to GPG key usage for repositories, so we can no longer use apt-key but instead we use:

curl -fsSL https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elastic.gpg

Since we now will be able to pull from the repo, we can add the repo to our sources list:

echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list

Then update and install

sudo apt update && sudo apt install elasticsearch -y

We do need to configure ES7 before we start it. For this example we presume yours is a development need, so a local isolated instance is what we want. We also are not to concerned with security, so will run this without security on the 0.0.0.0 network, so our internal machines can reach it, but do not use this in production without knowing this is what you need!

Also, since we “setup as a single discovery node”, this will allow ES to run without trying to connect to other ES servers, and just run as we need it.

Open the config for editing:

sudo nano /etc/elasticsearch/elasticsearch.yml

And change…

network.host: 0.0.0.0

And lastly add…

discovery.type: single-node

Then save and close the file (CTRL+o for save, and CTRL+x for exit)

Then we can start ElasticSearch for the first time.

sudo service elasticsearch start

The first time it will take a moment, as its initilizing. After it is complete, we suggest you enable the daemon to start on boot, like so:

sudo systemctl enable elasticsearch

Lets check our work…

curl -X GET 'http://localhost:9200'

And we see:

{
  "name" : "ubuntu-22.04",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "2fuEXbTxSnucZcCzpjyrZQ",
  "version" : {
    "number" : "7.17.21",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "d38e4b028f4a9784bb74de339ac1b877e2dbea6f",
    "build_date" : "2024-04-26T04:36:26.745220156Z",
    "build_snapshot" : false,
    "lucene_version" : "8.11.3",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

As you see, ES is running and available, enjoy!


Comments

Leave a Reply

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