SonarQube Platform Overview
Sonar 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 several to analyze projects
- The SonarQube platform cannot have more than one single web server and one single database.
- To set a performant platform:
- Each component (Database, Web Server, Clients) should be installed on a dedicated machine
- The Database and the Clients should be located in the same network
Several database engines are supported.
To give a quick try, you can stick with the H2 database that is shipped with SonarQube. It doesn't require any installation. Note that H2 must NOT be used to set up a production instance.
To use the database engine of your choice, just 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". 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
. Note that native packages are also available for Linux distributions
Setting the access to the Database
If you do 're not use using the default embedded H2 database, you need to edit SONARQUBE_HOME/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)::
username: sonarqube sonar.jdbc.
password: mypassword sonar.jdbc.
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).
Starting Sonar Server
The default listen port is 9000, 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 For Oracle, copy the JDBC driver into the SONARQUBE_HOME/extensions/jdbc-driver/oracle directory.
Starting the Web Server
By default, SonarQube starts an embedded Jetty web server. The default port is "9000" and the context path is "/". Parameters can be changed in the SONARQUBE_HOME/conf/sonar.properties file:
sonar.web.host : 192.0.0.1 sonar.web.port: 80 sonar.web.context: /sonar
- 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 SONARQUBE_HOME/conf/wrapper.conf:
To change the Java JVM used by SonarQube, simply edit SONARQUBE_HOME/conf/wrapper.conf and update the following line:
Advanced Installation Features
- Deploying Sonar SonarQube on a JEE Server Tomcat or Jetty web server of your choice
- Running Sonar SonarQube as a Service on Windows or Linux
- Running Sonar SonarQube behind a Proxy
There are different kinds of client to launch analysisclients available to run analyses:
- Sonar SonarQube Runner: recommended as the default one, see installation and configuration guide.
- Maven: recommended for projects built with Maven, see installation and configuration guide.
- SonarQube Ant Task: recommended for projects built with Ant, see installation and configuration guide.
- Gradle: recommended for projects built with Gradle, see installation and configuration guide.
- CI Engine: see Hudson/Jenkins plugin or 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.