[jumpbox]
Update your Server
Once you are logged in to your Ubuntu 20.04 server, run the following command to update your base system with the latest available packages.
apt-get update -y
You can also update your CentOS 8 system with the following command:
dnf update -y
Elasticsearch is an open-source, distributed search engine that allows you to store and analyze a large amount of data. It is specially designed for complex search requirements. It uses a simple set of APIs that provide the ability for full-text search. Elasticsearch is the best choice for you if you are looking to search a large, complex dataset.
In this tutorial, we will show you how to install Elasticsearch on Ubuntu 20.04 and CentOS 8.
Install Elasticsearch on Ubuntu 20.04
In this section, we will show you how to install Elasticsearch on Ubuntu 20.04.
First, you will need to install all the required dependencies to your server. You can install them with the following command:
apt-get install apt-transport-https ca-certificates gnupg2 curl -y
Once all the dependencies are installed, add the Elasticsearch GPG key with the following command:
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | apt-key add -
Next, add the Elasticsearch repository to APT with the following command:
sh -c 'echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" > /etc/apt/sources.list.d/elastic-7.x.list'
Once the repository is added, update the repository and install Elasticsearch with the following command:
apt-get update -y apt-get install elasticsearch -y
Once the installation is completed, start Elasticsearch and enable it to start at system reboot:
systemctl start elasticsearch systemctl enable elasticsearch
You can now verify Elasticsearch with the following command:
curl -X GET "localhost:9200/"
You should get the following output:
{ "name" : "ubuntu2004", "cluster_name" : "elasticsearch", "cluster_uuid" : "PKpCl7VJT6G8q8SxR7m6DQ", "version" : { "number" : "7.10.1", "build_flavor" : "default", "build_type" : "deb", "build_hash" : "1c34507e66d7db1211f66f3513706fdf548736aa", "build_date" : "2020-12-05T01:00:33.671820Z", "build_snapshot" : false, "lucene_version" : "8.7.0", "minimum_wire_compatibility_version" : "6.8.0", "minimum_index_compatibility_version" : "6.0.0-beta1" }, "tagline" : "You Know, for Search" }
Install Elasticsearch on CentOS 8
In this section, we will show you how to install Elasticsearch on CentOS 8.
First, install Java and other required dependencies with the following command:
dnf install java-11-openjdk-devel curl
Once the installation is completed, verify the Java version with the following command:
java -version
You should get the following output:
openjdk version "11.0.9.1" 2020-11-04 LTS OpenJDK Runtime Environment 18.9 (build 11.0.9.1+1-LTS) OpenJDK 64-Bit Server VM 18.9 (build 11.0.9.1+1-LTS, mixed mode, sharing)
Next, import the Elasticsearch GPG key with the following command:
rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
Next, create a repo file for Elasticsearch with the following command:
nano /etc/yum.repos.d/elasticsearch.repo
Add the following lines:
[elasticsearch-7.x] name=Elasticsearch repository for 7.x packages baseurl=https://artifacts.elastic.co/packages/7.x/yum gpgcheck=1 gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch enabled=1 autorefresh=1 type=rpm-md
Save and close the file, then install Elasticsearch with the following command:
dnf install elasticsearch -y
Once the installation is completed, start the Elasticsearch service and enable it to start at system reboot with the following command:
systemctl start elasticsearch systemctl enable elasticsearch
You can now verify the status of the Elasticsearch service with the following command:
systemctl status elasticsearch
You should get the following output:
-
elasticsearch.service - Elasticsearch
Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; disabled; vendor preset: disabled) Active: active (running) since Mon 2021-01-11 03:04:19 EST; 8s ago Docs: https://www.elastic.co Main PID: 1801 (java) Tasks: 65 (limit: 12523) Memory: 1.2G CGroup: /system.slice/elasticsearch.service ├─1801 /usr/share/elasticsearch/jdk/bin/java -Xshare:auto -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=1> └─1986 /usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller Jan 11 03:03:50 centos8 systemd[1]: Starting Elasticsearch... Jan 11 03:04:19 centos8 systemd[1]: Started Elasticsearch.
Next, run the following command to verify Elasticsearch:
curl -X GET "localhost:9200/"
You should see the following output:
{ "name" : "centos8", "cluster_name" : "elasticsearch", "cluster_uuid" : "vFz_YYRvTAWC3AiaMP_ORA", "version" : { "number" : "7.10.1", "build_flavor" : "default", "build_type" : "rpm", "build_hash" : "1c34507e66d7db1211f66f3513706fdf548736aa", "build_date" : "2020-12-05T01:00:33.671820Z", "build_snapshot" : false, "lucene_version" : "8.7.0", "minimum_wire_compatibility_version" : "6.8.0", "minimum_index_compatibility_version" : "6.0.0-beta1" }, "tagline" : "You Know, for Search" }
Conclusion
In the above guide, you learned how to install Elasticsearch on Ubuntu 20.04 and CentOS 8. You can now use Elasticsearch with your e-commerce store application on your dedicated server hosting plan from Atlantic.Net!