Elasticsearch is a flexible, powerful, open-source and real-time search and analytics engine. Using a simple set of APIs, it provides the ability for full-text search. Elastic search is freely available under the Apache 2 license, which provides the most flexibility.
This tutorial will help you to install Elasticsearch on Ubuntu 20.04 LTS system.
Prerequisites
Login to your Ubuntu system using sudo privileges. For the remote Ubuntu server using ssh to access it. Windows users can use putty or alternatives to log in to Ubuntu system.
Step 1 – Install Java
Elasticsearch required Java run time installed on system. Ubuntu 20.04 system users, can run the following commands to install Java (OpenJDK 11):
sudo apt update
sudo apt install openjdk-11-jdk
After installation, check the Java version on your system:
java -version
openjdk version "11.0.7" 2020-04-14 OpenJDK Runtime Environment (build 11.0.7+10-post-Ubuntu-3ubuntu1) OpenJDK 64-Bit Server VM (build 11.0.7+10-post-Ubuntu-3ubuntu1, mixed mode, sharing)
Also, make sure the JAVA_HOME environment variable is configured:
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
Step 2 – Install Elasticsearch on Ubuntu 20.04
The Elasticsearch official team provides an apt repository to install Elasticsearch on Ubuntu Linux system. After install below package and import GPG key for Elasticsearch packages.
sudo apt install apt-transport-https
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
Then configure the apt repository on your Debian system. The below command will add a repository to install latest Elasticsearch 6.X on your Ubuntu system.
add-apt-repository "deb https://artifacts.elastic.co/packages/7.x/apt stable main"
After adding the repository to your system. Run the following commands to update cache and then install Elasticsearch packages on your system.
sudo apt update
sudo apt install elasticsearch
The above commands will install Elasticsearch including all the required dependencies on your system.
Step 3 – Configure Elasticsearch
The Elasticsearch has been installed on your system. You can customize this by editing the Elasticsearch configuration file. Edit configuration file in your favorite text editor:
sudo nano /etc/elasticsearch/elasticsearch.yml
Then update the below basic configurations:
- network.host – Set the network host to 0.0.0.0 to listen on all interfaces and make it available publicly. You can use your LAN address for LAN access only.
network.host: 0.0.0.0
- cluster.name – Name of the cluster. For the multi-node cluster, all the nodes must use the same cluster name.
cluster.name: myCluster1
- node.name – Set the unique name of the node to identify in a cluster.
node.name: "myNode1"
Save your file and close it.
Step 4 – Manage Elasticsearch Service
Next, you need to enable Elasticsearch to start automatically on system boot. Also start service for the first time by running the following commands:
sudo /bin/systemctl enable elasticsearch
sudo /bin/systemctl start elasticsearch
You can use below commands to stop or restart Elasticsearch service from command line:
sudo systemctl stop elasticsearch
sudo systemctl restart elasticsearch
Step 5 – Connect to Elasticsearch
The Elasticsearch service is ready to use. You can test it using curl command-line utility. Run the simple GET command using curl to verify the setup. You will see the Elasticsearch cluster details with the version on your screen.
curl -X GET "http://localhost:9200/?pretty"
{ "name" : "myNode1", "cluster_name" : "myCluster1", "cluster_uuid" : "YLBEZHdqQ2W_gMiDUJXJyw", "version" : { "number" : "7.8.0", "build_flavor" : "default", "build_type" : "deb", "build_hash" : "757314695644ea9a1dc2fecd26d1a43856725e65", "build_date" : "2020-06-14T19:35:50.234439Z", "build_snapshot" : false, "lucene_version" : "8.5.1", "minimum_wire_compatibility_version" : "6.8.0", "minimum_index_compatibility_version" : "6.0.0-beta1" }, "tagline" : "You Know, for Search" }
The above output shows the specifications of your elasticsearch server.
You can create a new bucket to your elasticsearch server by running the following command. Change mybucket with your bucket name:
curl -XPUT http://localhost:9200/mybucket
Output:
{"acknowledged":true}
Conclusion
In this tutorial, you have learned how to install Elasticsearch on Ubuntu 20.04 LTS system. Also, helps you to do basic configuration of Elasticsearch server.
The post How To Install Elasticsearch on Ubuntu 20.04 appeared first on TecAdmin.