Sonarqube Startup

Hi @Tobias_Trabelsi,

I am trying to install SonarQube 8.4.2.36762 on an Ubuntu server on Digital Ocean following this tutorial.

It doesn’t seem to be starting OK on port 9000 as I can see the following in the output of sudo service sonarqube status:

● sonarqube.service - SonarQube service
   Loaded: loaded (/etc/systemd/system/sonarqube.service; enabled; vendor preset: enabled)
   Active: activating (start) since Fri 2020-10-16 08:45:02 UTC; 474ms ago
 Main PID: 27031 (code=exited, status=1/FAILURE); Control PID: 27079 (sonar.sh)
    Tasks: 24 (limit: 4915)
   CGroup: /system.slice/sonarqube.service
           ├─27079 /bin/sh /opt/sonarqube/bin/linux-x86-64/sonar.sh start
           ├─27132 /opt/sonarqube/bin/linux-x86-64/./wrapper /opt/sonarqube/bin/linux-x86-64/../../conf/wrapper.conf wrapper.syslog.ident=SonarQube wrapper.pidfile=
           ├─27136 /opt/sonarqube/bin/linux-x86-64/./wrapper /opt/sonarqube/bin/linux-x86-64/../../conf/wrapper.conf wrapper.syslog.ident=SonarQube wrapper.pidfile=
           └─27139 java -Dsonar.wrapped=true -Djava.awt.headless=true -Xms8m -Xmx32m -Djava.library.path=./lib -classpath ../../lib/jsw/wrapper-3.2.3.jar:../../lib/

Oct 16 08:45:02 martin systemd[1]: Starting SonarQube service...
Oct 16 08:45:02 martin sonar.sh[27079]: Starting SonarQube...

Can you help me?

Thanks!

Hi @martin.krcho.wpws ,

i moved your post to a new topic so the two cases don’t get mixed up.

i can see that this tutorial is based on sonarqube 7.5 which is rather old and was supporting mysql. the version that you try to deploy is not supporting mysql anymore. you can see the requirements for sonarqube listed here and we also have a installation guide in our docs, and a little more docs on how to use sonarqube with systemd.

if this does not help you, please post the output of the log files so we can have a look together :slight_smile:

Hi @Tobias_Trabelsi,

thank you for a prompt install. I swapped MySQL for PostgreSQL and also updated the systemd config for the service.

I think the service won’t start because of issues with Elasticsearch. Here’s what I found in /opt/sonarqube/logs/sonar.log. Do you know what needs to be changed to get it up and running?

Thanks

2020.10.16 11:56:17 INFO  app[][o.s.a.es.EsSettings] Elasticsearch listening on /127.0.0.1:9001
2020.10.16 11:56:17 INFO  app[][o.s.a.ProcessLauncherImpl] Launch process[[key='es', ipcIndex=1, logFilenamePrefix=es]] from [/opt/sonarqube/elasticsearch]: /opt/sonarqube/elasticsearch/bin/elasticsearch
2020.10.16 11:56:17 INFO  app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
2020.10.16 11:56:18 INFO  app[][o.e.p.PluginsService] no modules loaded
2020.10.16 11:56:18 INFO  app[][o.e.p.PluginsService] loaded plugin [org.elasticsearch.transport.Netty4Plugin]
OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
ERROR: [2] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
2020.10.16 11:56:26 WARN  app[][o.s.a.p.AbstractManagedProcess] Process exited with exit value [es]: 78
2020.10.16 11:56:26 INFO  app[][o.s.a.SchedulerImpl] Process[es] is stopped
2020.10.16 11:56:26 INFO  app[][o.s.a.SchedulerImpl] SonarQube is stopped
<-- Wrapper Stopped

this is noted in the requirements and boils down to:

sudo -Es
sysctl -w vm.max_map_count=524288
sysctl -w fs.file-max=131072
ulimit -n 131072
ulimit -u 8192
exit

Thanks for pointing me in the right direction.

It might be helpful to put the correct numbers in here as well:

Now there is nothing in logs (I deleted them before restarting the server and thus the service).

The service status now changed to the following. Any advice?

● sonarqube.service - SonarQube service
   Loaded: loaded (/etc/systemd/system/sonarqube.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Fri 2020-10-16 12:59:27 UTC; 2min 52s ago
  Process: 1145 ExecStart=/bin/nohup /opt/java/bin/java -Xms32m -Xmx32m -Djava.net.preferIPv4Stack=true -jar /opt/sonarqube/lib/sonar-application-7.4.jar (code=exit
 Main PID: 1145 (code=exited, status=203/EXEC)

Oct 16 12:59:27 martin systemd[1145]: sonarqube.service: Failed at step EXEC spawning /bin/nohup: No such file or directory
Oct 16 12:59:27 martin systemd[1]: sonarqube.service: Main process exited, code=exited, status=203/EXEC
Oct 16 12:59:27 martin systemd[1]: sonarqube.service: Failed with result 'exit-code'.
Oct 16 12:59:27 martin systemd[1]: sonarqube.service: Service hold-off time over, scheduling restart.
Oct 16 12:59:27 martin systemd[1]: sonarqube.service: Scheduled restart job, restart counter is at 5.
Oct 16 12:59:27 martin systemd[1]: Stopped SonarQube service.
Oct 16 12:59:27 martin systemd[1]: sonarqube.service: Start request repeated too quickly.
Oct 16 12:59:27 martin systemd[1]: sonarqube.service: Failed with result 'exit-code'.
Oct 16 12:59:27 martin systemd[1]: Failed to start SonarQube service.

please note that you should only base your service file on this documentation and not copy paste it directly :sweat_smile:

you have to adapt the path to the sonar-application.jar . i think in your case it will be another path and another version that noted in the docs

Thanks, @Tobias_Trabelsi. I change the path to nohup, java as well as the sonar application jar. However, I still cannot connect to the application on localhost using curl.

curl http://127.0.0.1:9000

This is preventing me from using nginx as a proxy. There is nothing explanatory in any of the sonar logs. It it OK to use it behind nginx proxy? I also tried telnet to connect with no success.

Hi @martin.krcho.wpws ,

can you provide the log files as well as your sonar.properties file? you should be able to reach sonarqube at http://127.0.0.1:9000 if you have not modified something like sonar.web.host, sonar.web.port or sonar.web.context

Hi @Tobias_Trabelsi,

I decided to start from scratch and managed install SonarQube successfully behing nginx proxy. I put together a mix of your installation guidelines with some stuff from Digital Ocean guides. I am sending my a step by step installation guide that worked for me. Feel free to update your notes or maybe post a single article for SonarQube + PostgreSQL + nginx proxy + SSL :slight_smile:

# intial firewall setup
ufw allow OpenSSH
ufw enable

# Java installation
sudo apt update
sudo apt install default-jre
sudo apt install default-jdk
sudo nano /etc/environment
>> add: JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64/bin/java"

# PostgreSQL
sudo apt install postgresql postgresql-contrib
sudo su -l postgres

createuser sonarqube
createdb sonarqube

psql
> ALTER USER sonarqube WITH PASSWORD 'mypostgrespassword';
> \q

exit
sudo service postgresql restart

# SonarQube
sudo adduser --system --no-create-home --group --disabled-login sonarqube
sudo mkdir /opt/sonarqube
sudo apt-get install unzip
cd /opt/sonarqube
sudo wget https://binaries.sonarsource.com/CommercialDistribution/sonarqube-developer/sonarqube-developer-8.5.0.37579.zip
sudo unzip sonarqube-developer-8.5.0.37579.zip
sudo rm sonarqube-developer-8.5.0.37579.zip
sudo chown -R sonarqube:sonarqube /opt/sonarqube

sudo nano sonarqube-8.5.0.37579/conf/sonar.properties
> sonar.jdbc.username=sonarqube
> sonar.jdbc.password=mypostgrespassword
> sonar.jdbc.url=jdbc:postgresql://localhost/sonarqube
> sonar.web.javaAdditionalOpts=-server
> sonar.web.host=127.0.0.1

sudo nano /etc/systemd/system/sonarqube.service

>> START:sonarqube.service

[Unit]
Description=SonarQube service
After=syslog.target network.target

[Service]
Type=simple
User=sonarqube
Group=sonarqube
PermissionsStartOnly=true
ExecStart=/usr/bin/nohup /usr/bin/java -Xms32m -Xmx32m -Djava.net.preferIPv4Stack=true -jar /opt/sonarqube/sonarqube-8.5.0.37579/lib/sonar-application-8.5.0.37579.jar
StandardOutput=syslog
LimitNOFILE=65536
LimitNPROC=8192
TimeoutStartSec=5
Restart=always
SuccessExitStatus=143

[Install]
WantedBy=multi-user.target

>> END:sonarqube.service

sysctl -w vm.max_map_count=524288
sysctl -w fs.file-max=131072
ulimit -n 131072
ulimit -u 8192

sudo systemctl enable sonarqube.service
sudo systemctl start sonarqube.service

# check if the service is running and accessible
curl http://127.0.0.1:9000

sudo apt update
sudo apt install nginx
sudo ufw allow 'Nginx HTTP'

sudo nano /etc/nginx/sites-available/sonarqube.example.com

>> START:sonarqube.example.com

server {
        listen 80;
        server_name sonarqube.example.com;
        location / {
                proxy_pass http://127.0.0.1:9000;
        }
}

>> END:sonarqube.example.com

sudo ln -s /etc/nginx/sites-available/sonarqube.example.com /etc/nginx/sites-enabled/
sudo unlink /etc/nginx/sites-enabled/default
sudo nginx -t
sudo service nginx restart

sudo add-apt-repository ppa:certbot/certbot
sudo apt install python3-certbot-nginx
sudo ufw allow 'Nginx Full'
sudo ufw delete allow 'Nginx HTTP'
sudo certbot --nginx -d sonarqube.example.com

A post was split to a new topic: Stop SQ Service on Windows