Sonarqube service doesn't start on linux

Hi
I just instaled sonraqube on linux (Linux ip-172-31-28-235 4.14.33-51.37.amzn1.x86_64 #1 SMP Thu May 3 20:07:43 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux)

I think that everything should works but “SonarQube is not running.”

I see something like that in log file:

2018.06.15 07:54:30 INFO  app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /opt/sonar/temp
2018.06.15 07:54:30 INFO  app[][o.s.a.es.EsSettings] Elasticsearch listening on /127.0.0.1:9001
2018.06.15 07:54:30 INFO  app[][o.s.a.p.ProcessLauncherImpl] Launch process[[key='es', ipcIndex=1, logFilenamePrefix=es]] from [/opt/sonar/elasticsearch]: /opt/sonar/elasticsearch/bin/elasticsearch -Epath.conf=/opt/sonar/temp/conf/es
2018.06.15 07:54:30 INFO  app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
2018.06.15 07:54:31 INFO  app[][o.e.p.PluginsService] no modules loaded
2018.06.15 07:54:31 INFO  app[][o.e.p.PluginsService] loaded plugin [org.elasticsearch.transport.Netty4Plugin]
2018.06.15 07:54:34 WARN  app[][o.s.a.p.AbstractProcessMonitor] Process exited with exit value [es]: 1
2018.06.15 07:54:34 INFO  app[][o.s.a.SchedulerImpl] Process [es] is stopped
2018.06.15 07:54:34 INFO  app[][o.s.a.SchedulerImpl] SonarQube is stopped
<-- Wrapper Stopped

I need a help. That are my first steps in sonaqube technology.

Hello,

check the logs in the logs directory to see if there is anything of relevance.

FYI: https://docs.sonarqube.org/display/SONAR/Troubleshooting

now i see in log directory something like es.log
Inside that log file is that:

2018.06.15 07:54:34 ERROR es[][o.e.b.Bootstrap] Exception
java.lang.RuntimeException: can not run elasticsearch as root
        at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:106) ~[elasticsearch-5.6.3.jar:5.6.3]
        at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:195) ~[elasticsearch-5.6.3.jar:5.6.3]
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:342) [elasticsearch-5.6.3.jar:5.6.3]
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:132) [elasticsearch-5.6.3.jar:5.6.3]
        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:123) [elasticsearch-5.6.3.jar:5.6.3]
        at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:70) [elasticsearch-5.6.3.jar:5.6.3]
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:134) [elasticsearch-5.6.3.jar:5.6.3]
        at org.elasticsearch.cli.Command.main(Command.java:90) [elasticsearch-5.6.3.jar:5.6.3]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91) [elasticsearch-5.6.3.jar:5.6.3]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84) [elasticsearch-5.6.3.jar:5.6.3]
2018.06.15 07:54:34 WARN  es[][o.e.b.ElasticsearchUncaughtExceptionHandler] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:136) ~[elasticsearch-5.6.3.jar:5.6.3]
        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:123) ~[elasticsearch-5.6.3.jar:5.6.3]
        at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:70) ~[elasticsearch-5.6.3.jar:5.6.3]
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:134) ~[elasticsearch-5.6.3.jar:5.6.3]
        at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-5.6.3.jar:5.6.3]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91) ~[elasticsearch-5.6.3.jar:5.6.3]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84) ~[elasticsearch-5.6.3.jar:5.6.3]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
        at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:106) ~[elasticsearch-5.6.3.jar:5.6.3]
        at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:195) ~[elasticsearch-5.6.3.jar:5.6.3]
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:342) ~[elasticsearch-5.6.3.jar:5.6.3]
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:132) ~[elasticsearch-5.6.3.jar:5.6.3]
        ... 6 more

Hi,

Pretty clear error message here:

can not run elasticsearch as root

SonarQube does not support being run as root, just use a regular user and you should be good !

P.S.: appreciate if you can format errors/stacktraces with message formatting options, that way it’s easier to process

When I changed user on regular i see somethin like that when i try to start sonraqube service:
Starting SonarQube…
Failed to start SonarQube.
Maybe regular user don’t have access to some directory or files? But to which directory or file?
Additionally i don’t see any info about that operation in any log files

Hi Rafal,

I recommend you take a ‘baby step’ approach here, as otherwise one cannot guess the problem accurately. Try to start, if it fails review all log files (see troubleshooting guide), understand what it the actual error, fix it, try once more, and see how it goes ! (and if any question then do share log files or actual errors)

Best regards

I don’t have any idea how to fix it. Can You send me a link to some instruction how to step by step install and configure sonarqube on Linux. I do this first time so maybe a used wrong instruction or I make some mistake.

Hi Rafal,

A few simple steps to get it working.

  1. Create a ‘sonar’ user.
  2. Chown -R sonar sonar-install-folder/
  3. Edit the sonar.sh start script and change the #RUN_AS_USER to be RUN_AS_USER=sonar

Start sonar. You are now golden!

10 Likes

Thanks and Its much helpful to start sonarqube

this worked for me

this setting is already configured in my machine but still getting this error