原英文版地址: https://www.elastic.co/guide/en/elasticsearch/reference/7.7/file-descriptors.html, 原文档版权归 www.elastic.co 所有
本地英文版地址: ../en/file-descriptors.html

文件描述符 (File Descriptors)

这仅与 Linux 和 macOS 相关,如果在 Windows 上运行 Elasticsearch,可以安全地忽略它。 在 Windows 上,JVM 使用的 API 只受可用资源的限制。

Elasticsearch使用了大量的文件描述符或文件句柄。 用完文件描述符可能是灾难性的,并且很可能导致数据丢失。 确保将运行Elasticsearch的用户的打开文件描述符的数量限制增加到 65,536 或更高。

对于使用 .zip.tar.gz 包的,在启动 Elasticsearch 前以 root 身份设置 ulimit -n 65535,或者在 /etc/security/limits.conf 中设置 nofile65535

在 macOS 上,还必须将 JVM 选项 -XX:-MaxFDLimit 传给 Elasticsearch,以便它能够利用更高的文件描述符限制。

RPM 和 Debian 包已经将文件描述符的最大数量默认为 65535,不需要进一步配置。

可以使用 Nodes stats API 检查为每个节点配置的 max_file_descriptors,如下所示:

GET _nodes/stats/process?filter_path=**.max_file_descriptors