Installing elasticsearch on windows

Elasticsearch Installing Elasticsearch on Windows

Example

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- 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:

You 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 you 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 CTRL C 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 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 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 you 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.

Installing elasticsearch on windows

Elasticsearch can be installed on Windows using the Windows .zip archive. This comes with a elasticsearch-service.bat command which will setup Elasticsearch to run as a service.

Elasticsearch has historically been installed on Windows using the .zip archive. An MSI installer package is available that provides the easiest getting started experience for Windows. You can continue using the .zip approach if you prefer.

This package is free to use under the Elastic license. It contains open source and free commercial features and access to paid commercial features. Start a 30-day trial to try out all of the paid commercial features. See the Subscriptions page for information about Elastic license levels.

On Windows the Elasticsearch machine learning feature requires the Microsoft Universal C Runtime library. This is built into Windows 10, Windows Server 2016 and more recent versions of Windows. For older versions of Windows it can be installed via Windows Update, or from a separate download. If you cannot install the Microsoft Universal C Runtime library you can still use the rest of Elasticsearch if you disable the machine learning feature.

The latest stable version of Elasticsearch can be found on the Download Elasticsearch page. Other versions can be found on the Past Releases page.

Elasticsearch includes a bundled version of OpenJDK from the JDK maintainers (GPLv2+CE). To use your own version of Java, see the JVM version requirements

Download and install the .zip packageedit

Alternatively, you can download the following package, which contains only features that are available under the Apache 2.0 license: https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-oss-7.10.2-windows-x86_64.zip

Unzip it with your favourite unzip tool. This will create a folder called elasticsearch-7.10.2 , which we will refer to as %ES_HOME% . In a terminal window, cd to the %ES_HOME% directory, for instance:

Enable automatic creation of system indicesedit

Some commercial features automatically create indices within Elasticsearch. By default, Elasticsearch is configured to allow automatic index creation, and no additional steps are required. However, if you have disabled automatic index creation in Elasticsearch, you must configure action.auto_create_index in elasticsearch.yml to allow the commercial features to create the following indices:

If you are using Logstash or Beats then you will most likely require additional index names in your action.auto_create_index setting, and the exact value will depend on your local configuration. If you are unsure of the correct value for your environment, you may consider setting the value to * which will allow automatic creation of all indices.

Running Elasticsearch from the command lineedit

Elasticsearch can be started from the command line as follows:

If you have password-protected the Elasticsearch keystore, you will be prompted to enter the keystore’s password. See Secure settings for more details.

By default, Elasticsearch runs in the foreground, prints its logs to STDOUT , and can be stopped by pressing Ctrl-C .

Configuring Elasticsearch on the command lineedit

Elasticsearch loads its configuration from the %ES_HOME%\config\elasticsearch.yml file by default. The format of this config file is explained in Configuring Elasticsearch.

Any settings that can be specified in the config file can also be specified on the command line, using the -E syntax as follows:

Values that contain spaces must be surrounded with quotes. For instance -Epath.logs=»C:\My Logs\logs» .

Typically, any cluster-wide settings (like cluster.name ) should be added to the elasticsearch.yml config file, while any node-specific settings such as node.name could be specified on the command line.

Checking that Elasticsearch is runningedit

You can test that your Elasticsearch node is running by sending an HTTP request to port 9200 on localhost :

which should give you a response something like this:

Installing Elasticsearch as a Service on Windowsedit

Elasticsearch can be installed as a service to run in the background or start automatically at boot time without any user interaction. This can be achieved through the elasticsearch-service.bat script in the bin\ folder which allows one to install, remove, manage or configure the service and potentially start and stop the service, all from the command-line.

The script requires one parameter (the command to execute) followed by an optional one indicating the service id (useful when installing multiple Elasticsearch services).

The commands available are:

Install Elasticsearch as a service

Remove the installed Elasticsearch service (and stop the service if started)

Start the Elasticsearch service (if installed)

Stop the Elasticsearch service (if started)

Start a GUI for managing the installed service

The name of the service and the value of JAVA_HOME will be made available during install:

While a JRE can be used for the Elasticsearch service, due to its use of a client VM (as opposed to a server JVM which offers better performance for long-running applications) its usage is discouraged and a warning will be issued.

The system environment variable JAVA_HOME should be set to the path to the JDK installation that you want the service to use. If you upgrade the JDK, you are not required to the reinstall the service but you must set the value of the system environment variable JAVA_HOME to the path to the new JDK installation. However, upgrading across JVM types (e.g. JRE versus SE) is not supported, and does require the service to be reinstalled.

Customizing service settingsedit

The Elasticsearch service can be configured prior to installation by setting the following environment variables (either using the set command from the command line, or through the System Properties->Environment Variables GUI).

A unique identifier for the service. Useful if installing multiple instances on the same machine. Defaults to elasticsearch-service-x64 .

The user to run as, defaults to the local system account.

The password for the user specified in %SERVICE_USERNAME% .

The name of the service. Defaults to Elasticsearch %SERVICE_ID% .

The description of the service. Defaults to Elasticsearch Windows Service — https://elastic.co .

The installation directory of the desired JVM to run the service under.

Service log directory, defaults to %ES_HOME%\logs . Note that this does not control the path for the Elasticsearch logs; the path for these is set via the setting path.logs in the elasticsearch.yml configuration file, or on the command line.

Configuration file directory (which needs to include elasticsearch.yml , jvm.options , and log4j2.properties files), defaults to %ES_HOME%\config .

Any additional JVM system properties you may want to apply.

Startup mode for the service. Can be either auto or manual (default).

The timeout in seconds that procrun waits for service to exit gracefully. Defaults to 0 .

At its core, elasticsearch-service.bat relies on Apache Commons Daemon project to install the service. Environment variables set prior to the service installation are copied and will be used during the service lifecycle. This means any changes made to them after the installation will not be picked up unless the service is reinstalled.

On Windows, the heap size can be configured as for any other Elasticsearch installation when running Elasticsearch from the command line, or when installing Elasticsearch as a service for the first time. To adjust the heap size for an already installed service, use the service manager: bin\elasticsearch-service.bat manager .

The service automatically configures a private temporary directory for use by Elasticsearch when it is running. This private temporary directory is configured as a sub-directory of the private temporary directory for the user running the installation. If the service will run under a different user, you can configure the location of the temporary directory that the service should use by setting the environment variable ES_TMPDIR to the preferred location before you execute the service installation.

Most changes (like JVM settings) made through the manager GUI will require a restart of the service in order to take affect.

Directory layout of .zip archiveedit

The .zip package is entirely self-contained. All files and directories are, by default, contained within %ES_HOME% — the directory created when unpacking the archive.

This is very convenient because you don’t have to create any directories to start using Elasticsearch, and uninstalling Elasticsearch is as easy as removing the %ES_HOME% directory. However, it is advisable to change the default locations of the config directory, the data directory, and the logs directory so that you do not delete important data later on.

home

Elasticsearch home directory or %ES_HOME%

Directory created by unpacking the archive

bin

Binary scripts including elasticsearch to start a node and elasticsearch-plugin to install plugins

conf

Configuration files including elasticsearch.yml

data

The location of the data files of each index / shard allocated on the node. Can hold multiple locations.

logs

Log files location.

plugins

Plugin files location. Each plugin will be contained in a subdirectory.

repo

Shared file system repository locations. Can hold multiple locations. A file system repository can be placed in to any subdirectory of any directory specified here.

Next stepsedit

You now have a test Elasticsearch environment set up. Before you start serious development or go into production with Elasticsearch, you must do some additional setup:

Installing elasticsearch on windows

Elasticsearch can be installed on Windows using the Windows .zip archive. This comes with a elasticsearch-service.bat command which will setup Elasticsearch to run as a service.

Elasticsearch has historically been installed on Windows using the .zip archive. An MSI installer package is available that provides the easiest getting started experience for Windows. You can continue using the .zip approach if you prefer.

This package contains both free and subscription features. Start a 30-day trial to try out all of the features.

On Windows the Elasticsearch machine learning feature requires the Microsoft Universal C Runtime library. This is built into Windows 10, Windows Server 2016 and more recent versions of Windows. For older versions of Windows it can be installed via Windows Update, or from a separate download. If you cannot install the Microsoft Universal C Runtime library you can still use the rest of Elasticsearch if you disable the machine learning feature.

The latest stable version of Elasticsearch can be found on the Download Elasticsearch page. Other versions can be found on the Past Releases page.

Elasticsearch includes a bundled version of OpenJDK from the JDK maintainers (GPLv2+CE). To use your own version of Java, see the JVM version requirements

Download and install the .zip packageedit

Unzip it with your favourite unzip tool. This will create a folder called elasticsearch-7.12.0 , which we will refer to as %ES_HOME% . In a terminal window, cd to the %ES_HOME% directory, for instance:

Enable automatic creation of system indicesedit

Some commercial features automatically create indices within Elasticsearch. By default, Elasticsearch is configured to allow automatic index creation, and no additional steps are required. However, if you have disabled automatic index creation in Elasticsearch, you must configure action.auto_create_index in elasticsearch.yml to allow the commercial features to create the following indices:

If you are using Logstash or Beats then you will most likely require additional index names in your action.auto_create_index setting, and the exact value will depend on your local configuration. If you are unsure of the correct value for your environment, you may consider setting the value to * which will allow automatic creation of all indices.

Running Elasticsearch from the command lineedit

Elasticsearch can be started from the command line as follows:

If you have password-protected the Elasticsearch keystore, you will be prompted to enter the keystore’s password. See Secure settings for more details.

By default, Elasticsearch runs in the foreground, prints its logs to STDOUT , and can be stopped by pressing Ctrl-C .

Configuring Elasticsearch on the command lineedit

Elasticsearch loads its configuration from the %ES_HOME%\config\elasticsearch.yml file by default. The format of this config file is explained in Configuring Elasticsearch.

Any settings that can be specified in the config file can also be specified on the command line, using the -E syntax as follows:

Values that contain spaces must be surrounded with quotes. For instance -Epath.logs=»C:\My Logs\logs» .

Typically, any cluster-wide settings (like cluster.name ) should be added to the elasticsearch.yml config file, while any node-specific settings such as node.name could be specified on the command line.

Checking that Elasticsearch is runningedit

You can test that your Elasticsearch node is running by sending an HTTP request to port 9200 on localhost :

which should give you a response something like this:

Installing Elasticsearch as a Service on Windowsedit

Elasticsearch can be installed as a service to run in the background or start automatically at boot time without any user interaction. This can be achieved through the elasticsearch-service.bat script in the bin\ folder which allows one to install, remove, manage or configure the service and potentially start and stop the service, all from the command-line.

The script requires one parameter (the command to execute) followed by an optional one indicating the service id (useful when installing multiple Elasticsearch services).

The commands available are:

Install Elasticsearch as a service

Remove the installed Elasticsearch service (and stop the service if started)

Start the Elasticsearch service (if installed)

Stop the Elasticsearch service (if started)

Start a GUI for managing the installed service

The name of the service and the value of ES_JAVA_HOME will be made available during install:

While a JRE can be used for the Elasticsearch service, due to its use of a client VM (as opposed to a server JVM which offers better performance for long-running applications) its usage is discouraged and a warning will be issued.

The system environment variable ES_JAVA_HOME should be set to the path to the JDK installation that you want the service to use. If you upgrade the JDK, you are not required to the reinstall the service but you must set the value of the system environment variable ES_JAVA_HOME to the path to the new JDK installation. However, upgrading across JVM types (e.g. JRE versus SE) is not supported, and does require the service to be reinstalled.

Customizing service settingsedit

The Elasticsearch service can be configured prior to installation by setting the following environment variables (either using the set command from the command line, or through the System Properties->Environment Variables GUI).

A unique identifier for the service. Useful if installing multiple instances on the same machine. Defaults to elasticsearch-service-x64 .

The user to run as, defaults to the local system account.

The password for the user specified in %SERVICE_USERNAME% .

The name of the service. Defaults to Elasticsearch %SERVICE_ID% .

The description of the service. Defaults to Elasticsearch Windows Service — https://elastic.co .

The installation directory of the desired JVM to run the service under.

Service log directory, defaults to %ES_HOME%\logs . Note that this does not control the path for the Elasticsearch logs; the path for these is set via the setting path.logs in the elasticsearch.yml configuration file, or on the command line.

Configuration file directory (which needs to include elasticsearch.yml , jvm.options , and log4j2.properties files), defaults to %ES_HOME%\config .

Any additional JVM system properties you may want to apply.

Startup mode for the service. Can be either auto or manual (default).

The timeout in seconds that procrun waits for service to exit gracefully. Defaults to 0 .

At its core, elasticsearch-service.bat relies on Apache Commons Daemon project to install the service. Environment variables set prior to the service installation are copied and will be used during the service lifecycle. This means any changes made to them after the installation will not be picked up unless the service is reinstalled.

By default, Elasticsearch automatically sizes JVM heap based on a node’s roles and total memory. We recommend this default sizing for most production environments. If needed, you can override default sizing by manually setting the heap size.

When installing Elasticsearch on Windows as a service for the first time or running Elasticsearch from the command line, you can manually set the heap size as described in Setting JVM heap size. To resize the heap for an already installed service, use the service manager: bin\elasticsearch-service.bat manager .

The service automatically configures a private temporary directory for use by Elasticsearch when it is running. This private temporary directory is configured as a sub-directory of the private temporary directory for the user running the installation. If the service will run under a different user, you can configure the location of the temporary directory that the service should use by setting the environment variable ES_TMPDIR to the preferred location before you execute the service installation.

Most changes (like JVM settings) made through the manager GUI will require a restart of the service in order to take affect.

Directory layout of .zip archiveedit

The .zip package is entirely self-contained. All files and directories are, by default, contained within %ES_HOME% — the directory created when unpacking the archive.

This is very convenient because you don’t have to create any directories to start using Elasticsearch, and uninstalling Elasticsearch is as easy as removing the %ES_HOME% directory. However, it is advisable to change the default locations of the config directory, the data directory, and the logs directory so that you do not delete important data later on.

Type Description Default Location Setting

home

Elasticsearch home directory or %ES_HOME%

Directory created by unpacking the archive

bin

Binary scripts including elasticsearch to start a node and elasticsearch-plugin to install plugins

conf

Configuration files including elasticsearch.yml

data

The location of the data files of each index / shard allocated on the node. Can hold multiple locations.

logs

Log files location.

plugins

Plugin files location. Each plugin will be contained in a subdirectory.

repo

Shared file system repository locations. Can hold multiple locations. A file system repository can be placed in to any subdirectory of any directory specified here.

Next stepsedit

You now have a test Elasticsearch environment set up. Before you start serious development or go into production with Elasticsearch, you must do some additional setup:

Читайте также:  How to install windows server virtualbox
Оцените статью
Type Description Default Location Setting