SonarQube Platform Overview
Sonar Image Added
The SonarQube platform is made of 3 components:
- A Database that stores One to store:
- the configuration
- A Web Server that is used to navigate the results of the analyzes and make configuration
- A Client that will run source code analyzers to compute data on projects
Sonar supports several database engines you can choose amongst.
If you simply want to make a test or a demo, you can use H2 (Apache Derby prior to Sonar 3.2) as a database. H2 (Derby prior to Sonar 3.2) is shipped with Sonar and does not need any installation. This database must not be used for production.
- of the SonarQube instance (security, plugins settings, etc.)
- the quality snapshots of projects, views, etc.
- One for users to browse quality snapshots and configure the SonarQube instance
- One or more to analyze projects
- The SonarQube platform cannot have more than a single web server and a single database.
- For optimal performance, each component (Database, Web Server, Clients) should be installed on a dedicated machine. However, the Server and the Database can be installed on the same machine.
- Clients will scale by adding machines.
- The Database and the Clients must be located in the same network.
- The Database and the Clients must not be installed on the same machine.
- All the machines must be time synchronized.
Several database engines are supported.
Create an empty schema and a sonarqube user. Grant this sonarqube user permissions to create, update and delete objects . Tables and indexes will then be automatically created when launching Sonar for the first time. A sample scripts to create the schema in MySQL can be found in here.
When creating a database, the recommended character set is UTF-8.
Installing Sonar Server
for this schema. The charset of the database has to be set to "UTF-8" and the language to "English". Here is a sample script for MySQL.
There are two well-known engines that can be used in MySQL: MyISAM and InnoDB. MyISAM is the oldest of the two engines and is being progressively replaced by InnoDB. InnoDB is clearly faster and scales better with SonarQube when the number of projects under quality control increases. If you have been an early adopter of SonarQube, you probably have a series of table that are still using MyISAM. To improve performances, you should change the engine for all tables to InnoDB.
Once all SonarQube tables are using the InnoDB engine, the first thing to do is allocate a maximum amount of RAM to your MySQL instance with the
First, check the requirements.
Then download and unzip the distribution (
do not unzip into a directory starting with a digit). Note that native packages are also available for Linux distributions
If you do not use the default embedded database, edit .
<install_directory> (below) refers to the path to the directory where the SonarQube distribution has been unzipped.
Setting the access to the Database
Edit <install_directory>/conf/sonar.properties to configure the database accesssettings. Templates are available for every supported database. Just uncomment them and configure the template you need and comment out the lines dedicated to H2 (Derby prior to version 3.2)::
For Oracle, copy the JDBC driver to /extensions/jdbc-driver/[YOUR DATABASE]/.
Adding the JDBC Driver
Drivers for the supported databases (except Oracle) are already provided. Do not replace the provided drivers; they are the only ones supported).
For Oracle, copy the JDBC driver into <install_directory>/extensions/jdbc-driver/oracle.
Starting the Web Server
The default listen port is "9000, " and the default context path is / and Sonar listens by default to all network interfaces: '0.0.0.0'. Once launched, the Sonar web server is available on http://localhost:9000. "/". Parameters can be changed into the file in <install_directory>/conf/sonar.properties:
sonar.web.host : =192.0.0.1 sonar.web.port: =80 sonar.web.context: =/sonar
Execute the following script to start the server:
- On Linux/Mac OS: bin/<YOUR OS>/sonar.sh start
- On Windows: bin/windows-x86-32XX/StartSonar.bat
- Read Installing SonarQube on AIX, HPUX or Solaris for other platforms
You can now browse to SonarQube at http://localhost:9000.
Tuning the Web Server
By default, SonarQube is configured to run on any computer with a simple Java JRE. The first thing to do when installing a production instance is to use a Java JDK and activate the server mode by uncommenting the following line in <install_directory>/conf/wrapper.conf:
To change the Java JVM used by SonarQube, simply edit <install_directory>/conf/wrapper.conf and update the following line:
Advanced Installation Features
- Deploying Sonar on a JEE Server
- Running Sonar Running SonarQube as a Service on Windows or Linux
- Running Sonar SonarQube behind a Proxy
- Running SonarQube over HTTPS
There are different kinds of client to launch analysis:
Multiple analysis clients are available:
- SonarQube Runner: recommended for all non-Maven projects
- Maven: recommended for all projects built with Maven, see installation and configuration guide.
- SonarQube Ant Task: recommended for to integrate with projects built with Ant, see installation and configuration guide.
- Gradle: to integrate with projects built with Gradle
- CI Engine: see Hudson/Jenkins plugin or Bamboo Hudson plugin or Bamboo plugin or AnthillPro plugin. Note that other CI engines can be used even if there is no Sonar SonarQube plugin available.