Elasticsearch 有一个活跃的社区,发布周期非常快。
因为 Elasticsearch 依赖于许多常见的 Java 库(Lucene、Guice 和 Jackson 是最著名的库),所以 Elasticsearch 社区试图让它们保持更新并修复在它们和 Elasticsearch 核心中发现的错误。庞大的用户群也是改进 Elasticsearch 用例的新想法和新功能的来源。
出于这些原因,如果可能,最好使用最新的可用版本(通常是更稳定且没有错误的版本)。
我们将从从网上下载 Elasticsearch 开始。最新版本始终可在 https://www.elastic.co/downloads/elasticsearch下载。可用于不同操作系统的版本如下:
- elasticsearch-{version-number}.zip and elasticsearch-{version-number}.msi are for the Windows operating systems.
- elasticsearch-{version-number}.tar.gz is for Linux/macOS X, while elasticsearch-{version-number}.deb is for Debian-based Linux distributions (this also covers the Ubuntu family); this is installable with Debian using the dpkg -i elasticsearch-*.deb command.
- elasticsearch-{version-number}.rpm is for Red Hat-based Linux distributions (this also covers the Cent OS family). This is installable with the rpm -i elasticsearch-*.rpm command.
The preceding packages contain everything to start Elasticsearch. This book targets version 7.x or higher. The latest and most stable version of Elasticsearch was 7.0.0. To check out whether this is the latest version or not, visit
https://www.elastic.co/downloads/elasticsearch.
提取二进制内容。为您的平台下载正确的版本后,安装涉及在工作目录中展开存档。
Choose a working directory that is safe to charset problems and does not have a long path. This prevents problems when Elasticsearch creates its directories to store index data.
对于 Windows 平台,安装 Elasticsearch 的好目录可能是 c:\es,在 Unix 上和 /opt/es 在 macOS X 上。
要运行 Elasticsearch,您需要安装 JVM 1.8 或更高版本。为了获得更好的性能,我建议您使用最新的 Sun/Oracle 版本。
If you are a macOS X user and you have installed
Homebrew (
http://brew.sh/ ), the first and the second steps are automatically managed by the
brew install elasticsearch command
.
让我们启动 Elasticsearch 来检查一切是否正常。要启动您的 Elasticsearch 服务器,只需访问该目录, 对于 Linux 和 macOS X 执行以下操作:
或者,您可以为 Windows 键入以下命令行:
您的服务器现在应该启动并显示日志 类似 到以下:
Elasticsearch 包一般包含以下目录:
- bin: This contains the scripts to start and manage Elasticsearch.
- elasticsearch.bat: This is the main executable script to start Elasticsearch.
- elasticsearch-plugin.bat: This is a script to manage plugins.
- config: This contains the Elasticsearch configs. The most important ones are as follows:
- elasticsearch.yml: This is the main config file for Elasticsearch
- log4j2.properties: This is the logging config file
- lib: This contains all the libraries required to run Elasticsearch.
- logs: This directory is empty at installation time, but in the future, it will contain the application logs.
- modules: This contains the Elasticsearch default plugin modules.
- plugins: This directory is empty at installation time, but it's the place where custom plugins will be installed.
在 Elasticsearch 启动期间,会发生以下事件:
- A node name is generated automatically (that is, fyBySLM) if it is not provided in elasticsearch.yml. The name is randomly generated, so it's a good idea to set it to a meaningful and memorable name instead.
- A node name hash is generated for this node, for example, fyBySLMcR3uqKiYC32P5Sg.
- The default installed modules are loaded. The most important ones are as follows:
- aggs-matrix-stats: This provides support for aggregation matrix stats.
- analysis-common: This is a common analyzer for Elasticsearch, which extends the language processing capabilities of Elasticsearch.
- ingest-common: These include common functionalities for the ingest module.
- lang-expression/lang-mustache/lang-painless: These are the default supported scripting languages of Elasticsearch.
- mapper-extras: This provides an extra mapper type to be used, such as token_count and scaled_float.
- parent-join: This provides an extra query, such as has_children and has_parent.
- percolator: This provides percolator capabilities.
- rank-eval: This provides support for the experimental rank evaluation APIs. These are used to evaluate hit scoring based on queries.
- reindex: This provides support for reindex actions (reindex/update by query).
- x-pack-*: All the xpack modules depend on a subscription for their activation.
- If there are plugins, they are loaded.
- If not configured, Elasticsearch binds the following two ports on the localhost 127.0.0.1 automatically:
- 9300: This port is used for internal intranode communication.
- 9200: This port is used for the HTTP REST API.
- After starting, if indices are available, they are restored and ready to be used.
如果这些端口号已经绑定,Elasticsearch 会自动增加端口号并尝试绑定它们,直到端口可用(即 9201、9202 等)。
在 Elasticsearch 启动期间会触发更多事件。我们将在其他食谱中详细了解它们。