For Elasticsearch installation in Linux download .tar file from below download link.
Latest Version : elasticsearch-5.4.0
Download Link : https://www.elastic.co/downloads/elasticsearch
- Java 8 +
- Set JAVA_HOME environment variable to your JDK directory like below by run manually or set in .bash.profile in home directory.
How to Install Elasticsearch?
Untar downloaded .tar file in directory where you want to install elasticsearch by using below command.
tar -zxvf elasticsearch-5.4.0.tar.gz
Your untar directory structure would look as below.
Below is description about all these directories.
|| Binary Script directory which keeps files to start elasticseach, install plugin
|| Keeps elasticsearch.yml file elasticseach configuration and jvm.options to make jvm related setting like heap etc.
||This is default directory set in elasticsearch for keeping node data that can be configure by changing path.data in elasticsearch.yml file.
|| Keeps all jar files for elasticsearch
|| This is default directory set in elasticsearch for keeping logs that can be configure by changing path.logs in elasticsearch.yml file
|| It keeps all functionality and processors required for data.
|| All installed plugin will store in plugins directory
Before going to start Elasticsearch need to make some basic changes in config/elasticsearch.yml file.
cluster.name : Elasticsearch Cluster name is unique name with in network which links all nodes.
node.name : Each node in cluster have unique name by which Cluster identify nodes.
http.port: Default http port for Elasticsearch is 9200 . You can update it .
network.host: This property will set when elasticsearch need to access other machine or by IP. For more on network.host follow link Why network.host?
Now Elasticsearch is ready for start.
How to start Elasticsearch?
There are multiple way to start elasticsearch as below.
- Run in foreground
- Run in background
- Run in background with commandline arguments
Run in Foreground
To run elastic search in Linux server as foreground process to see sysout in console use below command in elasticsearch home directory. When you will see started as in below screen means elasticsearch is started successfully.
In above screen elasticsearch is started on port 9200.
Note: To stop elasticsearch use CNTR+C.
Run in Background
use option “screen -d -m” to run elasticsearch in background
screen -d -m /bin/elasticsearch
Elasticsearch in Background by Command-line configuration
Instead of passing hard code value in elasticsearch.yml file .We can also pass all these above configurable fields from command-line as given below. For more detail follow link Elasticsearch Cluster with multi node on same machine.
./bin/elasticsearch -d -Ecluster.name=FACING-ISSUE-IN-IT
Where -E represents for arguments name where value need to set.
-d is for running elasticsearch as daemon in background .
Note :To stop Elasticsearch running in background findout the process as below and kill processId.
Now Elasticsearch is running and time to Test.
For testing elasticsearch cluster status copy below link try on your browser address bar. You will get result like below.
or as below if network.host configured
"cluster_name" : "FACING-ISSUE-IN-IT",
"status" : "green",
"timed_out" : false,
"number_of_nodes" : 1,
"number_of_data_nodes" : 1,
"active_primary_shards" : 0,
"active_shards" : 0,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 0,
"delayed_unassigned_shards" : 0,
"number_of_pending_tasks" : 0,
"number_of_in_flight_fetch" : 0,
"task_max_waiting_in_queue_millis" : 0,
"active_shards_percent_as_number" : 100.0
For learn more about Cluster follow link Cluster Configuration and Health
Same way you can get detail about your configured Node from below URLs.
or as below if network.host configured
For learn more about Node follow link Node Type,Configuration and status etc. Follow Link for Elasticsearch Tutorials.
To read more on Elasticsearch Configuration, sample Elasticsearch REST clients, Queries Type configurations with example follow link Elasticsearch Tutorial and Elasticsearch Issues.
Hope this blog was helpful for you.
Leave you feedback to enhance more on this topic so that make it more helpful for others.