Install and configure Elasticsearch in Windows

Mar 7, 2016

Recently I had to install & configure Elasticsearch and took some notes about it for further reference. Everything down here is actual at the moment of writing, March 2016 and Elasticsearch version 2.2.0.

Installation

Unzip downloaded file to location where your application will run from. C:\Program Files\Elasticsearch-2.2.0

Configuration

Location of configuration file: {install-path}\config\elasticsearch.yml. This is a text file using YAML format and that can be edited in any text editor.

Data folders

Uncomment lines containing path.data and path.logs keys. Set values to the location where elasticsearch should store indexes, documents and log files. Example:

path.data: D:\Elasticsearch\Data
path.logs: D:\Elasticsearch\Logs

Exposing elasticsearch endpoint over the local network

Uncomment network.host and set value to _site:

network.host: _site_

This will make elasticserch available under machine’s site name. Example: http://servername:9200.

Set the heap size

By default Elasticsearch will reserve 1 GB for it’s heap. For most installations it’s not enough. Set it appropriatelly to RAM available on your servers and server load. To set the heap size you have to create a system environment variable (more details here:

Configure to run as a service

Open Services management console (services.msc) and find Elasticsearch 2.2.0 service. Change Startup Type to Automatic. If you need to run the service under a specific user account that’s the place to set that up.

Start the service

Checks (post-configure & post-install)

After starting the service check logs for any errors.

Open http://machinename:9200/ in browser. No web page is opened but request should succeed by returning a JSON response or a file (depending on the browser).

If any of monitoring plugins is installed check there the state of your cluster and nodes (for example on http://machinename:9200/_plugin/kopf)

Setting up a basic cluster

If you want the simplest configuration but you want a your cluster to have some redundancy and good performance - then Elastic’s default settings will work well for you. Say, for redundancy and query distribution you want to run an ES cluster on 2 (or n nodes). Then your starting point will be a very basic elasticsearch.yml (example for 2 nodes):

Pretty self-explanatory. This should be enough to get you a working cluster of 2 boxes where both nodes will be master-eligible and data nodes and only one node will be playing the role of master node. But you can still query getting them processed on any of nodes. More about network settings