- Create a copy of the database of the currently used system version. In my case it was 7.6:
- Logging in as a sonar user →
su - sonar.
- Backing up the database →
pg_dump sonar > sonar_db-$(date +"%Y-%m-%d").sql.
- Move the copy to your user’s home folder →
cp /opt/sonarqube/sonar_db-2021-01-01.sql /home/owned_user/.
2. Download the latest version of the Sonarqube software and upload it to the appropriate directory:
- Entering to the /tmp directory →
- Downloading a package →
- Unpacking the package →
- Setting the appropriate owner →
chown -R sonar:sonar sonarqube-7.9.2.
- Copying to the correct directory →
cp -R sonarqube-7.9.2 /opt.
3. Modifying configuration files:
- Verify that the
wrapper.conffiles located in the
/opt/sonarqube-7.9.2/confpath have the correct configuration parameters. Compare them with their counterparts located in the same directory of an older version of the system. Do not copy files! Additionally, after installing Java 11, you have to provide the full path to the binary in the
wrapper.conffile as a parameter of the wrapper.java.command attribute. In my case the line looks like this →
4. Uploading the necessary plugins:
- The plugins are located in the directory →
/opt/sonarqube-7.9.2/extensions/plugins. Some of them are already installed. Before installing additional ones it is good to verify their compatibility with the site.
- Plugins can be downloaded directly to the mentioned above directory with the
wgetcommand using the links from this page.
5. When the settings in the configuration files are correct and the necessary plugins have been downloaded, stop the current version of the Sonarqube server, start the new one, and then perform the database update:
- The file that starts the sonarqube service is located in the path →
- Stopping the service →
service sonar stop.
- Update service file
/etc/systemd/system/sonar.service. Add two lines in the [Service] section. First one
LimitNOFILE=65536is an equivalent of the
ulimit -n. Second one
LimitNPROC=8192equivalent of the
- Reload the system service manager →
- Enter /opt directory →
- Delete the symbolic link leading to the existing Sonarqube root directory →
- Create a symbolic link leading to the new system version →
ln -s sonarqube-7.9.2 sonarqube.
- Starting a service (already using the linked new directory) →
service sonar start.
- Go to the page under whose domain Sonarqube is available + add ”/setup” → https://sonarqube.example.com/setup. The database update process is started, which in my case took a few seconds. Then the various components of the system are started and the login window is shown.
- After logging in to your administrator account under the System tab, you can verify that you have the latest (LTS) version.
Optional part: update Java on the server (system requires Java 11 JRE or JDK):
- Adding to the system repositories →
sudo add-apt-repository ppa:linuxuprising/java.
- If it does not exist then create a directory
mkdir -p /var/cache/oracle-jdk11-installer-local.
- Download the latest Java 11 from here (account required). It must be the latest, otherwise the installation process will end in an error. This is because the system repository contains information about the latest files that use the latest version of the Java package.
- Place the downloaded .tar.gz archive in the directory created above (without this archive, the command in the following section will throw an error).
sudo apt updateand then
sudo apt install oracle-java11-installer-local.
- The java executable is located in the path
/usr/lib/jvm/java-11-oracle/bin, which must be specified in the
wrapper.conffile as I described in the earlier section in step 3.
- Optionally, you can perform the installation of the
sudo apt-get install oracle-java11-set-default-local, to set the installed 11 version of Java as the default.
Disclaimer: This tutorial was done on Ubuntu Server 18.04 LTS with installed 7.6 version of the Sonarqube.