在ES服务安装完成后需要对服务器进行一些参数设置。
官方文档地址:Important System Configuration
1. 关闭swap
# 临时关闭
swapoff -a
# 永久禁用
编辑/etc/fstab文件,注释swap行
2. 文件描述符
Elasticsearch使用大量文件描述符或文件句柄。用完文件描述符可能是灾难性的,最有可能导致数据丢失。确保将运行Elasticsearch的用户的打开文件描述符数量限制增加到65,536或更高。
For the .zip and .tar.gz packages, set ulimit -n 65536 as root before starting Elasticsearch, or set nofile to 65536 in /etc/security/limits.conf.
curl -X GET "localhost:9200/_nodes/stats/process?filter_path=**.max_file_descriptors&pretty"
3. 确保有足够的虚拟内存
sysctl -w vm.max_map_count=262144
To set this value permanently, update the vm.max_map_count setting in /etc/sysctl.conf. To verify after rebooting, run sysctl vm.max_map_count.
The RPM and Debian packages will configure this setting automatically. No further configuration is required.
4. 确保足够的线程
Elasticsearch对不同类型的操作使用许多线程池。 能够在需要时创建新线程很重要。 确保Elasticsearch用户可以创建的线程数至少为4096。
这可以通过在启动Elasticsearch之前执行 ulimit -u 4096
或在/etc/security/limits.conf中将nproc设置为4096来完成。
软件包分发在systemd下作为服务运行时,将自动为Elasticsearch进程配置线程数。 无需其他配置。
5. JVM DNS cache settings