<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Elastic search Archives - Linux Windows and android Tutorials</title>
	<atom:link href="https://www.osradar.com/tag/elastic-search/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.osradar.com</link>
	<description>tutorials and news and Seurity</description>
	<lastBuildDate>Sat, 19 Jan 2019 01:21:34 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.8.13</generator>
	<item>
		<title>Setting up Elasticsearch on Linux</title>
		<link>https://www.osradar.com/setting-up-elasticsearch-on-linux/</link>
					<comments>https://www.osradar.com/setting-up-elasticsearch-on-linux/#comments</comments>
		
		<dc:creator><![CDATA[osradar_editor]]></dc:creator>
		<pubDate>Fri, 18 Jan 2019 08:35:42 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Elastic search]]></category>
		<guid isPermaLink="false">https://www.osradar.com/?p=9423</guid>

					<description><![CDATA[<p>Overview: If you are looking at options on selecting a database that is best on searching &#8220;full text&#8221; data, look no further than Elasticsearch. Now, you may curious on what are these &#8220;full text&#8221; data. At very basics, its about any context that we might be reading out within a paragraph. For example, a comment [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.osradar.com/setting-up-elasticsearch-on-linux/">Setting up Elasticsearch on Linux</a> appeared first on <a rel="nofollow" href="https://www.osradar.com">Linux  Windows and android  Tutorials</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Overview:</p>
<p>If you are looking at options on selecting a database that is best on searching &#8220;full text&#8221; data, look no further than Elasticsearch. Now, you may curious on what are these &#8220;full text&#8221; data. At very basics, its about any context that we might be reading out within a paragraph. For example, a comment someone post in one of the twitter post. Searching these full text data is one of the best aspect that Elasticsearch brings because performance of the search is  very fast and also reliable. Additionally, there are other benefits as well, including data visualization and aggregation.</p>
<p>OK, now we have a very basic idea about Elasticsearch. However, when it comes to Elasticsearch, you always be heard a stack called &#8220;ELK&#8221;-  acronym stands for ElasticSearch, Logstash &amp; Kibana. Kibana is one of the other component comes into play when we want to search data inside the Elasticsearch. It has got very user-friendly interface where you can perform your queries in a easy manner. Logstash, on the other hand in the stack provide user ability to push data from any source locations, for example from a text file or from a network socket into Elasticsearch in a compatible manner. However, In this article I am not going to talk about Logstash &amp; and its capabilities but it will be available in a separate document with all the powerful features we can discover upon.</p>
<p>Now we have enough background information, lets jump into configuration stuff.</p>
<ul>
<li>Note that the procedure that will follow up will have tar ball source installation, rather depending upon the built-in package managers like APT/YUM. This makes the whole procedure apply to any Linux systems, from Debian based to Fedora based. However, I would recommend to work on one of the latest releases of Linux distros, such as Ubuntu 18.04, CentOS 7, etc.</li>
<li>Further, of course there are benefits if we ever install application/software from their respective sources.
<ol>
<li>You have the full control over application version upgrades, freedom of assign access privileges &amp; isolate binaries and other files into a separate directory areas.</li>
<li> Also, application or the software won&#8217;t ever get impacted across system upgrades, for example, doing yum update or apt-get upgrade.</li>
</ol>
</li>
</ul>
<h2>Setting up the Elasticsearch Node.</h2>
<p>Download the source archive. Note the version numbering where on this demo we are installing Elasticsearch version 6.3.0.</p>
<pre class="lang:sh decode:true">wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.3.0.tar.gz</pre>
<p>&nbsp;</p>
<p>Lets create a directory named &#8220;elastic&#8221; under /opt that then will hold the entire installation files. Also you will notice another sub-directory &#8220;java&#8221; which we will later use to download oracle JDK.</p>
<pre class="lang:sh decode:true ">mkdir -p /opt/elastic/java</pre>
<p>&nbsp;</p>
<p>Now move the download tar archive, change the directory location and extract it</p>
<pre class="lang:sh decode:true">mv elasticsearch-6.3.0.tar.gz /opt/elastic/ &amp;&amp; cd /opt/elastic/ &amp;&amp; tar -xvf elasticsearch-6.3.0.tar.gz</pre>
<p>&nbsp;</p>
<p>Further, create two more directories called &#8220;data&#8221; &amp; &#8220;logs&#8221; that will hold the actual data and the elasticsearch own logging information respectively.</p>
<pre class="lang:sh decode:true">mkdir -p /opt/elastic/elasticsearch-6.3.0/{data,logs}</pre>
<p>&nbsp;</p>
<p>Its time to aware the Elasticsearch application about what we applied in  above step. To do this, we need to access the main configuration file and reference below settings appropriately.</p>
<pre class="">vim /opt/elastic/elasticsearch-6.3.0/config/elasticsearch.yml</pre>
<pre class=""># Path to directory where to store the actual Elasticsearch data
path.data: /opt/elastic/elasticsearch-6.3.0/data
#
# Path to log files that generated by Elasticsearch
path.logs: /opt/elastic/elasticsearch-6.3.0/logs
#
# Reference the IP address of the NIC that you want ELasticsearch to listen on 
network.host: 192.168.0.1</pre>
<p>Note that the &#8220;network.host&#8221; value which should be the IP address on which Elasticsearch process listen on.</p>
<p>Another Important aspect of the configuration is to assign half of the physical memory to Java HEAP. This is because Elasticsearch process actually runs on top of Java.</p>
<pre class="">vim /home/dlogs/elasticsearch/config/jvm.options</pre>
<pre class=""># If the system physical memory is 8GB, lets hand over half(4GB) onto Java Heap 
-Xms4g 
-Xmx4g</pre>
<p>&nbsp;</p>
<p>Further, Its also important to change the existing Kernel hard limits. Here we are looking at specifically changing the default value of &#8220;vm.max_map_count&#8221;.</p>
<pre class="">echo "vm.max_map_count = 262144" &gt;&gt; /etc/sysctl.conf</pre>
<p>&nbsp;</p>
<p>To get affect the above change, lets execute</p>
<pre class="">sysctl -p</pre>
<p>&nbsp;</p>
<p>As I already mentioned, JDK is part of elasticserch workspace. So lets download oracle JDK version 8 and move it to the desired location.</p>
<pre class="lang:sh decode:true">wget -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz</pre>
<pre class="">mv  jdk-8u131-linux-x64.tar.gz /opt/elastic/java/ &amp;&amp; cd  /opt/elastic/java/  &amp;&amp;  tar -xvf jdk-8u131-linux-x64.tar.gz</pre>
<p>&nbsp;</p>
<p>Of course, lets introduce Systemd unit file for the sack of controlling the service.</p>
<pre class="">vim /etc/systemd/system/elasticsearch.service</pre>
<pre class="lang:sh decode:true">[Unit]
Description=Elasticsearch
Documentation=http://www.elastic.co
Wants=network-online.target
After=network-online.target

[Service]
Environment=ES_HOME=/opt/elastic/elasticsearch-6.3.0/
Environment=CONF_DIR=/opt/elastic/elasticsearch-6.3.0/config/
Environment=DATA_DIR=/opt/elastic/elasticsearch-6.3.0/data/
Environment=LOG_DIR=/opt/elastic/elasticsearch-6.3.0/log/
Environment=PID_DIR=/opt/elastic/elasticsearch-6.3.0/
Environment=JAVA_HOME=/opt/elastic/java/jdk1.8.0_131
EnvironmentFile=-/etc/sysconfig/elasticsearch
WorkingDirectory=/opt/elastic/elasticsearch-6.3.0/

User=elastic
Group=elastic

ExecStart=/opt/elastic/elasticsearch-6.3.0/bin/elasticsearch \
                                                -p ${PID_DIR}/elasticsearch.pid \
                                                --quiet \
                                                -Edefault.path.logs=${LOG_DIR} \
                                                -Edefault.path.data=${DATA_DIR} \
                                                -Edefault.path.conf=${CONF_DIR}

StandardOutput=journal
StandardError=inherit
LimitNOFILE=65536
LimitMEMLOCK=infinity
TimeoutStopSec=0
KillSignal=SIGTERM
SendSIGKILL=no
SuccessExitStatus=143

[Install]
WantedBy=multi-user.target
</pre>
<p>&nbsp;</p>
<p>If you note down the above unit file, it supposes that Elasticsearch service should runs as a separate user called &#8220;elastic&#8221; &amp; group &#8220;elastic&#8221;. Lets create them.</p>
<pre class="">useradd elastic</pre>
<p>&nbsp;</p>
<p>Now its time to aware the system about the new Unit files that we placed.</p>
<pre class="">systemctl daemon-reload</pre>
<p>&nbsp;</p>
<p>As far as setting up the Elasticsearch node it&#8217;s done. Now you can invoke the process by calling the systemd service.</p>
<pre class="">systemctl start elasticsearch 
</pre>
<p>&nbsp;</p>
<p>Check the service status as well as the default TCP ports that should be listening on.</p>
<pre class="">systemctl status elasticsearch</pre>
<pre class="">ss -lnt</pre>
<p>If  you can see 9200/tcp &amp; 9300/tcp is being listing on..</p>
<p>Great job.! You done it.</p>
<p>Lets run our first API call to Elasticsearch.</p>
<pre class="">curl -XGET `hostname`:9200</pre>
<pre class="lang:sh decode:true ">{
  "name" : "node-1",
  "cluster_name" : "my-application",
  "cluster_uuid" : "PLiGiyKhSXykxxx7pKa_6w",
  "version" : {
    "number" : "6.3.0",
    "build_hash" : "260387d",
    "build_date" : "2017-06-30T23:16:05.735Z",
    "build_snapshot" : false,
    "lucene_version" : "6.6.0"
  },
  "tagline" : "You Know, for Search"
}
</pre>
<p>&nbsp;</p>
<h2>Setting up the Kibana.</h2>
<p>Its best practice to have all these Elastic stack into a desired directory. So lets download the kibana into the same /opt/elastic area.</p>
<pre class="">cd /opt/elastic/ &amp;&amp; wget https://artifacts.elastic.co/downloads/kibana/kibana-6.3.0-linux-x86_64.tar.gz</pre>
<p>&nbsp;</p>
<p>Once downloading process completed, extract the tar archive by</p>
<pre class="">tar -xvfkibana-6.3.0-linux-x86_64.tar.gz</pre>
<p>&nbsp;</p>
<p>Lets edit the main configuration file &amp; have reference the elasticsearch node IP.</p>
<pre class="">vim /opt/elastic/kibana-6.3.0-linux-x86_64/config/kibana.yml</pre>
<pre class="lang:sh decode:true"># Specifies the address to which the Kibana server will bind to
server.host: "192.168.0.1"

# The URL of the Elasticsearch instance to use for all your queries.
elasticsearch.url: "http://192.168.0.1:9200"</pre>
<p>&nbsp;</p>
<p>Introduce the Kibana Systemd unit file</p>
<pre class="">vim /etc/systemd/system/kibana.service</pre>
<pre class="lang:sh decode:true ">[Unit]
Description=Kibana

[Service]
Type=simple
User=elastic
Group=elastic
EnvironmentFile=-/etc/default/kibana
EnvironmentFile=-/etc/sysconfig/kibana
ExecStart=/opt/elastic/kibana-6.3.0-linux-x86_64/bin/kibana "-c /opt/elastic/kibana-6.3.0-linux-x86_64/config/kibana.yml"
Restart=always
WorkingDirectory=/opt/elastic/kibana-6.3.0-linux-x86_64/


[Install]
WantedBy=multi-user.target</pre>
<p>&nbsp;</p>
<p>Now its time to aware the system about the new Unit files that we placed.</p>
<pre class="">systemctl daemon-reload</pre>
<p>&nbsp;</p>
<p>Now you can invoke the process by calling the systemd service.</p>
<pre class="">systemctl start kibana</pre>
<p>&nbsp;</p>
<p>If you see 5601/tcp from the below output, it confirm that you successfully start the service.</p>
<pre class="">ss -lnt</pre>
<p>&nbsp;</p>
<p>Now, fireup your favorite web browser and visit the Kibana UI.</p>
<pre class="">http://192.168.0.1:5601</pre>
<p><img loading="lazy" class="alignnone size-full wp-image-9492" src="https://www.osradar.com/wp-content/uploads/2019/01/Kibana.png" alt="" width="1905" height="619" srcset="https://www.osradar.com/wp-content/uploads/2019/01/Kibana.png 1905w, https://www.osradar.com/wp-content/uploads/2019/01/Kibana-300x97.png 300w, https://www.osradar.com/wp-content/uploads/2019/01/Kibana-768x250.png 768w, https://www.osradar.com/wp-content/uploads/2019/01/Kibana-1024x333.png 1024w, https://www.osradar.com/wp-content/uploads/2019/01/Kibana-1068x347.png 1068w, https://www.osradar.com/wp-content/uploads/2019/01/Kibana-1293x420.png 1293w" sizes="(max-width: 1905px) 100vw, 1905px" /></p>
<p>Congratulations, You have successfully complete the Elasticsearch/Kibana deployment.</p>
<p>The post <a rel="nofollow" href="https://www.osradar.com/setting-up-elasticsearch-on-linux/">Setting up Elasticsearch on Linux</a> appeared first on <a rel="nofollow" href="https://www.osradar.com">Linux  Windows and android  Tutorials</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.osradar.com/setting-up-elasticsearch-on-linux/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
	</channel>
</rss>
