Install and Configure ElasticSearch in Linux
Download the latest version of Elasticsearch of linux from Elasticsearch Download Manager. Linux download format will be elasticsearch.tar.gz file. Get the download url from the above link.
Download and extract Elasticsearch
Assume we are going to install and configure elasticsearch 7.6.2 version in linux machine. Open terminal navigate to directory where elasticsearch to be installed.Run the following command to download and extract elasticsearch.
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.6.2-linux-x86_64.tar.gz
On running this command you see following output lines
--2020-05-12 00:56:02-- https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.6.2-linux-x86_64.tar.gz
Resolving artifacts.elastic.co... 151.101.190.222, 2a04:4e42:2d::734
Connecting to artifacts.elastic.co|151.101.190.222|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 296477546 (283M) [application/x-gzip]
Saving to: “elasticsearch-7.6.2-linux-x86_64.tar.gz”
100%[====================================================================================================================================================================================>] 296,477,546 48.9M/s in 11s
2020-05-12 00:56:13 (26.4 MB/s) - “elasticsearch-7.6.2-linux-x86_64.tar.gz” saved [296477546/296477546]
This enable successful download of elasticsearch. Now extract elasticsearch-7.6.2-linux-x86_64.tar.gz using following command.
tar xvfz elasticsearch-7.6.2-linux-x86_64.tar.gz
Configure Elasticsearch
There are 3 files to be configured before starting elasticsearch.
1. Elasticsearch.yml 2. jvm.options 3. log4j2.properties
Configuring Elasticsearch.yml
Open config/elasticsearch.yml to configure cluster, host and port. Configure Details are explained here: Config Elasticsearch.yml file
Sample configured elasticsearch.yml file and details are explained below
# =========== Elasticsearch Configuration=========================
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
cluster.name: Test-cluster
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: Test-node-1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /path/to/data
#
# Path to log files:
#
path.logs: /path/to/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 127.0.0.1
#
# Set a custom port for HTTP:
#
http.port: 9200
discovery.type: single-node
Configuring jvm.options
This will enable us to set the memory to be allocated, for heap memory. By default 1GB of heap space. To change heap size to 4gb open: config/jvm.options.
Xms →initial size of total heap space
Xmx → maximum size of total heap space
-Xms4g
-Xmx4g
Configuring log4j2.properties
By default we have console and file logging options. Default logger level is info. You could change any logging option in following file: config/log4j2.properties
Starting Elasticsearch
Execute the following command, from the top level elastic directory. Do not start elasticsearch with sudo (root access).
bin/elasticsearch
Output of the above command:
[2020-05-12T10:09:07,386][INFO ][o.e.d.DiscoveryModule ] [Test-node-1] using discovery type [single-node] and seed hosts providers [settings]
[2020-05-12T10:09:09,071][INFO ][o.e.n.Node ] [Test-node-1] initialized
[2020-05-12T10:09:09,071][INFO ][o.e.n.Node ] [Test-node-1] starting ...
[2020-05-12T10:09:09,288][INFO ][o.e.t.TransportService ] [Test-node-1] publish_address {10.20.192.56:9300}, bound_addresses {10.20.192.56:9300}
[2020-05-12T10:09:09,941][INFO ][o.e.c.c.Coordinator ] [Test-node-1] cluster UUID [ARv5AtHmTo6nYsPo58MJbA]
[2020-05-12T10:09:10,389][INFO ][o.e.h.AbstractHttpServerTransport] [Test-node-1] publish_address {10.20.192.56:9200}, bound_addresses {10.20.192.56:9200}
[2020-05-12T10:09:10,391][INFO ][o.e.n.Node ] [Test-node-1] started
[2020-05-12T10:09:10,850][INFO ][o.e.l.LicenseService ] [Test-node-1] license [cc4b68e3-507d-4cb0-aef9-0ef9e6014906] mode [basic] - valid
[2020-05-12T10:09:10,852][INFO ][o.e.x.s.s.SecurityStatusChangeListener] [Test-node-1] Active license is now [BASIC]; Security is disabled
[2020-05-12T10:09:10,870][INFO ][o.e.g.GatewayService ] [Test-node-1] recovered [0] indices into cluster_state
Once you could see above output, this means elasticsearch is started successfully. We could also verify the starting elasticsearch using curl command.
curl -XGET http://127.0.0.1:9200/
Output
{
"name" : "Test-node-1",
"cluster_name" : "Test-cluster",
"cluster_uuid" : "ARv5AtHmTo6nYsPo58MJbA",
"version" : {
"number" : "7.6.2",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "ef48eb35cf30adf4db14086e8aabd07ef6fb113f",
"build_date" : "2020-03-26T06:34:37.794943Z",
"build_snapshot" : false,
"lucene_version" : "8.4.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
Conclusion
Here elasticsearch is started as single node in Linux environment and started successfully.
My Name is PradeepKumar [pradeep185]. I am a software developer . If you enjoyed this article, please recommend and share it! Thanks for your time.
You can also contact me on mpradeeptce [at] gmail.com