windows.asciidoc 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. [[windows]]
  2. === Install Elasticsearch on Windows
  3. Elasticsearch can be installed on Windows using the `.zip` package. This
  4. comes with a `elasticsearch-service.bat` command which will setup Elasticsearch to run as a
  5. service.
  6. The latest stable version of Elasticsearch can be found on the
  7. link:/downloads/elasticsearch[Download Elasticsearch] page.
  8. Other versions can be found on the
  9. link:/downloads/past-releases[Past Releases page].
  10. NOTE: Elasticsearch requires Java 8 or later. Use the
  11. http://www.oracle.com/technetwork/java/javase/downloads/index.html[official Oracle distribution]
  12. or an open-source distribution such as http://openjdk.java.net[OpenJDK].
  13. [[install-windows]]
  14. ==== Download and install the `.zip` package
  15. ifeval::["{release-state}"=="unreleased"]
  16. Version {version} of Elasticsearch has not yet been released.
  17. endif::[]
  18. ifeval::["{release-state}"!="unreleased"]
  19. Download the `.zip` archive for Elasticsearch v{version} from: https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-{version}.zip
  20. Unzip it with your favourite unzip tool. This will create a folder called
  21. +elasticsearch-{version}+, which we will refer to as `%ES_HOME%`. In a terminal
  22. window, `cd` to the `%ES_HOME%` directory, for instance:
  23. ["source","sh",subs="attributes"]
  24. ----------------------------
  25. cd c:\elasticsearch-{version}
  26. ----------------------------
  27. endif::[]
  28. [[windows-running]]
  29. ==== Running Elasticsearch from the command line
  30. Elasticsearch can be started from the command line as follows:
  31. [source,sh]
  32. --------------------------------------------
  33. .\bin\elasticsearch
  34. --------------------------------------------
  35. By default, Elasticsearch runs in the foreground, prints its logs to `STDOUT`,
  36. and can be stopped by pressing `Ctrl-C`.
  37. [[windows-configuring]]
  38. ==== Configuring Elasticsearch on the command line
  39. Elasticsearch loads its configuration from the `%ES_HOME%/config/elasticsearch.yml`
  40. file by default. The format of this config file is explained in
  41. <<settings>>.
  42. Any settings that can be specified in the config file can also be specified on
  43. the command line, using the `-E` syntax as follows:
  44. [source,sh]
  45. --------------------------------------------
  46. ./bin/elasticsearch -Ecluster.name=my_cluster -Enode.name=node_1
  47. --------------------------------------------
  48. NOTE: Values that contain spaces must be surrounded with quotes. For instance `-Epath.logs="C:\My Logs\logs"`.
  49. TIP: Typically, any cluster-wide settings (like `cluster.name`) should be
  50. added to the `elasticsearch.yml` config file, while any node-specific settings
  51. such as `node.name` could be specified on the command line.
  52. include::check-running.asciidoc[]
  53. [[windows-service]]
  54. ==== Installing Elasticsearch as a Service on Windows
  55. Elasticsearch can be installed as a service to run in the background or start
  56. automatically at boot time without any user interaction. This can be achieved
  57. through the `elasticsearch-service.bat` script in the `bin\` folder which allows one to
  58. install, remove, manage or configure the service and potentially start and
  59. stop the service, all from the command-line.
  60. ["source","sh",subs="attributes,callouts"]
  61. --------------------------------------------------
  62. c:\elasticsearch-{version}{backslash}bin>elasticsearch-service
  63. Usage: elasticsearch-service.bat install|remove|start|stop|manager [SERVICE_ID]
  64. --------------------------------------------------
  65. The script requires one parameter (the command to execute) followed by an
  66. optional one indicating the service id (useful when installing multiple
  67. Elasticsearch services).
  68. The commands available are:
  69. [horizontal]
  70. `install`:: Install Elasticsearch as a service
  71. `remove`:: Remove the installed Elasticsearch service (and stop the service if started)
  72. `start`:: Start the Elasticsearch service (if installed)
  73. `stop`:: Stop the Elasticsearch service (if started)
  74. `manager`:: Start a GUI for managing the installed service
  75. Based on the architecture of the available JDK/JRE (set through `JAVA_HOME`),
  76. the appropriate 64-bit(x64) or 32-bit(x86) service will be installed. This
  77. information is made available during install:
  78. ["source","sh",subs="attributes"]
  79. --------------------------------------------------
  80. c:\elasticsearch-{version}{backslash}bin>elasticsearch-service install
  81. Installing service : "elasticsearch-service-x64"
  82. Using JAVA_HOME (64-bit): "c:\jvm\jdk1.8"
  83. The service 'elasticsearch-service-x64' has been installed.
  84. --------------------------------------------------
  85. NOTE: The service installer requires that the thread stack size setting
  86. be configured in jvm.options *before* you install the service. On
  87. 32-bit Windows, you should add `-Xss320k` to the jvm.options file, and
  88. on 64-bit Windows you should add `-Xss1m` to the jvm.options file.
  89. 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.
  90. NOTE: Upgrading (or downgrading) JVM versions does not require the service to be reinstalled. However, upgrading across JVM types (e.g. JRE versus SE) is not supported, and does require the service to be reinstalled.
  91. [[windows-service-settings]]
  92. [float]
  93. === Customizing service settings
  94. The Elasticsearch service can be configured prior to installation by setting the 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).
  95. [horizontal]
  96. `SERVICE_ID`::
  97. 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).
  98. `SERVICE_USERNAME`::
  99. The user to run as, defaults to the local system account.
  100. `SERVICE_PASSWORD`::
  101. The password for the user specified in `%SERVICE_USERNAME%`.
  102. `SERVICE_DISPLAY_NAME`::
  103. The name of the service. Defaults to `Elasticsearch <version> %SERVICE_ID%`.
  104. `SERVICE_DESCRIPTION`::
  105. The description of the service. Defaults to `Elasticsearch <version> Windows Service - https://elastic.co`.
  106. `JAVA_HOME`::
  107. The installation directory of the desired JVM to run the service under.
  108. `LOG_DIR`::
  109. Log directory, defaults to `%ES_HOME%\logs`.
  110. `DATA_DIR`::
  111. Data directory, defaults to `%ES_HOME%\data`.
  112. `CONF_DIR`::
  113. Configuration file directory (which needs to include `elasticsearch.yml`
  114. and `log4j2.properties` files), defaults to `%ES_HOME%\conf`.
  115. `ES_JAVA_OPTS`::
  116. Any additional JVM system properties you may want to apply.
  117. `ES_START_TYPE`::
  118. Startup mode for the service. Can be either `auto` or `manual` (default).
  119. `ES_STOP_TIMEOUT` ::
  120. The timeout in seconds that procrun waits for service to exit gracefully. Defaults to `0`.
  121. NOTE: At its core, `elasticsearch-service.bat` relies on http://commons.apache.org/proper/commons-daemon/[Apache Commons Daemon] project
  122. 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.
  123. NOTE: On Windows, the <<heap-size,heap size>> can be configured as for
  124. any other Elasticsearch installation when running Elasticsearch from the
  125. command line, or when installing Elasticsearch as a service for the
  126. first time. To adjust the heap size for an already installed service,
  127. use the service manager: `bin\elasticsearch-service.bat manager`.
  128. Using the Manager GUI::
  129. 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:
  130. image::images/service-manager-win.png["Windows Service Manager GUI",align="center"]
  131. Most changes (like JVM settings) made through the manager GUI will require a restart of the service in order to take affect.
  132. [[windows-layout]]
  133. ==== Directory layout of `.zip` archive
  134. The `.zip` package is entirely self-contained. All files and directories are,
  135. by default, contained within `%ES_HOME%` -- the directory created when
  136. unpacking the archive.
  137. This is very convenient because you don't have to create any directories to
  138. start using Elasticsearch, and uninstalling Elasticsearch is as easy as
  139. removing the `%ES_HOME%` directory. However, it is advisable to change the
  140. default locations of the config directory, the data directory, and the logs
  141. directory so that you do not delete important data later on.
  142. [cols="<h,<,<m,<m",options="header",]
  143. |=======================================================================
  144. | Type | Description | Default Location | Setting
  145. | home
  146. | Elasticsearch home directory or `%ES_HOME%`
  147. d| Directory created by unpacking the archive
  148. |
  149. | bin
  150. | Binary scripts including `elasticsearch` to start a node
  151. and `elasticsearch-plugin` to install plugins
  152. | %ES_HOME%\bin
  153. d|
  154. | conf
  155. | Configuration files including `elasticsearch.yml`
  156. | %ES_HOME%\config
  157. | path.conf
  158. | data
  159. | The location of the data files of each index / shard allocated
  160. on the node. Can hold multiple locations.
  161. | %ES_HOME%\data
  162. | path.data
  163. | logs
  164. | Log files location.
  165. | %ES_HOME%\logs
  166. | path.logs
  167. | plugins
  168. | Plugin files location. Each plugin will be contained in a subdirectory.
  169. | %ES_HOME%\plugins
  170. |
  171. | repo
  172. | 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.
  173. d| Not configured
  174. | path.repo
  175. | script
  176. | Location of script files.
  177. | %ES_HOME%\scripts
  178. | path.scripts
  179. |=======================================================================
  180. include::next-steps.asciidoc[]