elasticsearch - Installing elasticsearch on windows - elastic - elastic search - elasticsearch tutorial - elasticsearch docker
Prerequisites
- 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:
We should get a response that looks like this:
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 we don't yet know how to inspect these variables consult this tutorial.
Run from batch file
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.
Run as a Windows service
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
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 the jvm.options file. [source] Once you made that change, open a command prompt and navigate to the bin directory by running the following command:
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:
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:
After installing the service, you can start and stop it with the respective arguments. To start the service, run
and to stop it, run
If we prefer a GUI to manage the service instead, you can use the following command:
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