Elasticsearch Reference 5.5 中文翻译2

来源:互联网 发布:我和僵尸有个约会知乎 编辑:程序博客网 时间:2024/05/22 02:09

Set up Elasticsearch

开始探索Elasticsearch

 

This section includes information on how to setup Elasticsearch and get it running, including:

这个章节包含的内容是开始探索Elasticsearch以及如何运行并且包括:

 

    Downloading

下载

    Installing

安装

    Starting

开始探索

    Configuring

配置

 

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.

官方支持的系统以及JVM在这里可见:https://www.elastic.co/support/matrixElasticsearch在列表的平台进行过测试,但是他也可以运行于其他的平台。

 

Java (JVM) Version

JavaJVM)版本

 

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

Elasticsearch是基于Java构建的,并且要求至少使用Java8以上的条件来执行。只支持OracleJavaOpenJDK。相同的JVM版本应当被适用于Elasticsearch的节点和客户端。

 

We recommend installing Java version 1.8.0_131 or later. Elasticsearch will refuse to start if a known-bad version of Java is used.

我们建议安装的Java版本是1.8.0_131或者更新的版本。Elasticsearch将拒绝启动如果你使用了一个错误的版本号。

 

The version of Java that Elasticsearch will use can be configured by setting the JAVA_HOME environment variable.

Elasticsearch使用的Java版本需要通过设置JAVA_HOME环境变量来设置。

 

Note

注意

 

Elasticsearch ships with default configuration for running Elasticsearch on 64-bit server JVMs. If you are using a 32-bit client JVM, you must remove -server from jvm.options and if you are using any 32-bit JVM you should reconfigure the thread stack size from -Xss1m to -Xss320k.

Elasticsearch的默认配置使得Elasticsearch可以运行于64位服务器的JVM。如果你使用32位的客户端JVM,你必须从jvm.opions中去掉-server的标志并且如果你使用32位的JVM你应当重新配置线程栈从-Xss1m改为-Xss320k

 

Installing Elasticsearch

安装Elasticsearch

 

Elasticsearch is provided in the following package formats:

Elasticsearch提供了以下形式的安装包:

 

zip/tar.gz

 

The zip and tar.gz packages are suitable for installation on any system and are the easiest choice for getting started with Elasticsearch on most systems.

ziptar.gz包适用于安装在任何的系统可以作为大部分系统的简单的选择

Install Elasticsearch with .zip or .tar.gz orInstall Elasticsearch with .zip on Windows

deb

The deb package is suitable for Debian, Ubuntu, and other Debian-based systems. Debian packages may be downloaded from the Elasticsearch website or from our Debian repository.

deb安装包用于DebianUbuntu和其他基于Debian的系统。Debian包可以从Elasticsearch的网站的Debian库中下载。

Install Elasticsearch with Debian Package

rpm

The rpm package is suitable for installation on Red Hat, Centos, SLES, OpenSuSE and other RPM-based systems. RPMs may be downloaded from the Elasticsearch website or from our RPM repository.

rpm包适合于RedHatCentOSSLESOpenSuSE和其他基于RPM的系统。RPM可以从Elasticsearch的网站的RPM库中下载。

Install Elasticsearch with RPM

msi

The msi package is suitable for installation on Windows 64-bit systems with at least .NET 4.5 framework installed, and is the easiest choice for getting started with Elasticsearch on Windows. MSIs may be downloaded from the Elasticsearch website.

mis包适用于Windows64位的系统并且要求.NET框架版本4.5以上,对于在WIndows上使用Elasticsearch是一个简单的选择可以从Elasticsearch的网站上下载。

Install Elasticsearch with Windows MSI Installer

docker

An image is available for running Elasticsearch as a Docker container. It ships withX-Pack pre-installed and may be downloaded from the Elastic Docker Registry.

可以运行Elasticsearch作为一个Docker容器中的镜像来运行。他是用X-Pack的提前安装并且可以从ElasticDocker的注册中心中下载。

Install Elasticsearch with Docker

 

Configuration Management Tools

配置管理工具

 

We also provide the following configuration management tools to help with large deployments:

我们也提供了下列的配置管理工具用于处理大型的开发环境:

Pueept

https://github.com/elastic/puppet-elasticsearch

Chef

https://github.com/elastic/cookbook-elasticsearch

Ansible

https://github.com/elastic/ansible-elasticsearch

 

Install Elasticsearch with .zip or .tar.gz

安装Elasticsearch使用ziptar.gz

 

Elasticsearch is provided as a .zip and as a .tar.gz package. These packages can be used to install Elasticsearch on any system and are the easiest package format to use when trying out Elasticsearch.

Elasticsearch提供了ziptar.gz的安装包。这些包可以被使用来安装Elasticsearch对于任何的系统并且是最简单的方式来使用对于Elasticsearch

 

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可以被找到在https://www.elastic.co/downloads/elasticsearch页面上。其他的版本可以找到在https://www.elastic.co/downloads/past-releases页面上。

 

Note

注意

 

Elasticsearch requires Java 8 or later. Use the official Oracle distribution or an open-source distribution such as OpenJDK.

Elasticsearch要求Java8或以上的版本。使用官方的Oracle发行版或开源的发行版例如OpenJDK

 

Download and install the .zip package

下载和安装使用zip安装包

 

The .zip archive for Elasticsearch v5.5.1 can be downloaded and installed as follows:

用于Elasticsearch5.5.1zip格式的安装包可以下载并安装如下:

 

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.5.1.zip

sha1sum elasticsearch-5.5.1.zip //1

unzip elasticsearch-5.5.1.zip

cd elasticsearch-5.5.1/ //2

 

1 Compare the SHA produced by sha1sum or shasum with the published SHA.

比较SHA值通过与https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.5.1.zip.sha1

 

2 This directory is known as $ES_HOME.

这个路径也就是$ES_HOME

 

Download and install the .tar.gz package

下载和安装tar.gz

 

The .tar.gz archive for Elasticsearch v5.5.1 can be downloaded and installed as follows:

用于Elasticsearch5.5.1tar.gz格式的安装包可以下载并安装如下:

 

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.5.1.tar.gz

sha1sum elasticsearch-5.5.1.tar.gz //1

tar -xzf elasticsearch-5.5.1.tar.gz

cd elasticsearch-5.5.1/ //2

 

1 Compare the SHA produced by sha1sum or shasum with the published SHA.

比较SHA值通过与https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.5.1.tar.gz.sha1

 

2 This directory is known as $ES_HOME.

这个路径也就是$ES_HOME

 

Running Elasticsearch from the command line

使用命令行来运行Elasticsearch

 

Elasticsearch can be started from the command line as follows:

Elasticsearch可以启动通过如下的命令行方式:

 

./bin/elasticsearch

 

By default, Elasticsearch runs in the foreground, prints its logs to the standard output (stdout), and can be stopped by pressing Ctrl-C.

默认的,Elasticsearch是前台启动的,打印他的日志到屏幕上,并且可以使用Ctrl+C来停止进程。

 

Note

注意

 

All scripts packaged with Elasticsearch require a version of Bash that supports arrays and assume that Bash is available at /bin/bash. As such, Bash should be available at this path either directly or via a symbolic link.

所有使用脚本安装Elasticsearch都需要Bash来支持并且Bash支持在/bin/bash。同样的,Bash应当可用在这个路径上不管是目录还是通过符号链接。

 

Checking that Elasticsearch is running

检查Elasticsearch是否在执行

 

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

你可以测试Elasticsearch的节点是否在运行通过发送HTTP请求到本地的9200端口:

 

GET /

 

which should give you a response something like this:

你可能会收到类似如下的返回结果:

 

{

  "name" : "Cp8oag6",

  "cluster_name" : "elasticsearch",

  "cluster_uuid" : "AT69_T_DTp-1qgIJlatQqA",

  "version" : {

    "number" : "5.5.1",

    "build_hash" : "f27399d",

    "build_date" : "2016-03-30T09:51:41.449Z",

    "build_snapshot" : false,

    "lucene_version" : "6.5.1"

  },

  "tagline" : "You Know, for Search"

}

 

Log printing to stdout can be disabled using the -q or --quiet option on the command line.

日志打印标准输出可以被关闭通过使用-q--quiet选项在命令行中。

 

Running as a daemon

后台运行

 

To run Elasticsearch as a daemon, specify -d on the command line, and record the process ID in a file using the -p option:

为了让Elasticsearch可以后台运行,指定-d在命令行中并且记录进程ID使用-p选项到一个指定的文件中:

 

./bin/elasticsearch -d -p pid

 

Log messages can be found in the $ES_HOME/logs/ directory.

日志消息可以被找到在$ES_HOME/logs/目录中。

 

To shut down Elasticsearch, kill the process ID recorded in the pid file:

为了关闭Elasticsearch,可以直接killpid文件中的进程ID

 

kill `cat pid`

 

Note

注意

 

The startup scripts provided in the RPM and Debian packages take care of starting and stopping the Elasticsearch process for you.

启动脚本被提供在RPMDebian包中用于启动和关闭Elasticsearch进程。

 

Configuring Elasticsearch on the command line

使用命令行来配置Elasticsearch

 

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.

Elasticsearch默认加载他的配置从$ES_HOME/config/elasticsearch.yml文件。这个配置文件的格式在“配置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:

任何可以指定在配置文件中的设置也可以通过命令行来指定,使用-E的语法格式如下:

 

./bin/elasticsearch -d -Ecluster.name=my_cluster -Enode.name=node_1

 

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.

通常任何集群范围的设置(例如cluster.name)应当被添加到elasticsearch.yml配置文件中,任何非节点指定设置例如node.name可以通过命令行来指定。

 

Directory layout of .zip and .tar.gz archives

ziptar.gz格式压缩包的目录结构

 

The .zip and .tar.gz packages are entirely self-contained. All files and directories are, by default, contained within $ES_HOME — the directory created when unpacking the archive.

ziptar.gz包都是自包含的。所有的文件和目录在默认情况下在$ES_HOME中————当解压缩包的路径。

 

This is very convenient because you dont 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.

这是很方便的因为你不需要创建任何目录来使用Elasticsearch,以及理解Elasticsearch可以很容易的从$ES_HOME目录中被移除。然而,建议你修改默认的配置目录的位置,数据目录的位置和日志目录的位置以免于你无意中进行的删除操作。

 

Type

类型

Description

描述

Default Location

默认位置

Setting

设置

home

Elasticsearch home directory or $ES_HOME

ELasticsearch的根目录或$ES_HOME

Directory created by unpacking the archive

解压缩安装包的路径

 

bin

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

包含二进制脚本用于Elasticsearch的启动节点和安装插件

$ES_HOME/bin

 

conf

Configuration files including elasticsearch.yml

配置文件包含elasticsearch.yml文件

$ES_HOME/config

path.conf

data

The location of the data files of each index / shard allocated on the node. Can hold multiple locations.

每个索引的data文件的位置。节点分片的shard。可以包含多个位置。

$ES_HOME/data

path.data

logs

Log files location.

日志文件的位置

$ES_HOME/logs

path.logs

plugins

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

插件文件的位置。每个插件将被包含在一个子目录中。

$ES_HOME/plugins

 

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.

shared文件系统库的位置。可以包含多个locations。一个文件系统库可以被指定在任何子目录中。

Not configured

path.repo

script

Location of script files.

脚本文件的位置。

$ES_HOME/scripts

path.scripts

 

Next steps

下一步

 

You now have a test Elasticsearch environment set up. Before you start serious development or go into production with Elasticsearch, you will need to do some additional setup:

你现在已经启动了一个可以测试Elasticsearch的环境。在你进行开发之前或准备将Elasticsearch投入生产之前,你需要一些额外的配置:

 

    Learn how to configure Elasticsearch.

学习如何配置Elasticsearch

    Configure important Elasticsearch settings.

配置重要的Elasticsearch设置

    Configure important system settings.

配置重要的系统设置

 

Install Elasticsearch with .zip on Windows

Windows上使用zip安装Elasticsearch

 

Elasticsearch can be installed on Windows using the .zip package. This comes with a elasticsearch-service.bat command which will setup Elasticsearch to run as a service.

Elasticsearch可以通过zip的形式在Windows上安装。使用elasticsearch-service.bat命令将会设置Elasticsearch以服务的形式运行。

 

Tip

提示

 

Elasticsearch has historically been installed on Windows using the .zip archive. An MSI installer package is available that provides the easiest getting started experience for Windows. You can continue using the .zip approach if you prefer.

Elasticsearch以前开始就可以使用zipWindows上进行安装。MSI的安装包可以提供一种比较简单的方式来安装。你也可以根据需要使用zip的安装包。

 

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版本可以在https://www.elastic.co/downloads/elasticsearch页面找到。其他的版本可以在https://www.elastic.co/downloads/past-releases页面被找到。

 

Note

注意

 

Elasticsearch requires Java 8 or later. Use the official Oracle distribution or an open-source distribution such as OpenJDK.

Elasticsearch要求至少是Java8以上。使用官方Oracle的发行版或开源的发行版例如OpenJDK

 

Download and install the .zip package

下载和安装zip安装包

 

Download the .zip archive for Elasticsearch v5.5.1 from: https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.5.1.zip

下载Elasticsearch5.5.1zip安装包从https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.5.1.zip这个地址。

 

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

解压缩这个zip包。他将会创建一个目录名字为elasticsearch-5.5.1,我们将把他设置为%ES_HOME%。在一个终端窗口,进入到%ES_HOME%目录,如下:

 

cd c:\elasticsearch-5.5.1

 

Running Elasticsearch from the command line

使用命令行运行Elasticsearch

 

Elasticsearch can be started from the command line as follows:

Elasticsearch可以使用如下的命令启动:

 

.\bin\elasticsearch.bat

 

By default, Elasticsearch runs in the foreground, prints its logs to STDOUT, and can be stopped by pressing Ctrl-C.

默认的,Elasticsearch是前台运行的,将日志输出到屏幕上,并且可以使用Ctrl-C来停止运行。

 

Configuring Elasticsearch on the command line

使用命令行配置Elasticsearch

 

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.

Elasticsearch默认从%ES_HOME%\config\elasticsearch.yml文件中加载配置。这个配置文件的格式解释在后续的内容中。

 

Any settings that can be specified in the config file can also be specified on the command line, using the -E syntax as follows:

任何在配置文件中的设置都可以通过命令行来指定,使用-E的符号如下:

 

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

 

Note

注意

 

Values that contain spaces must be surrounded with quotes. For instance -Epath.logs="C:\My Logs\logs".

如果含有空格的命令参数则必须使用引号包裹。例如-Epath.logs="C:\My Logs\logs"

 

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.

通常,有关集群方面的设置(例如cluster.name)最好被添加到elasticsearch.yml配置文件中,这样就不用在命令行指定节点的名字。

 

Checking that Elasticsearch is running

检查Elasticsearch是否在运行。

 

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

你可以通过发送HTTP请求给本地的9200端口的方式来确认Elasticsearch是否正在运行:

 

GET /

 

which should give you a response something like this:

则你应该会收到返回如下:

 

{

  "name" : "Cp8oag6",

  "cluster_name" : "elasticsearch",

  "cluster_uuid" : "AT69_T_DTp-1qgIJlatQqA",

  "version" : {

    "number" : "5.5.1",

    "build_hash" : "f27399d",

    "build_date" : "2016-03-30T09:51:41.449Z",

    "build_snapshot" : false,

    "lucene_version" : "6.5.1"

  },

  "tagline" : "You Know, for Search"

}

 

Installing Elasticsearch as a Service on Windows

Windows上将Elasticsearch安装为一个服务

 

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 through the elasticsearch-service.bat script in the bin\ folder which allows one to install, remove, manage or configure the service and potentially start and stop the service, all from the command-line.

Elasticsearch可以被安装为一个服务在后台运行或在开机时自动启动而不需要任何用户的参与。这个可以通过elasticsearch-service.bat脚本来实现,脚本位于bin目录下允许你安装、卸载、管理和配置服务并且可以启动和关闭服务使用命令行的方式。

 

c:\elasticsearch-5.5.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).

这个脚本要求至少指定一个参数(执行的命令)并且后面指定服务id(当安装多个Elasticsearch服务时使用)。

 

The commands available are:

可以使用的命令如下:

 

install Install Elasticsearch as a service

Elasticsearch安装为一个服务

 

remove Remove the installed Elasticsearch service (and stop the service if started)

删除已经安装的Elasticsearch服务(如果正在运行会先行停止Elasticsearch服务)

 

start Start the Elasticsearch service (if installed)

启动Elasticsearch服务(如果服务已经被安装)

 

stop Stop the Elasticsearch service (if started)

停止Elasticsearch服务(如果服务处于开启的状态)

 

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:

基于可用的JDKJRE的结构(通过JAVA_HOME来设置),指定的64位或32位服务将被安装。这个信息可以在安装时可见:

 

c:\elasticsearch-5.5.1\bin>elasticsearch-service.bat install

Installing service      :  "elasticsearch-service-x64"

Using JAVA_HOME (64-bit):  "c:\jvm\jdk1.8"

The service 'elasticsearch-service-x64' has been installed.

 

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.

当使用JRE用于Elasticsearch服务,由于使用了clientVM(相对于服务版本的VM将提供更好的性能),不建议使用clientVM并且会提出警告。

 

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.

系统环境变量JAVA_HOME可以被设置为JDK安装路径使得你可以运行服务。如果你更新的JDK,你不需要重新安装服务但是你需要修改环境变量JAVA_HOME指向新的JDK安装位置。然而,更新JVM的类型(例如JRE版本的SE)是不支持的,要求服务重新被安装。

 

Customizing service settings

自定义服务设置

 

The Elasticsearch service can be configured prior to installation by setting the following environment variables (either using the set command from the command line, or through the System Properties->Environment Variables GUI).

Elasticsearch服务可以被配置来安装通过下面的环境变量(可以使用命令行货通过系统属性——》环境变量的用户图形界面)。

 

SERVICE_ID

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

用于标识服务的唯一的id。在同一台机器上安装多个服务时使用。默认是elasticsearch-service-x86(在32位的Windows上)或者elasticsearch-service-x64(在64位的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_USERNAME%指定的密码

SERVICE_DISPLAY_NAME

The name of the service. Defaults to Elasticsearch <version> %SERVICE_ID%.

服务的名字。默认是Elasticsearch <版本号> %SERVICE_ID%

SERVICE_DESCRIPTION

The description of the service. Defaults to Elasticsearch <version> Windows Service -https://elastic.co.

服务的描述。默认是Elasticsearch <version> Windows Service - https://elastic.co。

JAVA_HOME

The installation directory of the desired JVM to run the service under.

对于服务的JVM的安装路径。

LOG_DIR

Log directory, defaults to %ES_HOME%\logs.

日志目录,默认是%ES_HOME%\logs。

DATA_DIR

Data directory, defaults to %ES_HOME%\data.

数据目录,默认是%ES_HOME%\data。

CONF_DIR

Configuration file directory (which needs to include elasticsearch.yml and log4j2.properties files), defaults to %ES_HOME%\conf.

配置目录(需要包含elasticsearch.yml和log4j2.properties文件),默认是%ES_HOME%\conf。

ES_JAVA_OPTS

Any additional JVM system properties you may want to apply.

任何你可能需要指定的额外的JVM系统属性

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.

等待服务退出的超时。默认是0

 

Note

注意

 

At its core, elasticsearch-service.bat relies on Apache Commons Daemon project 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.

由于他的核心,elasticsearch-service.bat依赖于ApacheCommonDaemon项目来安装服务。环境变量设置指向服务的安装可以被服务并且可以被使用在服务的整个生命周期。这意味着可以改变他们的配置在服务安装之后而不需要重新安装服务。

 

Note

注意

 

On Windows, the 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, use the service manager: bin\elasticsearch-service.bat manager.

对于Windows,堆空间可以被配置用于Elasticsearch的安装当使用命令行来运行Elasticsearch时或当安装Elasticsearch作为服务时直接指定。为了调整堆大小对于已经安装的服务,使用服务管理工具:bin\elasticsearch-service.bat manager

 

Using the Manager GUI

使用管理器的用户图形界面

    It is also possible to configure the service after its 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:

可以配置服务在安装之后通过使用管理器工具的图形界面(elasticsearch-mgr.exe),提供了可视化的界面对于已经安装的服务,包含他的状态、启动类型、JVM、开始和停止等等设置。简单的调用elasticsearch-service.bat manager对于命令行来打开管理器窗口:

 

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

大部分配置(例如JVM设置)可以使用管理器界面来设置要求重新启动服务来使得配置生效。

 

Directory layout of .zip archive

zip安装包的目录结构

 

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.

zip安装包是自包含的。所有的文件和目录等,默认的,包含在%ES_HOME%中————解压缩安装包是创建的目录。

 

This is very convenient because you dont 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.

这是很方便的,你不需要创建任何目录来开始使用Elasticsearch,并且卸载Elasticsearch也十分简单只要删除%ES_HOME%目录就可以。然而,他可以改变配置目录的默认位置,数据目录、日志目录因此你不能删除这些重要的数据。

 

Type

类型

Description

描述

Default Location

默认位置

Setting

设置

home

Elasticsearch home directory or $ES_HOME

ELasticsearch的根目录或$ES_HOME

Directory created by unpacking the archive

解压缩安装包的路径

 

bin

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

包含二进制脚本用于Elasticsearch的启动节点和安装插件

$ES_HOME/bin

 

conf

Configuration files including elasticsearch.yml

配置文件包含elasticsearch.yml文件

$ES_HOME/config

path.conf

data

The location of the data files of each index / shard allocated on the node. Can hold multiple locations.

每个索引的data文件的位置。节点分片的shard。可以包含多个位置。

$ES_HOME/data

path.data

logs

Log files location.

日志文件的位置

$ES_HOME/logs

path.logs

plugins

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

插件文件的位置。每个插件将被包含在一个子目录中。

$ES_HOME/plugins

 

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.

shared文件系统库的位置。可以包含多个locations。一个文件系统库可以被指定在任何子目录中。

Not configured

path.repo

script

Location of script files.

脚本文件的位置。

$ES_HOME/scripts

path.scripts

 

Next steps

下一步

 

You now have a test Elasticsearch environment set up. Before you start serious development or go into production with Elasticsearch, you will need to do some additional setup:

你现在已经启动了一个可以测试Elasticsearch的环境。在你进行开发之前或准备将Elasticsearch投入生产之前,你需要一些额外的配置:

 

    Learn how to configure Elasticsearch.

学习如何配置Elasticsearch

    Configure important Elasticsearch settings.

配置重要的Elasticsearch设置

    Configure important system settings.

配置重要的系统设置

 

Install Elasticsearch with Debian Package

使用Debian安装包来安装Elasticsearch

 

The Debian package for Elasticsearch can be downloaded from our website or from our APT repository. It can be used to install Elasticsearch on any Debian-based system such as Debian and Ubuntu.

用于安装ElasticsearchDebian安装包可以下载从我们的网站或来自API库。它可以使用来安装Elasticsearch或任何基于Debian的系统例如DebianUbuntu

 

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版本可以被找到在https://www.elastic.co/downloads/elasticsearch页面。其他的版本可以被找到在https://www.elastic.co/downloads/past-releases页面。

 

Note

注意

 

Elasticsearch requires Java 8 or later. Use the official Oracle distribution or an open-source distribution such as OpenJDK.

Elasticsearch要求运行在Java8及以上的版本。使用官方的Oracle的发行版或开源的发行版例如OpenJDK

 

Import the Elasticsearch PGP Key

导入ElasticsearchPGPkey

 

We sign all of our packages with the Elasticsearch Signing Key (PGP key D88E42B4, available from https://pgp.mit.edu) with fingerprint:

我们签名了所有Elasticsearch的安装包的签名keyPGP key D88E42B4,来自https://pgp.mit.edu)使用了签名:

 

4609 5ACC 8548 582C 1A26 99A9 D27D 666C D88E 42B4

 

Download and install the public signing key:

下载并安装公共的签名key

 

wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -

 

Installing from the APT repository

使用APT库来安装

 

You may need to install the apt-transport-https package on Debian before proceeding:

你可能需要安装apt-transport-https包在Debian上在执行之前

 

sudo apt-get install apt-transport-https

 

Save the repository definition to /etc/apt/sources.list.d/elastic-5.x.list:

将库的位置保存到/etc/apt/sources.list.d/elastic-5.x.list

 

echo "deb https://artifacts.elastic.co/packages/5.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list

 

Note

注意

 

These instructions do not use add-apt-repository for several reasons:

这些说明不需要添加使用add-apt-repository由于下面的原因:

 

    add-apt-repository adds entries to the system /etc/apt/sources.list file rather than a clean per-repository file in /etc/apt/sources.list.d

add-apt-repository添加entries到系统的/etc/apt/sources.list文件中而不是一个干净的库文件在/etc/apt/sources.list.d

    add-apt-repository is not part of the default install on many distributions and requires a number of non-default dependencies.

add-apt-repository不是默认安装到许多发行版的一部分并且要求非默认的依赖

    Older versions of add-apt-repository always add a deb-src entry which will cause errors because we do not provide a source package. If you have added the deb-src entry, you will see an error like the following until you delete the deb-src line:

一些老版本的add-apt-repository已经添加了deb-srcentry将导致错误因为我们没有提供源码包。如果你添加了deb-srcentry,你将看到一个错误在你删除deb-sec行之前:

 

    Unable to find expected entry 'main/source/Sources' in Release file

    (Wrong sources.list entry or malformed file)

 

You can install the Elasticsearch Debian package with:

你可以按照ElasticsearchDebian包使用如下的命令:

 

sudo apt-get update && sudo apt-get install elasticsearch

 

Warning

警告

 

If two entries exist for the same Elasticsearch repository, you will see an error like this during apt-get update:

如果两个entries存在于相同的Elasticsearch库中,你将会在apt-get update中看到如下的错误:

 

Duplicate sources.list entry https://artifacts.elastic.co/packages/5.x/apt/ ...`

 

Examine /etc/apt/sources.list.d/elasticsearch-5.x.list for the duplicate entry or locate the duplicate entry amongst the files in /etc/apt/sources.list.d/ and the /etc/apt/sources.list file.

检查/etc/apt/sources.list.d/elasticsearch-5.x.list对于重复的entry或定位重复的entry对于文件/etc/apt/sources.list.d//etc/apt/sources.list文件。

 

Note

注意

 

On systemd-based distributions, the installation scripts will attempt to set kernel parameters (e.g., vm.max_map_count); you can skip this by masking the systemd-sysctl.service unit.

对于基于系统的发行版,安装脚本将试图设置核心参数(例如,vm.max_map_count);你可以跳过他们使用systemd-sysctl.service单元。

 

Download and install the Debian package manually

手动下载并安装Debian安装包

 

The Debian package for Elasticsearch v5.5.1 can be downloaded from the website and installed as follows:

对于Elasticsearch5.5.1Debian安装包可以从网页中下载并且使用如下的方式安装:

 

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.5.1.deb

sha1sum elasticsearch-5.5.1.deb  Compare the SHA produced by sha1sum or shasum with the published SHA.比较SHA值和公共发布的SHA

sudo dpkg -i elasticsearch-5.5.1.deb

 

SysV init vs systemd

 

Elasticsearch is not started automatically after installation. How to start and stop Elasticsearch depends on whether your system uses SysV init or systemd (used by newer distributions). You can tell which is being used by running this command:

Elasticsearch在安装后没有自动启动。如何启动和停止Elasticsearch依赖于你的系统使用SysV初始化或systemd(在新的发行版中使用)。你可以区分它们使用命令如下:

 

ps -p 1

 

Running Elasticsearch with SysV init

使用SysV初始化运行Elasticsearch

 

Use the update-rc.d command to configure Elasticsearch to start automatically when the system boots up:

使用update-rc.d命令来配置Elasticsearch自动启动当你的系统启动的时候:

 

sudo update-rc.d elasticsearch defaults 95 10

 

Elasticsearch can be started and stopped using the service command:

Elasticsearch可以被启动或停止使用服务命令如下:

 

sudo -i service elasticsearch start

sudo -i service elasticsearch stop

 

If Elasticsearch fails to start for any reason, it will print the reason for failure to STDOUT. Log files can be found in /var/log/elasticsearch/.

如果Elasticsearch启动时出现了错误,他将会将原因打印到STDOUT.log文件可以在/var/log/elasticsearch/目录下被找到。

 

Running Elasticsearch with systemd

使用systemd来运行Elasticsearch

 

To configure Elasticsearch to start automatically when the system boots up, run the following commands:

为了配置Elasticsearch自动启动当系统系统的时候,运行下面的命令:

 

sudo /bin/systemctl daemon-reload

sudo /bin/systemctl enable elasticsearch.service

 

Elasticsearch can be started and stopped as follows:

Elasticsearch可以被启动或停止使用服务命令如下:

 

sudo systemctl start elasticsearch.service

sudo systemctl stop elasticsearch.service

 

These commands provide no feedback as to whether Elasticsearch was started successfully or not. Instead, this information will be written in the log files located in /var/log/elasticsearch/.

这些命令没有提供反馈对于Elasticsearch是否成功启动。作为替代,这些信息被写入到日志文件中位于/var/log/elasticsearch/目录下。

 

By default the Elasticsearch service doesnt log information in the systemd journal. To enable journalctl logging, the --quiet option must be removed from the ExecStart command line in the elasticsearch.service file.

默认的Elasticsearch服务不会记录信息在系统日志中。为了开启日志记录,--quiet选项必须被移除从ExecStart命令行红在elasticsearch.service文件中。

 

When systemd logging is enabled, the logging information are available using the journalctl commands:

当系统日志被启用,日志信息将可以使用journalctl命令来查看:

 

To tail the journal:

查看jorunal的尾部:

 

sudo journalctl -f

 

To list journal entries for the elasticsearch service:

为了列出journalentries对于Elasticsearch服务:

 

sudo journalctl --unit elasticsearch

 

To list journal entries for the elasticsearch service starting from a given time:

为了列出journalentries用于Elasticsearch服务对于指定给定的时间:

 

sudo journalctl --unit elasticsearch --since  "2016-10-30 18:17:16"

 

Check man journalctl or https://www.freedesktop.org/software/systemd/man/journalctl.html for more command line options.

可以使用man journalctlhttps://www.freedesktop.org/software/systemd/man/journalctl.html来了解更多的命令行参数。

 

Checking that Elasticsearch is running

检查Elasticsearch是否正在运行

 

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

你可以通过发送HTTP请求给本地的9200端口的方式来确认Elasticsearch是否正在运行:

 

GET /

 

which should give you a response something like this:

则你应该会收到返回如下:

 

{

  "name" : "Cp8oag6",

  "cluster_name" : "elasticsearch",

  "cluster_uuid" : "AT69_T_DTp-1qgIJlatQqA",

  "version" : {

    "number" : "5.5.1",

    "build_hash" : "f27399d",

    "build_date" : "2016-03-30T09:51:41.449Z",

    "build_snapshot" : false,

    "lucene_version" : "6.5.1"

  },

  "tagline" : "You Know, for Search"

}

 

Configuring Elasticsearch

配置Elasticsearch

 

Elasticsearch loads its configuration from the /etc/elasticsearch/elasticsearch.yml file by default. The format of this config file is explained in Configuring Elasticsearch.

Elasticsearch默认从/etc/elasticsearch/elasticsearch.yml文件中加载配置。这个配置文件的格式解释在后续的内容中。

 

The Debian package also has a system configuration file (/etc/default/elasticsearch), which allows you to set the following parameters:

Debian安装包夜有一些系统配置文件(/etc/default/elasticsearch),允许你设置下面的参数:

 

ES_USER

The user to run as, defaults to elasticsearch.

运行的用户,默认是elasticsearch

ES_GROUP

The group to run as, defaults to elasticsearch.

运行的用户组,默认是elasticsearch

JAVA_HOME

Set a custom Java path to be used.

设置使用的Java路径

MAX_OPEN_FILES

Maximum number of open files, defaults to 65536.

最大开启的文件数目,默认是65536

MAX_LOCKED_MEMORY

Maximum locked memory size. Set to unlimited if you use the bootstrap.memory_lock option in elasticsearch.yml.

最大锁定的内存空间大小。如果你在elasticsearch.yml中使用bootstrap.memory_lock设置的话可以设置为无限制。

MAX_MAP_COUNT

Maximum number of memory map areas a process may have. If you use mmapfs as index store type, make sure this is set to a high value. For more information, check the linux kernel documentation about max_map_count. This is set via sysctl before starting elasticsearch. Defaults to 262144.

一个进行可以使用的最大内存map区域。如果你使用mmapfs作为索引存储类型保证设置为一个较高的值。更多的信息,从哪看linux内核文档有关max_map_count。这个可以通过sysctl在启动elasticsearch之前设置。默认是262144

LOG_DIR

Log directory, defaults to /var/log/elasticsearch.

日志目录,默认是/var/log/elasticsearch。

DATA_DIR

Data directory, defaults to /var/lib/elasticsearch.

数据目录,默认是/var/lib/elasticsearch。

CONF_DIR

Configuration file directory (which needs to include elasticsearch.yml and log4j2.properties files), defaults to/etc/elasticsearch.

配置文件目录(需要包含elasticsearch.ymllog4j2.properties文件),默认是/etc/elasticsearch。

ES_JAVA_OPTS

Any additional JVM system properties you may want to apply.

一个额外的JVM系统属性你可以指定。

RESTART_ON_UPGRADE

Configure restart on package upgrade, defaults to false. This means you will have to restart your elasticsearch instance after installing a package manually. The reason for this is to ensure, that upgrades in a cluster do not result in a continuous shard reallocation resulting in high network traffic and reducing the response times of your cluster.

配置重新启动对于包更新,默认是false。意味着你将不会重启你的Elasticsearch实例在手动安装包之后。这可以保证在集群中更新不会影响共享复制结果在拥堵的网络中并且减少集群的响应时间。

Note

注意

 

Distributions that use systemd require that system resource limits be configured via systemd rather than via the /etc/sysconfig/elasticsearch file. See Systemd configuration for more information.

使用systmd的发行版要求系统资源现在可以通过systmd来配置而不是通过/etc/sysconfig/elasticsearch文件。参考Systmd的配置来了解更多内容。

 

Directory layout of Debian package

Debian包的目录结构

 

The Debian package places config files, logs, and the data directory in the appropriate locations for a Debian-based system:

Debian包放置了配置文件、日志和数据目录在相应的位置基于Debian系统:

Type

类型

Description

描述

Default Location

默认位置

Setting

设置

home

Elasticsearch home directory or $ES_HOME

ELasticsearch的根目录或$ES_HOME

/usr/share/elasticsearch

 

bin

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

包含二进制脚本用于Elasticsearch的启动节点和安装插件

/usr/share/elasticsearch/bin

 

conf

Configuration files including elasticsearch.yml

配置文件包含elasticsearch.yml文件

/etc/elasticsearch

path.conf

conf

Environment variables including heap size, file descriptors.

环境变量包含堆大小、文件描述符

/etc/default/elasticsearch

 

data

The location of the data files of each index / shard allocated on the node. Can hold multiple locations.

每个索引的data文件的位置。节点分片的shard。可以包含多个位置。

/var/lib/elasticsearch

path.data

logs

Log files location.

日志文件的位置

/var/log/elasticsearch

path.logs

plugins

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

插件文件的位置。每个插件将被包含在一个子目录中。

/usr/share/elasticsearch/plugins

 

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.

shared文件系统库的位置。可以包含多个locations。一个文件系统库可以被指定在任何子目录中。

Not configured

path.repo

script

Location of script files.

脚本文件的位置。

/etc/elasticsearch/scripts

path.scripts

 

Next steps

下一步

 

You now have a test Elasticsearch environment set up. Before you start serious development or go into production with Elasticsearch, you will need to do some additional setup:

你现在已经启动了一个可以测试Elasticsearch的环境。在你进行开发之前或准备将Elasticsearch投入生产之前,你需要一些额外的配置:

 

    Learn how to configure Elasticsearch.

学习如何配置Elasticsearch

    Configure important Elasticsearch settings.

配置重要的Elasticsearch设置

    Configure important system settings.

配置重要的系统设置

 

Install Elasticsearch with RPM

使用RPM安装Elasticsearch

 

The RPM for Elasticsearch can be downloaded from our website or from our RPM repository. It can be used to install Elasticsearch on any RPM-based system such as OpenSuSE, SLES, Centos, Red Hat, and Oracle Enterprise.

用于Elasticsearch安装的RPM可以下载来自https://www.elastic.co/guide/en/elasticsearch/reference/5.5/rpm.html#install-rpm或从我们的RPM库中下载。他可以被使用来安装Elasticsearch对于任何基于RPM的系统例如OpenSuSESLESCentosRed HatOracle企业版。

 

Note

注意

 

RPM install is not supported on distributions with old versions of RPM, such as SLES 11 and CentOS 5. Please see Install Elasticsearch with .zip or .tar.gz instead.

使用RPM安装不支持老版本的RPM,例如SLES11CentOS5.请参考使用ziptar.gz来安装作为替代。

 

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最新的稳定版本可以在https://www.elastic.co/downloads/elasticsearch中找到。其他的版本可以在https://www.elastic.co/downloads/past-releases中找到。

 

Note

注意

 

Elasticsearch requires Java 8 or later. Use the official Oracle distribution or an open-source distribution such as OpenJDK.

Elasticsearch要求Java8或以上的版本。使用官方的Oracle的发行版或开源的发行版例如OpenJDK

 

Import the Elasticsearch PGP Key

导入ElasticsearchPGPkey

 

We sign all of our packages with the Elasticsearch Signing Key (PGP key D88E42B4, available from https://pgp.mit.edu) with fingerprint:

我们签名了所有Elasticsearch的安装包的签名keyPGP key D88E42B4,来自https://pgp.mit.edu)使用了签名:

 

4609 5ACC 8548 582C 1A26 99A9 D27D 666C D88E 42B4

 

Download and install the public signing key:

下载并安装公共的签名key

 

rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch

 

Installing from the RPM repository

使用RPM库来安装

 

Create a file called elasticsearch.repo in the /etc/yum.repos.d/ directory for RedHat based distributions, or in the /etc/zypp/repos.d/ directory for OpenSuSE based distributions, containing:

创建一个文件名字为elasticsearch.repo/etc/yum.repos.d/目录适用于基于RedHat的发行版或在/etc/zypp/repos.d/目录中适用于OpenSuSE的发行版,包含:

 

[elasticsearch-5.x]

name=Elasticsearch repository for 5.x packages

baseurl=https://artifacts.elastic.co/packages/5.x/yum

gpgcheck=1

gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch

enabled=1

autorefresh=1

type=rpm-md

 

And your repository is ready for use. You can now install Elasticsearch with one of the following commands:

并且你的库可以使用。你可以现在安装Elasticsearch使用下面的其中一个命令:

 

sudo yum install elasticsearch  //1

sudo dnf install elasticsearch  //2

sudo zypper install elasticsearch  //3

 

1Use yum on CentOS and older Red Hat based distributions.

使用yumCentOS和老版本的Red Hat发行版中。

 

2Use dnf on Fedora and other newer Red Hat distributions.

使用dnfFedora和其他新的Read Hat的发行版中。

 

3Use zypper on OpenSUSE based distributions

使用zyper在基于OpenSUSE的发行版中。

 

Download and install the RPM manually

手动下载和安装RPM

 

The RPM for Elasticsearch v5.5.2 can be downloaded from the website and installed as follows:

Elasticsearch5.5.2RPM包可以从网页下载并且安装如下:

 

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.5.2.rpm

sha1sum elasticsearch-5.5.2.rpm  //1

sudo rpm --install elasticsearch-5.5.2.rpm

 

1Compare the SHA produced by sha1sum or shasum with the published SHA.

比较SHA值和公共发布的SHA

 

Note

注意

 

On systemd-based distributions, the installation scripts will attempt to set kernel parameters (e.g., vm.max_map_count); you can skip this by masking the systemd-sysctl.service unit.

对于基于systemd的发行版,安装脚本会尝试设置内核参数(e.g., vm.max_map_count);你可以跳过他们屏蔽systmd-sysctl.service单元

 

SysV init vs systemd

SysVinitsystemd

 

Elasticsearch is not started automatically after installation. How to start and stop Elasticsearch depends on whether your system uses SysV init or systemd (used by newer distributions). You can tell which is being used by running this command:

Elasticsearch在安装后没有自动启动。如何启动和停止Elasticsearch依赖于你的系统使用SysV初始化或systemd(在新的发行版中使用)。你可以区分它们使用命令如下:

 

ps -p 1

 

Running Elasticsearch with SysV init

使用SysV初始化运行Elasticsearch

 

Use the chkconfig command to configure Elasticsearch to start automatically when the system boots up:

使用chkconfig命令来配置Elasticsearch来自动启动当系统启动的时候:

 

sudo chkconfig --add elasticsearch

 

Elasticsearch can be started and stopped using the service command:

Elasticsearch可以被启动或停止使用服务命令如下:

 

sudo -i service elasticsearch start

sudo -i service elasticsearch stop

 

If Elasticsearch fails to start for any reason, it will print the reason for failure to STDOUT. Log files can be found in /var/log/elasticsearch/.

如果Elasticsearch启动时出现了错误,他将会将原因打印到STDOUT.log文件可以在/var/log/elasticsearch/目录下被找到。

 

Running Elasticsearch with systemd

使用systemd来运行Elasticsearch

 

To configure Elasticsearch to start automatically when the system boots up, run the following commands:

为了配置Elasticsearch自动启动当系统系统的时候,运行下面的命令:

 

sudo /bin/systemctl daemon-reload

sudo /bin/systemctl enable elasticsearch.service

 

Elasticsearch can be started and stopped as follows:

Elasticsearch可以被启动或停止使用服务命令如下:

 

sudo systemctl start elasticsearch.service

sudo systemctl stop elasticsearch.service

 

These commands provide no feedback as to whether Elasticsearch was started successfully or not. Instead, this information will be written in the log files located in /var/log/elasticsearch/.

这些命令没有提供反馈对于Elasticsearch是否成功启动。作为替代,这些信息被写入到日志文件中位于/var/log/elasticsearch/目录下。

 

By default the Elasticsearch service doesnt log information in the systemd journal. To enable journalctl logging, the --quiet option must be removed from the ExecStart command line in the elasticsearch.service file.

默认的Elasticsearch服务不会记录信息在系统日志中。为了开启日志记录,--quiet选项必须被移除从ExecStart命令行红在elasticsearch.service文件中。

 

When systemd logging is enabled, the logging information are available using the journalctl commands:

当系统日志被启用,日志信息将可以使用journalctl命令来查看:

 

To tail the journal:

查看jorunal的尾部:

 

sudo journalctl -f

 

To list journal entries for the elasticsearch service:

 

sudo journalctl --unit elasticsearch

 

To list journal entries for the elasticsearch service starting from a given time:

为了列出journalentries对于Elasticsearch服务:

 

sudo journalctl --unit elasticsearch --since  "2016-10-30 18:17:16"

 

Check man journalctl or https://www.freedesktop.org/software/systemd/man/journalctl.html for more command line options.

可以使用man journalctlhttps://www.freedesktop.org/software/systemd/man/journalctl.html来了解更多的命令行参数。

 

Checking that Elasticsearch is running

检查Elasticsearch是否正在运行

 

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

你可以通过发送HTTP请求给本地的9200端口的方式来确认Elasticsearch是否正在运行:

 

GET /

 

which should give you a response something like this:

则你应该会收到返回如下:

 

{

  "name" : "Cp8oag6",

  "cluster_name" : "elasticsearch",

  "cluster_uuid" : "AT69_T_DTp-1qgIJlatQqA",

  "version" : {

    "number" : "5.5.2",

    "build_hash" : "f27399d",

    "build_date" : "2016-03-30T09:51:41.449Z",

    "build_snapshot" : false,

    "lucene_version" : "6.5.1"

  },

  "tagline" : "You Know, for Search"

}

 

Configuring Elasticsearch

配置Elasticsearch

 

Elasticsearch loads its configuration from the /etc/elasticsearch/elasticsearch.yml file by default. The format of this config file is explained in Configuring Elasticsearch.

Elasticsearch默认从/etc/elasticsearch/elasticsearch.yml文件中加载配置。这个配置文件的格式解释在后续的内容中。

 

The RPM also has a system configuration file (/etc/sysconfig/elasticsearch), which allows you to set the following parameters:

RPM也有一些系统配置文件(/etc/sysconfig/elasticsearch),允许你设置下面的参数:

ES_USER

The user to run as, defaults to elasticsearch.

运行的用户,默认是elasticsearch

ES_GROUP

The group to run as, defaults to elasticsearch.

运行的用户组,默认是elasticsearch

JAVA_HOME

Set a custom Java path to be used.

设置使用的Java路径

MAX_OPEN_FILES

Maximum number of open files, defaults to 65536.

最大开启的文件数目,默认是65536

MAX_LOCKED_MEMORY

Maximum locked memory size. Set to unlimited if you use the bootstrap.memory_lock option in elasticsearch.yml.

最大锁定的内存空间大小。如果你在elasticsearch.yml中使用bootstrap.memory_lock设置的话可以设置为无限制。

MAX_MAP_COUNT

Maximum number of memory map areas a process may have. If you use mmapfs as index store type, make sure this is set to a high value. For more information, check the linux kernel documentation about max_map_count. This is set via sysctl before starting elasticsearch. Defaults to 262144.

一个进行可以使用的最大内存map区域。如果你使用mmapfs作为索引存储类型保证设置为一个较高的值。更多的信息,从哪看linux内核文档有关max_map_count。这个可以通过sysctl在启动elasticsearch之前设置。默认是262144

LOG_DIR

Log directory, defaults to /var/log/elasticsearch.

日志目录,默认是/var/log/elasticsearch。

DATA_DIR

Data directory, defaults to /var/lib/elasticsearch.

数据目录,默认是/var/lib/elasticsearch。

CONF_DIR

Configuration file directory (which needs to include elasticsearch.yml and log4j2.properties files), defaults to /etc/elasticsearch.

配置文件目录(需要包含elasticsearch.ymllog4j2.properties文件),默认是/etc/elasticsearch。

ES_JAVA_OPTS

Any additional JVM system properties you may want to apply.

一个额外的JVM系统属性你可以指定。

RESTART_ON_UPGRADE

Configure restart on package upgrade, defaults to false. This means you will have to restart your elasticsearch instance after installing a package manually. The reason for this is to ensure, that upgrades in a cluster do not result in a continuous shard reallocation resulting in high network traffic and reducing the response times of your cluster.

配置重新启动对于包更新,默认是false。意味着你将不会重启你的Elasticsearch实例在手动安装包之后。这可以保证在集群中更新不会影响共享复制结果在拥堵的网络中并且减少集群的响应时间。

Note

注意

 

Distributions that use systemd require that system resource limits be configured via systemd rather than via the /etc/sysconfig/elasticsearch file. See Systemd configuration for more information.

使用systmd的发行版要求系统资源现在可以通过systmd来配置而不是通过/etc/sysconfig/elasticsearch文件。参考Systmd的配置来了解更多内容。

 

Directory layout of RPM

RPM的目录

 

The RPM places config files, logs, and the data directory in the appropriate locations for an RPM-based system:

RPM的配置文件、日志和数据目录在基于RPM系统的适当的位置:

Type

类型

Description

描述

Default Location

默认位置

Setting

设置

home

Elasticsearch home directory or $ES_HOME

ELasticsearch的根目录或$ES_HOME

/usr/share/elasticsearch

 

bin

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

包含二进制脚本用于Elasticsearch的启动节点和安装插件

/usr/share/elasticsearch/bin

 

conf

Configuration files including elasticsearch.yml

配置文件包含elasticsearch.yml文件

/etc/elasticsearch

path.conf

conf

Environment variables including heap size, file descriptors.

环境变量包含堆大小、文件描述符

/etc/default/elasticsearch

 

data

The location of the data files of each index / shard allocated on the node. Can hold multiple locations.

每个索引的data文件的位置。节点分片的shard。可以包含多个位置。

/var/lib/elasticsearch

path.data

logs

Log files location.

日志文件的位置

/var/log/elasticsearch

path.logs

plugins

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

插件文件的位置。每个插件将被包含在一个子目录中。

/usr/share/elasticsearch/plugins

 

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.

shared文件系统库的位置。可以包含多个locations。一个文件系统库可以被指定在任何子目录中。

Not configured

path.repo

script

Location of script files.

脚本文件的位置。

/etc/elasticsearch/scripts

path.scripts

 

Next steps

下一步

 

You now have a test Elasticsearch environment set up. Before you start serious development or go into production with Elasticsearch, you will need to do some additional setup:

你现在已经启动了一个可以测试Elasticsearch的环境。在你进行开发之前或准备将Elasticsearch投入生产之前,你需要一些额外的配置:

 

    Learn how to configure Elasticsearch.

学习如何配置Elasticsearch

    Configure important Elasticsearch settings.

配置重要的Elasticsearch设置

    Configure important system settings.

配置重要的系统设置

 

Install Elasticsearch with Windows MSI Installer

使用WindowsMSI安装器来安装Elasticsearch

 

Elasticsearch can be installed on Windows using the .msi package. This can install Elasticsearch as a Windows service or allow it to be run manually using the included elasticsearch.exe executable.

可以使用msi包来安装Elasticsearch。这可以安装Elasticsearch作为一个Windows服务或运行它可以被手动运行使用例如elasticsearch.exe的可执行文件。

 

Tip

提示

 

Elasticsearch has historically been installed on Windows using the .zip archive. You can continue using the .zip approach if you prefer.

Elasticsearch可以安装在Windows上使用zip压缩包。你也可以根据喜好使用zip安装包。

 

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版本可以在https://www.elastic.co/downloads/elasticsearch上找到。之前的版本可以在https://www.elastic.co/downloads/past-releases上找到。

 

Note

注意

 

Elasticsearch requires Java 8 or later. Use the official Oracle distribution or an open-source distribution such as OpenJDK.

Elasticsearch要求Java8或以上版本。使用官方的Oracle发行版或开源的发行版例如OpenJDK

 

Download the .msi package

下载MSI安装包

 

Download the .msi package for Elasticsearch v5.5.2 from https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.5.2.msi

下载msi安装包用于Elasticsearch5.5.2https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.5.2.msi

 

Install using the graphical user interface (GUI)

使用用户图形界面安装

 

Double-click the downloaded .msi package to launch a GUI wizard that will guide you through the installation process. You can view help on any step by clicking the ? button, which reveals an aside panel with additional information for each input:

双击下载的msi安装包来启动GUI向导将会引导你通过安装程序。你可以查看帮助通过点击问号按钮在每个安装过程中,内部的面板可能会需要一些输入信息:

 

 

Within the first screen, select the directory for the installation. In addition, select directories for where data, logs and configuration will reside or roll with the default locations:

在第一个页面中,选择安装的目录。此外,选择数据、日志和配置的目录将会被设置或使用默认的位置

 

 

Then select whether to install as a service or start Elasticsearch manually as needed. When installing as a service, you can also decide which account to run the service under as well as whether the service should be started after installation and when Windows is started or restarted:

然后选择是否根据需要手动启动Elasticsearch或安装为一个服务。当安装为一个服务是,你可以指定运行服务的用户以及是否在安装完后启动以及开机启动或重启的时候:

 

 

Important

重要

 

When selecting an account to run the service with, be sure that the chosen account has sufficient privileges to access the installation and other deployment directories chosen.

当选择一个用户运行服务,保证选择的用户有足够的权限访问安装和其他部署的选择的目录。

 

Common configuration settings are exposed within the Configuration section, allowing the cluster name, node name and roles to be set, in addition to memory and network settings:

通用的配置设置在配置选项中,允许设置集群的名字、节点名字和设置的角色,此外还有内存和网络的设置:

 

 

Finally, the installer provides a list of common plugins that can be downloaded and installed as part of the installation:

最后,安装将提供一个通用的插件列表可以下载和安装作为安装包的一部分:

 

 

Note

注意

 

X-Pack includes a trial license for 30 days. After that, you can obtain one of the available subscriptions or disable Security. The Basic license is free and includes the Monitoring extension.

X-Pack包括一个30天的使用期限。之后,你可以获得其中一个可用的订购或关闭安全使用。基本的协议是免费的并且包含监控扩展。

 

After clicking the install button, Elasticsearch will be installed:

之后点击安装按钮,Elasticsearch将被安装:

 

 

Install using the command line

使用命令行安装

 

The .msi can also install Elasticsearch using the command line. The simplest installation using the same defaults as the GUI is achieved by first navigating to the download directory, then running:

安装Elasticsearchmsi可以使用命令行进行安装。最简单的安装使用相同默认设置同GUI通过指定下载的目录并且运行:

 

msiexec.exe /i elasticsearch-5.5.2.msi /qn

 

By default, msiexec does not wait for the installation process to complete, since it runs in the Windows subsystem. To wait on the process to finish and ensure that %ERRORLEVEL% is set accordingly, it is recommended to use start /wait to create a process and wait for it to exit

默认,msiexec不会等待安装程序的完成,因此他运行于Windows的子系统中。为了等待进程的完成和保证%ERRORLEVEL%被设置,建议使用start /wait来创建进程并且等待他的退出

 

start /wait msiexec.exe /i elasticsearch-5.5.2.msi /qn

 

As with any MSI installation package, a log file for the installation process can be found within the %TEMP% directory, with a randomly generated name adhering to the format MSI<random>.LOG. The path to a log file can be supplied using the /l command line argument

由于任何MSI安装包,用于安装进程的日志文件可以在%TEMP%目录中找到,对于只读生成的名字格式为MSI<random>.LOG。日志文件的路径可以被提供使用/l命令行参数

 

start /wait msiexec.exe /i elasticsearch-5.5.2.msi /qn /l install.log

 

Supported Windows Installer command line arguments can be viewed using

支持Windows安装命令行参数可以参考使用

 

msiexec.exe /help

 

or by consulting the Windows Installer SDK Command-Line Options.

或者参考https://msdn.microsoft.com/en-us/library/windows/desktop/aa367988(v=vs.85).aspx

 

Command line options

命令行选项

 

All settings exposed within the GUI are also available as command line arguments (referred to as properties within Windows Installer documentation) that can be passed to msiexec:

所有的设置对于GUI可以使用命令行参数来指定(参考使用WIndows安装的文档)可以通过msiexec来指定:

INSTALLDIR

The installation directory. Defaults to %ProgramW6432%\Elastic\Elasticsearch

安装的目录,默认是%ProgramW6432%\Elastic\Elasticsearch

DATADIRECTORY

The directory in which to store your data. Defaults to %ALLUSERSPROFILE%\Elastic\Elasticsearch\data

存储数据的位置。默认是%ALLUSERSPROFILE%\Elastic\Elasticsearch\data

CONFIGDIRECTORY

The directory in which to store your configuration. Defaults to %ALLUSERSPROFILE%\Elastic\Elasticsearch\config

存储配置的目录。默认是%ALLUSERSPROFILE%\Elastic\Elasticsearch\config

LOGSDIRECTORY

The directory in which to store your logs. Defaults to %ALLUSERSPROFILE%\Elastic\Elasticsearch\logs

存储日志的目录,默认是%ALLUSERSPROFILE%\Elastic\Elasticsearch\logs

PLACEWRITABLELOCATIONSINSAMEPATH

Whether the data, configuration and logs directories should be created under the installation directory. Defaults to false

数据、配置和日志目录应当被创建在安装目录下。默认是false

INSTALLASSERVICE

Whether Elasticsearch is installed and configured as a Windows Service. Defaults to true

Elasticsearch是否被安装作为一个Windows服务。默认是true

STARTAFTERINSTALL

Whether the Windows Service is started after installation finishes. Defaults to true

作为Windows服务是否在完成安装后启动。默认是true

STARTWHENWINDOWSSTARTS

Whether the Windows Service is started when Windows is started. Defaults to true

作为Windows服务是否在开机时启动。默认是true

USELOCALSYSTEM

Whether the Windows service runs under the LocalSystem Account. Defaults to true

作为Windows服务是否运行于本地系统管理员的账户下,默认是true

USENETWORKSERVICE

Whether the Windows service runs under the NetworkService Account. Defaults to false

作为WIndows服务是否运行于网络服务用户下。默认是false

USEEXISTINGUSER

Whether the Windows service runs under a specified existing account. Defaults to false

作为Windows服务是否运行于已有的指定用户,默认是false

USER

The username for the account under which the Windows service runs. Defaults to ""

运行Windows服务的指定的用户名

PASSWORD

The password for the account under which the Windows service runs. Defaults to ""

运行Windows服务的指定的用户密码

CLUSTERNAME

The name of the cluster. Defaults to elasticsearch

集群的名字。默认是elasticsearch

NODENAME

The name of the node. Defaults to %COMPUTERNAME%

节点的名字。默认是%COMPUTERNAME%

MASTERNODE

Whether Elasticsearch is configured as a master node. Defaults to true

Elasticsearch是否配置为master模式,默认是true

DATANODE

Whether Elasticsearch is configured as a data node. Defaults to true

Elasticsearch是否配置为数据节点,默认是true

INGESTNODE

Whether Elasticsearch is configured as an ingest node. Defaults to true

Elasticsearch是否配置为服务节点,默认是true

SELECTEDMEMORY

The amount of memory to allocate to the JVM heap for Elasticsearch. Defaults to 2048. If the target machine has less than 4GB in total, defaults to 50% of total memory.

分配给JVM堆的内存用于Elasticsearch。默认是2048。如果目标机器总内存没有¥GB,默认是50%的内存数目。

LOCKMEMORY

Whether bootstrap.memory_lock should be used to try to lock the process address space into RAM. Defaults to false

是否使用bootstrap.memory_lock来锁定处理器地址为RAM,默认为false

UNICASTNODES

A comma separated list of hosts in the form host:port or host to be used for unicast discovery. Defaults to ""

使用hostport之间的分隔符或host用于单播。默认是””

MINIMUMMASTERNODES

The minimum number of master-eligible nodes that must be visible in order to form a cluster. Defaults to ""

最少的master节点应该在集群中。默认是””

NETWORKHOST

The hostname or IP address to bind the node to and publish (advertise) this host to other nodes in the cluster. Defaults to ""

主机名或IP地址绑定节点和发布host给其他节点。默认是””

HTTPPORT

The port to use for exposing Elasticsearch APIs over HTTP. Defaults to 9200

对于HTTP暴露Elasticsearch服务的端口,默认是9200

TRANSPORTPORT

The port to use for internal communication between nodes within the cluster. Defaults to 9300

使用于集群之间数据传输的端口号,默认是9300

PLUGINS

A comma separated list of the plugins to download and install as part of the installation. Defaults ""

分隔符用于下载和安装插件,默认是””

 

To pass a value, simply append the property name and value using the format <PROPERTYNAME>="<VALUE>" to the installation command. For example, to use a different installation directory to the default one and to install X-Pack:

为了传递至,简单的添加属性名和属性值使用格式<PROPERTYNAME>="<VALUE>"对于安装的命令行。例如,使用不同的安装目录并且安装X-Pack

 

start /wait msiexec.exe /i elasticsearch-5.5.2.msi /qn INSTALLDIR="C:\Custom Install Directory" PLUGINS="x-pack"

 

Consult the Windows Installer SDK Command-Line Options for additional rules related to values containing quotation marks.

参考https://msdn.microsoft.com/en-us/library/windows/desktop/aa367988(v=vs.85).aspx来了解其他有关的规则对于包含的标志。

 

Running Elasticsearch from the command line

使用命令行运行Elasticsearch

 

Once installed, Elasticsearch can be started from the command line, if not installed as a service and configured to start when installation completes, as follows:

一旦安装,Elasticsearch可以使用命令行启动,如果没有安装为服务和配置在应用完成时启动,可以使用如下的命令:

 

.\bin\elasticsearch.exe

 

The command line terminal will display output similar to the following:

这个命令终端将输出类似于如下:

 

 

By default, Elasticsearch runs in the foreground, prints its logs to STDOUT in addition to the <cluster name>.log file within LOGSDIRECTORY, and can be stopped by pressing Ctrl-C.

默认的,Elasticsearch是前台运行的,打印日志到屏幕上以及<cluster name>.log文件中使用LOGSDIRECTORY,并且可以使用Ctrl-C来终止。

 

Configuring Elasticsearch on the command line

使用命令行来配置Elasticsearch

 

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.

Elasticsearch默认从%ES_HOME%\config\elasticsearch.yml中加载配置文件。这个配置文件的格式在后续会有说明。

 

Any settings that can be specified in the config file can also be specified on the command line, using the -E syntax as follows:

任何设置可以被指定通过配置文件的都可以通过命令行来指定,使用-E符号如下:

 

.\bin\elasticsearch.exe -E cluster.name=my_cluster -E node.name=node_1

 

Note

注意

 

Values that contain spaces must be surrounded with quotes. For instance -E path.logs="C:\My Logs\logs".

如果值中包含空格则应该使用引号,例如-E path.logs="C:\My Logs\logs"

 

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.

通常,有关集群的设置(例如cluster.name)应当被设置在elasticsearch.yml配置文件中,有关节点的设置可以通过命令行来指定。

 

Checking that Elasticsearch is running

检查Elasticsearch是否在运行

 

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

你可以测试Elasticsearch节点是否在运行通过发送HTTP请求到本地的9200端口:

 

GET /

 

which should give you a response something like this:

将会收到响应信息如下:

 

{

  "name" : "Cp8oag6",

  "cluster_name" : "elasticsearch",

  "cluster_uuid" : "AT69_T_DTp-1qgIJlatQqA",

  "version" : {

    "number" : "5.5.2",

    "build_hash" : "f27399d",

    "build_date" : "2016-03-30T09:51:41.449Z",

    "build_snapshot" : false,

    "lucene_version" : "6.5.1"

  },

  "tagline" : "You Know, for Search"

}

 

Installing Elasticsearch as a Service on Windows

Elasticsearch安装为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 upon installation using the following command line options

Elasticsearch可以被安装为Windows服务在后台运行或开机启动而不需要人工参与。这可以在安装时配置或通过命令行配置:

 

    INSTALLASSERVICE=true

    STARTAFTERINSTALL=true

    STARTWHENWINDOWSSTARTS=true

 

Once installed, Elasticsearch will appear within the Services control panel:

一旦安装,Elasticsearch将出现在服务控制面板中:

 

 

and can be stopped and restarted from within the control panel, or from the command line using:

并且可以停止和重启使用控制面板或命令行参数:

 

with Command Prompt:

使用命令行:

 

sc.exe stop Elasticsearch

sc.exe start Elasticsearch

 

with PowerShell:

使用PowerShell

 

Get-Service Elasticsearch | Stop-Service | Start-Service

 

Changes can be made to jvm.options and elasticsearch.yml configuration files to configure the service after installation. Most changes (like JVM settings) will require a restart of the service in order to take affect.

可以使用jvm.optionselasticsearch.yml配置文件来配置服务在安装之后。大部分更改(例如JVM设置)将要求重新启动服务使得其生效。

 

Upgrade using the graphical user interface (GUI)

使用用户界面进行更新操作:

 

The .msi package supports upgrading an installed version of Elasticsearch to a newer version of Elasticsearch. The upgrade process through the GUI handles upgrading all installed plugins as well as retaining both your data and configuration.

msi安装包支持更新Elasticsearch为一个新的版本。更新进程会更新所有已经安装的插件包括你的数据和配置。

 

Downloading and clicking on a newer version of the .msi package will launch the GUI wizard. The first step will list the read only properties from the previous installation:

下载和单击新版本的msi安装包将启动GUI向导。第一步将列出之前安装中只读的属性:

 

 

 

The following configuration step allows certain configuration options to be changed:

下面的配置允许修改一些配置信息:

 


Finally, the plugins step allows currently installed plugins to be upgraded or removed, and for plugins not currently installed, to be downloaded and installed:

最后,插件被更新和移除并且还可以下载和安装当前没有被安装的插件:

 


Upgrade using the command line

使用命令行更新

 

The .msi can also upgrade Elasticsearch using the command line.

也可以使用命令行来操作msi来更新Elasticsearch

 

Important

重要

 

A command line upgrade requires passing the same command line properties as used at first install time; the Windows Installer does not remember these properties.

命令行更新要求传入相同的命令行属性就像在第一次安装时一样;Windows安装器是不会记住这些属性的。

 

For example, if you originally installed with the command line options PLUGINS="x-pack" and LOCKMEMORY="true", then you must pass these same values when performing an upgrade from the command line.

例如,如果你原来使用了命令例如PLUGINS="x-pack"LOCKMEMORY="true",则你必须在更新时也同时传入相同的命令选项。

 

The simplest upgrade, assuming Elasticsearch was installed using all defaults, is achieved by first navigating to the download directory, then running:

最简单的更新,假设Elasticsearch被安装使用了默认的设置,首先将安装包放到下载目录,然后执行命令:

 

start /wait msiexec.exe /i elasticsearch-5.5.2.msi /qn

 

Similar to the install process, a path to a log file for the upgrade process can be passed using the /l command line argument

和安装过程相似,更新的日志记录可以通过传递/l命令来指定文件。

 

start /wait msiexec.exe /i elasticsearch-5.5.2.msi /qn /l upgrade.log

 

Uninstall using Add/Remove Programs

使用添加和删除卸载

 

The .msi package handles uninstallation of all directories and files added as part of installation.

msi安装包处理所有目录和文件的卸载作为安装程序的一部分。

 

Warning

警告

 

Uninstallation will remove all directories and their contents created as part of installation, including data within the data directory. If you wish to retain your data upon uninstallation, it is recommended that you make a copy of the data directory before uninstallation.

卸载将会移除所有的目录以及他们包含的内容,包括数据。如果你要保留数据,则建议你在卸载之前备份数据目录。

 

MSI installer packages do not provide a GUI for uninstallation. An installed program can be uninstalled by pressing the Windows key and typing add or remove programs to open the system settings.

MSI安装包没有提供GUI用于卸载。可以通过WIndows的添加和删除程序来运行卸载功能。

 

Once opened, find the Elasticsearch installation within the list of installed applications, click and choose Uninstall:

一旦启动,在安装列表中找到Elasticsearch,点击和选择卸载:

 


This will launch the uninstallation process.

这将会启动卸载进程

 

Uninstall using the command line

使用命令行卸载

 

Uninstallation can also be performed from the command line by navigating to the directory containing the .msi package and running:

卸载操作也可以通过命令行来执行对于包含msi程序的位置运行:

 

start /wait msiexec.exe /x elasticsearch-5.5.2.msi /qn

 

Similar to the install process, a path to a log file for the uninstallation process can be passed using the /l command line argument

类似于安装过程,可以指定日文件的路径通过使用/l命令行参数

 

start /wait msiexec.exe /x elasticsearch-5.5.2.msi /qn /l uninstall.log

 

Next steps

下一步

 

You now have a test Elasticsearch environment set up. Before you start serious development or go into production with Elasticsearch, you will need to do some additional setup:

你现在已经启动了一个可以测试Elasticsearch的环境。在你进行开发之前或准备将Elasticsearch投入生产之前,你需要一些额外的配置:

 

    Learn how to configure Elasticsearch.

学习如何配置Elasticsearch

    Configure important Elasticsearch settings.

配置重要的Elasticsearch设置

    Configure important system settings.

配置重要的系统设置

 

Install Elasticsearch with Docker

使用Docker来安装Elasticsearch

 

Elasticsearch is also available as a Docker image. The image is built with X-Pack and uses centos:7 as the base image. The source code can be found on GitHub.

Elasticsearch也可以通过使用Docker镜像的方式来安装。镜像使用X-Pack来构建基于CentOS:7作为基础镜像。源代码可以在https://github.com/elastic/elasticsearch-docker/tree/5.5上找到。

 

Security note

安装提示

 

Note

注意

 

X-Pack is preinstalled in this image. Please take a few minutes to familiarize yourself with X-Pack Security and how to change default passwords. The default password for the elastic user is changeme.

X-Pack被集成在这个镜像中。请还肥一段时间熟悉X-Pack的安装设置以及如何改变默认的密码。默认的密码用于elastic用户是changeme

 

Note

注意

 

X-Pack includes a trial license for 30 days. After that, you can obtain one of the available subscriptions or disable Security. The Basic license is free and includes the Monitoring extension.

X-Pack包含一个使用的限制在30天内。之后,你可以获得一个可用的订阅或关闭安装。基本的协议是免费的并且包含监控。

 

Obtaining Elasticsearch for Docker is as simple as issuing a docker pull command against the Elastic Docker registry.

获取Elasticsearch镜像可以使用docker pull命令来从Docker镜像库中拉取。

 

The Docker image can be retrieved with the following command:

可以使用下面的命令来获取Docker镜像:

 

docker pull docker.elastic.co/elasticsearch/elasticsearch:5.5.2

 

Running Elasticsearch from the command line

使用命令行运行Elasticsearch

 

Development mode

开发模式

 

Elasticsearch can be quickly started for development or testing use with the following command:

Elasticsearch在开发和测试中可以快速启动通过如下的命令:

 

docker run -p 9200:9200 -e "http.host=0.0.0.0" -e "transport.host=127.0.0.1" docker.elastic.co/elasticsearch/elasticsearch:5.5.2

 

Production mode

生产模式

 

Important

重要

 

The vm_max_map_count kernel setting needs to be set to at least 262144 for production use. Depending on your platform:

vm_max_map_count内核设置需要被设置为至少是262144用于生产使用。依赖于你的平台。

 

    Linux

 

    The vm_map_max_count setting should be set permanently in /etc/sysctl.conf:

vm_max_map_count应当被设置在/etc/sysctl.conf中:

 

    $ grep vm.max_map_count /etc/sysctl.conf

    vm.max_map_count=262144

 

    To apply the setting on a live system type: sysctl -w vm.max_map_count=262144

可以使用命令来直接修改:sysctl -w vm.max_map_count=262144

 

    OSX with Docker for Mac

Mac上使用Docker

 

    The vm_max_map_count setting must be set within the xhyve virtual machine:

vm_max_map_count设置必须使用xhyve虚拟机:

 

    $ screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty

 

    Log in with root and no password. Then configure the sysctl setting as you would for Linux:

使用root空密码登录。配置sysctl设置类似于Linux

 

    sysctl -w vm.max_map_count=262144

 

    OSX with Docker Toolbox

使用DockerToolbox

 

    The vm_max_map_count setting must be set via docker-machine:

vm_max_map_count应当被设置通过docker-machine

 

    docker-machine ssh

    sudo sysctl -w vm.max_map_count=262144

 

The following example brings up a cluster comprising two Elasticsearch nodes. To bring up the cluster, use the docker-compose.yml and just type:

下面的例子引入了两个节点的集群。为了启动集群,使用了docker-compose.yml并且输入如下:

 

docker-compose up

 

Note

注意

 

docker-compose is not pre-installed with Docker on Linux. Instructions for installing it can be found on the docker-compose webpage.

docker-compose没有被docker装在Linux上。安装指南可以在ocker-compose的网站上找到。

 

The node elasticsearch1 listens on localhost:9200 while elasticsearch2 talks to elasticsearch1 over a Docker network.

节点elasticsearch1监听本机的9200,并且elasticsearch2使用Docker网络和elasticsearch1通讯。

 

This example also uses Docker named volumes, called esdata1 and esdata2 which will be created if not already present.

这个例子也适用了Docker的命名卷,名字为esdata1esdata2如果不存在的话将被创建。

 

docker-compose.yml:

 

version: '2'

services:

  elasticsearch1:

    image: docker.elastic.co/elasticsearch/elasticsearch:5.5.2

    container_name: elasticsearch1

    environment:

      - cluster.name=docker-cluster

      - bootstrap.memory_lock=true

      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"

    ulimits:

      memlock:

        soft: -1

        hard: -1

    mem_limit: 1g

    volumes:

      - esdata1:/usr/share/elasticsearch/data

    ports:

      - 9200:9200

    networks:

      - esnet

  elasticsearch2:

    image: docker.elastic.co/elasticsearch/elasticsearch:5.5.2

    environment:

      - cluster.name=docker-cluster

      - bootstrap.memory_lock=true

      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"

      - "discovery.zen.ping.unicast.hosts=elasticsearch1"

    ulimits:

      memlock:

        soft: -1

        hard: -1

    mem_limit: 1g

    volumes:

      - esdata2:/usr/share/elasticsearch/data

    networks:

      - esnet

 

volumes:

  esdata1:

    driver: local

  esdata2:

    driver: local

 

networks:

  esnet:

 

To stop the cluster, type docker-compose down. Data volumes will persist, so its possible to start the cluster again with the same data using docker-compose up. To destroy the cluster and the data volumes just type docker-compose down -v.

为了关闭集群,键入docker-compose donw。数据卷将会持久存在因此可以在此开启集群使用相同的数据使用docker-compose up。为了关闭集群和数据卷可以键入docker-compose down -v

 

Inspect status of cluster:

查看集群的状态

 

curl -u elastic http://127.0.0.1:9200/_cat/health

Enter host password for user 'elastic':

1472225929 15:38:49 docker-cluster green 2 2 4 2 0 0 0 0 - 100.0%

 

Log messages go to the console and are handled by the configured Docker logging driver. By default you can access logs with docker logs.

日志消息来自控制台通过配置Docker的日志驱动来处理。默认是你可以访问日志通过docker logs

 

Configuring Elasticsearch with Docker

使用Docker来配置Elasticsearch

 

Elasticsearch loads its configuration from files under /usr/share/elasticsearch/config/. These configuration files are documented in Configuring Elasticsearch and Setting JVM options.

Elasticsearch从文件/usr/share/elasticsearch/config/来加载配置。这些配置文件记录在https://www.elastic.co/guide/en/elasticsearch/reference/5.5/settings.htmlhttps://www.elastic.co/guide/en/elasticsearch/reference/5.5/setting-system-settings.html#jvm-options中。

 

The image offers several methods for configuring Elasticsearch settings with the conventional approach being to provide customized files, i.e. elasticsearch.yml, but its also possible to use environment variables to set options:

镜像提供了一些方法用于配置Elasticsearch设置使用方便的方法通过提供自定义文件,例如elasticsearch.yml,但是他不能使用环境变量来设置:

 

A. Present the parameters via Docker environment variables

通过Docker环境变量来持久化参数

 

For example, to define the cluster name with docker run you can pass -e "cluster.name=mynewclustername". Double quotes are required.

例如为了定义集群的名字可以在docker run中传递-e "cluster.name=mynewclustername"。需要引号。

 

B. Bind-mounted configuration

绑定配置

 

Create your custom config file and mount this over the images corresponding file. For example, bind-mounting a custom_elasticsearch.yml with docker run can be accomplished with the parameter:

创建一个自定义的配置文件并且加载到镜像中的相应的文件上。例如,绑定custom_elasticsearch.yml使用docker run可以通过参数如下来实现:

 

-v full_path_to/custom_elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml

 

Important

重要

 

The container runs Elasticsearch as user elasticsearch using uid:gid 1000:1000. Bind mounted host directories and files, such as custom_elasticsearch.yml above, need to be accessible by this user. For the data and log dirs, such as /usr/share/elasticsearch/data, write access is required as well.

容器运行Elasticsearch使用用户elasticsearch使用uig:gid 1000:1000。绑定主目录和文件,例如custom_elasticsearch.yml如上,需要通过这个用户来访问。对于数据和日志目录,例如/usr/share/elasticsearch/config/,需要写的权限。

 

C. Customized image

自定义镜像

 

In some environments, it may make more sense to prepare a custom image containing your configuration. A Dockerfile to achieve this may be as simple as:

在一些情况下,可以准备一个自定义镜像包含你的配置。一个Dockerfile可以实现并且很简单:

 

FROM docker.elastic.co/elasticsearch/elasticsearch:5.5.2

ADD elasticsearch.yml /usr/share/elasticsearch/config/

USER root

RUN chown elasticsearch:elasticsearch config/elasticsearch.yml

USER elasticsearch

 

You could then build and try the image with something like:

你应当使用如下的方式来构建这个镜像:

 

docker build --tag=elasticsearch-custom .

docker run -ti -v /usr/share/elasticsearch/data elasticsearch-custom

 

D. Override the images default CMD

覆盖镜像默认的CMD

 

Options can be passed as command-line options to the Elasticsearch process by overriding the default command for the image. For example:

可以通过命令行选项传递给Elasticsearch通过覆盖默认的镜像命令。例如:

 

docker run <various parameters> bin/elasticsearch -Ecluster.name=mynewclustername

 

Notes for production use and defaults

注意生产使用和默认

 

We have collected a number of best practices for production use.

我们收集了一些好的实践对于生产使用。

 

Note

注意

 

Any Docker parameters mentioned below assume the use of docker run.

任何Docker参数在下面提到的都可以使用docker run来传递。

 

    1Elasticsearch runs inside the container as user elasticsearch using uid:gid 1000:1000. If you are bind-mounting a local directory or file, ensure it is readable by this user, while the data and log dirs additionally require write access.

Elasticsearch运行在容器中使用用户elasticsearch使用uid:gic 1000:1000。如果你绑定了一个本地目录或文件,保证这个用户的读权限,对于数据和日志目录还要保证写的权限。

 

    2It is important to ensure increased ulimits for nofile and nproc are available for the Elasticsearch containers. Verify the init system for the Docker daemon is already setting those to acceptable values and, if needed, adjust them in the Daemon, or override them per container, for example using docker run:

保证nofilenproc的限制对于Elasticsearch的容器。验证init system用于Dockerdaemon已经被设置为可接受的值并且如果需要则在Daemon中进行调整或覆盖他们对于每一个容器,例如使用docker run

 

    --ulimit nofile=65536:65536

 

    Note

注意

 

    One way of checking the Docker daemon defaults for the aforementioned ulimits is by running:

检查Docker daemon的一种方式是通过运行如下命令:

 

    docker run --rm centos:7 /bin/bash -c 'ulimit -Hn && ulimit -Sn && ulimit -Hu && ulimit -Su'

 

    3Swapping needs to be disabled for performance and node stability. This can be achieved through any of the methods mentioned in the Elasticsearch docs. If you opt for the bootstrap.memory_lock: true approach, apart from defining it through any of the configuration methods, you will additionally need the memlock: true ulimit, either defined in the Docker Daemon or specifically set for the container. This has been demonstrated earlier in the docker-compose.yml, or using docker run:

需要关闭交换分区以保证性能和节点的稳定。这可以使用任何在https://www.elastic.co/guide/en/elasticsearch/reference/5.5/setup-configuration-memory.html中提到的方式。如果你使用bootstrap.memory_lock: true方式,可以定义通过配置方法,你需要设置memlock: true定义在Docker Daemon或指定在容器上。这在之前的docker-compose.yml中有过描述或使用docker run

 

    -e "bootstrap.memory_lock=true" --ulimit memlock=-1:-1

 

    4The image exposes TCP ports 9200 and 9300. For clusters it is recommended to randomize the published ports with --publish-all, unless you are pinning one container per host.

暴露TCP9200端口和9300端口。对于集群建议随机发布端口使用--publish-all,除非你对于每个主机有一定的规划。

    5Use the ES_JAVA_OPTS environment variable to set heap size, e.g. to use 16GB use -e ES_JAVA_OPTS="-Xms16g -Xmx16g" with docker run. It is also recommended to set a memory limit for the container.

使用ES_JAVA_OPTS环境变量来设置堆的大小,例如使用16GB的,使用docker run-e ES_JAVA_OPTS="-Xms16g -Xmx16g"来指定。建议对容器设置内存的大小。

    6Pin your deployments to a specific version of the Elasticsearch Docker image, e.g. docker.elastic.co/elasticsearch/elasticsearch:5.5.2.

注意你部署的Docker镜像的版本,例如docker.elastic.co/elasticsearch/elasticsearch:5.5.2

 

    7Always use a volume bound on /usr/share/elasticsearch/data, as shown in the production example, for the following reasons:

使用卷来绑定/usr/share/elasticsearch/data,就像在上面展示过的那样,理由是:

        aThe data of your elasticsearch node wont be lost if the container is killed

elasticsearch的数据在容器关闭时不会丢失

        bElasticsearch is I/O sensitive and the Docker storage driver is not ideal for fast I/O

ElasticsearchIO敏感的并且Docker的存储驱动不能初始快速IO

        cIt allows the use of advanced Docker volume plugins

他允许你使用高级的Docker卷插件

    8If you are using the devicemapper storage driver (default on at least RedHat (rpm) based distributions) make sure you are not using the default loop-lvm mode. Configure docker-engine to use direct-lvm instead.

如果你使用devicemapper卷驱动(默认是基于RedHat发行版)保证你没有使用默认的loop-lvm模式,修改docker的引擎来直接使用direct-lvm作为替代。

    9Consider centralizing your logs by using a different logging driver. Also note that the default json-file logging driver is not ideally suited for production use.

考虑使用不同的日志驱动来中心化你的日志。注意默认的json-file日志不是很适合生产使用。

 

Next steps

下一步

 

You now have a test Elasticsearch environment set up. Before you start serious development or go into production with Elasticsearch, you will need to do some additional setup:

你现在已经启动了一个可以测试Elasticsearch的环境。在你进行开发之前或准备将Elasticsearch投入生产之前,你需要一些额外的配置:

 

    Learn how to configure Elasticsearch.

学习如何配置Elasticsearch

    Configure important Elasticsearch settings.

配置重要的Elasticsearch设置

    Configure important system settings.

配置重要的系统设置

 

 

原创粉丝点击