遇到执行elasticsearch.bat闪退问题,然后通过cmd手动执行该文件,报错如下:
Error occurred during initialization of VM Could not reserve enough space for 2097152KB object heap。
意思是说初始化虚拟机时,没有足够的内存空间(2097152KB )创建堆。换算了一下很明显是2g。
既然在运行该文件时报出如上错误,个人推测应该会存在一些代码,直接或间接指向JVM配置的。打开elasticsearch.bat搜索JVM关键词不难发现如下这段
if "%ES_JVM_OPTIONS%" == "" (
rem '0' is the batch file, '~dp' appends the drive and path
set "ES_JVM_OPTIONS=%~dp0\..\config\jvm.options"
重点锁定\config\jvm.options
重点:解决办法
安装目录下找到config\jvm.options,修改
-Xms2g
-Xmx2g
为
-Xms512m
-Xmx512m
tips:两个值一定要相等。