SQ Official Doc Link: https://docs.sonarqube.org/display/SONAR/How+To+Implement+an+Active-Passive+Cluster
Table of Contents
SonarQube has no built-in feature allowing to setup an active-active or active-passive cluster. It's up to you to setup it.
Here are guidelines to setup an active-passive cluster.
Note:
- this page is for SonarQube Server only and doesn't deal with database.
- Server1 is active and Server2 is passive
Setup
- Server1 is started and connected to DB : ServerID is generated and Licenses are correctly set
- Server2 is a copy of Server1 and is stopped
- Change Server2 JDBC configuration to use the default embedded H2 DB
- Start Server2 and generate the ServerID
- Ask to contact@sonarsource.com the licenses corresponding to Server2's ServerID
- Stop Server2
- Change Server2 JDBC configuration to the real DB
BAU Process
- Have a rsync that syncs $SONAR_HOME/conf and $SONAR_HOME/extensions directories, between Server1 and Server2 every X hours
- Every nights, backup ES indices to avoid long rebuild of them:
- Stop SonarQube Server1
- Do a rsync that syncs $SONAR_HOME/data/es of Server1 and Server2
- Start SonarQube Server1
In Case of Failure
Server1 is down.
- Start Server2
- Have a script using the SQ API to set the Organisation, IP, ServerID and Licenses gathered during the Setup phase
Web API URLS Sample
curl -u admin:admin -X POST 'http://localhost:9000/api/properties?id=sonar.organisation&value=AlexCorp'
curl -u admin:admin -X POST 'http://localhost:9000/api/properties?id=sonar.server_id.ip_address&value=192.168.0.1'
curl -u admin:admin -X POST 'http://localhost:9000/api/properties?id=sonar.server_id&value=1cd5b4936302808'
curl -s -u admin:admin -X POST "http://localhost:9000/api/properties?id=sonarsource.$1.license.secured&value=$LICENSE" where $1 is the key of a commercial plugin and $LICENSE its license