-
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/important-setting #6
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,14 +1,12 @@ | ||
[[cluster.name]] | ||
=== `cluster.name` | ||
|
||
A node can only join a cluster when it shares its `cluster.name` with all the | ||
other nodes in the cluster. The default name is `elasticsearch`, but you should | ||
change it to an appropriate name which describes the purpose of the cluster. | ||
一个节点只能在与集群所有其他节点共享 `cluster.name` 后才能加入集群。 默认集群名称是 `elasticsearch` ,但你应该 | ||
将其更改为描述集群用途的合适名称。 | ||
|
||
[source,yaml] | ||
-------------------------------------------------- | ||
cluster.name: logging-prod | ||
-------------------------------------------------- | ||
|
||
Make sure that you don't reuse the same cluster names in different environments, | ||
otherwise you might end up with nodes joining the wrong cluster. | ||
请确保不同环境不要复用相同的集群名,否则你可能会遇到节点加入错误集群问题。 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,16 @@ | ||
[[discovery-settings]] | ||
=== Discovery settings | ||
=== 发现设置 | ||
|
||
Elasticsearch uses a custom discovery implementation called "Zen Discovery" for | ||
node-to-node clustering and master election. There are two important discovery | ||
settings that should be configured before going to production. | ||
Elasticsearch 使用称为 "Zen Discovery" 的自定义发现实现 node-to-node 集群和主选举。 在投入生产之前应该配置两个重要的发现设置。 | ||
|
||
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. 。后多了空格 |
||
[float] | ||
[[unicast.hosts]] | ||
==== `discovery.zen.ping.unicast.hosts` | ||
|
||
Out of the box, without any network configuration, Elasticsearch will bind to | ||
the available loopback addresses and will scan ports 9300 to 9305 to try to | ||
connect to other nodes running on the same server. This provides an auto- | ||
clustering experience without having to do any configuration. | ||
开箱即用,没有任何网络配置,Elasticsearch 将绑定到可用的环回地址,并扫描 9300 至 9305 端口以尝试 | ||
连接到同一服务器上的其他运行节点。 这提供了一个 auto-clustering 体验,而无需进行任何配置。 | ||
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. 。后多了空格 |
||
|
||
When the moment comes to form a cluster with nodes on other servers, you have to | ||
provide a seed list of other nodes in the cluster that are likely to be live and | ||
contactable. This can be specified as follows: | ||
当需要与其他服务器上的节点组成集群时,你必须提供存活且可达集群中其他节点的种子列表。 可用以下方式指定: | ||
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] | ||
-------------------------------------------------- | ||
|
@@ -25,32 +19,25 @@ discovery.zen.ping.unicast.hosts: | |
- 192.168.1.11 <1> | ||
- seeds.mydomain.com <2> | ||
-------------------------------------------------- | ||
<1> The port will default to `transport.profiles.default.port` and fallback to | ||
`transport.tcp.port` if not specified. | ||
<2> A hostname that resolves to multiple IP addresses will try all resolved | ||
addresses. | ||
<1> 默认端口是 `transport.profiles.default.port` ,如果没有指定则回退为 | ||
`transport.tcp.port` 。 | ||
<2> 尝试解析主机名的全部 IP 地址。 | ||
|
||
[float] | ||
[[minimum_master_nodes]] | ||
==== `discovery.zen.minimum_master_nodes` | ||
|
||
To prevent data loss, it is vital to configure the | ||
`discovery.zen.minimum_master_nodes` setting so that each master-eligible node | ||
knows the _minimum number of master-eligible nodes_ that must be visible in | ||
order to form a cluster. | ||
为了防止数据丢失,配置 `discovery.zen.minimum_master_nodes` 设置至关重要,以便每个候选主节点 | ||
知道组成集群所需的 _最小候选主节点数_ 。 | ||
|
||
Without this setting, a cluster that suffers a network failure is at risk of | ||
having the cluster split into two independent clusters -- a split brain -- which | ||
will lead to data loss. A more detailed explanation is provided in | ||
<<split-brain>>. | ||
如果没有设置,遭受网络故障的集群有将这个集群分裂成两个独立的集群的风险 -- 脑裂 -- 会导致数据丢失。 | ||
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. 如果没有设置,遭受网络故障的集群有将这个集群分裂成两个独立的集群的风险 -- 脑裂(split brain) -- 会导致数据丢失。 |
||
更详细的解释由 <<split-brain>> 提供。 | ||
|
||
To avoid a split brain, this setting should be set to a _quorum_ of | ||
master-eligible nodes: | ||
为了避免脑裂,这个设置应该设置为候选主节点的 _quorum_: | ||
|
||
(master_eligible_nodes / 2) + 1 | ||
|
||
In other words, if there are three master-eligible nodes, then minimum master | ||
nodes should be set to `(3 / 2) + 1` or `2`: | ||
换句话说,如果有三个候选主节点,最小主节点数应该设为 `(3 / 2) + 1` 或 `2` : | ||
|
||
[source,yaml] | ||
-------------------------------------------------- | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
[[gc-logging]] | ||
=== GC logging | ||
|
||
By default, Elasticsearch enables GC logs. These are configured in | ||
<<jvm-options,`jvm.options`>> and default to the same default location as the | ||
Elasticsearch logs. The default configuration rotates the logs every 64 MB and | ||
can consume up to 2 GB of disk space. | ||
默认情况下,Elasticsearch 启用 GC 日志。这些日志由 <<jvm-options,`jvm.options`>> 配置,且默认与 Elasticsearch 默认日志位置相同。 | ||
默认每隔 64 MB 结转一次日志,最高消耗 2 GB 磁盘空间。 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,11 @@ | ||
[[heap-dump-path]] | ||
=== JVM heap dump path | ||
=== JVM 堆 dump 路径 | ||
|
||
The <<rpm,RPM>> and <<deb,Debian>> package distributions default to configuring | ||
the JVM to dump the heap on out of memory exceptions to | ||
`/var/lib/elasticsearch`. If this path is not suitable for storing heap dumps, | ||
you should modify the entry `-XX:HeapDumpPath=/var/lib/elasticsearch` in | ||
<<jvm-options,`jvm.options`>> to an alternate path. If you specify a filename | ||
instead of a directory, the JVM will repeatedly use the same file; this is one | ||
mechanism for preventing heap dumps from accumulating in the heap dump path. | ||
Alternatively, you can configure a scheduled task via your OS to remove heap | ||
dumps that are older than a configured age. | ||
<<rpm,RPM>> 和 <<deb,Debian>> 包版本默认在内存溢出时将 JVM dump 到 `/var/lib/elasticsearch` 。 | ||
如果这个路径不适合存储堆 dump,你可以修改 <<jvm-options,`jvm.options`>> 里面的 `-XX:HeapDumpPath=/var/lib/elasticsearch` 。 | ||
如果你指定一个文件名而不是目录,JVM 将重复使用这个相同文件;这是一个防止堆 dump 在 dump 路径中累积的机制。 | ||
或者,您可以通过操作系统配置一个调度任务来删除早于配置时间的堆 dump 文件。 | ||
|
||
Note that the archive distributions do not configure the heap dump path by | ||
default. Instead, the JVM will default to dumping to the working directory for | ||
the Elasticsearch process. If you wish to configure a heap dump path, you should | ||
modify the entry `#-XX:HeapDumpPath=/heap/dump/path` in | ||
<<jvm-options,`jvm.options`>> to remove the comment marker `#` and to specify an | ||
actual path. | ||
注意归档版本默认不配置堆 dump 路径。相反,JVM 将默认 dump 到 Elasticsearch 进程工作目录。 | ||
如果你想配置一个 dump 路径,你可以通过移除 <<jvm-options,`jvm.options`>> 里 `-XX:HeapDumpPath=/heap/dump/path` 项前面的 `#` 注释标记, | ||
并指定一个实际路径来修改该路径。 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,54 @@ | ||
[[heap-size]] | ||
=== Setting the heap size | ||
=== 设置堆大小 | ||
|
||
By default, Elasticsearch tells the JVM to use a heap with a minimum and maximum | ||
size of 1 GB. When moving to production, it is important to configure heap size | ||
to ensure that Elasticsearch has enough heap available. | ||
默认情况下,Elasticsearch 通知 JVM 使用最小和最大值均为 1 GB 的堆。当转到生产时,为了确保 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 有足够的可用堆,配置堆大小非常重要。 |
||
|
||
Elasticsearch will assign the entire heap specified in | ||
<<jvm-options,jvm.options>> via the `Xms` (minimum heap size) and `Xmx` (maximum | ||
heap size) settings. | ||
Elasticsearch 通过指定设置 <<jvm-options,jvm.options>> 内的 `Xms` (最小堆大小)和 `Xmx` (最大堆大小)分配整个堆。 | ||
|
||
The value for these setting depends on the amount of RAM available on your | ||
server. Good rules of thumb are: | ||
这些设置值取决于你的服务器 RAM 可用量。好的经验规则是: | ||
|
||
* Set the minimum heap size (`Xms`) and maximum heap size (`Xmx`) to be equal to | ||
each other. | ||
* 设置最小堆大小(`Xms`)等于最大堆大小(`Xmx`)。 | ||
|
||
* The more heap available to Elasticsearch, the more memory it can use for | ||
caching. But note that too much heap can subject you to long garbage | ||
collection pauses. | ||
* Elasticsearch 可用的堆越多,就有更多内存用于缓存。但请注意,堆太大会让垃圾收集暂停时间更长。 | ||
|
||
* Set `Xmx` to no more than 50% of your physical RAM, to ensure that there is | ||
enough physical RAM left for kernel file system caches. | ||
* `Xmx` 不要设置大于物理 RAM 的 50%,这是为了确保有足够物理 RAM 用于内核文件系统缓存。 | ||
|
||
* Don’t set `Xmx` to above the cutoff that the JVM uses for compressed object | ||
pointers (compressed oops); the exact cutoff varies but is near 32 GB. You can | ||
verify that you are under the limit by looking for a line in the logs like the | ||
following: | ||
* 不要将 `Xmx` 设置为 JVM 压缩对象指针(压缩的 oops)临界点以上;确切的临界值有所不同,但接近 32 GB。 | ||
你可以通过在日志中查找以下行来验证是否在限制以下: | ||
+ | ||
heap size [1.9gb], compressed ordinary object pointers [true] | ||
|
||
* Even better, try to stay below the threshold for zero-based compressed oops; | ||
the exact cutoff varies but 26 GB is safe on most systems, but can be as large | ||
as 30 GB on some systems. You can verify that you are under the limit by | ||
starting Elasticsearch with the JVM options `-XX:+UnlockDiagnosticVMOptions | ||
-XX:+PrintCompressedOopsMode` and looking for a line like the following: | ||
* 更好的是,尽量保持低于零基压缩阈值;准确的临界值有所不同,但在大多数系统上 26 GB 是安全的,不过 | ||
在某些系统上可达 30 GB。你可以通过在启动 Elasticsearch 时配置 `-XX:+UnlockDiagnosticVMOptions -XX:+PrintCompressedOopsMode` JVM 选项 | ||
并查找以下行来验证是否受限: | ||
+ | ||
-- | ||
heap address: 0x000000011be00000, size: 27648 MB, zero based Compressed Oops | ||
|
||
showing that zero-based compressed oops are enabled instead of | ||
以下显示启用零基压缩: | ||
|
||
heap address: 0x0000000118400000, size: 28672 MB, Compressed Oops with base: 0x00000001183ff000 | ||
-- | ||
|
||
Here are examples of how to set the heap size via the jvm.options file: | ||
以下是通过 jvm.options 文件设置堆大小的一些例子: | ||
|
||
[source,txt] | ||
------------------ | ||
-Xms2g <1> | ||
-Xmx2g <2> | ||
------------------ | ||
<1> Set the minimum heap size to 2g. | ||
<2> Set the maximum heap size to 2g. | ||
<1> 设置最小堆为 2g。 | ||
<2> 设置最大堆为 2g。 | ||
|
||
It is also possible to set the heap size via an environment variable. This can | ||
be done by commenting out the `Xms` and `Xmx` settings in the | ||
<<jvm-options,`jvm.options`>> file and setting these values via `ES_JAVA_OPTS`: | ||
通过环境变量设置堆大小同样可行。这可以通过注释 <<jvm-options,`jvm.options`>> 文件中的 `Xms` 和 `Xmx` ,并在 `ES_JAVA_OPTS` 中设置这些值: | ||
|
||
[source,sh] | ||
------------------ | ||
ES_JAVA_OPTS="-Xms2g -Xmx2g" ./bin/elasticsearch <1> | ||
ES_JAVA_OPTS="-Xms4000m -Xmx4000m" ./bin/elasticsearch <2> | ||
------------------ | ||
<1> Set the minimum and maximum heap size to 2 GB. | ||
<2> Set the minimum and maximum heap size to 4000 MB. | ||
<1> 设置最小最大堆为 2 GB。 | ||
<2> 设置最小最大堆为 4000 MB。 | ||
|
||
NOTE: Configuring the heap for the <<windows-service,Windows service>> is | ||
different than the above. The values initially populated for the Windows service | ||
can be configured as above but are different after the service has been | ||
installed. Consult the <<windows-service,Windows service documentation>> for | ||
additional details. | ||
NOTE: 为 <<windows-service,Windows 服务>> 配置堆与上文方式不同。 Windows 服务初始值可以通过上文方式配置,但在服务安装完成后会有所不同。 | ||
更多细节请查看 <<windows-service,Windows 服务文档>> 。 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,22 @@ | ||
[[network.host]] | ||
=== `network.host` | ||
|
||
By default, Elasticsearch binds to loopback addresses only -- e.g. `127.0.0.1` | ||
and `[::1]`. This is sufficient to run a single development node on a server. | ||
Elasticsearch 默认只绑定环回地址 -- 例如 `127.0.0.1` 和 `[::1]` 。 | ||
这足以在服务器上运行单个开发节点。 | ||
|
||
TIP: In fact, more than one node can be started from the same `$ES_HOME` | ||
location on a single node. This can be useful for testing Elasticsearch's | ||
ability to form clusters, but it is not a configuration recommended for | ||
production. | ||
TIP: 实际上,在同一 `$ES_HOME` 路径下可以启动多个节点。这对测试 Elasticsearch 组成集群能力 | ||
十分有用,但这并不是生产环境的推荐配置。 | ||
|
||
In order to communicate and to form a cluster with nodes on other servers, your | ||
node will need to bind to a non-loopback address. While there are many | ||
<<modules-network,network settings>>, usually all you need to configure is | ||
`network.host`: | ||
为了让不同服务器上的节点通信并组成集群,你的节点需要绑定一个非环回地址。虽然有很多 <<modules-network,网络设置>> , | ||
但通常你只需要配置 `network.host` 。 | ||
|
||
[source,yaml] | ||
-------------------------------------------------- | ||
network.host: 192.168.1.10 | ||
-------------------------------------------------- | ||
|
||
The `network.host` setting also understands some special values such as | ||
`_local_`, `_site_`, `_global_` and modifiers like `:ip4` and `:ip6`, details of | ||
which can be found in <<network-interface-values>>. | ||
`network.host` 设置同样支持一些特殊值,例如 `_local_` 、`_site_` 、 `_global_` 和类似 `:ip4` 与 `:ip6` 修饰符, | ||
具体细节可从 <<network-interface-values>> 找到。 | ||
|
||
IMPORTANT: As soon you provide a custom setting for `network.host`, | ||
Elasticsearch assumes that you are moving from development mode to production | ||
mode, and upgrades a number of system startup checks from warnings to | ||
exceptions. See <<dev-vs-prod>> for more information. | ||
IMPORTANT: 一旦你提供一个自定义 `network.host` 设置,Elasticsearch 会假设你正从开发模式转为生产模式, | ||
并将一些系统启动检查从警告升级到异常。更多信息请查看 <<dev-vs-prod>> 。 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,19 @@ | ||
[[node.name]] | ||
=== `node.name` | ||
|
||
By default, Elasticsearch will use the first seven characters of the randomly | ||
generated UUID as the node id.Note that the node id is persisted and does | ||
not change when a node restarts and therefore the default node name will also | ||
not change. | ||
默认情况下,Elasticsearch 将使用一个随机生成的 7 字符 UUID 作为节点 id。注意这个节点 id 是固定的, | ||
在重启时节点时 id 和默认节点名都不会改变。 | ||
|
||
It is worth configuring a more meaningful name which will also have the | ||
advantage of persisting after restarting the node: | ||
有必要配置一个更有意义的名称,它在重启节点后具有持续优势: | ||
|
||
[source,yaml] | ||
-------------------------------------------------- | ||
node.name: prod-data-2 | ||
-------------------------------------------------- | ||
|
||
The `node.name` can also be set to the server's HOSTNAME as follows: | ||
`node.name` 同样可用以下方式设置为服务器的 HOSTNAME: | ||
|
||
[source,yaml] | ||
-------------------------------------------------- | ||
node.name: ${HOSTNAME} | ||
-------------------------------------------------- | ||
-------------------------------------------------- |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
[[path-settings]] | ||
=== `path.data` and `path.logs` | ||
=== `path.data` 和 `path.logs` | ||
|
||
If you are using the `.zip` or `.tar.gz` archives, the `data` and `logs` | ||
directories are sub-folders of `$ES_HOME`. If these important folders are left | ||
in their default locations, there is a high risk of them being deleted while | ||
upgrading Elasticsearch to a new version. | ||
如果你使用的是 `.zip` 或 `.tar.gz` 归档版本,`data` 和 `logs` 目录是 `$ES_HOME` 子文件夹。 | ||
如果这些重要的文件夹保留在它们的默认路径,那么在升级 Elasticsearch 到新版本时被删除的风险很高。 | ||
|
||
In production use, you will almost certainly want to change the locations of the | ||
data and log folder: | ||
在生产中,你几乎肯定想要改变 data 和 log 文件夹的位置: | ||
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. 在生产中,你几乎肯定想要改变 data 和 log 文件夹的位置: |
||
|
||
[source,yaml] | ||
-------------------------------------------------- | ||
|
@@ -16,11 +13,10 @@ path: | |
data: /var/data/elasticsearch | ||
-------------------------------------------------- | ||
|
||
The RPM and Debian distributions already use custom paths for `data` and `logs`. | ||
RPM 和 Debian 版本已经为 `data` 和 `logs` 使用了自定义路径。 | ||
|
||
The `path.data` settings can be set to multiple paths, in which case all paths | ||
will be used to store data (although the files belonging to a single shard will | ||
all be stored on the same data path): | ||
`path.data` 可以设置为多路径,在这种情况下,所有路径 | ||
将用于存储数据(尽管属于单个分片的文件将被存储在相同数据路径上): | ||
|
||
[source,yaml] | ||
-------------------------------------------------- | ||
|
@@ -29,4 +25,4 @@ path: | |
- /mnt/elasticsearch_1 | ||
- /mnt/elasticsearch_2 | ||
- /mnt/elasticsearch_3 | ||
-------------------------------------------------- | ||
-------------------------------------------------- |
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.
一个节点只能加入一个集群,并且和集群中的所有其他节点共享
cluster.name
。默认集群名称是elasticsearch
,但你应该将其更改为描述集群用途的合适名称。