Setup

本章内容为如何安装并运行 elasticsearh。如果你还没准备好的话,那你先 下载 它,然后再核对 安装 文档。

注意

也可以用 apt 或者 yum 命令来从软件库中直接安装 Elasticsearch。在 Repositories 一文中有详细介绍。

支持的平台

官方对于各操作平台和 Java 版本的支持信息可以参见:Support Matrix 。Elasticsearch 在这些平台上都测试过,但它或许也可以工作在其他平台上。

安装

下载 好最新发布的软件包后再把它解压开,你就可以用下面这段命令来执行 Elastcsearch 了:

$ bin/elasticsearch

在类 Unix 系统中,这个命令将在前台启动程序。

在后台运行

如果要在后台运行的话,加一个-d就行:

$ bin/elasticsearch -d

PID (Process Identification 进程ID)

Elasticsearch 可以在启动的时候把它的 PID 写入到指定的文件中,这使得在关闭它的时候变得非常方便:

$ bin/elasticsearch -d -p pid ①
$ kill `cat pid` ②

① PID 被写入一个叫 pid 的文件中。

② kill 命令给存储在pid文件中的 PID 发送了一个 TERM 信号。

注意

LinuxWindows 的启动脚本会帮你处理好 Elasticsearch 的启动和停止动作。

类 Unix 系统
elasticsearch shell 脚本有一些额外的功能,比如刚才提到的,你可以指定要它运行在前台还是后台。

另一个功能是你可以传入 -D 或者 getopt 长格式的配置参数。那你传入后,你就可以覆盖JAVA_OPTS 或者 ES_JAVA_OPTS。下面一个示例:

$ bin/elasticsearch -Des.index.refresh_interval=5s --node.name=my-node

Java (JVM) 版本

Elasticsearch 是用 Java 构建的,要运行它的话,只要需要 Java 7 版本。目前只支持 Oracle 或者 OpenJDK 的 Java。所有的 Elasticsearch 的节点或者客户端都应该使用相同版本的 JVM。

我们推荐安装 Java 8 update 20 或者更高的版本,或者Java 7 update 55 或更高的版本。Java 7 的其他低版本中有一些已知的 BUG 会导致索引受到污染并丢失数据。如果 Elasticsearch 检测当前的 Java 环境不适宜的话,它就会拒绝运行命令。

Java 的版本可以通过JAVA_HOME环境变量来指定


This section includes information on how to setup elasticsearch and get it running. If you haven’t already, download it, and then check the installation docs.

Note

Elasticsearch can also be installed from our repositories using apt or yum. See Repositories.

Supported platforms

The matrix of officially supported operating systems and JVMs is available here: Support Matrix. Elasticsearch is tested on the listed platforms, but it is possible that it will work on other platforms too.

Installation

After downloading the latest release and extracting it, elasticsearch can be started using:

$ bin/elasticsearch

On *nix systems, the command will start the process in the foreground.

Running as a daemonedit

To run it in the background, add the -d switch to it:

$ bin/elasticsearch -d

PID

The Elasticsearch process can write its PID to a specified file on startup, making it easy to shut down the process later on:

$ bin/elasticsearch -d -p pid ①
$ kill `cat pid` ②

① The PID is written to a file called pid.

② The kill command sends a TERM signal to the PID stored in the pid file.

Note

The startup scripts provided for Linux and Windows take care of starting and stopping the Elasticsearch process for you.

*NIX
There are added features when using the elasticsearch shell script. The first, which was explained earlier, is the ability to easily run the process either in the foreground or the background.

Another feature is the ability to pass -D or getopt long style configuration parameters directly to the script. When set, all override anything set using either JAVA_OPTS or ES_JAVA_OPTS. For example:

$ bin/elasticsearch -Des.index.refresh_interval=5s --node.name=my-node

Java (JVM) version

Elasticsearch is built using Java, and requires at least Java 7 in order to run. Only Oracle’s Java and the OpenJDK are supported. The same JVM version should be used on all Elasticsearch nodes and clients.

We recommend installing the Java 8 update 20 or later, or Java 7 update 55 or later. Previous versions of Java 7 are known to have bugs that can cause index corruption and data loss. Elasticsearch will refuse to start if a known-bad version of Java is used.

The version of Java to use can be configured by setting the JAVA_HOME environment variable.

results matching ""

    No results matching ""