{"id":14594,"date":"2022-02-01T08:47:55","date_gmt":"2022-02-01T08:47:55","guid":{"rendered":"https:\/\/linuxways.net\/?p=14594"},"modified":"2022-02-01T08:47:55","modified_gmt":"2022-02-01T08:47:55","slug":"how-to-install-elasticsearch-on-almalinux-8","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/red-hat\/how-to-install-elasticsearch-on-almalinux-8\/","title":{"rendered":"How to Install ElasticSearch on AlmaLinux 8"},"content":{"rendered":"<p>A key component of the Elastic Stack groups of software components is Elasticsearch. Developed in Java, <a href=\"https:\/\/www.elastic.co\/what-is\/elasticsearch\"> Elasticsearch<\/a> is a opensource, fast and scalable , distributed search and analytics engine.. It allows you to store, index, analyze and search massive volumes of data in near real-time speed. You can store and retrieve data in JSON format using REST APIs.<\/p>\n<p>Over the course of time, Elasticsearch has become a popular search engine in fields such as log analytics, business analytics, security intelligence as well as full-text search.<\/p>\n<p>Notable bluechip companies that leverage Elasticsearch in their tech stacks include Uber, Udemy, Shopify, Netflix, Facebook and many more.<\/p>\n<p>In this article, we will go through the installation of ElasticSearch on AlmaLinux 8.<\/p>\n<h2><strong>Step 1 : Install Java<\/strong><\/h2>\n<p>ElasticSearch was built on Java. You therefore need to install Java on your system. Run:<\/p>\n<pre><strong>$ sudo dnf install java-11-openjdk<\/strong><\/pre>\n<p>Confirm java is installed successfully with the command:<\/p>\n<pre><strong>$ java \u2014version<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"704\" height=\"96\" class=\"wp-image-14595\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-710.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-710.png 704w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-710-300x41.png 300w\" sizes=\"auto, (max-width: 704px) 100vw, 704px\" \/><\/strong><\/p>\n<h2><strong>Step 2: Import Elastic search GPG key<\/strong><\/h2>\n<p>Next, we need to import the GPG key for the Elasticsearch rpm packages. Execute the command:<\/p>\n<pre>$ <strong>sudo rpm --import <\/strong><a href=\"https:\/\/artifacts.elastic.co\/GPG-KEY-elasticsearch\"><strong>https:\/\/artifacts.elastic.co\/GPG-KEY-elasticsearch<\/strong><\/a><\/pre>\n<h2><strong>Step 3: Install Elasticsearch on AlmaLinux<\/strong><\/h2>\n<p>Next, create a file called elasticsearch.repo in the \/etc\/yum.repos.d\/ .<\/p>\n<pre><strong>$ sudo vim \/etc\/yum.repos.d\/elasticsearch.repo<\/strong><\/pre>\n<p>Paste the lines below to the file:<\/p>\n<pre><strong>[elasticsearch]<\/strong>\r\n\r\n<strong>name=Elasticsearch repository for 7.x packages<\/strong>\r\n\r\n<strong>baseurl=https:\/\/artifacts.elastic.co\/packages\/7.x\/yum<\/strong>\r\n\r\n<strong>gpgcheck=1<\/strong>\r\n\r\n<strong>gpgkey=https:\/\/artifacts.elastic.co\/GPG-KEY-elasticsearch<\/strong>\r\n\r\n<strong>enabled=0<\/strong>\r\n\r\n<strong>autorefresh=1<\/strong>\r\n\r\n<strong>type=rpm-md<\/strong><\/pre>\n<p>After that, install elastic search as follows:<\/p>\n<pre><strong>$ sudo dnf install --enablerepo=elasticsearch -y elasticsearch<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"734\" height=\"433\" class=\"wp-image-14596\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-711.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-711.png 734w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-711-300x177.png 300w\" sizes=\"auto, (max-width: 734px) 100vw, 734px\" \/><\/strong><\/p>\n<p>The Elasticsearch service is disabled by default. Run the following systemctl command to start and enable the elastic search service:<\/p>\n<pre><strong>$ sudo systemctl enable elasticsearch.service --now<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"727\" height=\"164\" class=\"wp-image-14597\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-712.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-712.png 727w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-712-300x68.png 300w\" sizes=\"auto, (max-width: 727px) 100vw, 727px\" \/><\/strong><\/p>\n<p>Check the status of the service with the command:<\/p>\n<pre><strong>$ sudo systemctl status elasticsearch<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"733\" height=\"319\" class=\"wp-image-14598\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-713.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-713.png 733w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-713-300x131.png 300w\" sizes=\"auto, (max-width: 733px) 100vw, 733px\" \/><\/strong><\/p>\n<h2><strong>Step 4: Configure ElasticSearch<\/strong><\/h2>\n<p>After a successful installation, edit the Elasticsearch configuration file. The default configuration settings are okay for single operating servers as Elasticsearch runs on localhost only. However, If you want to set up a cluster, you&#8217;ll have to change the configuration file to allow remote connections.<\/p>\n<p>In the example, we have specified the address 0.0.0. 0. This allows Elasticsearch to listen on all interfaces. If you wish to specify a specific IP address, do so in this section.<\/p>\n<pre><strong>$ sudo nano \/etc\/elasticsearch\/elasticsearch.yml<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"728\" height=\"418\" class=\"wp-image-14599\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-714.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-714.png 728w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-714-300x172.png 300w\" sizes=\"auto, (max-width: 728px) 100vw, 728px\" \/><\/strong><\/p>\n<p>For the changes to take effect, run the command:<\/p>\n<pre><strong>$ sudo systemctl restart elasticsearch<\/strong><\/pre>\n<h2><strong>Testing ElasticSearch installation<\/strong><\/h2>\n<p>To confirm that Elasticsearch is up and running on our system, run the following curl command. Elasticsearch listens on port 9200 by default.<\/p>\n<pre><strong>$ curl -X GET \"localhost:9200\/\"<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"724\" height=\"347\" class=\"wp-image-14600\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-715.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-715.png 724w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-715-300x144.png 300w\" sizes=\"auto, (max-width: 724px) 100vw, 724px\" \/><\/strong><\/p>\n<h2><strong>Simple Operations to perform with elastic search<\/strong><\/h2>\n<p>First, we will add data to ElasticSearch, you can use the curl command together with a POST request as shown below:<\/p>\n<pre><strong>$ curl -H 'Content-Type: application\/json' -X POST 'http:\/\/localhost:9200\/employee\/task\/1' -d '{ \"name\": \"Update Jira\" }'<\/strong><\/pre>\n<p>You will get the output below:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"762\" height=\"118\" class=\"wp-image-14601\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-716.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-716.png 762w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-716-300x46.png 300w\" sizes=\"auto, (max-width: 762px) 100vw, 762px\" \/><\/p>\n<p>Next, let\u2019s retrieve that data using a GET request.<\/p>\n<pre><strong>$ curl -X GET '<\/strong><a href=\"http:\/\/localhost:9200\/employee\/task\/1\"><strong>http:\/\/localhost:9200\/employee\/task\/1<\/strong><\/a><strong>'<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"762\" height=\"118\" class=\"wp-image-14602\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-717.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-717.png 762w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-717-300x46.png 300w\" sizes=\"auto, (max-width: 762px) 100vw, 762px\" \/><\/strong><\/p>\n<p>You can retrieve the data in a in human-readable format as follows:<\/p>\n<pre><strong>$ curl -X GET 'http:\/\/localhost:9200\/employee\/task\/1?pretty'<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"777\" height=\"260\" class=\"wp-image-14603\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-718.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-718.png 777w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-718-300x100.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-718-768x257.png 768w\" sizes=\"auto, (max-width: 777px) 100vw, 777px\" \/><\/p>\n<p>You can now use ElasticSearch to handle large volumes of data.<\/p>","protected":false},"excerpt":{"rendered":"<p>A key component of the Elastic Stack groups of software components is Elasticsearch. Developed in Java, Elasticsearch is a opensource, fast and scalable , distributed search and analytics&hellip;<\/p>","protected":false},"author":1,"featured_media":14665,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[165],"tags":[435,358],"class_list":["post-14594","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-red-hat","tag-almalinux-8","tag-elasticsearch"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/14594","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=14594"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/14594\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/14665"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=14594"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=14594"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=14594"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}