Trying to evaluate sonarqube 7.9.1 on an ubuntu linux system. Cannot seem to get sonarqube started. Every time I install or fix something, something else breaks. Initially could not run elasticsearch because I was trying to start sonarqube as root. I added sonarqube user but then I got an error about sonarqube not being able to write to elasticsearch yml settings file.
Also, when I try to start sonarqube as an initd service, I get the error about sonarqube unable to run elasticsearch as root again. This is getting a little crazy. How do I ensure the proper user is used by sonarqube as a service to run elasticsearch or whatever else it needs?
Can someone throw me a bone here?
Here is the sonar.log log file excerpt with the errors:
--> Wrapper Started as Console
Launching a JVM...
Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved.
2019.10.18 15:24:13 INFO app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /opt/sonarqube/sonarqube-7.9.1/temp
2019.10.18 15:24:13 INFO app[][o.s.a.es.EsSettings] Elasticsearch listening on /127.0.0.1:9001
2019.10.18 15:24:13 ERROR app[][o.s.a.p.ManagedProcessHandler] Fail to launch process [es]
java.lang.IllegalStateException: Cannot write Elasticsearch yml settings file
at org.sonar.application.es.EsYmlSettings.writeToYmlSettingsFile(EsYmlSettings.java:53)
at org.sonar.application.ProcessLauncherImpl.writeConfFiles(ProcessLauncherImpl.java:152)
at org.sonar.application.ProcessLauncherImpl.launch(ProcessLauncherImpl.java:84)
at org.sonar.application.SchedulerImpl.lambda$tryToStartProcess$2(SchedulerImpl.java:192)
at org.sonar.application.process.ManagedProcessHandler.start(ManagedProcessHandler.java:72)
at org.sonar.application.SchedulerImpl.tryToStartProcess(SchedulerImpl.java:190)
at org.sonar.application.SchedulerImpl.tryToStartEs(SchedulerImpl.java:142)
at org.sonar.application.SchedulerImpl.tryToStartAll(SchedulerImpl.java:134)
at org.sonar.application.SchedulerImpl.schedule(SchedulerImpl.java:108)
at org.sonar.application.App.start(App.java:68)
at org.sonar.application.App.main(App.java:98)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:240)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.nio.file.AccessDeniedException: /opt/sonarqube/sonarqube-7.9.1/temp/conf/es/elasticsearch.yml
at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:90)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:219)
at java.base/java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:478)
at java.base/java.nio.file.Files.newOutputStream(Files.java:219)
at java.base/java.nio.file.Files.write(Files.java:3422)
at org.sonar.application.es.EsYmlSettings.writeToYmlSettingsFile(EsYmlSettings.java:51)
... 16 common frames omitted
2019.10.18 15:24:13 INFO app[][o.s.a.SchedulerImpl] Process[es] is stopped
2019.10.18 15:24:13 INFO app[][o.s.a.SchedulerImpl] Hard stopping SonarQube
2019.10.18 15:24:13 INFO app[][o.s.a.SchedulerImpl] SonarQube is stopped
WrapperSimpleApp: Encountered an error running main: java.lang.IllegalStateException: Cannot write Elasticsearch yml settings file
java.lang.IllegalStateException: Cannot write Elasticsearch yml settings file
at org.sonar.application.es.EsYmlSettings.writeToYmlSettingsFile(EsYmlSettings.java:53)
at org.sonar.application.ProcessLauncherImpl.writeConfFiles(ProcessLauncherImpl.java:152)
at org.sonar.application.ProcessLauncherImpl.launch(ProcessLauncherImpl.java:84)
at org.sonar.application.SchedulerImpl.lambda$tryToStartProcess$2(SchedulerImpl.java:192)
at org.sonar.application.process.ManagedProcessHandler.start(ManagedProcessHandler.java:72)
at org.sonar.application.SchedulerImpl.tryToStartProcess(SchedulerImpl.java:190)
at org.sonar.application.SchedulerImpl.tryToStartEs(SchedulerImpl.java:142)
at org.sonar.application.SchedulerImpl.tryToStartAll(SchedulerImpl.java:134)
at org.sonar.application.SchedulerImpl.schedule(SchedulerImpl.java:108)
at org.sonar.application.App.start(App.java:68)
at org.sonar.application.App.main(App.java:98)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:240)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.nio.file.AccessDeniedException: /opt/sonarqube/sonarqube-7.9.1/temp/conf/es/elasticsearch.yml
at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:90)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:219)
at java.base/java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:478)
at java.base/java.nio.file.Files.newOutputStream(Files.java:219)
at java.base/java.nio.file.Files.write(Files.java:3422)
at org.sonar.application.es.EsYmlSettings.writeToYmlSettingsFile(EsYmlSettings.java:51)
... 16 more
<-- Wrapper Stopped