{"id":3064,"date":"2020-04-26T11:14:39","date_gmt":"2020-04-26T05:44:39","guid":{"rendered":"https:\/\/www.24x7serversupport.com\/blog\/?p=3064"},"modified":"2020-04-26T11:16:38","modified_gmt":"2020-04-26T05:46:38","slug":"how-to-install-elasticsearch-on-centos-7-6","status":"publish","type":"post","link":"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-elasticsearch-on-centos-7-6\/","title":{"rendered":"How to Install Elasticsearch on CentOS 7\/6"},"content":{"rendered":"\n<p><strong>Elasticsearch<\/strong> is flexible and powerful open-source, distributed real-time search and analytics engine. Using a simple set of APIs provides the ability for full-text search. Elastic search is freely available under the Apache 2 license, which provides the most flexibility.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1 \u2013 Prerequsities<\/h2>\n\n\n\n<p>Java is the primary requirement for installing Elasticsearch on any system. You can check the installed version of Java by executing the following command. <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">java -version\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2 \u2013 Setup Yum Repository<\/h2>\n\n\n\n<p>First of all, install GPG key for the elasticsearch rpm packages.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo rpm --import https:\/\/artifacts.elastic.co\/GPG-KEY-elasticsearch\n<\/pre>\n\n\n\n<p>Then create yum repository file for the elasticsearch. Edit \/etc\/yum.repos.d\/elasticsearch.repo file:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo vi \/etc\/yum.repos.d\/elasticsearch.repo\n<\/pre>\n\n\n\n<p>Add below content:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[Elasticsearch-7]\nname=Elasticsearch repository for 7.x packages\nbaseurl=https:\/\/artifacts.elastic.co\/packages\/7.x\/yum\ngpgcheck=1\ngpgkey=https:\/\/artifacts.elastic.co\/GPG-KEY-elasticsearch\nenabled=1\nautorefresh=1\ntype=rpm-md\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3 \u2013 Install Elasticsearch<\/h2>\n\n\n\n<p>After adding yum repository, just install Elasticsearch on CentOS and RHEL system using the following command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo yum install elasticsearch\n<\/pre>\n\n\n\n<p>After successful installation edit Elasticsearch configuration file \u201c\/etc\/elasticsearch\/elasticsearch.yml\u201d and set the network.host to localhost. You can also change it to the system LAP IP address to make it accessible over the network.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">vim \/etc\/elasticsearch\/elasticsearch.yml\n<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">  network.host: localhost\n<\/pre>\n\n\n\n<p>Then enable the elasticsearch service and start it.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo systemctl enable elasticsearch\nsudo systemctl start elasticsearch\n<\/pre>\n\n\n\n<p>The ElasticSearch has been successfully installed and running on your CentOS or RHEL system.<\/p>\n\n\n\n<p>Run the following command to verify service:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">curl -X GET \"localhost:9200\/?pretty\"\n<\/pre>\n\n\n\n<p>You will see the results like below:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{\n  \"name\" : \"supportadmin\",\n  \"cluster_name\" : \"elasticsearch\",\n  \"cluster_uuid\" : \"HY8HoLHnRCeb3QzXnTcmrQ\",\n  \"version\" : {\n    \"number\" : \"7.4.0\",\n    \"build_flavor\" : \"default\",\n    \"build_type\" : \"rpm\",\n    \"build_hash\" : \"22e1767283e61a198cb4db791ea66e3f11ab9910\",\n    \"build_date\" : \"2019-09-27T08:36:48.569419Z\",\n    \"build_snapshot\" : false,\n    \"lucene_version\" : \"8.2.0\",\n    \"minimum_wire_compatibility_version\" : \"6.8.0\",\n    \"minimum_index_compatibility_version\" : \"6.0.0-beta1\"\n  },\n  \"tagline\" : \"You Know, for Search\"\n}\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 4 \u2013 Elasticsearch Examples (Optional)<\/h2>\n\n\n\n<p>The following examples will help you to add, fetch and search data in the Elasticsearch cluster.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Create New Bucket<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">curl -XPUT http:\/\/localhost:9200\/mybucket\n<\/pre>\n\n\n\n<p><em>Output:<\/em><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{\"acknowledged\":true}\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Adding Data to Elasticsearch<\/h3>\n\n\n\n<p>Use following commands to add some data in Elasticsearch.<br><strong>Command 1:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">curl -XPUT 'http:\/\/localhost:9200\/mybucket\/user\/johny' -d '{ \"name\" : \"supportadmin \" }'\n<\/pre>\n\n\n\n<p><em>Output:<\/em><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{\"_index\":\"mybucket\",\"_type\":\"user\",\"_id\":\"johny\",\"_version\":1,\"created\":true}\n<\/pre>\n\n\n\n<p><strong>Command 2:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">curl -XPUT 'http:\/\/localhost:9200\/mybucket\/post\/1' -d '\n{\n    \"user\": \"test\",\n    \"postDate\": \"02-25-2019\",\n    \"body\": \"This is Demo Post 1 in Elasticsearch\" ,\n    \"title\": \"Demo Post 1\"\n}'\n<\/pre>\n\n\n\n<p><em>Output:<\/em><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{\"_index\":\"mybucket\",\"_type\":\"post\",\"_id\":\"1\",\"_version\":1,\"created\":true}\n<\/pre>\n\n\n\n<p><strong>Command 3:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">curl -XPUT 'http:\/\/localhost:9200\/mybucket\/post\/2' -d '\n{\n    \"user\": \"supportadmin\",\n    \"postDate\": \"02-25-2019\",\n    \"body\": \"This is Demo Post 2 in Elasticsearch\" ,\n    \"title\": \"Demo Post 2\"\n}'\n<\/pre>\n\n\n\n<p><em>Output:<\/em><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{\"_index\":\"mybucket\",\"_type\":\"post\",\"_id\":\"2\",\"_version\":1,\"created\":true}\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Fetching Data from Elasticsearch<\/h3>\n\n\n\n<p>Use the following command to GET data from ElasticSearch and read the output.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">curl -XGET 'http:\/\/localhost:9200\/mybucket\/user\/johny?pretty=true'\ncurl -XGET 'http:\/\/localhost:9200\/mybucket\/post\/1?pretty=true'\ncurl -XGET 'http:\/\/localhost:9200\/mybucket\/post\/2?pretty=true'\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Searching in Elasticsearch<\/h3>\n\n\n\n<p>Use the following command to search data from elastic search. Below command will search all data associated with user johny.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">curl 'http:\/\/localhost:9200\/mybucket\/post\/_search?q=user:TecAdmin&amp;pretty=true'\n<\/pre>\n\n\n\n<p><em>Output:<\/em><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{\n  \"took\" : 145,\n  \"timed_out\" : false,\n  \"_shards\" : {\n    \"total\" : 5,\n    \"successful\" : 5,\n    \"failed\" : 0\n  },\n  \"hits\" : {\n    \"total\" : 1,\n    \"max_score\" : 0.30685282,\n    \"hits\" : [ {\n      \"_index\" : \"mybucket\",\n      \"_type\" : \"post\",\n      \"_id\" : \"2\",\n      \"_score\" : 0.30685282,\n      \"_source\":\n{\n    \"user\": \"supportadmin\",\n    \"postDate\": \"02-25-2019\",\n    \"body\": \"This is Demo Post 2 in Elasticsearch\" ,\n    \"title\": \"Demo Post 2\"\n}\n    } ]\n  }\n}\n\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Elasticsearch is flexible and powerful open-source, distributed real-time search and analytics engine. Using a simple set of APIs provides the ability for full-text search. Elastic search is freely available under the Apache 2 license, which provides the most flexibility. Step 1 \u2013 Prerequsities Java is the primary requirement for installing Elasticsearch on any system. You [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[30],"tags":[],"class_list":["post-3064","post","type-post","status-publish","format-standard","hentry","category-centos"],"jetpack_publicize_connections":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Install Elasticsearch on CentOS 7\/6 | 24x7serversupport Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-elasticsearch-on-centos-7-6\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Install Elasticsearch on CentOS 7\/6 | 24x7serversupport Blog\" \/>\n<meta property=\"og:description\" content=\"Elasticsearch is flexible and powerful open-source, distributed real-time search and analytics engine. Using a simple set of APIs provides the ability for full-text search. Elastic search is freely available under the Apache 2 license, which provides the most flexibility. Step 1 \u2013 Prerequsities Java is the primary requirement for installing Elasticsearch on any system. You [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-elasticsearch-on-centos-7-6\/\" \/>\n<meta property=\"og:site_name\" content=\"24x7serversupport Blog\" \/>\n<meta property=\"article:published_time\" content=\"2020-04-26T05:44:39+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-04-26T05:46:38+00:00\" \/>\n<meta name=\"author\" content=\"24x7support\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@24x7serversuppo\" \/>\n<meta name=\"twitter:site\" content=\"@24x7serversuppo\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"24x7support\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-elasticsearch-on-centos-7-6\/\",\"url\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-elasticsearch-on-centos-7-6\/\",\"name\":\"How to Install Elasticsearch on CentOS 7\/6 | 24x7serversupport Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/#website\"},\"datePublished\":\"2020-04-26T05:44:39+00:00\",\"dateModified\":\"2020-04-26T05:46:38+00:00\",\"author\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/#\/schema\/person\/decfb5fad6bde6ac6822d4e965c6d401\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-elasticsearch-on-centos-7-6\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-elasticsearch-on-centos-7-6\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-elasticsearch-on-centos-7-6\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.24x7serversupport.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Install Elasticsearch on CentOS 7\/6\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/#website\",\"url\":\"https:\/\/www.24x7serversupport.com\/blog\/\",\"name\":\"24x7serversupport Blog\",\"description\":\"Linux | CPanel | WHM | webhosting| Plesk | DirectAdmin | CentOs | Debian | Ubuntu Blog\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.24x7serversupport.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/#\/schema\/person\/decfb5fad6bde6ac6822d4e965c6d401\",\"name\":\"24x7support\",\"url\":\"https:\/\/www.24x7serversupport.com\/blog\/author\/24x7support\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Install Elasticsearch on CentOS 7\/6 | 24x7serversupport Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-elasticsearch-on-centos-7-6\/","og_locale":"en_US","og_type":"article","og_title":"How to Install Elasticsearch on CentOS 7\/6 | 24x7serversupport Blog","og_description":"Elasticsearch is flexible and powerful open-source, distributed real-time search and analytics engine. Using a simple set of APIs provides the ability for full-text search. Elastic search is freely available under the Apache 2 license, which provides the most flexibility. Step 1 \u2013 Prerequsities Java is the primary requirement for installing Elasticsearch on any system. You [&hellip;]","og_url":"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-elasticsearch-on-centos-7-6\/","og_site_name":"24x7serversupport Blog","article_published_time":"2020-04-26T05:44:39+00:00","article_modified_time":"2020-04-26T05:46:38+00:00","author":"24x7support","twitter_card":"summary_large_image","twitter_creator":"@24x7serversuppo","twitter_site":"@24x7serversuppo","twitter_misc":{"Written by":"24x7support","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-elasticsearch-on-centos-7-6\/","url":"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-elasticsearch-on-centos-7-6\/","name":"How to Install Elasticsearch on CentOS 7\/6 | 24x7serversupport Blog","isPartOf":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/#website"},"datePublished":"2020-04-26T05:44:39+00:00","dateModified":"2020-04-26T05:46:38+00:00","author":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/#\/schema\/person\/decfb5fad6bde6ac6822d4e965c6d401"},"breadcrumb":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-elasticsearch-on-centos-7-6\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.24x7serversupport.com\/blog\/how-to-install-elasticsearch-on-centos-7-6\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.24x7serversupport.com\/blog\/how-to-install-elasticsearch-on-centos-7-6\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.24x7serversupport.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Install Elasticsearch on CentOS 7\/6"}]},{"@type":"WebSite","@id":"https:\/\/www.24x7serversupport.com\/blog\/#website","url":"https:\/\/www.24x7serversupport.com\/blog\/","name":"24x7serversupport Blog","description":"Linux | CPanel | WHM | webhosting| Plesk | DirectAdmin | CentOs | Debian | Ubuntu Blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.24x7serversupport.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.24x7serversupport.com\/blog\/#\/schema\/person\/decfb5fad6bde6ac6822d4e965c6d401","name":"24x7support","url":"https:\/\/www.24x7serversupport.com\/blog\/author\/24x7support\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/posts\/3064","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/comments?post=3064"}],"version-history":[{"count":2,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/posts\/3064\/revisions"}],"predecessor-version":[{"id":3066,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/posts\/3064\/revisions\/3066"}],"wp:attachment":[{"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/media?parent=3064"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/categories?post=3064"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/tags?post=3064"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}