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.
2 Comments
i am getting this error
elasticsearch.service – Elasticsearch
Loaded: loaded (/lib/systemd/system/elasticsearch.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2020-08-12 21:57:26 IST; 19s ago
Docs: https://www.elastic.co
Process: 5913 ExecStart=/usr/share/elasticsearch/bin/systemd-entrypoint -p ${PID_DIR}/elasticsearch.pid –quiet (code=exited, status=1/FAILURE)
Main PID: 5913 (code=exited, status=1/FAILURE)
Aug 12 21:57:26 mukesh-GA-78LMT-S2PT systemd-entrypoint[5913]: at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:161)
Aug 12 21:57:26 mukesh-GA-78LMT-S2PT systemd-entrypoint[5913]: at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
Aug 12 21:57:26 mukesh-GA-78LMT-S2PT systemd-entrypoint[5913]: at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:127)
Aug 12 21:57:26 mukesh-GA-78LMT-S2PT systemd-entrypoint[5913]: at org.elasticsearch.cli.Command.main(Command.java:90)
Aug 12 21:57:26 mukesh-GA-78LMT-S2PT systemd-entrypoint[5913]: at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:126)
Aug 12 21:57:26 mukesh-GA-78LMT-S2PT systemd-entrypoint[5913]: at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92)
Aug 12 21:57:26 mukesh-GA-78LMT-S2PT systemd-entrypoint[5913]: For complete error details, refer to the log at /var/log/elasticsearch/mycluster1.log
Aug 12 21:57:26 mukesh-GA-78LMT-S2PT systemd[1]: elasticsearch.service: Main process exited, code=exited, status=1/FAILURE
Aug 12 21:57:26 mukesh-GA-78LMT-S2PT systemd[1]: elasticsearch.service: Failed with result ‘exit-code’.
Aug 12 21:57:26 mukesh-GA-78LMT-S2PT systemd[1]: Failed to start Elasticsearch.
The first sentence is politically smart: “Elasticsearch is a flexible and powerful open-source, distributed real-time search and analytics engine. … ”
Old time ex-manager, long retired now, so I had to research this further. Wikipedia says: (15 July 2020 2:34)
> “This article has multiple issues. …
> “This article relies too much on references to primary sources. Some of this article’s listed sources may not be reliable.
Then Google shows me:
> “elasticsearch vs sql performance” … About 1,160,000 results (0.57 seconds)
> “elasticsearch vs sql terminology” … About 541,000 results (0.94 seconds)
Tradition shows that SQL: “First appeared – 1974; 46 years ago” (Wikipedia), from: “About 283,000,000 results (0.61 seconds)”.
Newcomer elasticsearch is: “Initial release – 8 February 2010; 10 years ago” (Wikipedia), from: “About 14,900,000 results (0.67 seconds)”.
A quick summary follows. Tradition is from 46 years ago, with very strong corporate support. This youngster is one fifth the age, and has one twentieth of the publications about it. There are so few supporters for this youngster, that Wikipedia is asking for someone to tell more about it.
Is it true?
> “Why is Elastic Search [sic] faster at querying compared to raw SQL … ”
> “Leveraging Elasticsearch for a 1,000% performance boost … ”
Traditionalists seem so hostile to the unknown youngsters. Many big wealthy names are threatened by Open Source stuff. If our elected leaders of the “Free World” continue their way, Wikipedia, Elasticsearch, etc will eventually become privatized, like the health industries of the USA.