The Windows version of Elasticsearch can be obtained from this link: https://www.elastic.co/downloads/elasticsearch. The latest stable release is always at the top.
As we are installing on Windows, we need the .ZIP
archive. Click the link in the Downloads:
section and save the file to your computer.
This version of elastic is "portable", meaning you don't need to run an installer to use the program. Unzip the contents of the file to a location you can easily remember. For demonstration we'll assume you unzipped everything to C:\elasticsearch
.
Note that the archive contains a folder named elasticsearch-<version>
by default, you can either extract that folder to C:\
and rename it to elasticsearch
or create C:\elasticsearch
yourself, then unzip only the contents of the folder in the archive to there.
Because Elasticsearch is written in Java, it needs the Java Runtime Environment to function. So before running the server, check if Java is available by opening a command prompt and typing:
java -version
You should get a response that looks like this:
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) Client VM (build 25.91-b14, mixed mode)
If you see the following instead
'java' is not recognized as an internal or external command, operable program or batch file.
Java is not installed on your system or is not configured properly. You can follow this tutorial to (re)install Java. Also, make sure that these environment variables are set to similar values:
Variable | Value |
---|---|
JAVA_HOME | C:\Program Files\Java\jre |
PATH | …;C:\Program Files\Java\jre |
If you don't yet know how to inspect these variables consult this tutorial.
With Java installed, open the bin
folder. It can be found directly within the folder you unzipped everything to, so it should be under c:\elasticsearch\bin
. Within this folder is a file called elasticsearch.bat
which can be used to start Elasticsearch in a command window. This means that information logged by the process will be visible in the command prompt window. To stop the server, press CTRLC or simply close the window.
Ideally you don't want to have an extra window you can't get rid of during development, and for this reason, Elasticsearch can be configured to run as a service.
Before we could install Elasticsearch as a service we need to add a line to the file C:\elasticsearch\config\jvm.options
:
The service installer requires that the thread stack size setting be configured in
jvm.options
before you install the service. On 32-bit Windows, you should add-Xss320k
[…] and on 64-bit Windows you should add-Xss1m
to thejvm.options
file. [source]
Once you made that change, open a command prompt and navigate to the bin
directory by running the following command:
C:\Users\user> cd c:\elasticsearch\bin
Service management is handled by elasticsearch-service.bat
. In older versions this file might simply be called service.bat
. To see all available arguments, run it without any:
C:\elasticsearch\bin> elasticsearch-service.bat
Usage: elasticsearch-service.bat install|remove|start|stop|manager [SERVICE_ID]
The output also tells us that there's an optional SERVICE_ID
argument, but we can ignore it for now. To install the service, simply run:
C:\elasticsearch\bin> elasticsearch-service.bat install
After installing the service, you can start and stop it with the respective arguments. To start the service, run
C:\elasticsearch\bin> elasticsearch-service.bat start
and to stop it, run
C:\elasticsearch\bin> elasticsearch-service.bat stop
If you prefer a GUI to manage the service instead, you can use the following command:
C:\elasticsearch\bin> elasticsearch-service.bat manager
This will open the Elastic Service Manager, which allows you to customize some service-related settings as well as stop/start the service using the buttons found at the bottom of the first tab.