Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to start elasticsearch service

I am trying to start elasticsearch on windows.

ES 5.0.0, JDK 1.8.0.66, Windows 10

Service is installed properly but failed to start.

D:\Softwares\Elastic_Project\elasticsearch-5.0.0\bin>elasticsearch-service install
C:\Program Files\Java\jdk1.8.0_66
Installing service : "elasticsearch-service-x64"
Using JAVA_HOME (64-bit): "C:\Program Files\Java\jdk1.8.0_66"
The service 'elasticsearch-service-x64' has been installed.

D:\Softwares\Elastic_Project\elasticsearch-5.0.0\bin>elasticsearch-service start
C:\Program Files\Java\jdk1.8.0_66
Failed starting 'elasticsearch-service-x64' service

Logs

[2016-11-24 14:21:19] [info] [11120] Commons Daemon procrun (1.0.15.0 64-bit) started
[2016-11-24 14:21:20] [info] [11120] Starting service 'elasticsearch-service-x64' ...
[2016-11-24 14:21:20] [info] [11572] Commons Daemon procrun (1.0.15.0 64-bit) started
[2016-11-24 14:21:20] [info] [11572] Running 'elasticsearch-service-x64' Service...
[2016-11-24 14:21:20] [info] [ 5916] Starting service...
[2016-11-24 14:21:21] [info] [ 5916] Service started in 1487 ms.
[2016-11-24 14:21:21] [info] [11572] Run service finished.
[2016-11-24 14:21:21] [info] [11572] Commons Daemon procrun finished
[2016-11-24 14:21:23] [error] [11120] Failed to start 'elasticsearch-service-x64' service
[2016-11-24 14:21:23] [error] [11120] The data area passed to a system call is too small.
[2016-11-24 14:21:23] [info] [11120] Start service finished.
[2016-11-24 14:21:23] [error] [11120] Commons Daemon procrun failed with exit value: 5 (Failed to start service)
[2016-11-24 14:21:23] [error] [11120] The data area passed to a system call is too small.

I have added JAVA_HOME in system variable. System logs

The Elasticsearch 5.0.0 (elasticsearch-service-x64) service terminated with the following service-specific error: 
Incorrect function.

Any help ?

like image 507
ASP Avatar asked Dec 18 '22 11:12

ASP


2 Answers

In Windows 7 on a system that had Java 1.7 then upgraded to Oracle Java 1.8 SDK (jdk-8u45-windows-x64.exe) the system JAVA_HOME was different to the JAVA_HOME in the elasticsearch manager and a different version of java was in the path. Also, elasticsearch-service install failed as the system was not loading Java 8.

Set the system JAVA_HOME to the correct folder:

  1. Open Windows File Explorer Super+E
  2. Right-click My Computer
  3. Select Advanced system settings
  4. Select Environment Variables
  5. Select JAVA_HOME
  6. Edit JAVA_HOME to change the value to the correct root folder e.g. C:\Progra~1\Java\jre1.8.0_45
  7. OK twice

Check that JAVA_HOME is set and java works:

  • java -version
  • echo %JAVA_HOME%

If this fails then eleasticsearch-service install won't work. To fix in a DOS prompt:

  • set JAVA_HOME=C:\Progra~1\Java\jre1.8.0_45
  • path=C:\Program Files\Java\jdk1.8.0_45\bin;%path%

Check the JAVA_PATH value in Elasticsearch manager and fix it if required. Open the manager program from a DOS prompt:

  1. Run elasticsearch-service.bat manager from a DOS prompt.
  2. Click on the Java tab
  3. Click the ... button to the right of %JAVA_HOME%\bin\server\jvm.dll
  4. Select the correct JRE folder if required or set the value manually, e.g. C:\Program Files\Java\jdk1.8.0_45\jre\bin\server\jvm.dll
  5. Click Apply
  6. Select the General tab
  7. Click Start
  8. Click OK to close the Elasticsearch manager

Removing and re-adding the elasticsearch service may be needed:

  • elasticsearch-service.bat remove
  • elasticsearch-service.bat install

Open elasticsearch in a browser using the settings in config\elasticsearch.yml to check that it is running:

http://localhost:9200/

like image 134
Underverse Avatar answered Jan 16 '23 09:01

Underverse


I had the same problem. I could find the cause of the issue by looking up the log file at e.g. ~/elasticsearch-5.2.1/log/elasticsearch-service-x64.2017-02-20. It complained about "Failed creating java %JAVA_HOME%\jre\bin\server\jvm.dll". So, I reset JAVA_HOME as system variable (not user variable) in environment variables, and it's resolved.

like image 31
Yohan Chung Avatar answered Jan 16 '23 09:01

Yohan Chung