Installing the SonarQube Community Build database
We recommend that for production installation, the database used by SonarQube Server is hosted on a machine that is physically separate from the SonarQube Server host, with low latency between both hosts.
The embedded H2 database is used by default. It is recommended for tests but not for production use.
Database requirements
Several external database engines are supported.
Database engine | Requirement |
---|---|
PostgreSQL | Version: 13 to 17 |
Microsoft SQL Server | Version:
Notes:
|
Oracle | Version: 23ai, 21C, 19C, XE Editions. Recommendation: Use the latest Oracle JDBC driver. Notes:
|
H2 | Recommendation: Use the H2 embedded database for non-production use cases:
Why avoid H2 in production:
Use PostgreSQL, Oracle, or MS SQL for production to ensure reliability and scalability. Limit H2 to development, testing, or trials. |
Creating a new database instance for SonarQube
- Create an empty schema for SonarQube to populate.
- Create a
sonarqube
user. Grant thissonarqube
user permissions tocreate
,update
, anddelete
objects for this schema. - Perform the setup as described below depending on your database type.
Setup if using an MS SQL Server database
This page describes operations to be performed on your MS SQL Server instance for SonarQube.
Set collation to CS and AS
Collation MUST be case-sensitive (CS) and accent-sensitive (AS).
Enable READ_COMMITTED_SNAPSHOT
READ_COMMITTED_SNAPSHOT
MUST be set on the SonarQube database.
MS SQL database's shared lock strategy may impact SonarQube Server runtime. Making sure that is_read_committed_snapshot_on
is set to true
will prevent SonarQube from facing potential deadlocks under heavy loads.
To check is_read_committed_snapshot_on
, you may use the following query:
SELECT is_read_committed_snapshot_on FROM sys.databases WHERE name='YourSonarQubeDatabase';
To update is_read_committed_snapshot_on
, you may use the following query:
ALTER DATABASE YourSonarQubeDatabase SET READ_COMMITTED_SNAPSHOT ON WITH ROLLBACK IMMEDIATE;
Encryption-related setup
If your Microsoft SQL Server doesn't support encryption, you must add encrypt=false
to the JDBC URL connection string.
If your Microsoft SQL Server requires encryption but you don't want SonarQube to validate the certificate, you must add trustServerCertificate=true
to the JDBC URL connection string.
Using integrated security
To use integrated security:
- Download the Microsoft SQL JDBC Auth 12.10.0 package and copy
mssql-jdbc_auth-12.10.0.x64.dll
to a folder location set in the PATH environment variable on SonarQube Server host. - If you're running SonarQube as a Windows service, make sure the Windows account under which the service is running has permission to connect your SQL server.
If using an Oracle database
If there are two SonarQube schemas on the same Oracle instance, especially if they are for two different versions, SonarQube gets confused and picks the first it finds. To avoid this issue:
- Either privileges associated to the SonarQube's Oracle user should be decreased.
- Or a trigger should be defined on the Oracle side to automatically alter the SonarQube's Oracle user session when establishing a new connection:
ALTER SESSION SET current_schema="MY_SONARQUBE_SCHEMA"
.
Setup if using a PostgreSQL database
Your PostgreSQL instance for SonarQube:
- Must be configured to use UTF-8 charset.
- If you want to use a custom schema and not the default "public" one: the PostgreSQL
search_path
property must be set:
ALTER USER mySonarUser SET search_path to mySonarQubeSchema
Was this page helpful?