添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
文雅的葡萄酒  ·  Finding Lead Water ...·  1 周前    · 
斯文的烈马  ·  CRS catalogue·  3 周前    · 
满身肌肉的凉面  ·  How to create ...·  7 月前    · 

Install Elasticsearch with .zip on Windows edit

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.

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 package edit

Download the .zip archive for Elasticsearch 8.14.1 from: https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.14.1-windows-x86_64.zip

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

cd C:\Program Files\elasticsearch-8.14.1

Enable automatic creation of system indices edit

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:

action.auto_create_index: .monitoring*,.watches,.triggered_watches,.watcher-history*,.ml*

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.

Run Elasticsearch from the command line edit

Run the following command to start Elasticsearch from the command line:

.\bin\elasticsearch.bat

When starting Elasticsearch for the first time, security features are enabled and configured by default. The following security configuration occurs automatically:

Authentication and authorization are enabled, and a password is generated for the elastic built-in superuser. Certificates and keys for TLS are generated for the transport and HTTP layer, and TLS is enabled and configured with these keys and certificates. An enrollment token is generated for Kibana, which is valid for 30 minutes.

The password for the elastic user and the enrollment token for Kibana are output to your terminal.

We recommend storing the elastic password as an environment variable in your shell. Example:

$ELASTIC_PASSWORD = "your_password"

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 prints its logs to the console ( STDOUT ) and to the <cluster name>.log file within the logs directory . Elasticsearch logs some information while it is starting, but after it has finished initializing it will continue to run in the foreground and won’t log anything further until something happens that is worth recording. While Elasticsearch is running you can interact with it through its HTTP interface which is on port 9200 by default.

To stop Elasticsearch, press Ctrl-C .

Enroll nodes in an existing cluster edit

When Elasticsearch starts for the first time, the security auto-configuration process binds the HTTP layer to 0.0.0.0 , but only binds the transport layer to localhost. This intended behavior ensures that you can start a single-node cluster with security enabled by default without any additional configuration.

Before enrolling a new node, additional actions such as binding to an address other than localhost or satisfying bootstrap checks are typically necessary in production clusters. During that time, an auto-generated enrollment token could expire, which is why enrollment tokens aren’t generated automatically.

Additionally, only nodes on the same host can join the cluster without additional configuration. If you want nodes from another host to join your cluster, you need to set transport.host to a supported value (such as uncommenting the suggested value of 0.0.0.0 ), or an IP address that’s bound to an interface where other hosts can reach it. Refer to transport settings for more information.

To enroll new nodes in your cluster, create an enrollment token with the elasticsearch-create-enrollment-token tool on any existing node in your cluster. You can then start a new node with the --enrollment-token parameter so that it joins an existing cluster.

In a separate terminal from where Elasticsearch is running, navigate to the directory where you installed Elasticsearch and run the elasticsearch-create-enrollment-token tool to generate an enrollment token for your new nodes.

bin\elasticsearch-create-enrollment-token -s node

Copy the enrollment token, which you’ll use to enroll new nodes with your Elasticsearch cluster.

From the installation directory of your new node, start Elasticsearch and pass the enrollment token with the --enrollment-token parameter.

bin\elasticsearch --enrollment-token <enrollment-token>

Elasticsearch automatically generates certificates and keys in the following directory:

config\certs
Repeat the previous step for any new nodes that you want to enroll.

Configure Elasticsearch on the command line edit

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:

.\bin\elasticsearch.bat -Ecluster.name=my_cluster -Enode.name=node_1

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.

Check that Elasticsearch is running edit

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

curl --cacert %ES_HOME%\config\certs\http_ca.crt -u elastic:$ELASTIC_PASSWORD https://localhost:9200 
"name" : "Cp8oag6", "cluster_name" : "elasticsearch", "cluster_uuid" : "AT69_T_DTp-1qgIJlatQqA", "version" : { "number" : "8.14.1", "build_type" : "tar", "build_hash" : "f27399d", "build_flavor" : "default", "build_date" : "2016-03-30T09:51:41.449Z", "build_snapshot" : false, "lucene_version" : "9.10.0", "minimum_wire_compatibility_version" : "1.2.3", "minimum_index_compatibility_version" : "1.2.3" "tagline" : "You Know, for Search"

Install and run Elasticsearch as a service on Windows edit

You can install Elasticsearch as a service that runs in the background or starts automatically at boot time without user interaction.

Install Elasticsearch as a service. The name of the service and the value of ES_JAVA_HOME will be made available during install:

C:\Program Files\elasticsearch-8.14.1\bin>elasticsearch-service.bat install
Installing service      :  "elasticsearch-service-x64"
Using ES_JAVA_HOME (64-bit):  "C:\jvm\jdk1.8"
The service 'elasticsearch-service-x64' has been installed.

Start Elasticsearch as a service. When Elasticsearch starts, authentication is enabled by default:

C:\Program Files\elasticsearch-8.14.1\bin>bin\elasticsearch-service.bat start

Generate a password for the elastic user with the elasticsearch-reset-password tool. The password is output to the command line.

C:\Program Files\elasticsearch-8.14.1\bin>\bin\elasticsearch-reset-password -u elastic

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 of 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.

Manage Elasticsearch as a service on Windows edit

Run the elasticsearch-service.bat script in the bin\ folder to install, remove, manage, or configure the service and potentially start and stop the service from the command line.

C:\Program Files\elasticsearch-8.14.1\bin>elasticsearch-service.bat
Usage: elasticsearch-service.bat install|remove|start|stop|manager [SERVICE_ID]

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:

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 .

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

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. Invoke elasticsearch-service.bat manager from the command-line to open the manager window.

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

Connect clients to Elasticsearch edit

When you start Elasticsearch for the first time, TLS is configured automatically for the HTTP layer. A CA certificate is generated and stored on disk at:

%ES_HOME%\config\certs\http_ca.crt

The hex-encoded SHA-256 fingerprint of this certificate is also output to the terminal. Any clients that connect to Elasticsearch, such as the Elasticsearch Clients , Beats, standalone Elastic Agents, and Logstash must validate that they trust the certificate that Elasticsearch uses for HTTPS. Fleet Server and Fleet-managed Elastic Agents are automatically configured to trust the CA certificate. Other clients can establish trust by using either the fingerprint of the CA certificate or the CA certificate itself.

If the auto-configuration process already completed, you can still obtain the fingerprint of the security certificate. You can also copy the CA certificate to your machine and configure your client to use it.

Use the CA fingerprint edit

Copy the fingerprint value that’s output to your terminal when Elasticsearch starts, and configure your client to use this fingerprint to establish trust when it connects to Elasticsearch.

If the auto-configuration process already completed, you can still obtain the fingerprint of the security certificate by running the following command. The path is to the auto-generated CA certificate for the HTTP layer.

openssl x509 -fingerprint -sha256 -in config/certs/http_ca.crt

The command returns the security certificate, including the fingerprint. The issuer should be Elasticsearch security auto-configuration HTTP CA .

issuer= /CN=Elasticsearch security auto-configuration HTTP CA
SHA256 Fingerprint=<fingerprint>
Use the CA certificate edit

If your library doesn’t support a method of validating the fingerprint, the auto-generated CA certificate is created in the following directory on each Elasticsearch node:

%ES_HOME%\config\certs\http_ca.crt

Copy the http_ca.crt file to your machine and configure your client to use this certificate to establish trust when it connects to Elasticsearch.

Directory layout of .zip archive edit

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.

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

%ES_HOME%\bin

Configuration files including elasticsearch.yml

%ES_HOME%\config

ES_PATH_CONF

Generated TLS keys and certificates for the transport and HTTP layer.

%ES_HOME%\config\certs

The location of the data files of each index / shard allocated on the node.

%ES_HOME%\data

path.data

Log files location.

%ES_HOME%\logs

path.logs

plugins

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

%ES_HOME%\plugins

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.

Not configured

path.repo

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:

Learn how to configure Elasticsearch . Configure important Elasticsearch settings . Configure important system settings .