Windows下双击elasticsearch.bat闪退
cmd 直接进入 elasticsearch.bat 所在目录下:
直接启动报错如下:
H:\Elasticsearch\elasticsearch-5.6.8\bin>elasticsearch.bat
Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap
打开 elasticsearch.bat 文件,发现有这么一行:
if "%ES_JVM_OPTIONS%" == "" (
rem '0' is the batch file, '~dp' appends the drive and path
set "ES_JVM_OPTIONS=%~dp0\..\config\jvm.options"
)
于是找到对应的 jvm.options 文件打开:
减小最大堆限制
将这里的(位置在第20行附近)
# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space
-Xms2g
-Xmx2g
改为:
# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space
-Xms256m
-Xmx256m
完美解决