Install the server as a cluster
Running SonarQube as a Cluster is only possible with a Data Center Edition.
The Data Center Edition allows SonarQube to run in a clustered configuration to make it resilient to failures.
The default configuration for the Data Center Edition comprises five servers, a load balancer, and a database server:
- Two application nodes responsible for handling web requests from users (WebServer process) and handling analysis reports (ComputeEngine process). You can add application nodes to increase computing capabilities.
- Three search nodes that host the Elasticsearch process that will store data indices. SSDs perform significantly better than HDDs for these nodes.
- A reverse proxy / load balancer to load balance traffic between the two application nodes. The installing organization must supply this hardware or software component.
- PostgreSQL, Oracle, or Microsoft SQL Server database server. This software must be supplied by the installing organization.
With this configuration, one application node and one search node can be lost without impacting users. Here is a diagram of the default topology:
You need a minimum of five servers (two application nodes and three search nodes) to form a SonarQube application cluster. Servers can be virtual machines; it is not necessary to use physical machines. You can also add application nodes to increase computing capabilities.
The operating system requirements for servers are available on the Requirements page.
All application nodes should be identical in terms of hardware and software. Similarly, all search nodes should be identical to each other. Application and search nodes, however, can differ from one another. Generally, search nodes are configured with more CPU and RAM than application nodes.
Search nodes can be located in different availability zones, but they must be in the same region. In this case, each search node should be located in a separate availability zone to maintain availability in the event of a failure in one zone.
Here are the machines we used to perform our validation with a 200M issues database. You can use this as a minimum recommendation to build your cluster.
- App Node made of Amazon EC2 general purpose xlarge: 4 vCPUs, 16GB RAM
- Search Node made of Amazon EC2 general purpose 2xlarge: 8 vCPUs, 32GB RAM - 16GB allocated to Elasticsearch. SSDs perform significantly better than HDDs for these nodes.
Supported database systems are available on the Requirements page.
SonarSource does not provide specific recommendations for reverse proxy / load balancer or solution-specific configuration. The general requirements for SonarQube Data Center Edition are:
- Ability to balance HTTP requests (load) between the application nodes configured in the SonarQube cluster.
- If terminating HTTPS, meets the requirements set out in Securing SonarQube behind a proxy.
- No requirement to preserve or sticky sessions; this is handled by the built-in JWT mechanism.
- Ability to check for node health for routing
Example with HAproxy
You need a dedicated license to activate the Data Center Edition. If you don't have one yet, please contact the SonarSource Sales Team.
Don't start this journey alone! As a Data Center Edition subscriber, SonarSource will assist with the setup and configuration of your cluster. Get in touch with SonarSource Support for help.
Installing SonarQube from the ZIP file
Additional parameters are required to activate clustering capabilities and specialize each node. These parameters are in addition to standard configuration properties used in a single-node configuration.
The sonar.properties file on each node will be edited to configure the node's specialization. A list of all cluster-specific configuration parameters is available in the Operate the cluster documentation.
Prior to configuration, you will need to generate a value for the
sonar.auth.jwtBase64Hs256Secret property for the application nodes. The value is a HS256 key encoded with base64 and will be the same for both nodes. The following is an example on how to generate this value on a Unix system:
The following example represents a sample configuration of a SonarQube cluster. The example assumes:
- The VMs having IP addresses ip1 and ip2 (server1, server2) are application nodes
- The VMs having IP addresses ip3, ip4, and ip5 (server3, server4 and server5) are search nodes
The configuration to be added to sonar.properties for each node is the following:
Sample Installation Process
The following is an example of the default SonarQube cluster installation process. You need to tailor your installation to the specifics of the target installation environment and the operational requirements of the hosting organization.
Prepare the cluster environment:
- Prepare the cluster environment by setting up the network and provisioning the nodes and load balancer.
- Follow the Install the server documentation to configure the database server.
Prepare a personalized SonarQube package:
- On a single application node of the cluster, download and install SonarQube Data Center Edition, following the usual Install the server documentation.
- Add cluster-related parameters to
- This is also a good opportunity to install plugins. Download and place a copy of each plugin JAR in
$SONARQUBE_HOME/extensions/plugins. Be sure to check compatibility with your SonarQube version using the Plugin version matrix.
- Zip the directory
$SONARQUBE_HOME. This archive is a customized SonarQube Data Center Edition package that can be copied to other nodes.
Test configuration on a single node:
- On the application node where you created your Zip package, comment out all cluster-related parameters in
- Configure the load balancer to proxy with single application node.
- Start server and test access through load balancer.
- Request license from SonarSource Sales Team.
- After applying license, you will have a full-featured SonarQube system operating on a single node.
Deploy SonarQube package on other nodes:
- Unzip SonarQube package on the other four nodes.
- Configure node-specific parameters on all five nodes in
$SONARQUBE_HOME/conf/sonar.propertiesand ensure application node-specific and search node-specific parameters are properly set.
- Start all search nodes.
- After all search nodes are running, start all application nodes.
- Configure the load balancer to proxy with both application nodes.
Install SonarQube from the Docker image
You can also install a cluster using our docker images. The general setup is the same but is shifted to a Docker-specific terminology.
All containers should be in the same network. This includes search and application nodes. For the best performance, it is advised to check for low latency between the database and the cluster nodes.
The limits of each container depend on the workload that each container has. A good starting point would be:
- cpus: 0.5
- mem_limit: 4096M
- mem_reservation: 1024M
The 4Gb mem_limit should not be lower as this is the minimal value for Elasticsearch.
Application nodes can be scaled using replicas. This is not the case for the Search nodes as Elasticsearch will not become ready. See the Configure and operate a cluster for more information.
You'll use the following volumes in your configuration:
sonarqube_data– In the Docker Compose configuration example in the following section, volumes are shared between replicas in the application nodes, so you don't need a
sonarqube_datavolume on your application nodes. In the search nodes, the
sonarqube_datavolume contains the Elasticsearch data and helps reduce startup time, so we recommend having a
sonarqube_datavolume on each search node.
sonarqube_extensions– For application nodes, we recommend sharing a common
sonarqube_extensionsvolume which contains any plugins you install and the Oracle JDBC driver if necessary.
sonarqube_logs– For both application and search nodes, we recommend sharing a common
sonarqube_logsvolume which contains SonarQube logs. The volume will be populated with a new folder depending on the container's hostname and all logs of this container will be put into this folder. This behavior also happens when a custom log path is specified via the Docker environment variables.
Example Docker Compose configuration
Click the heading below to expand the docker-compose.yml file example.
The example below will use the latest version of the SonarQube Docker image. If want to use the LTS version of SonarQube, you need to update the example with the
sonarqube:lts-datacenter-search image tags.
Once you've completed these steps, check out the Operate your cluster documentation.
© 2008-2023, SonarSource S.A, Switzerland. Except where otherwise noted, content in this space is licensed under a Creative Commons Attribution-NonCommercial 3.0 United States License. SONARQUBE is a trademark of SonarSource SA. All other trademarks and copyrights are the property of their respective owners.