2016-04-03 10:09:24 -04:00
[[windows]]
=== Install Elasticsearch on Windows
Elasticsearch can be installed on Windows using the `.zip` package. This
2016-09-15 09:53:44 -04:00
comes with a `elasticsearch-service.bat` command which will setup Elasticsearch to run as a
2016-04-03 10:09:24 -04:00
service.
The latest stable version of Elasticsearch can be found on the
link:/downloads/elasticsearch[Download Elasticsearch] page.
Other versions can be found on the
link:/downloads/past-releases[Past Releases page].
2016-11-01 17:52:09 -04:00
NOTE: Elasticsearch requires Java 8 or later. Use the
http://www.oracle.com/technetwork/java/javase/downloads/index.html[official Oracle distribution]
or an open-source distribution such as http://openjdk.java.net[OpenJDK].
2016-04-03 10:09:24 -04:00
[[install-windows]]
==== Download and install the `.zip` package
2016-10-06 11:56:55 -04:00
ifeval::["{release-state}"=="unreleased"]
Version {version} of Elasticsearch has not yet been released.
endif::[]
ifeval::["{release-state}"!="unreleased"]
2016-09-19 21:10:45 -04:00
Download the `.zip` archive for Elasticsearch v{version} from: https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-{version}.zip
2016-04-03 10:09:24 -04:00
Unzip it with your favourite unzip tool. This will create a folder called
2016-04-06 17:06:42 -04:00
+elasticsearch-{version}+, which we will refer to as `%ES_HOME%`. In a terminal
2016-11-03 15:37:37 -04:00
window, `cd` to the `%ES_HOME%` directory, for instance:
2016-04-03 10:09:24 -04:00
["source","sh",subs="attributes"]
----------------------------
2016-11-03 15:37:37 -04:00
cd c:\elasticsearch-{version}
2016-04-03 10:09:24 -04:00
----------------------------
2016-10-06 15:40:17 -04:00
endif::[]
2016-10-06 11:56:55 -04:00
2016-04-03 10:09:24 -04:00
[[windows-running]]
==== Running Elasticsearch from the command line
Elasticsearch can be started from the command line as follows:
[source,sh]
--------------------------------------------
2017-05-16 09:57:05 -04:00
.\bin\elasticsearch.bat
2016-04-03 10:09:24 -04:00
--------------------------------------------
By default, Elasticsearch runs in the foreground, prints its logs to `STDOUT`,
and can be stopped by pressing `Ctrl-C`.
2016-04-06 17:06:42 -04:00
[[windows-configuring]]
==== Configuring Elasticsearch on the command line
2017-05-16 09:57:05 -04:00
Elasticsearch loads its configuration from the `%ES_HOME%\config\elasticsearch.yml`
2016-04-06 17:06:42 -04:00
file by default. The format of this config file is explained in
<<settings>>.
Any settings that can be specified in the config file can also be specified on
2016-05-19 14:08:08 -04:00
the command line, using the `-E` syntax as follows:
2016-04-06 17:06:42 -04:00
[source,sh]
--------------------------------------------
2017-05-16 09:57:05 -04:00
.\bin\elasticsearch.bat -Ecluster.name=my_cluster -Enode.name=node_1
2016-04-06 17:06:42 -04:00
--------------------------------------------
2016-05-19 14:08:08 -04:00
NOTE: Values that contain spaces must be surrounded with quotes. For instance `-Epath.logs="C:\My Logs\logs"`.
2016-04-06 17:06:42 -04:00
TIP: 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.
2016-04-03 10:09:24 -04:00
include::check-running.asciidoc[]
[[windows-service]]
==== Installing Elasticsearch as a Service on Windows
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
2016-09-15 09:53:44 -04:00
through the `elasticsearch-service.bat` script in the `bin\` folder which allows one to
2016-04-03 10:09:24 -04:00
install, remove, manage or configure the service and potentially start and
stop the service, all from the command-line.
["source","sh",subs="attributes,callouts"]
--------------------------------------------------
2016-11-03 15:37:37 -04:00
c:\elasticsearch-{version}{backslash}bin>elasticsearch-service
2016-04-03 10:09:24 -04:00
2016-09-15 09:53:44 -04:00
Usage: elasticsearch-service.bat install|remove|start|stop|manager [SERVICE_ID]
2016-04-03 10:09:24 -04:00
--------------------------------------------------
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:
[horizontal]
`install`:: Install Elasticsearch as a service
`remove`:: Remove the installed Elasticsearch service (and stop the service if started)
`start`:: Start the Elasticsearch service (if installed)
`stop`:: Stop the Elasticsearch service (if started)
`manager`:: Start a GUI for managing the installed service
Based on the architecture of the available JDK/JRE (set through `JAVA_HOME`),
the appropriate 64-bit(x64) or 32-bit(x86) service will be installed. This
information is made available during install:
["source","sh",subs="attributes"]
--------------------------------------------------
2016-11-03 15:37:37 -04:00
c:\elasticsearch-{version}{backslash}bin>elasticsearch-service install
2016-04-03 10:09:24 -04:00
Installing service : "elasticsearch-service-x64"
Using JAVA_HOME (64-bit): "c:\jvm\jdk1.8"
The service 'elasticsearch-service-x64' has been installed.
--------------------------------------------------
2016-04-06 17:06:42 -04:00
NOTE: 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.
2017-04-21 18:22:55 -04:00
NOTE: 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.
2016-04-03 10:09:24 -04:00
2016-04-06 17:06:42 -04:00
[[windows-service-settings]]
2016-04-03 10:09:24 -04:00
[float]
=== Customizing service settings
2017-02-07 17:25:46 -05:00
The Elasticsearch service can be configured prior to installation by setting the following environment variables (either using the https://technet.microsoft.com/en-us/library/cc754250(v=ws.10).aspx[set command] from the command line, or through the `System Properties->Environment Variables` GUI).
2016-04-03 10:09:24 -04:00
2016-04-06 17:06:42 -04:00
[horizontal]
`SERVICE_ID`::
2016-04-03 10:09:24 -04:00
2016-04-06 17:06:42 -04:00
A unique identifier for the service. Useful if installing multiple instances on the same machine. Defaults to `elasticsearch-service-x86` (on 32-bit Windows) or `elasticsearch-service-x64` (on 64-bit Windows).
`SERVICE_USERNAME`::
The user to run as, defaults to the local system account.
`SERVICE_PASSWORD`::
The password for the user specified in `%SERVICE_USERNAME%`.
`SERVICE_DISPLAY_NAME`::
The name of the service. Defaults to `Elasticsearch <version> %SERVICE_ID%`.
`SERVICE_DESCRIPTION`::
The description of the service. Defaults to `Elasticsearch <version> Windows Service - https://elastic.co`.
`JAVA_HOME`::
The installation directory of the desired JVM to run the service under.
2016-04-03 10:09:24 -04:00
2016-04-06 17:06:42 -04:00
`LOG_DIR`::
Log directory, defaults to `%ES_HOME%\logs`.
`DATA_DIR`::
Data directory, defaults to `%ES_HOME%\data`.
`CONF_DIR`::
Configuration file directory (which needs to include `elasticsearch.yml`
2016-08-31 15:51:52 -04:00
and `log4j2.properties` files), defaults to `%ES_HOME%\conf`.
2016-04-06 17:06:42 -04:00
`ES_JAVA_OPTS`::
Any additional JVM system properties you may want to apply.
`ES_START_TYPE`::
Startup mode for the service. Can be either `auto` or `manual` (default).
`ES_STOP_TIMEOUT` ::
The timeout in seconds that procrun waits for service to exit gracefully. Defaults to `0`.
2016-09-15 09:53:44 -04:00
NOTE: At its core, `elasticsearch-service.bat` relies on http://commons.apache.org/proper/commons-daemon/[Apache Commons Daemon] project
2016-04-06 17:06:42 -04:00
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.
2016-06-01 16:31:16 -04:00
NOTE: On Windows, the <<heap-size,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,
2016-09-15 09:53:44 -04:00
use the service manager: `bin\elasticsearch-service.bat manager`.
2016-06-01 16:31:16 -04:00
2016-04-06 17:06:42 -04:00
Using the Manager GUI::
2016-09-15 09:53:44 -04:00
It is also possible to configure the service after it's been installed using the manager GUI (`elasticsearch-service-mgr.exe`), which offers insight into the installed service, including its status, startup type, JVM, start and stop settings amongst other things. Simply invoking `elasticsearch-service.bat manager` from the command-line will open up the manager window:
2016-04-06 17:06:42 -04:00
image::images/service-manager-win.png["Windows Service Manager GUI",align="center"]
Most changes (like JVM settings) made through the manager GUI will require a restart of the service in order to take affect.
2016-04-03 10:09:24 -04:00
[[windows-layout]]
==== Directory layout of `.zip` archive
The `.zip` package is entirely self-contained. All files and directories are,
2016-04-06 17:06:42 -04:00
by default, contained within `%ES_HOME%` -- the directory created when
2016-04-03 10:09:24 -04:00
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
2016-04-06 17:06:42 -04:00
removing the `%ES_HOME%` directory. However, it is advisable to change the
2016-04-03 10:09:24 -04:00
default locations of the config directory, the data directory, and the logs
directory so that you do not delete important data later on.
[cols="<h,<,<m,<m",options="header",]
|=======================================================================
| Type | Description | Default Location | Setting
| home
2016-04-06 17:06:42 -04:00
| Elasticsearch home directory or `%ES_HOME%`
2016-04-03 10:09:24 -04:00
d| Directory created by unpacking the archive
|
| bin
| Binary scripts including `elasticsearch` to start a node
and `elasticsearch-plugin` to install plugins
2016-04-06 17:06:42 -04:00
| %ES_HOME%\bin
2016-04-03 10:09:24 -04:00
d|
| conf
| Configuration files including `elasticsearch.yml`
2016-04-06 17:06:42 -04:00
| %ES_HOME%\config
2016-04-03 10:09:24 -04:00
| path.conf
| data
| The location of the data files of each index / shard allocated
on the node. Can hold multiple locations.
2016-04-06 17:06:42 -04:00
| %ES_HOME%\data
2016-04-03 10:09:24 -04:00
| path.data
| logs
| Log files location.
2016-04-06 17:06:42 -04:00
| %ES_HOME%\logs
2016-04-03 10:09:24 -04:00
| path.logs
| plugins
| Plugin files location. Each plugin will be contained in a subdirectory.
2016-04-06 17:06:42 -04:00
| %ES_HOME%\plugins
2016-11-09 05:54:56 -05:00
|
2016-04-03 10:09:24 -04:00
| 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.
d| Not configured
| path.repo
|=======================================================================
2016-04-06 17:06:42 -04:00
include::next-steps.asciidoc[]