17

不断收到以下警告消息。不知道应该怎么做。看到一些相关的帖子要求增加文件描述符的数量。

如何做同样的事情?

即使我现在增加,我是否会在添加新索引时遇到同样的问题。(目前使用大约 400 个索引、6 个分片和 1 个副本)。指数的数量往往会增加更多。

[03:58:24,165][WARN ][cluster.action.shard     ] [node1] received shard failed for [index9][2], node[node_hash3], [P], s[INITIALIZING], reason [Failed to start shard, message [IndexShardGatewayRecoveryException[[index9][2] failed recovery]; nested: EngineCreationFailureException[[index9][2] failed to open reader on writer]; nested: FileNotFoundException[/data/elasticsearch/whatever/nodes/0/indices/index9/2/index/segments_1 (Too many open files)]; ]] 
[03:58:24,166][WARN ][cluster.action.shard     ] [node1] received shard failed for [index15][0], node[node_hash2], [P], s[INITIALIZING], reason [Failed to create shard, message [IndexShardCreationException[[index15][0] failed to create shard]; nested: IOException[directory '/data/elasticsearch/whatever/nodes/0/indices/index15/0/index' exists and is a directory, but cannot be listed: list() returned null]; ]] 
[03:58:24,195][WARN ][cluster.action.shard     ] [node1] received shard failed for [index16][3], node[node_hash3], [P], s[INITIALIZING], reason [Failed to start shard, message [IndexShardGatewayRecoveryException[[index16][3] failed recovery]; nested: EngineCreationFailureException[[index16][3] failed to open reader on writer]; nested: FileNotFoundException[/data/elasticsearch/whatever/nodes/0/indices/index16/3/index/segments_1 (Too many open files)]; ]] 
[03:58:24,196][WARN ][cluster.action.shard     ] [node1] received shard failed for [index17][0], node[node_hash3], [P], s[INITIALIZING], reason [Failed to start shard, message [IndexShardGatewayRecoveryException[[index17][0] failed recovery]; nested: EngineCreationFailureException[[index17][0] failed to open reader on writer]; nested: FileNotFoundException[/data/elasticsearch/whatever/nodes/0/indices/index17/0/index/segments_1 (Too many open files)]; ]] 
[03:58:24,198][WARN ][cluster.action.shard     ] [node1] received shard failed for [index21][4], node[node_hash3], [P], s[INITIALIZING], reason [Failed to start shard, message [IndexShardGatewayRecoveryException[[index21][4] failed recovery]; nested: EngineCreationFailureException[[index21][4] failed to create engine]; nested: LockReleaseFailedException[Cannot forcefully unlock a NativeFSLock which is held by another indexer component: /data/elasticsearch/whatever/nodes/0/indices/index21/4/index/write.lock]; ]] 

节点api的输出

curl -XGET 'http://localhost:9200/_nodes?os=true&process=true&pretty=true'

{ 
  "ok" : true, 
  "cluster_name" : "whatever", 
  "nodes" : { 
    "node_hash1" : { 
      "name" : "node1", 
      "transport_address" : "transportip1", 
      "hostname" : "myhostip1", 
      "version" : "0.20.4", 
      "http_address" : "httpip1", 
      "attributes" : { 
        "data" : "false", 
        "master" : "true" 
      }, 
      "os" : { 
        "refresh_interval" : 1000, 
        "available_processors" : 8, 
        "cpu" : { 
          "vendor" : "Intel", 
          "model" : "Xeon", 
          "mhz" : 2133, 
          "total_cores" : 8, 
          "total_sockets" : 8, 
          "cores_per_socket" : 16, 
          "cache_size" : "4kb", 
          "cache_size_in_bytes" : 4096 
        }, 
        "mem" : { 
          "total" : "7gb", 
          "total_in_bytes" : 7516336128 
        }, 
        "swap" : { 
          "total" : "30gb", 
          "total_in_bytes" : 32218378240 
        } 
      }, 
      "process" : { 
        "refresh_interval" : 1000, 
        "id" : 26188, 
        "max_file_descriptors" : 16384 
      } 
    }, 
    "node_hash2" : { 
      "name" : "node2", 
      "transport_address" : "transportip2", 
      "hostname" : "myhostip2", 
      "version" : "0.20.4", 
      "attributes" : { 
        "master" : "false" 
      }, 
      "os" : { 
        "refresh_interval" : 1000, 
        "available_processors" : 4, 
        "cpu" : { 
          "vendor" : "Intel", 
          "model" : "Xeon", 
          "mhz" : 2400, 
          "total_cores" : 4, 
          "total_sockets" : 4, 
          "cores_per_socket" : 32, 
          "cache_size" : "20kb", 
          "cache_size_in_bytes" : 20480 
        }, 
        "mem" : { 
          "total" : "34.1gb", 
          "total_in_bytes" : 36700303360 
        }, 
        "swap" : { 
          "total" : "0b", 
          "total_in_bytes" : 0 
        } 
      }, 
      "process" : { 
        "refresh_interval" : 1000, 
        "id" : 24883, 
        "max_file_descriptors" : 16384 
      } 
    }, 
    "node_hash3" : { 
      "name" : "node3", 
      "transport_address" : "transportip3", 
      "hostname" : "myhostip3", 
      "version" : "0.20.4", 
      "attributes" : { 
        "master" : "false" 
      }, 
      "os" : { 
        "refresh_interval" : 1000, 
        "available_processors" : 4, 
        "cpu" : { 
          "vendor" : "Intel", 
          "model" : "Xeon", 
          "mhz" : 2666, 
          "total_cores" : 4, 
          "total_sockets" : 4, 
          "cores_per_socket" : 16, 
          "cache_size" : "8kb", 
          "cache_size_in_bytes" : 8192 
        }, 
        "mem" : { 
          "total" : "34.1gb", 
          "total_in_bytes" : 36700303360 
        }, 
        "swap" : { 
          "total" : "0b", 
          "total_in_bytes" : 0 
        } 
      }, 
      "process" : { 
        "refresh_interval" : 1000, 
        "id" : 25328, 
        "max_file_descriptors" : 16384 
      } 
    } 
  } 
4

3 回答 3

13

如何增加允许打开文件的最大数量取决于您的 Linux 发行版。以下是 ubuntu 和 centos 的一些说明:

http://posidev.com/blog/2009/06/04/set-ulimit-parameters-on-ubuntu/ http://pro.benjaminste.in/post/318453669/increase-the-number-of-file- centos 上的描述符和

elasticsearch 文档建议将最大文件限制设置为 32k 或 64k。既然你是 16k 并且已经达到了极限,我可能会把它设置得更高;像128k这样的东西。请参阅:http ://www.elasticsearch.org/guide/reference/setup/installation/

增加打开文件的数量并重新启动 elasticsearch 后,您将需要通过重新运行您提到的 curl 命令来验证它是否有效:

curl -XGET 'http://localhost:9200/_nodes?os=true&process=true&pretty=true'

随着您添加更多索引(以及更多文档),您还将看到 elasticsearch 跟踪的文件数量增加。如果您注意到所有指标和文档的性能下降,您可以尝试向集群添加一个新节点:http ://www.elasticsearch.org/guide/reference/setup/configuration/ - 因为您已经有一个分片,复制配置,这应该是一个相对无痛的过程。

于 2013-04-09T15:35:27.517 回答
3
  1. 停止弹性搜索。如果您从 (bin/elasticsearch) 之类的命令开始,请在启动时指定此设置以设置堆。例如,我使用一个 16GB 的盒子,所以我的命令是

    一种。bin/elasticsearch -Xmx8g -Xms8g

    湾。转到配置(elasticsearch/config/elasticsearch.yml)并确保

    bootstrap.mlockall:真

    C。将ulimits -Hn和ulimits -Sn增加到200000 以上

  2. 如果您作为服务启动,请执行以下操作

    一种。出口 ES_HEAP_SIZE=10g b. 转到配置(/etc/elasticsearch/elasticsearch.yml)并确保

    bootstrap.mlockall: 真的 c. 将ulimits -Hn和ulimits -Sn增加到200000 以上

确保输入的大小不超过堆的 50%,无论是作为服务启动还是从命令行启动

于 2015-10-08T20:53:58.063 回答
2

请注意,如果 elasticsearch 是一项服务,则通过更改 ulimit/etc/security/limits.conf不会产生任何影响。systemd

增加 systemd 下的 elasticsearch 限制,请创建一个/etc/systemd/system/elasticsearch.service.d/override.conf包含以下内容的文件:

[服务]
LimitNOFILE=infinity

然后运行systemctl daemon-reload && systemctl restart elasticsearch

于 2020-01-13T17:25:05.710 回答