{"id":2724,"date":"2019-04-28T21:59:24","date_gmt":"2019-04-28T18:59:24","guid":{"rendered":"https:\/\/kifarunix.com\/?p=2724"},"modified":"2024-03-11T22:36:09","modified_gmt":"2024-03-11T19:36:09","slug":"install-elasticsearch-7-x-on-ubuntu-18-04-debian-9-8","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-elasticsearch-7-x-on-ubuntu-18-04-debian-9-8\/","title":{"rendered":"Install Elasticsearch 7.x on Ubuntu 18.04\/Debian 9.8"},"content":{"rendered":"\n<p>Today we are going to learn how to install Elasticsearch 7.x on Ubuntu 18.04\/Debian 9.8. Elasticsearch is an open source, distributed, RESTful, JSON-based search and analytics engine based on the Lucene library. It is one of the major components of Elastic (ELK) stack.<\/p>\n\n\n\n<div class=\"wp-block-rank-math-toc-block\" id=\"rank-math-toc\"><h2>Table of Contents<\/h2><nav><ul><li><a href=\"#installing-elasticsearch-7-x-on-ubuntu-debian\">Installing Elasticsearch 7.x on Ubuntu\/Debian<\/a><ul><li><a href=\"#install-elasticsearch-7-x-using-apt-repository\">Install Elasticsearch 7.x using APT Repository<\/a><ul><li><a href=\"#import-the-elasticsearch-pgp-key\">Import the Elasticsearch PGP Key<\/a><\/li><li><a href=\"#add-elasticsearch-7-x-apt-repository\">Add Elasticsearch 7.x APT repository<\/a><\/li><li><a href=\"#install-elasticsearch-7-x-on-ubuntu-debian\">Install Elasticsearch 7.x on Ubuntu\/Debian<\/a><\/li><\/ul><\/li><li><a href=\"#installing-elasticsearch-7-x-using-the-debian-package\">Installing Elasticsearch 7.x Using the Debian Package<\/a><ul><li><a href=\"#download-elasticsearch-debian-package\">Download Elasticsearch Debian package<\/a><\/li><li><a href=\"#install-elasticsearch-7-17-9-using-the-debian-package\">Install Elasticsearch 7.17.9 using the Debian package<\/a><\/li><\/ul><\/li><li><a href=\"#running-elasticsearch\">Running Elasticsearch<\/a><\/li><li><a href=\"#bootstrap-checks-single-node-discovery\">Bootstrap Checks\/Single-node discovery.<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"installing-elasticsearch-7-x-on-ubuntu-debian\">Installing Elasticsearch 7.x on Ubuntu\/Debian<\/h2>\n\n\n\n<p>There are different methods in which you can install Elasticsearch 7.0.0 on Ubuntu 18.04 or Debian 9.8. These include the use of the tar.gz archive, the Debian package (DEB) or from the APT repository.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"install-elasticsearch-7-x-using-apt-repository\">Install Elasticsearch 7.x using APT Repository<\/h3>\n\n\n\n<p>Before you can proceed, re-synchronize your system packages to the latest versions.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apt update<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"import-the-elasticsearch-pgp-key\">Import the Elasticsearch PGP Key<\/h4>\n\n\n\n<p>To install Elasticsearch 7.0.0 from APT repository, you need to import the Elasticsearch Signing Key by running the command below;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install gnupg2 -y<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>wget -qO - https:\/\/artifacts.elastic.co\/GPG-KEY-elasticsearch | gpg --dearmor &gt; \/etc\/apt\/trusted.gpg.d\/elk.gpg<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"add-elasticsearch-7-x-apt-repository\">Add Elasticsearch 7.x APT repository<\/h4>\n\n\n\n<p>Next, you need to create Elasticsearch 7.x repository by executing the command below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>echo \"deb https:\/\/artifacts.elastic.co\/packages\/7.x\/apt stable main\" | sudo tee \/etc\/apt\/sources.list.d\/elastic-7.x.list<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"install-elasticsearch-7-x-on-ubuntu-debian\">Install Elasticsearch 7.x on Ubuntu\/Debian<\/h4>\n\n\n\n<p>Once you have the repo in place, update your system and install Elasticsearch 7.0.0 by running the commands below. Note that Elasticsearch includes a bundled version of OpenJDK from the JDK maintainers.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apt update<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>apt-get install apt-transport-https<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>apt install elasticsearch<\/code><\/pre>\n\n\n\n<p>There you go.<\/p>\n\n\n\n<p>You have successfully installed Elasticsearch 7.x on Ubuntu 18.04\/Debian 9.8.<\/p>\n\n\n\n<p>You can find the Elasticsearch configuration file as <strong>\/etc\/elasticsearch\/elasticsearch.yml<\/strong>. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"installing-elasticsearch-7-x-using-the-debian-package\">Installing Elasticsearch 7.x Using the Debian Package<\/h3>\n\n\n\n<p>As stated above, another option of installing Elasticsearch 7.x on Ubuntu 18.04\/Debian 9.8 is by using the Debian package (DEB).<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"download-elasticsearch-debian-package\">Download Elasticsearch Debian package<\/h4>\n\n\n\n<p>Run the command below to download Elasticsearch debian package.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>wget https:\/\/artifacts.elastic.co\/downloads\/elasticsearch\/elasticsearch-7.17.9-amd64.deb<\/code><\/pre>\n\n\n\n<p>Once the download is done, you need to verify the integrity of the Debian package. Hence, download the checksum file.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>wget https:\/\/artifacts.elastic.co\/downloads\/elasticsearch\/elasticsearch-7.17.9-amd64.deb.sha512<\/code><\/pre>\n\n\n\n<p>Run the comparison of SHA of the downloaded Debian package and the published checksum as shown below. If all is well, you should get an OK output.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>shasum -a 512 -c elasticsearch-7.17.9-amd64.deb.sha512 <\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>elasticsearch-7.17.9-amd64.deb: OK<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"install-elasticsearch-7-17-9-using-the-debian-package\">Install Elasticsearch 7.17.9 using the Debian package<\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo apt install .\/elasticsearch-7.17.9-amd64.deb<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"running-elasticsearch\">Running Elasticsearch<\/h3>\n\n\n\n<p>To configure Elasticsearch to start on system boot, run the following commands:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl daemon-reload<br>systemctl enable elasticsearch<\/code><\/pre>\n\n\n\n<p>To start and stop Elasticsearch, run the commands below respectively:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl enable --now elasticsearch<\/code><\/pre>\n\n\n\n<p>To check the status, run the command below;<\/p>\n\n\n\n<p><\/p>\n\n\n\n<pre class=\"scroll-box\"><code>\n\u25cf elasticsearch.service - Elasticsearch\n     Loaded: loaded (\/lib\/systemd\/system\/elasticsearch.service; disabled; vendor preset: enabled)\n     Active: active (running) since Fri 2023-04-07 19:16:41 EAT; 3h 11min ago\n       Docs: https:\/\/www.elastic.co\n   Main PID: 636 (java)\n      Tasks: 86 (limit: 4679)\n     Memory: 1.2G\n        CPU: 10min 17.111s\n     CGroup: \/system.slice\/elasticsearch.service\n             \u251c\u2500636 \/usr\/share\/elasticsearch\/jdk\/bin\/java -Xshare:auto -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=10 -XX:+AlwaysPreTouch -Xss1m>\n             \u2514\u2500840 \/usr\/share\/elasticsearch\/modules\/x-pack-ml\/platform\/linux-x86_64\/bin\/controller\n\nApr 07 19:16:09 ubuntu systemd[1]: Starting Elasticsearch...\nApr 07 19:16:41 ubuntu systemd[1]: Started Elasticsearch.\n<\/code><\/pre>\n\n\n\n<p>You can also check Elasticsearch log file, <strong>\/var\/log\/elasticsearch\/elasticsearch.log<\/strong>, for more details.<\/p>\n\n\n\n<p>You can also use curl command to check if Elasticsearch is running. Note that Elasticsearch listens on tcp port 9200 by default.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apt install curl<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>curl -XGET \"localhost:9200\/\"<\/code><\/pre>\n\n\n\n{\n  &#8220;name&#8221; : &#8220;ubuntu&#8221;,\n  &#8220;cluster_name&#8221; : &#8220;elasticsearch&#8221;,\n  &#8220;cluster_uuid&#8221; : &#8220;pE3v-1oSTfaiF3Dp2VbOjg&#8221;,\n  &#8220;version&#8221; : {\n    &#8220;number&#8221; : &#8220;7.17.0&#8221;,\n    &#8220;build_flavor&#8221; : &#8220;default&#8221;,\n    &#8220;build_type&#8221; : &#8220;deb&#8221;,\n    &#8220;build_hash&#8221; : &#8220;bee86328705acaa9a6daede7140defd4d9ec56bd&#8221;,\n    &#8220;build_date&#8221; : &#8220;2022-01-28T08:36:04.875279988Z&#8221;,\n    &#8220;build_snapshot&#8221; : false,\n    &#8220;lucene_version&#8221; : &#8220;8.11.1&#8221;,\n    &#8220;minimum_wire_compatibility_version&#8221; : &#8220;6.8.0&#8221;,\n    &#8220;minimum_index_compatibility_version&#8221; : &#8220;6.0.0-beta1&#8221;\n  },\n  &#8220;tagline&#8221; : &#8220;You Know, for Search&#8221;\n}\n\n\n\n<h3 class=\"wp-block-heading\" id=\"bootstrap-checks-single-node-discovery\">Bootstrap Checks\/Single-node discovery.<\/h3>\n\n\n\n<p>Elasticsearch is listening on <strong>localhost<\/strong> by default. If you are running Elasticsearch for testing and you need to access it from outside, you need to change the network bind address. However, for this to work, you need to configure <strong>single-node discovery<\/strong>. <\/p>\n\n\n\n<p>Hence, open the configuration file and;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>vim \/etc\/elasticsearch\/elasticsearch.yml<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>configure specific Interface IP by uncommenting and changing the value of <strong>network.host<\/strong> and uncomment the <strong>http.port<\/strong> line under the Network settings section. Be sure to implement strict firewall rules for security purposes.<\/li>\n<\/ul>\n\n\n\n# &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- Network &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;\n#\n# Set the bind address to a specific IP (IPv4 or IPv6):\n#\n#network.host: 192.168.0.1\nnetwork.host: 192.168.0.101\n#\n# Set a custom port for HTTP:\n#\n#http.port: 9200\nhttp.port: 9200\n#\n# For more information, consult the network module documentation.\n#\n\n\n\n<ul class=\"wp-block-list\">\n<li>add the line, <strong>discovery.type: single-node<\/strong>, under the Discovery settings section.<\/li>\n<\/ul>\n\n\n\n# &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; Discovery &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-\n#\n# Pass an initial list of hosts to perform discovery when this node is started:\n# The default list of hosts is [&#8220;127.0.0.1&#8221;, &#8220;[::1]&#8221;]\n#\n#discovery.seed_hosts: [&#8220;host1&#8221;, &#8220;host2&#8221;]\n#\n# Bootstrap the cluster using an initial set of master-eligible nodes:\n#\n#cluster.initial_master_nodes: [&#8220;node-1&#8221;, &#8220;node-2&#8221;]\n#\n# For more information, consult the discovery and cluster formation module documentation.\n#\ndiscovery.type: single-node\n\n\n\n<p>Restart Elasticsearch and confirm that it is listening on an interface IP.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>curl -X GET \"192.168.0.101:9200\/\"<\/code><\/pre>\n\n\n\n{\n  &#8220;name&#8221; : &#8220;ubuntu&#8221;,\n  &#8220;cluster_name&#8221; : &#8220;elasticsearch&#8221;,\n  &#8220;cluster_uuid&#8221; : &#8220;pE3v-1oSTfaiF3Dp2VbOjg&#8221;,\n  &#8220;version&#8221; : {\n    &#8220;number&#8221; : &#8220;7.17.0&#8221;,\n    &#8220;build_flavor&#8221; : &#8220;default&#8221;,\n    &#8220;build_type&#8221; : &#8220;deb&#8221;,\n    &#8220;build_hash&#8221; : &#8220;bee86328705acaa9a6daede7140defd4d9ec56bd&#8221;,\n    &#8220;build_date&#8221; : &#8220;2022-01-28T08:36:04.875279988Z&#8221;,\n    &#8220;build_snapshot&#8221; : false,\n    &#8220;lucene_version&#8221; : &#8220;8.11.1&#8221;,\n    &#8220;minimum_wire_compatibility_version&#8221; : &#8220;6.8.0&#8221;,\n    &#8220;minimum_index_compatibility_version&#8221; : &#8220;6.0.0-beta1&#8221;\n  },\n  &#8220;tagline&#8221; : &#8220;You Know, for Search&#8221;\n}\n\n\n\n<p>Well, Elasticsearch is now running.<\/p>\n\n\n\n<p>You can also check our guide on how to <a aria-label=\"install Elasticsearch 7.x on CentOS 7\/Fedora 29 (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/install-elasticsearch-7-x-on-centos-7-fedora-29\/\" target=\"_blank\" rel=\"noreferrer noopener\">install Elasticsearch 7.x on CentOS 7\/Fedora 29<\/a>. Enjoy.<\/p>\n\n\n\n<p>To build Elastic Stack, you need to install and configure other Components such as Kibana, Logstash, Beats. See the links below;<\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" href=\"https:\/\/kifarunix.com\/install-elastic-stack-7-on-ubuntu-18-04-debian-9-8\/\" target=\"_blank\">Install Kibana 7 on Ubuntu 18.04\/Debian 9.8<\/a><\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/install-and-configure-logstash-7-on-ubuntu-18-debian-9-8\/\" target=\"_blank\">Install and Configure Logstash 7 on Ubuntu 18\/Debian 9.8<\/a><\/p>\n\n\n\n<p><a aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/install-and-configure-filebeat-7-on-ubuntu-18-04-debian-9-8\/\" target=\"_blank\" rel=\"noreferrer noopener\">Install and Configure Filebeat 7 on Ubuntu 18.04\/Debian 9.8<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today we are going to learn how to install Elasticsearch 7.x on Ubuntu 18.04\/Debian 9.8. Elasticsearch is an open source, distributed, RESTful, JSON-based search and<\/p>\n","protected":false},"author":1,"featured_media":5014,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[72,910],"tags":[287,912,911,913,67],"class_list":["post-2724","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-monitoring","category-elastic-stack","tag-debian-9","tag-elastic-stack","tag-elasticsearch-7-0","tag-elk","tag-ubuntu-18-04","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50","resize-featured-image"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/2724"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=2724"}],"version-history":[{"count":9,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/2724\/revisions"}],"predecessor-version":[{"id":21139,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/2724\/revisions\/21139"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/5014"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=2724"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=2724"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=2724"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}