How to Install SonarQube on Ubuntu 20.04 LTS

In this article, we are going to perform, How to Install SonarQube on Ubuntu 20.04 LTS.

Introduction

SonarQube is an opensource web based tool to manage code quality and code analysis. It is most widely used in continuous code inspection which performs reviews of code to detect bugs, code smells and vulnerability issues of programming languages such as PHP, C#, JavaScript, C/C++ and Java , Also tracks statistics and creates charts that enable developers to quickly identify problems in their code.

Prerequisites

  • Ubuntu 20.04 LTS with minimum 2GB RAM and 1 CPU.
  • PostgreSQL Version 9.3 or higher
  • SSH access with sudo privileges
  • Firewall Port: 9000
Here, We are installing SonarQube 8.9 version and have to install Oracle JAVA/Open JDK, Postgres/MS-SQL as database and Latest browser before installing SonarQube. To know Prerequisite visit sonarqube official page Note: MySQL Support for SonarQube is depricated. Increase the vm.max_map_count kernal ,file discriptor and ulimit for current session at runtime.
 sudo sysctl -w vm.max_map_count=262144
 sudo sysctl -w fs.file-max=65536
ulimit -n 65536
ulimit -u 4096
To Increase the vm.max_map_count kernal ,file discriptor and ulimit permanently . Open the below config file and Insert the below value as shown below,
 sudo nano /etc/security/limits.conf
/etc/security/limits.conf
sonarqube   -   nofile   65536
sonarqube   -   nproc    4096
OR If you are using systemd to manage the sonarqube services then add below value in sonarqube unit file under [service] section.
[Service]
...
LimitNOFILE=65536
LimitNPROC=4096
...
Before installing, Lets update and upgrade System Packages
 sudo apt-get update
 sudo apt-get upgrade
Install wget and unzip package
 sudo apt-get install wget unzip -y

Step #1:Install OpenJDK 17 on Ubuntu 20.04 LTS

Install OpenJDK and JRE 11 using following command,
 sudo apt-get install openjdk-17-jdk -y
sudo apt-get install openjdk-17-jre -y

SET Default JDK

To set default JDK or switch to OpenJDK enter below command,
 sudo update-alternatives --config java
You will see below choices for the alternative java (providing /usr/bin/java).
Selection    Path                                            Priority   Status

------------------------------------------------------------

  0            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111      auto mode

  1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111      manual mode

  2            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      manual mode

* 3            /usr/lib/jvm/java-8-oracle/jre/bin/java          1081      manual mode
Type  1 to switch OpenJDK 11.

Check JAVA Version:

 java -version
Output:
java -version

openjdk version "11.0.7" 2020-04-14

OpenJDK Runtime Environment (build 11.0.7+10-post-Ubuntu-3ubuntu1)

OpenJDK 64-Bit Server VM (build 11.0.7+10-post-Ubuntu-3ubuntu1, mixed mode, sharing)

Step #2: Install and Setup PostgreSQL 10 Database For SonarQube

Add and download the PostgreSQL Repo
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
 wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | sudo apt-key add -
Install the PostgreSQL database Server by using following command,
sudo apt-get -y install postgresql postgresql-contrib
Start PostgreSQL Database server
sudo systemctl start postgresql
Enable it to start automatically at boot time.
 sudo systemctl enable postgresql
Change the password for the default PostgreSQL user.
 sudo passwd postgres
Switch to the postgres user.
su - postgres
Create a new user by typing:
createuser sonar
Switch to the PostgreSQL shell.
psql
Set a password for the newly created user for SonarQube database.
ALTER USER sonar WITH ENCRYPTED password 'sonar';
Create a new database for PostgreSQL database by running:
CREATE DATABASE sonarqube OWNER sonar;
grant all privileges to sonar user on sonarqube Database.
grant all privileges on DATABASE sonarqube to sonar;
Exit from the psql shell:
\q
Switch back to the sudo user by running the exit command.
exit

Step #3:How to Install SonarQube on Ubuntu 20.04 LTS

Download sonaqube installer files archieve To download latest version of visit SonarQube download page.
 cd /tmp
sudo wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-9.9.0.65466.zip
Output:
sudo wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-9.9.0.65466.zip

https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-9.9.0.65466.zip

Resolving binaries.sonarsource.com (binaries.sonarsource.com)... 91.134.125.245

Connecting to binaries.sonarsource.com (binaries.sonarsource.com)|91.134.125.245|:443... connected.

HTTP request sent, awaiting response... 200 OK

Length: 209531101 (200M) [application/zip]

Saving to: ‘sonarqube-8.9.1.zip’

sonarqube-9.9.0.65466.zip                    100%[==========================================================================>] 199.82M  1.31MB/s    in 34s

 ‘sonarqube-9.9.0.65466.zip’ saved [209531101/209531101]
Unzip the archeve setup to /opt directory
sudo unzip sonarqube-9.9.0.65466.zip -d /opt
Move extracted setup to /opt/sonarqube directory
sudo mv /opt/sonarqube-9.9.0.65466 /opt/sonarqube

Step #4: Configure SonarQube

We can’t run Sonarqube as a root user , if you run using root user it stops automatically. We have found solution on this to create saparate group and user to run sonarqube.

1. Create Group and User:

Create a group as sonar
 sudo groupadd sonar
Now add the user with directory access
 sudo useradd -c "user to run SonarQube" -d /opt/sonarqube -g sonar sonar 
 sudo chown sonar:sonar /opt/sonarqube -R
Open the SonarQube configuration file using your favorite text editor.
 sudo nano /opt/sonarqube/conf/sonar.properties
Find the following lines.
#sonar.jdbc.username=
#sonar.jdbc.password=
Uncomment and Type the PostgreSQL Database username and password which we have created in above steps and add the postgres connection string.
/opt/sonarqube/conf/sonar.properties
#--------------------------------------------------------------------------------------------------

# DATABASE

#

# IMPORTANT:

# - The embedded H2 database is used by default. It is recommended for tests but not for

#   production use. Supported databases are Oracle, PostgreSQL and Microsoft SQLServer.

# - Changes to database connection URL (sonar.jdbc.url) can affect SonarSource licensed products.

# User credentials.

# Permissions to create tables, indices and triggers must be granted to JDBC user.

# The schema must be created first.

sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
sonar.jdbc.url=jdbc:postgresql://localhost:5432/sonarqube
Edit the sonar script file and set RUN_AS_USER
 sudo nano /opt/sonarqube/bin/linux-x86-64/sonar.sh
/opt/sonarqube/bin/linux-x86-64/sonar.sh
# If specified, the Wrapper will be run as the specified user.

# IMPORTANT - Make sure that the user has the required privileges to write

#  the PID file and wrapper.log files.  Failure to be able to write the log

#  file will cause the Wrapper to exit without any way to write out an error

#  message.

# NOTE - This will set the user which is used to run the Wrapper as well as

#  the JVM and is not useful in situations where a privileged resource or

#  port needs to be allocated prior to the user being changed.

 RUN_AS_USER=sonar
Type CTRL+X to save and close the file.

2. Start SonarQube:

Now to start SonarQube we need to do following: Switch to sonar user
 sudo su sonar
Move to the script directory
 cd /opt/sonarqube/bin/linux-x86-64/
Run the script to start SonarQube
./sonar.sh start
Output:
Starting SonarQube...

Started SonarQube
We can also add this in service and can run as a service.

3. Check SonarQube Running Status:

To check if sonaqube is running enter below command,
./sonar.sh status
Output:
sonar@fosstechnix:~/bin/linux-x86-64$ ./sonar.sh status

SonarQube is running (9490).

4. SonarQube Logs:

To check sonarqube logs, navigate to /opt/sonarqube/logs/sonar.log directory
 tail /opt/sonarqube/logs/sonar.log
Output:
INFO  app[][o.s.a.ProcessLauncherImpl] Launch process[[key='ce', ipcIndex=3, logFilenamePrefix=ce]] from [/opt/sonarqube]: /usr/lib/jvm/java-11-openjdk-amd64/bin/java -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djava.io.tmpdir=/opt/sonarqube/temp --add-opens=java.base/java.util=ALL-UNNAMED -Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -Dhttp.nonProxyHosts=localhost|127.*|[::1] -cp ./lib/common/*:/opt/sonarqube/lib/jdbc/h2/h2-1.3.176.jar org.sonar.ce.app.CeServer /opt/sonarqube/temp/sq-process15059956114837198848properties

 INFO  app[][o.s.a.SchedulerImpl] Process[ce] is up

 INFO  app[][o.s.a.SchedulerImpl] SonarQube is up
using about output you will see that sonaqube is up and running successfully.

Step #5: Configure Systemd service

First stop the SonarQube service as we started manually using above steps Navigate to the SonarQube installed path
 cd /opt/sonarqube/bin/linux-x86-64/
Run the script to start SonarQube
./sonar.sh stop
Create a systemd service file for SonarQube to run as System Startup.
 sudo nano /etc/systemd/system/sonar.service
Add the below lines,
/etc/systemd/system/sonar.service
[Unit]
Description=SonarQube service
After=syslog.target network.target

[Service]
Type=forking

ExecStart=/opt/sonarqube/bin/linux-x86-64/sonar.sh start
ExecStop=/opt/sonarqube/bin/linux-x86-64/sonar.sh stop

User=sonar
Group=sonar
Restart=always

LimitNOFILE=65536
LimitNPROC=4096

[Install]
WantedBy=multi-user.target
Save and close the file. Now stop the sonarqube script earlier we started to run using as daemon. Start the Sonarqube daemon by running:
 sudo systemctl start sonar
Enable the SonarQube service to automatically  at boot time System Startup.
 sudo systemctl enable sonar
check if the sonarqube service is running,
 sudo systemctl status sonar
Successfully, We have covered How to Install SonarQube on Ubuntu 20.04 LTS .

Step #6: Access SonarQube

To access the SonarQube using browser type server IP followed by port 9000.
http://server_IP:9000 OR http://localhost:9000
Login to SonarQube  with default administrator username and password is admin. sonarqube-web-interface Finally, We have successfully performed all steps to for sonarqube setup.. If you want to change IP address , adding multipla IP address and change the default change in SonarQube Properties as shown below
 sudo nano /opt/sonarqube/conf/sonar.properties
/opt/sonarqube/conf/sonar.properties
# Binding IP address. For servers with more than one IP address, this property specifies which

# address will be used for listening on the specified ports.

# By default, ports will be used on all IP addresses associated with the server.

sonar.web.host=0.0.0.0


# Web context. When set, it must start with forward slash (for example /sonarqube).

# The default value is root context (empty value).

#sonar.web.context=

# TCP port for incoming HTTP connections. Default value is 9000.

sonar.web.port=9000

Troubleshooting

loaded plugin [org.elasticsearch.transport.Netty4Plugin] ERROR: [1] bootstrap checks failed. max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]. Solution: Elasticsearch uses a MMap FS directory to store its indices. The default operating system limits on mmap counts is possibly to be too low, which may result in out of memory exceptions. Enter the below command to increase virtual memory value using sudo privileges,
 sudo sysctl -w vm.max_map_count=262144
Output:
 sudo sysctl -w vm.max_map_count=262144
vm.max_map_count = 262144
To set value permanently, update the vm.max_map_count value in /etc/sysctl.conf. To verify after rebooting,
 sysctl vm.max_map_count
Conclusion: In this article, We have performed ,How to Download and How to Install SonarQube on Ubuntu 20.04 LTS with Configure Sonarqube, Creating Systemd Service and Troubleshooting sonarqube. Related Articles:
FOSS TechNix

FOSS TechNix (Free,Open Source Software's and Technology Nix*) founded in 2019 is a community platform where you can find How-to Guides, articles for DevOps Tools,Linux and Databases.

11 thoughts on “How to Install SonarQube on Ubuntu 20.04 LTS”

  1. ubuntu@ip-172-31-9-51:/opt/sonarqube/logs$ ls
    README.txt access.log es.log sonar.log web.log
    ubuntu@ip-172-31-9-51:/opt/sonarqube/logs$ cd sonar.log
    -bash: cd: sonar.log: Not a directory
    ubuntu@ip-172-31-9-51:/opt/sonarqube/logs$ sudo nano sonar.log
    GNU nano 4.8 sonar.log
    –> Wrapper Started as Daemon
    Launching a JVM…
    Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
    Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved.

    2020.12.25 05:56:31 INFO app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /opt/sonarqube/temp
    2020.12.25 05:56:31 INFO app[][o.s.a.es.EsSettings] Elasticsearch listening on /127.0.0.1:9001
    2020.12.25 05:56:31 INFO app[][o.s.a.ProcessLauncherImpl] Launch process[[key=’es’, ipcIndex=1, logFilenamePrefix=es]] from [/opt/sonarqube/elasticsearch]: /opt/sonarqube/>
    2020.12.25 05:56:31 INFO app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
    2020.12.25 05:56:31 INFO app[][o.e.p.PluginsService] no modules loaded
    2020.12.25 05:56:31 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.
    2020.12.25 05:56:44 INFO app[][o.s.a.SchedulerImpl] Process[es] is up
    2020.12.25 05:56:44 INFO app[][o.s.a.ProcessLauncherImpl] Launch process[[key=’web’, ipcIndex=2, logFilenamePrefix=web]] from [/opt/sonarqube]: /usr/lib/jvm/java-11-openjd>
    2020.12.25 05:56:50 INFO app[][o.s.a.SchedulerImpl] Process[web] is stopped
    2020.12.25 05:56:50 WARN app[][o.s.a.p.AbstractManagedProcess] Process exited with exit value [es]: 143
    2020.12.25 05:56:50 INFO app[][o.s.a.SchedulerImpl] Process[es] is stopped
    2020.12.25 05:56:50 INFO app[][o.s.a.SchedulerImpl] SonarQube is stopped
    Wrapper Started as Daemon
    Launching a JVM…
    Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
    Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved.

    2020.12.25 05:57:51 INFO app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /opt/sonarqube/temp
    2020.12.25 05:57:51 INFO app[][o.s.a.es.EsSettings] Elasticsearch listening on /127.0.0.1:9001
    2020.12.25 05:57:52 INFO app[][o.s.a.ProcessLauncherImpl] Launch process[[key=’es’, ipcIndex=1, logFilenamePrefix=es]] from [/opt/sonarqube/elasticsearch]: /opt/sonarqube/>
    2020.12.25 05:57:52 INFO app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
    2020.12.25 05:57:52 INFO app[][o.e.p.PluginsService] no modules loaded
    2020.12.25 05:57:52 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.
    2020.12.25 05:58:04 INFO app[][o.s.a.SchedulerImpl] Process[es] is up
    2020.12.25 05:58:04 INFO app[][o.s.a.ProcessLauncherImpl] Launch process[[key=’web’, ipcIndex=2, logFilenamePrefix=web]] from [/opt/sonarqube]: /usr/lib/jvm/java-11-openjd>
    2020.12.25 05:58:09 INFO app[][o.s.a.SchedulerImpl] Process[web] is stopped
    2020.12.25 05:58:09 WARN app[][o.s.a.p.AbstractManagedProcess] Process exited with exit value [es]: 143
    2020.12.25 05:58:09 INFO app[][o.s.a.SchedulerImpl] Process[es] is stopped
    2020.12.25 05:58:09 INFO app[][o.s.a.SchedulerImpl] SonarQube is stopped
    Wrapper Started as Daemon
    Launching a JVM…
    Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
    Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved.

    2020.12.25 05:58:12 INFO app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /opt/sonarqube/temp
    2020.12.25 05:58:13 INFO app[][o.s.a.es.EsSettings] Elasticsearch listening on /127.0.0.1:9001
    2020.12.25 05:58:13 INFO app[][o.s.a.ProcessLauncherImpl] Launch process[[key=’es’, ipcIndex=1, logFilenamePrefix=es]] from [/opt/sonarqube/elasticsearch]: /opt/sonarqube/>
    2020.12.25 05:58:13 INFO app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
    2020.12.25 05:58:13 INFO app[][o.e.p.PluginsService] no modules loaded

    Reply
  2. Hello guys,

    I can’t edit the sonar.service file. I’m receiving “Error wrinting /etc/systemd/system/sonar.service: Permission denied”.
    I have been searching and is necessary grant access in systemd, but I can’t to do this with my root user and I can’t save the sonar. service file.
    Do you have any idea ?

    Reply
  3. hai ,

    Your log is very easy to understand easy way to learn. thanks for the information. i setup everything properly , sonaris up and runninig but i am unable to access from the browser. htttp://localhost:9000…….. please help me to resolve this issue

    Reply
  4. I’m trying to open the 9000 port while sonarqube is running but I’m not able to. This is from the error log file:

    –> Wrapper Started as Daemon
    Launching a JVM…
    Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
    Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved.

    16:45:49.238 [WrapperSimpleAppMain] WARN org.sonar.application.config.JdbcSettings – Both ‘JDBC_EMBEDDED_PORT’ and ‘JDBC_URL’ properties are set. The value of property ‘JDBC_URL’ (‘jdbc:postgresql://localhost:5432/sonarqube’) is not consistent with the value of property ‘JDBC_EMBEDDED_PORT’ (‘9092’). The value of property ‘JDBC_URL’ will be ignored and value ‘jdbc:h2:tcp://127.0.0.1:9092/sonar’ will be used instead. To remove this warning, either remove property ‘JDBC_URL’ if your intent was to use the embedded H2 database, otherwise remove property ‘JDBC_EMBEDDED_PORT’.
    2022.01.07 16:45:49 INFO app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /opt/sonarqube/temp
    2022.01.07 16:45:49 INFO app[][o.s.a.es.EsSettings] Elasticsearch listening on [HTTP: 127.0.0.1:9001, TCP: 127.0.0.1:42859]
    2022.01.07 16:45:49 INFO app[][o.s.a.ProcessLauncherImpl] Launch process[[key=’es’, ipcIndex=1, logFilenamePrefix=es]] from [/opt/sonarqube/elasticsearch]: /opt/sonarqube/elasticsearch/bin/elasticsearch
    2022.01.07 16:45:49 INFO app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
    2022.01.07 16:46:03 INFO app[][o.s.a.SchedulerImpl] Process[es] is up
    2022.01.07 16:46:03 INFO app[][o.s.a.ProcessLauncherImpl] Launch process[[key=’web’, ipcIndex=2, logFilenamePrefix=web]] from [/opt/sonarqube]: /usr/lib/jvm/java-11-openjdk-amd64/bin/java -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djava.io.tmpdir=/opt/sonarqube/temp -XX:-OmitStackTraceInFastThrow –add-opens=java.base/java.util=ALL-UNNAMED –add-opens=java.base/java.lang=ALL-UNNAMED –add-opens=java.base/java.io=ALL-UNNAMED –add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED –add-exports=java.base/jdk.internal.ref=ALL-UNNAMED –add-opens=java.base/java.nio=ALL-UNNAMED –add-opens=java.base/sun.nio.ch=ALL-UNNAMED –add-opens=java.management/sun.management=ALL-UNNAMED –add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED -Dcom.redhat.fips=false -Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -Dhttp.nonProxyHosts=localhost|127.*|[::1] -cp ./lib/sonar-application-9.2.1.49989.jar:/opt/sonarqube/lib/jdbc/h2/h2-1.4.199.jar org.sonar.server.app.WebServer /opt/sonarqube/temp/sq-process18428828812002858095properties

    Reply
  5. Hi I tried followed setup as above mentioned
    localhost:9000 is not opening
    ———————————————————————————————–
    sonar@ip-172-31-87-173:~/bin/linux-x86-64$ ./sonar.sh start
    Starting SonarQube…
    SonarQube is already running.
    sonar@ip-172-31-87-173:~/bin/linux-x86-64$ ./sonar.sh status
    SonarQube is running (19451).
    sonar@ip-172-31-87-173:~/bin/linux-x86-64$ cd
    sonar@ip-172-31-87-173:~$ exit
    exit
    $ exit
    ubuntu@ip-172-31-87-173:~$ sudo systemctl enable sonar
    ubuntu@ip-172-31-87-173:~$ sudo systemctl start sonar
    Job for sonar.service failed because the control process exited with error code.
    See “systemctl status sonar.service” and “journalctl -xe” for details.
    ubuntu@ip-172-31-87-173:~$ sudo systemctl status sonar.service
    ● sonar.service – SonarQube service
    Loaded: loaded (/etc/systemd/system/sonar.service; enabled; vendor preset: enabled)
    Active: failed (Result: exit-code) since Sun 2022-01-30 06:21:39 UTC; 26s ago
    Process: 43002 ExecStart=/opt/sonarqube/bin/linux-x86-64/sonar.sh start (code=exited, status=1/FAILURE)

    Jan 30 06:21:39 ip-172-31-87-173 systemd[1]: sonar.service: Scheduled restart job, restart counter is at 5.
    Jan 30 06:21:39 ip-172-31-87-173 systemd[1]: Stopped SonarQube service.
    Jan 30 06:21:39 ip-172-31-87-173 systemd[1]: sonar.service: Start request repeated too quickly.
    Jan 30 06:21:39 ip-172-31-87-173 systemd[1]: sonar.service: Failed with result ‘exit-code’.
    Jan 30 06:21:39 ip-172-31-87-173 systemd[1]: Failed to start SonarQube service.

    Reply
  6. Hi I tried followed setup as above mentioned
    localhost:9000 is not opening

    *********************************************************************************************************************************************************************************************************************************************************************************

    sonar@ip-172-31-87-173:~/bin/linux-x86-64$ ./sonar.sh start
    Starting SonarQube…
    SonarQube is already running.
    sonar@ip-172-31-87-173:~/bin/linux-x86-64$ ./sonar.sh status
    SonarQube is running (19451).
    sonar@ip-172-31-87-173:~/bin/linux-x86-64$ cd
    sonar@ip-172-31-87-173:~$ exit
    exit
    $ exit
    ubuntu@ip-172-31-87-173:~$ sudo systemctl enable sonar
    ubuntu@ip-172-31-87-173:~$ sudo systemctl start sonar
    Job for sonar.service failed because the control process exited with error code.
    See “systemctl status sonar.service” and “journalctl -xe” for details.
    ubuntu@ip-172-31-87-173:~$ sudo systemctl status sonar.service
    ● sonar.service – SonarQube service
    Loaded: loaded (/etc/systemd/system/sonar.service; enabled; vendor preset: enabled)
    Active: failed (Result: exit-code) since Sun 2022-01-30 06:21:39 UTC; 26s ago
    Process: 43002 ExecStart=/opt/sonarqube/bin/linux-x86-64/sonar.sh start (code=exited, status=1/FAILURE)

    Jan 30 06:21:39 ip-172-31-87-173 systemd[1]: sonar.service: Scheduled restart job, restart counter is at 5.
    Jan 30 06:21:39 ip-172-31-87-173 systemd[1]: Stopped SonarQube service.
    Jan 30 06:21:39 ip-172-31-87-173 systemd[1]: sonar.service: Start request repeated too quickly.
    Jan 30 06:21:39 ip-172-31-87-173 systemd[1]: sonar.service: Failed with result ‘exit-code’.
    Jan 30 06:21:39 ip-172-31-87-173 systemd[1]: Failed to start SonarQube service.

    **************************************************************************************************************************************************************************************
    ******************************************************************************************
    LOG FILE

    –> Wrapper Started as Daemon
    Launching a JVM…
    Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
    Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved.

    2022.01.30 03:47:27 INFO app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /opt/sonarqube/temp
    2022.01.30 03:47:27 INFO app[][o.s.a.es.EsSettings] Elasticsearch listening on [HTTP: 127.0.0.1:9001, TCP: 127.0.0.1:44137]
    2022.01.30 03:47:27 INFO app[][o.s.a.ProcessLauncherImpl] Launch process[[key=’es’, ipcIndex=1, logFilenamePrefix=es]] from [/opt/sonarqube/elasticsearch]: /opt/sonarqube/elasticsearch/bin/elasticsearch
    2022.01.30 03:47:27 INFO app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
    warning: no-jdk distributions that do not bundle a JDK are deprecated and will be removed in a future release
    2022.01.30 03:47:35 INFO app[][o.s.a.SchedulerImpl] Process[es] is up
    2022.01.30 03:47:35 INFO app[][o.s.a.ProcessLauncherImpl] Launch process[[key=’web’, ipcIndex=2, logFilenamePrefix=web]] from [/opt/sonarqube]: /usr/lib/jvm/java-11-openjdk-amd64/bin/java -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djava.io.tmpdir=/opt/sonarqube/temp -XX:-OmitStackTraceInFastThrow –add-opens=java.base/java.util=ALL-UNNAMED –add-opens=java.base/java.lang=ALL-UNNAMED –add-opens=java.base/java.io=ALL-UNNAMED –add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED -Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -Dhttp.nonProxyHosts=localhost|127.*|[::1] -cp ./lib/sonar-application-8.9.6.50800.jar:/opt/sonarqube/lib/jdbc/postgresql/postgresql-42.2.19.jar org.sonar.server.app.WebServer /opt/sonarqube/temp/sq-process15186845845390566215properties

    *******************************************************************************************
    *****************************************************************************************************************sonar.properties****************************************************

    # Property values can:
    # – be overridden by environment variables. The name of the corresponding environment variable is the
    # upper-cased name of the property where all the dot (‘.’) and dash (‘-‘) characters are replaced by
    # underscores (‘_’). For example, to override ‘sonar.web.systemPasscode’ use ‘SONAR_WEB_SYSTEMPASSCODE’.
    # – be encrypted. See https://redirect.sonarsource.com/doc/settings-encryption.html

    #————————————————————————————————–
    # DATABASE
    #
    # IMPORTANT:
    # – The embedded H2 database is used by default. It is recommended for tests but not for
    # production use. Supported databases are Oracle, PostgreSQL and Microsoft SQLServer.
    # – Changes to database connection URL (sonar.jdbc.url) can affect SonarSource licensed products.

    # User credentials.
    # Permissions to create tables, indices and triggers must be granted to JDBC user.
    # The schema must be created first.
    sonar.jdbc.username=sonar
    sonar.jdbc.password=sonar
    sonar.jdbc.url=jdbc:postgresql://localhost:5432/sonarqube
    sonar.web.javaAdditionalOpts=-server
    sonar.web.host=0.0.0.0
    sonar.web.port=9000
    #—– Embedded Database (default)
    # H2 embedded database server listening port, defaults to 9092
    #sonar.embeddedDatabase.port=9092

    #—– Oracle 12c/18c/19c
    # The Oracle JDBC driver must be copied into the directory extensions/jdbc-driver/oracle/.
    # Only the thin client is supported, and we recommend using the latest Oracle JDBC driver. See
    # https://jira.sonarsource.com/browse/SONAR-9758 for more details.
    # If you need to set the schema, please refer to http://jira.sonarsource.com/browse/SONAR-5000
    #sonar.jdbc.url=jdbc:oracle:thin:@localhost:1521/XE

    #—– PostgreSQL 9.3 or greater
    # By default the schema named “public” is used. It can be overridden with the parameter “currentSchema”.
    #sonar.jdbc.url=jdbc:postgresql://localhost/sonarqube?currentSchema=my_schema

    #—– Microsoft SQLServer 2014/2016/2017/2019 and SQL Azure
    # A database named sonar must exist and its collation must be case-sensitive (CS) and accent-sensitive (AS)
    # Use the following connection string if you want to use integrated security with Microsoft Sql Server
    # Do not set sonar.jdbc.username or sonar.jdbc.password property if you are using Integrated Security
    # For Integrated Security to work, you have to download the Microsoft SQL JDBC Driver 9.2.0 package from
    # https://docs.microsoft.com/en-us/sql/connect/jdbc/release-notes-for-the-jdbc-driver?view=sql-server-ver15#92
    # and copy mssql-jdbc_auth-9.2.0.x64.dll to your path.
    #sonar.jdbc.url=jdbc:sqlserver://localhost;databaseName=sonar;integratedSecurity=true

    # Use the following connection string if you want to use SQL Auth while connecting to MS Sql Server.
    # Set the sonar.jdbc.username and sonar.jdbc.password appropriately.
    #sonar.jdbc.url=jdbc:sqlserver://localhost;databaseName=sonar

    #—– Connection pool settings
    # The maximum number of active connections that can be allocated
    # at the same time, or negative for no limit.
    # The recommended value is 1.2 * max sizes of HTTP pools. For example if HTTP ports are
    # enabled with default sizes (50, see property sonar.web.http.maxThreads)
    # then sonar.jdbc.maxActive should be 1.2 * 50 = 60.
    #sonar.jdbc.maxActive=60

    # The maximum number of connections that can remain idle in the
    # pool, without extra ones being released, or negative for no limit.
    #sonar.jdbc.maxIdle=5

    # The minimum number of connections that can remain idle in the pool,
    # without extra ones being created, or zero to create none.
    #sonar.jdbc.minIdle=2

    # The maximum number of milliseconds that the pool will wait (when there
    # are no available connections) for a connection to be returned before
    # throwing an exception, or <= 0 to wait indefinitely.
    #sonar.jdbc.maxWait=5000

    #sonar.jdbc.minEvictableIdleTimeMillis=600000
    #sonar.jdbc.timeBetweenEvictionRunsMillis=30000

    #————————————————————————————————–
    # WEB SERVER
    # Web server is executed in a dedicated Java process. By default heap size is 512MB.
    # Use the following property to customize JVM options.
    # Recommendations:
    #
    # The HotSpot Server VM is recommended. The property -server should be added if server mode
    # is not enabled by default on your environment:
    # http://docs.oracle.com/javase/8/docs/technotes/guides/vm/server-class.html
    #
    # Startup can be long if entropy source is short of entropy. Adding
    # -Djava.security.egd=file:/dev/./urandom is an option to resolve the problem.
    # See https://wiki.apache.org/tomcat/HowTo/FasterStartUp#Entropy_Source
    #
    #sonar.web.javaOpts=-Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError

    # Same as previous property, but allows to not repeat all other settings like -Xmx
    #sonar.web.javaAdditionalOpts=

    # Binding IP address. For servers with more than one IP address, this property specifies which
    # address will be used for listening on the specified ports.
    # By default, ports will be used on all IP addresses associated with the server.
    sonar.web.host=0.0.0.0

    # Web context. When set, it must start with forward slash (for example /sonarqube).
    # The default value is root context (empty value).
    #sonar.web.context=
    # TCP port for incoming HTTP connections. Default value is 9000.
    sonar.web.port=9000

    # The maximum number of connections that the server will accept and process at any given time.
    # When this number has been reached, the server will not accept any more connections until
    # the number of connections falls below this value. The operating system may still accept connections
    # based on the sonar.web.connections.acceptCount property. The default value is 50.
    #sonar.web.http.maxThreads=50

    # The minimum number of threads always kept running. The default value is 5.
    #sonar.web.http.minThreads=5

    # The maximum queue length for incoming connection requests when all possible request processing
    # threads are in use. Any requests received when the queue is full will be refused.
    # The default value is 25.
    #sonar.web.http.acceptCount=25

    # By default users are logged out and sessions closed when server is restarted.
    # If you prefer keeping user sessions open, a secret should be defined. Value is
    # HS256 key encoded with base64. It must be unique for each installation of SonarQube.
    # Example of command-line:
    # echo -n "type_what_you_want" | openssl dgst -sha256 -hmac "key" -binary | base64
    #sonar.auth.jwtBase64Hs256Secret=

    # The inactivity timeout duration of user sessions, in minutes. After the configured
    # period of time, the user is logged out.
    # The default value is set to 3 days (4320 minutes).
    # It must be set between 5 minutes and 3 months.
    # Value must be strictly positive.
    #sonar.web.sessionTimeoutInMinutes=4320

    # A passcode can be defined to access some web services from monitoring
    # tools without having to use the credentials of a system administrator.
    # Check the Web API documentation to know which web services are supporting this authentication mode.
    # The passcode should be provided in HTTP requests with the header "X-Sonar-Passcode".
    # By default feature is disabled.
    #sonar.web.systemPasscode=

    #————————————————————————————————–
    # SSO AUTHENTICATION

    # Enable authentication using HTTP headers
    #sonar.web.sso.enable=false

    # Name of the header to get the user login.
    # Only alphanumeric, '.' and '@' characters are allowed
    #sonar.web.sso.loginHeader=X-Forwarded-Login

    # Name of the header to get the user name
    #sonar.web.sso.nameHeader=X-Forwarded-Name

    # Name of the header to get the user email (optional)
    #sonar.web.sso.emailHeader=X-Forwarded-Email

    # Name of the header to get the list of user groups, separated by comma (optional).
    # If the sonar.sso.groupsHeader is set, the user will belong to those groups if groups exist in SonarQube.
    # If none of the provided groups exists in SonarQube, the user will only belong to the default group.
    # Note that the default group will always be set.
    #sonar.web.sso.groupsHeader=X-Forwarded-Groups

    # Interval used to know when to refresh name, email and groups.
    # During this interval, if for instance the name of the user is changed in the header, it will only be updated after X minutes.
    #sonar.web.sso.refreshIntervalInMinutes=5

    #————————————————————————————————–
    # LDAP CONFIGURATION

    # Enable the LDAP feature
    # sonar.security.realm=LDAP

    # Set to true when connecting to a LDAP server using a case-insensitive setup.
    # sonar.authenticator.downcase=true

    # URL of the LDAP server. Note that if you are using ldaps, then you should install the server certificate into the Java truststore.
    # ldap.url=ldap://localhost:10389

    # Bind DN is the username of an LDAP user to connect (or bind) with. Leave this blank for anonymous access to the LDAP directory (optional)
    # ldap.bindDn=cn=sonar,ou=users,o=mycompany

    # Bind Password is the password of the user to connect with. Leave this blank for anonymous access to the LDAP directory (optional)
    # ldap.bindPassword=secret

    # Possible values: simple | CRAM-MD5 | DIGEST-MD5 | GSSAPI See http://java.sun.com/products/jndi/tutorial/ldap/security/auth.html (default: simple)
    # ldap.authentication=simple

    # See :
    # * http://java.sun.com/products/jndi/tutorial/ldap/security/digest.html
    # * http://java.sun.com/products/jndi/tutorial/ldap/security/crammd5.html
    # (optional)
    # ldap.realm=example.org

    # Context factory class (optional)
    # ldap.contextFactoryClass=com.sun.jndi.ldap.LdapCtxFactory

    # Enable usage of StartTLS (default : false)
    # ldap.StartTLS=true

    # Follow or not referrals. See http://docs.oracle.com/javase/jndi/tutorial/ldap/referral/jndi.html (default: true)
    # ldap.followReferrals=false

    # USER MAPPING

    # Distinguished Name (DN) of the root node in LDAP from which to search for users (mandatory)
    # ldap.user.baseDn=cn=users,dc=example,dc=org

    # LDAP user request. (default: (&(objectClass=inetOrgPerson)(uid={login})) )
    # ldap.user.request=(&(objectClass=user)(sAMAccountName={login}))

    # Attribute in LDAP defining the user’s real name. (default: cn)
    # ldap.user.realNameAttribute=name

    # Attribute in LDAP defining the user’s email. (default: mail)
    # ldap.user.emailAttribute=email

    # GROUP MAPPING

    # Distinguished Name (DN) of the root node in LDAP from which to search for groups. (optional, default: empty)
    # ldap.group.baseDn=cn=groups,dc=example,dc=org

    # LDAP group request (default: (&(objectClass=groupOfUniqueNames)(uniqueMember={dn})) )
    # ldap.group.request=(&(objectClass=group)(member={dn}))

    # Property used to specifiy the attribute to be used for returning the list of user groups in the compatibility mode. (default: cn)
    # ldap.group.idAttribute=sAMAccountName

    #————————————————————————————————–
    # COMPUTE ENGINE
    # The Compute Engine is responsible for processing background tasks.
    # Compute Engine is executed in a dedicated Java process. Default heap size is 512MB.
    # Use the following property to customize JVM options.
    # Recommendations:
    #
    # The HotSpot Server VM is recommended. The property -server should be added if server mode
    # is not enabled by default on your environment:
    # http://docs.oracle.com/javase/8/docs/technotes/guides/vm/server-class.html
    #
    #sonar.ce.javaOpts=-Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError

    # Same as previous property, but allows to not repeat all other settings like -Xmx
    #sonar.ce.javaAdditionalOpts=

    #————————————————————————————————–
    # ELASTICSEARCH
    # Elasticsearch is used to facilitate fast and accurate information retrieval.
    # It is executed in a dedicated Java process. Default maximum heap size is 512MB.
    # It is recommended to also set MaxDirectMemorySize (-XX:MaxDirectMemorySize) and set it to half the maximum heap size.
    #
    # ————————————————–
    # Word of caution for Linux users on 64bits systems
    # ————————————————–
    # Please ensure Virtual Memory on your system is correctly configured for Elasticsearch to run properly
    # (see https://www.elastic.co/guide/en/elasticsearch/reference/5.5/vm-max-map-count.html for details).
    #
    # When SonarQube runs standalone, a warning such as the following may appear in logs/es.log:
    # "max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]"
    # When SonarQube runs as a cluster, however, Elasticsearch will refuse to start.
    #

    # JVM options of Elasticsearch process
    #sonar.search.javaOpts=-Xmx512m -Xms512m -XX:MaxDirectMemorySize=256m -XX:+HeapDumpOnOutOfMemoryError

    # Same as previous property, but allows to not repeat all other settings like -Xmx
    #sonar.search.javaAdditionalOpts=

    # Elasticsearch port for incoming HTTP connections. Default is 9001. Use 0 to get a free port.
    # As a security precaution, should be blocked by a firewall and not exposed to the Internet.
    #sonar.search.port=9001

    # Elasticsearch TCP transport port that is bound to loopback address. When nothing is set, a random port will be chosen.
    # As a security precaution, your OS configuration should not expose this port for external access.
    #sonar.es.port=

    # Elasticsearch host. The search server will bind this address and the search client will connect to it.
    # Default is loopback address.
    # As a security precaution, should NOT be set to a publicly available address.
    #sonar.search.host=

    #————————————————————————————————–
    # UPDATE CENTER

    # Update Center requires an internet connection to request https://update.sonarsource.org
    # It is enabled by default.
    #sonar.updatecenter.activate=true

    # HTTP proxy (default none)
    #http.proxyHost=
    #http.proxyPort=
    # HTTPS proxy (defaults are values of http.proxyHost and http.proxyPort)
    #https.proxyHost=
    #https.proxyPort=

    # NT domain name if NTLM proxy is used
    #http.auth.ntlm.domain=

    # SOCKS proxy (default none)
    #socksProxyHost=
    #socksProxyPort=

    # Proxy authentication (used for HTTP, HTTPS and SOCKS proxies)
    #http.proxyUser=
    #http.proxyPassword=

    # Proxy exceptions: list of hosts that can be accessed without going through the proxy
    # separated by the '|' character, wildcard character '*' can be used for pattern matching
    # used for HTTP and HTTPS (default none)
    # (note: localhost and its literal notations (127.0.0.1, …) are always excluded)
    #http.nonProxyHosts=

    #————————————————————————————————–
    # LOGGING

    # SonarQube produces logs in 4 logs files located in the same directory (see property sonar.path.logs below),
    # one per process:
    # Main process (aka. App) logs in sonar.log
    # Web Server (aka. Web) logs in web.log
    # Compute Engine (aka. CE) logs in ce.log
    # Elasticsearch (aka. ES) logs in es.log
    #
    # Depending on the startup, all 4 files follow the same rolling policy (see sonar.log.rollingPolicy and sonar.log.maxFiles) but it applies
    # individually (eg. if sonar.log.maxFiles=4, there can be at most 4 of each files, ie. 16 files in total).
    # If the SonarQube wrapper is used (for example, with the provided start.sh script), the sonar.log rotation policy needs to be set in the wrapper.conf
    #
    # All 4 files have logs in the same format:
    # 1 2 3 4 5 6
    # |—————–| |—| |-|——————–||——————————| |——————————————————————————————————————————|
    # 2016.11.16 16:47:00 INFO ce[AVht0dNXFcyiYejytc3m][o.s.s.c.t.CeWorkerCallableImpl] Executed task | project=org.sonarqube:example-java-maven | type=REPORT | id=AVht0dNXFcyiYejytc3m | submitter=admin | time=1699ms
    #
    # 1: timestamp. Format is YYYY.MM.DD HH:MM:SS
    # YYYY: year on 4 digits
    # MM: month on 2 digits
    # DD: day on 2 digits
    # HH: hour of day on 2 digits in 24 hours format
    # MM: minutes on 2 digits
    # SS: seconds on 2 digits
    # 2: log level.
    # Possible values (in order of descending criticality): ERROR, WARN, INFO, DEBUG and TRACE
    # 3: process identifier. Possible values: app (main), web (Web Server), ce (Compute Engine) and es (Elasticsearch)
    # 4: SQ thread identifier. Can be empty.
    # In the Web Server, if present, it will be the HTTP request ID.
    # In the Compute Engine, if present, it will be the task ID.
    # 5: logger name. Usually a class canonical name.
    # Package names are truncated to keep the whole field to 20 characters max
    # 6: log payload. Content of this field does not follow any specific format, can vary in length and include line returns.
    # Some logs, however, will follow the convention to provide data in payload in the format " | key=value"
    # Especially, log of profiled pieces of code will end with " | time=XXXXms".

    # Global level of logs (applies to all 4 processes).
    # Supported values are INFO (default), DEBUG and TRACE
    #sonar.log.level=INFO

    # Level of logs of each process can be controlled individually with their respective properties.
    # When specified, they overwrite the level defined at global level.
    # Supported values are INFO, DEBUG and TRACE
    #sonar.log.level.app=INFO
    #sonar.log.level.web=INFO
    #sonar.log.level.ce=INFO
    #sonar.log.level.es=INFO

    # Path to log files. Can be absolute or relative to installation directory.
    # Default is /logs
    #sonar.path.logs=logs

    # Rolling policy of log files
    # – based on time if value starts with “time:”, for example by day (“time:yyyy-MM-dd”)
    # or by month (“time:yyyy-MM”)
    # – based on size if value starts with “size:”, for example “size:10MB”
    # – disabled if value is “none”. That needs logs to be managed by an external system like logrotate.
    #sonar.log.rollingPolicy=time:yyyy-MM-dd

    # Maximum number of files to keep if a rolling policy is enabled.
    # – maximum value is 20 on size rolling policy
    # – unlimited on time rolling policy. Set to zero to disable old file purging.
    #sonar.log.maxFiles=7

    # Access log is the list of all the HTTP requests received by server. If enabled, it is stored
    # in the file {sonar.path.logs}/access.log. This file follows the same rolling policy as other log file
    # (see sonar.log.rollingPolicy and sonar.log.maxFiles).
    #sonar.web.accessLogs.enable=true

    # Format of access log. It is ignored if sonar.web.accessLogs.enable=false. Possible values are:
    # – “common” is the Common Log Format, shortcut to: %h %l %u %user %date “%r” %s %b
    # – “combined” is another format widely recognized, shortcut to: %h %l %u [%t] “%r” %s %b “%i{Referer}” “%i{User-Agent}”
    # – else a custom pattern. See http://logback.qos.ch/manual/layouts.html#AccessPatternLayout.
    # The login of authenticated user is not implemented with “%u” but with “%reqAttribute{LOGIN}” (since version 6.1).
    # The value displayed for anonymous users is “-“.
    # The SonarQube’s HTTP request ID can be added to the pattern with “%reqAttribute{ID}” (since version 6.2).
    # If SonarQube is behind a reverse proxy, then the following value allows to display the correct remote IP address:
    #sonar.web.accessLogs.pattern=%i{X-Forwarded-For} %l %u [%t] “%r” %s %b “%i{Referer}” “%i{User-Agent}” “%reqAttribute{ID}”
    # Default value (which was “combined” before version 6.2) is equivalent to “combined + SQ HTTP request ID”:
    #sonar.web.accessLogs.pattern=%h %l %u [%t] “%r” %s %b “%i{Referer}” “%i{User-Agent}” “%reqAttribute{ID}”

    #————————————————————————————————–
    # OTHERS

    # Delay in seconds between processing of notification queue. Default is 60 seconds.
    #sonar.notifications.delay=60

    # Paths to persistent data files (embedded database and search index) and temporary files.
    # Can be absolute or relative to installation directory.
    # Defaults are respectively /data and /temp
    #sonar.path.data=data
    #sonar.path.temp=temp

    # Telemetry – Share anonymous SonarQube statistics
    # By sharing anonymous SonarQube statistics, you help us understand how SonarQube is used so we can improve the product to work even better for you.
    # We don’t collect source code or IP addresses. And we don’t share the data with anyone else.
    # To see an example of the data shared: login as a global administrator, call the WS api/system/info and check the Statistics field.
    #sonar.telemetry.enable=true
    ****************************************END*****************************************************************************************************************************************

    Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share via
Copy link
Powered by Social Snap