1

I installed sonarqube on centos. After making all the required configuration changes when I start sonarqube service, it doesn't start. In logs I see error that elasticsearch could not be started. In es log it mentions that elasticsearch could not be started as root user. I'm running as centos user and not root. Also I have made centos as owner on sonarqube folder recursively. I have also set run_as_user as centos in the config. Still the issue is coming. Looking for help.

G. Ann - SonarSource Team
  • 22,346
  • 4
  • 40
  • 76
Abhilash Jain
  • 11
  • 1
  • 3
  • 2
    Could you please add your es.log file ? – Eric Hartmann Apr 23 '18 at 05:59
  • 2018.04.23 05:11:21 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] – Abhilash Jain Apr 23 '18 at 10:32
  • Indeed, you are running SonarQube as root user. So you should try to look why it's running as root. Please describe in your question how you install SonarQube and where did you put run_as_user. – Eric Hartmann Apr 23 '18 at 14:23

1 Answers1

-2

I am late in this conversation. I faced the same issue while running sonarqube in Ubuntu and found that elasticsearch is failed as its trying to run as root user. Elasticsearch will not run on root user, instead you should create a user say sonar and then give all grants and permission in order to run.

I followed below steps to the issue.

  1. Add user

    sudo useradd sonar

  2. Add group

    sudo groupadd sonar

  3. grant permission to sonar

    sudo chown -R sonar:sonar {sonar-installed-folder}/

  4. Edit sonar.properties file to user 'sonar' user

    now edit the sonar.sh file which is location under /sonar/conf and change the #RUN_AS_USER to be RUN_AS_USER=sonar

  5. Run sonar go to folder where sonar is installed (/opt/sonar in my case)

    /sonar/bin/linux-x86-64$ sudo ./sonar.sh start

  6. Check status

    /sonar/bin/linux-x86-64$ ./sonar.sh status

Happy coding

Kushwaha
  • 850
  • 10
  • 13