Facing following error while running sonar on suse linux : java.lang.IllegalStateException: Cannot write Elasticsearch yml settings file

Hi I am new to Sonarqube while running sonar on suse linux I am facing above issue.

Please help !

Error log is as follows

:/home/Sonarqube/sonarqube 8.2.0.32929/bin/linux-x86-64> ./sonar.sh console
Running SonarQube…
wrapper | --> Wrapper Started as Console
wrapper | Launching a JVM…
jvm 1 | Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
jvm 1 | Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved.
jvm 1 |
jvm 1 | 2020.05.08 13:38:33 INFO app[o.s.a.AppFileSystem] Cleaning or creating temp directory /home/Sonarqube/sonarqube-8.2.0.32929/temp
jvm 1 | 2020.05.08 13:38:33 INFO app[o.s.a.es.EsSettings] Elasticsearch listening on /127.0.0.1:9001
jvm 1 | 2020.05.08 13:38:33 ERROR app[o.s.a.p.ManagedProcessHandler] Fail to launch process [es]
jvm 1 | java.lang.IllegalStateException: Cannot write Elasticsearch yml settings file
jvm 1 | at org.sonar.application.es.EsYmlSettings.writeToYmlSettingsFile(EsYmlSettings.java:53)
jvm 1 | at org.sonar.application.ProcessLauncherImpl.writeConfFiles(ProcessLauncherImpl.java:152)
jvm 1 | at org.sonar.application.ProcessLauncherImpl.launch(ProcessLauncherImpl.java:84)
jvm 1 | at org.sonar.application.SchedulerImpl.lambda$tryToStartProcess$2(SchedulerImpl.java:196)
jvm 1 | at org.sonar.application.process.ManagedProcessHandler.start(ManagedProcessHandler.java:73)
jvm 1 | at org.sonar.application.SchedulerImpl.tryToStartProcess(SchedulerImpl.java:194)
jvm 1 | at org.sonar.application.SchedulerImpl.tryToStartEs(SchedulerImpl.java:146)
jvm 1 | at org.sonar.application.SchedulerImpl.tryToStartAll(SchedulerImpl.java:138)
jvm 1 | at org.sonar.application.SchedulerImpl.schedule(SchedulerImpl.java:112)
jvm 1 | at org.sonar.application.App.start(App.java:69)
jvm 1 | at org.sonar.application.App.main(App.java:98)
jvm 1 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
jvm 1 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
jvm 1 | at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
jvm 1 | at java.base/java.lang.reflect.Method.invoke(Method.java:566)
jvm 1 | at org.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:240)
jvm 1 | at java.base/java.lang.Thread.run(Thread.java:834)
jvm 1 | Caused by: java.nio.file.AccessDeniedException: /home/Sonarqube/sonarqube-8.2.0.32929/temp/conf/es/elasticsearch.yml
jvm 1 | at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:90)
jvm 1 | at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
jvm 1 | at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
jvm 1 | at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:219)
jvm 1 | at java.base/java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:478)
jvm 1 | at java.base/java.nio.file.Files.newOutputStream(Files.java:219)
jvm 1 | at java.base/java.nio.file.Files.write(Files.java:3424)
jvm 1 | at org.sonar.application.es.EsYmlSettings.writeToYmlSettingsFile(EsYmlSettings.java:51)
jvm 1 | … 16 common frames omitted
jvm 1 | 2020.05.08 13:38:33 INFO app[o.s.a.SchedulerImpl] Process[es] is stopped
jvm 1 | 2020.05.08 13:38:33 INFO app[o.s.a.SchedulerImpl] SonarQube is stopped
jvm 1 | 2020.05.08 13:38:33 INFO app[o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running

Hey there.

This error has come up before in a few threads.

https://community.sonarsource.com/search?q=Cannot%20write%20Elasticsearch%20yml%20settings%20file

Have you had a look around to see if any apply to your situation?

Colin

Hi I tried the steps given in above links but none of them is working in my case .

Hi I solved my problem with following commands

  1. chown user elasticsearch.yml #change owner of .yml file to user (should be non-root)
  2. chown user:users elasticsearch.yml #chnage user group of .yml file to users
  3. exit the root using CTRL+D and run sonar.sh

owner of the above files are root and user group is a root but sonar doesn’t work with root user so in the above case I need to change the owner and owner group to user and users respectively