Elasticsearch简单入门--elasticsearch重要的系统配置(二)

1. File Descriptors 文件描述符

这只适用于Linux和macOS,如果在Windows上运行Elasticsearch,可以安全地忽略它。在Windows上,JVM使用的API仅受可用资源的限制。(This is only relevant for Linux and macOS and can be safely ignored if running Elasticsearch on Windows. On Windows that JVM uses an API limited only by available resources.)

Elasticsearch使用许多文件描述符或文件句柄,耗尽文件描述符可能是灾难性的,并且很可能导致数据丢失。(Elasticsearch uses a lot of file descriptors or file handles. Running out of file descriptors can be disastrous and will most probably lead to data loss),

请确保将运行Elasticsearch的用户的打开文件描述符的数量限制增加到65,536或更高。(Make sure to increase the limit on the number of open files descriptors for the user running Elasticsearch to 65,536 or higher.)

对于使用zip或tar.gz包安装的Elasticsearch,在启动Elasticsearch之前,作为Root用户先设置ulimit -n 65535,或者在/etc/security/limits.conf文件中设置 nofile to 65535,如下

#在文件最后添加
# * hard  nofile  65536
# * soft   nofile  65536
[root@zzf ~]# vim /etc/security/limits.conf

RPM和Debian包已经将文件描述符的最大数量默认为65536,不需要进一步配置(RPM and Debian packages already default the maximum number of file descriptors to 65536 and do not require further configuration)

你可以使用Nodes Stats API检查为每个节点配置的max_file_descriptors

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

或者

http://192.168.101.118:9200/_nodes/stats/process?filter_path=**.max_file_descriptors

2. Virtual memory 虚拟内存

Elasticsearch在64位系统中默认使用一个叫mmapfs的目录来存储索引,操作系统对mmap的数量的限制默认似乎太低,可能导致内存不足的异常,

在Linux上,可以通过root身份运行以下命令来增加这个限制:(On Linux, you can increase the limits by running the following command as root

sysctl -w vm.max_map_count=262144

要永久设置此值,更新在/etc/sysctl.conf中的设置vm.max_map_count,要在重新启动后进行验证,请运行sysctl vm.max_map_count。

[root@zzf elasticsearch-5.6.14]$ vim /etc/sysctl.conf 

保存之后,运行如下命令使其生效。

[es@zzf elasticsearch-5.6.14]$ sudo sysctl -p /etc/sysctl.conf

RPM和Debian包将自动配置该设置项,不需要进一步配置。

3. Number of threads

Elasticsearch为不同类型的操作使用许多线程池,重要的是,它能够在任何需要的时候创建新线程。请确保Elasticsearch用户可以创建的线程数至少为2048(Elasticsearch uses a number of thread pools for different types of operations. It is important that it is able to create new threads whenever needed. Make sure that the number of threads that the Elasticsearch user can create is at least 2048.)

这可以通过在启动Elasticsearch之前使用root用户将ulimit -u 2048来实现, 或者在/etc/security/limits.conf中,将nproc设置为2048

[root@zzf ~]# vim /etc/security/limits.conf

4. DNS cache settings DNS缓存设置

Elasticsearch与安全管理器一起运行。使用安全管理器时,JVM默认无限期地缓存正的主机名解析。如果您的Elasticsearch节点在DNS解决方案随时间变化的环境中依赖于DNS(例如,用于节点到节点发现),那么您可能需要修改默认的JVM行为。这可以通过添加networkaddress.cache.ttl= 到您的 Java安全策略进行修改 。任何未能解决的主机都将被记录。还要注意,在安装Java安全管理器的情况下,JVM默认将缓存负面主机名解析十秒钟。这可以通过添加networkaddress.cache.negative.ttl= 到您的 Java安全策略进行修改 

猜你喜欢

转载自blog.csdn.net/zhen_6137/article/details/86212816