我试图在我的本地Ubuntu机器上安装elasticsearch以下指南:
https://www.elastic.co/guide/en/elasticsearch/reference/current/_installation.html
,当试图运行“./elasticsearch”时,出现以下错误:
Java HotSpot(TM) 64-Bit Server VM warning: INFO: <br> os::commit_memory(0x00007f0e50cc0000, 64075595776, 0) failed; <br> error='Cannot allocate memory' (errno=12) <br> There is insufficient memory for the Java Runtime Environment to continue.<br> Native memory allocation (mmap) failed to map 64075595776 bytes for committing reserved memory
这里是内存统计:
total used free shared buffers cached Mem: 8113208 4104900 4008308 44244 318076 1926964 -/+ buffers/cache: 1859860 6253348 Swap: 7812092 0 7812092
来自日志的错误消息:
There is insufficient memory for the Java Runtime Environment to continue. # Native memory allocation (mmap) failed to map 64075595776 bytes for committing reserved memory. # Possible reasons: # The system is out of physical RAM or swap space # In 32 bit mode, the process size limit was hit # Possible solutions: # Reduce memory load on the system # Increase physical memory or swap space # Check if swap backing store is full # Use 64 bit Java on a 64 bit OS # Decrease Java heap size (-Xmx/-Xms) # Decrease number of Java threads # Decrease Java thread stack sizes (-Xss) # Set larger code cache with -XX:ReservedCodeCacheSize= # This output file may be truncated or incomplete. # # Out of Memory Error (os_linux.cpp:2627), pid=13021, tid=139764129740544 # # JRE version: (8.0_66-b17) (build ) # Java VM: Java HotSpot(TM) 64-Bit Server VM (25.66-b17 mixed mode linux-amd64 ) # Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
已经尝试过早期版本,使用apt从软件仓库安装,没有任何工作。
任何人有任何想法可能是什么问题?
看起来你试图用默认选项启动ElasticSearch,它试图设置2Go的堆栈大小。 如果你没有这个免费的… kaboom(无声)。
看看/etc/elasticsearch/jvm.options
并修改这些行:
-Xms2g -Xmx2g
到适合你的可用内存的东西。 但请注意,ElasticSearch是一个巨大的记忆猪,并希望这一切。 2Go限制下可能无法获得有用的系统。
首先,Elasticsearch使用混合mmapfs / niofs目录。 操作系统限制mmap计数,通常默认值为65536.这可能会导致内存不足的异常。 在Linux上,可以通过以root身份运行以下命令来增加此默认内核值:
sysctl -w vm.max_map_count=262144
或者通过更新/etc/sysctl.conf中的vm.max_map_count设置来永久保存。 您也可以通过以下命令进行更改:
echo 262144 > /proc/sys/vm/max_map_count
有关更多信息,请查看Linux内核文档 :
max_map_count:该文件包含进程可能具有的最大内存映射区域数量。 内存映射区域被用作调用malloc的一个副作用,直接通过mmap和mprotect,以及加载共享库时。 虽然大多数应用程序需要少于一千个地图,但某些程序(尤其是malloc调试程序)可能会消耗大量的应用程序,例如,每个分配最多有一个或两个地图。 默认值是65536。
您应该考虑的第二件事是JVM最小堆大小和最大堆大小。 您可以在/etc/elasticsearch/jvm.options中的计算机上更改此值。 要选择合适的值,您可以在Elastic set JVM堆大小页面上找到合适的规则。