-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
setup/configuration+jvm+logging+secure #5
base: cn
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,44 @@ | ||
[[settings]] | ||
== Configuring Elasticsearch | ||
== 配置 Elasticsearch | ||
|
||
Elasticsearch ships with good defaults and requires very little configuration. | ||
Most settings can be changed on a running cluster using the | ||
<<cluster-update-settings>> API. | ||
Elasticsearch 具有良好的默认配置,同时只需少量配置。 | ||
大多数设置可在集群运行时使用 | ||
<<cluster-update-settings>> API 更改。 | ||
|
||
The configuration files should contain settings which are node-specific (such | ||
as `node.name` and paths), or settings which a node requires in order to be | ||
able to join a cluster, such as `cluster.name` and `network.host`. | ||
配置文件应该包含节点特定(例如 `node.name` 和路径)设置,或者节点加入集群而需要的设置,例如 `cluster.name` 和 `network.host` 。 | ||
|
||
[[config-files-location]] | ||
[float] | ||
=== Config files location | ||
=== 配置文件路径 | ||
|
||
Elasticsearch has three configuration files: | ||
Elasticsearch 有三个配置文件: | ||
|
||
* `elasticsearch.yml` for configuring Elasticsearch | ||
* `jvm.options` for configuring Elasticsearch JVM settings | ||
* `log4j2.properties` for configuring Elasticsearch logging | ||
* `elasticsearch.yml` 用于配置 Elasticsearch | ||
* `jvm.options` 用于配置 Elasticsearch JVM 设置 | ||
* `log4j2.properties` 用于配置 Elasticsearch 日志 | ||
|
||
These files are located in the config directory, whose default location depends | ||
on whether or not the installation is from an archive distribution (`tar.gz` or | ||
`zip`) or a package distribution (Debian or RPM packages). | ||
这些文件存在于 config 目录,默认路径取决于安装来源是归档版本(`tar.gz` 或者 | ||
`zip` )还是包版本(Debian 或 RPM 包)。 | ||
|
||
For the archive distributions, the config directory location defaults to | ||
`$ES_HOME/config`. The location of the config directory can be changed via the | ||
`ES_PATH_CONF` environment variable as follows: | ||
对于归档版本,config 目录位于 `$ES_HOME/config` 。config 目录路径可以通过 `ES_PATH_CONF` 环境变量改变: | ||
|
||
[source,sh] | ||
------------------------------- | ||
ES_PATH_CONF=/path/to/my/config ./bin/elasticsearch | ||
------------------------------- | ||
|
||
Alternatively, you can `export` the `ES_PATH_CONF` environment variable via the | ||
command line or via your shell profile. | ||
你可以通过命令行或 shell 配置 `export` `ES_PATH_CONF` 环境变量。 | ||
|
||
For the package distributions, the config directory location defaults to | ||
`/etc/elasticsearch`. The location of the config directory can also be changed | ||
via the `ES_PATH_CONF` environment variable, but note that setting this in your | ||
shell is not sufficient. Instead, this variabled is sourced from | ||
`/etc/default/elasticsearch` (for the Debian package) and | ||
`/etc/sysconfig/elasticsearch` (for the RPM package). You will need to edit the | ||
`ES_PATH_CONF=/etc/elasticsearch` entry in one of these files accordingly to | ||
change the config directory location. | ||
对于包版本,config 默认目录位置为 `/etc/elasticsearch` 。 可以通过 `ES_PATH_CONF` 环境变量更改 config 目录位置,但请注意,仅仅在 shell 中设置不够的。 相反,这个变量来源于 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 。后面多了空格 |
||
`/etc/default/elasticsearch` (Debian 包)和 | ||
`/etc/sysconfig/elasticsearch` (RPM 包)。 | ||
你需要编辑位于这些文件的 `ES_PATH_CONF=/etc/elasticsearch` 项来更改 config 目录位置。 | ||
|
||
|
||
[float] | ||
=== Config file format | ||
=== 配置文件格式 | ||
|
||
The configuration format is http://www.yaml.org/[YAML]. Here is an | ||
example of changing the path of the data and logs directories: | ||
配置格式是 http://www.yaml.org/[YAML] 。 以下是一个更改数据和日志目录路径的示例: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 。后面多了空格 |
||
|
||
[source,yaml] | ||
-------------------------------------------------- | ||
|
@@ -58,7 +47,7 @@ path: | |
logs: /var/log/elasticsearch | ||
-------------------------------------------------- | ||
|
||
Settings can also be flattened as follows: | ||
可用如下方式展开设置: | ||
|
||
[source,yaml] | ||
-------------------------------------------------- | ||
|
@@ -67,11 +56,9 @@ path.logs: /var/log/elasticsearch | |
-------------------------------------------------- | ||
|
||
[float] | ||
=== Environment variable substitution | ||
=== 替换环境变量 | ||
|
||
Environment variables referenced with the `${...}` notation within the | ||
configuration file will be replaced with the value of the environment | ||
variable, for instance: | ||
配置文件内用 `${...}` 符号引用的环境变量将被替换为环境变量值,例如: | ||
|
||
[source,yaml] | ||
-------------------------------------------------- | ||
|
@@ -80,28 +67,22 @@ network.host: ${ES_NETWORK_HOST} | |
-------------------------------------------------- | ||
|
||
[float] | ||
=== Prompting for settings | ||
=== 提示设置 | ||
|
||
For settings that you do not wish to store in the configuration file, you can | ||
use the value `${prompt.text}` or `${prompt.secret}` and start Elasticsearch | ||
in the foreground. `${prompt.secret}` has echoing disabled so that the value | ||
entered will not be shown in your terminal; `${prompt.text}` will allow you to | ||
see the value as you type it in. For example: | ||
如果不希望将设置存储在配置文件中,你可以使用 `${prompt.text}` 或 `${prompt.secret}` 值并在前台启动 Elasticsearch。 | ||
`${prompt.secret}` 禁用回显所以输入的值不会显示在终端;`${prompt.text}` 允许你在输入时查看该值。例如: | ||
|
||
[source,yaml] | ||
-------------------------------------------------- | ||
node: | ||
name: ${prompt.text} | ||
-------------------------------------------------- | ||
|
||
When starting Elasticsearch, you will be prompted to enter the actual value | ||
like so: | ||
启动 Elasticsearch 时,系统会提示你像这样输入实际值: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 启动 Elasticsearch 时,系统会提示你输入实际值,例如: |
||
|
||
[source,sh] | ||
-------------------------------------------------- | ||
Enter value for [node.name]: | ||
-------------------------------------------------- | ||
|
||
NOTE: Elasticsearch will not start if `${prompt.text}` or `${prompt.secret}` | ||
is used in the settings and the process is run as a service or in the background. | ||
|
||
NOTE: 如果在设置中使用了 `${prompt.text}` 或 `${prompt.secret}` ,同时该进程作为后台服务运行,则无法启动 Elasticsearch。 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,86 +1,66 @@ | ||
[[jvm-options]] | ||
=== Setting JVM options | ||
=== 设置 JVM 参数 | ||
|
||
You should rarely need to change Java Virtual Machine (JVM) options. If you do, | ||
the most likely change is setting the <<heap-size,heap size>>. The remainder of | ||
this document explains in detail how to set JVM options. | ||
你应该很少需要更改 Java 虚拟机(JVM)选项。 如果你这样做,最有可能的变化是设置 <<heap-size,堆大小>>。本文档详细介绍了如何设置 JVM 选项。 | ||
|
||
The preferred method of setting JVM options (including system properties and JVM | ||
flags) is via the `jvm.options` configuration file. The default location of this | ||
file is `config/jvm.options` (when installing from the tar or zip distributions) | ||
and `/etc/elasticsearch/jvm.options` (when installing from the Debian or RPM | ||
packages). | ||
设置 JVM 选项(包括系统属性和 JVM 标志)的首选方法是通过 `jvm.options` 配置文件。该文件默认位置是 `config/jvm.options` (tar 或 zip 版本安装方式) | ||
和 `/etc/elasticsearch/jvm.options` (Debian 或 RPM 包安装方式)。 | ||
|
||
This file contains a line-delimited list of JVM arguments following | ||
a special syntax: | ||
该文件包含横线分隔的特殊 JVM 参数列表语法: | ||
|
||
* lines consisting of whitespace only are ignored | ||
* lines beginning with `#` are treated as comments and are ignored | ||
* 仅包含空白的行将被忽略 | ||
* 以 `#` 开始的行视为注释并被忽略 | ||
+ | ||
[source,text] | ||
------------------------------------- | ||
# this is a comment | ||
------------------------------------- | ||
|
||
* lines beginning with a `-` are treated as a JVM option that applies | ||
independent of the version of the JVM | ||
* 以 `-` 开始的行视为适用于独立 JVM 版本选项 | ||
+ | ||
[source,text] | ||
------------------------------------- | ||
-Xmx2g | ||
------------------------------------- | ||
|
||
* lines beginning with a number followed by a `:` followed by a `-` are treated | ||
as a JVM option that applies only if the version of the JVM matches the number | ||
* 数字后跟着 `:` 和 `-` 视为适用于匹配该数值的 JVM 版本选项。 | ||
+ | ||
[source,text] | ||
------------------------------------- | ||
8:-Xmx2g | ||
------------------------------------- | ||
|
||
* lines beginning with a number followed by a `-` followed by a `:` are treated | ||
as a JVM option that applies only if the version of the JVM is greater than or | ||
equal to the number | ||
* 数字后跟着 `-` 和 `:` 视为适用于不低于该数值的 JVM 版本选项。 | ||
+ | ||
[source,text] | ||
------------------------------------- | ||
8-:-Xmx2g | ||
------------------------------------- | ||
|
||
* lines beginning with a number followed by a `-` followed by a number followed | ||
by a `:` are treated as a JVM option that applies only if the version of the | ||
JVM falls in the range of the two numbers | ||
* 数字后跟着 `-` 再跟着数字视为只适用于该俩数值间的 JVM 版本选项。 | ||
+ | ||
[source,text] | ||
------------------------------------- | ||
8-9:-Xmx2g | ||
------------------------------------- | ||
|
||
* all other lines are rejected | ||
* 所有其他行都会被拒绝 | ||
|
||
You can add custom JVM flags to this file and check this configuration into your | ||
version control system. | ||
你可以将自定义 JVM 标识添加到该文件,并在版本控制系统里检查该配置。 | ||
|
||
An alternative mechanism for setting Java Virtual Machine options is via the | ||
`ES_JAVA_OPTS` environment variable. For instance: | ||
另一种设置 Java 虚拟机选项的方式是使用 `ES_JAVA_OPTS` 环境变量。例如: | ||
|
||
[source,sh] | ||
--------------------------------- | ||
export ES_JAVA_OPTS="$ES_JAVA_OPTS -Djava.io.tmpdir=/path/to/temp/dir" | ||
./bin/elasticsearch | ||
--------------------------------- | ||
|
||
When using the RPM or Debian packages, `ES_JAVA_OPTS` can be specified in the | ||
<<sysconfig,system configuration file>>. | ||
当使用 RPM 或 Debian 包时, `ES_JAVA_OPTS` 可从 | ||
<<sysconfig,system configuration file>> 指定。 | ||
|
||
The JVM has a built-in mechanism for observing the `JAVA_TOOL_OPTIONS` | ||
environment variable. We intentionally ignore this environment variable in our | ||
packaging scripts. The primary reason for this is that on some OS (e.g., Ubuntu) | ||
there are agents installed by default via this environment variable that we do | ||
not want interfering with Elasticsearch. | ||
JVM 具有观察 `JAVA_TOOL_OPTIONS` 环境变量的内置机制。 我们在打包脚本中故意忽略这个环境变量。主要原因是在某些操作系统上(例如 Ubuntu), | ||
我们不想通过干涉 Elasticsearch 环境变量安装默认代理。 | ||
|
||
Additionally, some other Java programs support the `JAVA_OPTS` environment | ||
variable. This is *not* a mechanism built into the JVM but instead a convention | ||
in the ecosystem. However, we do not support this environment variable, instead | ||
supporting setting JVM options via the `jvm.options` file or the environment | ||
variable `ES_JAVA_OPTS` as above. | ||
另外,还有一些其他 Java 程序支持 `JAVA_OPTS` 环境变量。这 *不是* JVM 内置的机制,而是一种生态约定。 然而,我们不支持这个环境变量, | ||
而支持通过 `jvm.options` 文件或上文提及的 `ES_JAVA_OPTS` 环境变量设置 JVM 选项。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
此外,你可以在命令行或修改 shell profile 文件
export
ES_PATH_CONF
以修改环境变量。