Migrating sonarqube 6.7.x db from mysql to postgresql 10 on ubuntu 16.04
Before migrating
Make sure that you download the same version as your sonarqube 6.7.x And make sure your running in sudo
In this tutorial I will be using the sonarqube 6.7.5
-
Add PostgreSQL APT Repositories
echo 'deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main' >> /etc/apt/sources.list.d/pgdg.list
-
Import repositories key
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
-
Install PostgreSQL
sudo apt-get update sudo apt-get install postgresql-10
-
Create database for sonarqube
sudo su - postgres psql create database sonar; create user sonar_user with encrypted password 'sonar_password'; grant all privileges on database sonar to sonar_user;
-
Setup new sonarqube that use postgresql
wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-6.7.5.zip unzip sonarqube-6.7.5.zip mv sonarqube-6.7.5.zip /opt/sonarqube-6.7.5 vim /opt/sonarqube-6.7.5/conf/sonar.properties
-
Stop the old sonarqube service
/opt/sonarqube/bin/linux86-64/sonar.sh stop
-
Start the new sonarqube service
/opt/sonarqube-6.7.5/bin/linux86-64/sonar.sh start
-
Stop the new sonarqube service
/opt/sonarqube-6.7.5/bin/linux86-64/sonar.sh stop
-
Download MySQL Migrator
wget https://binaries.sonarsource.com/Distribution/mysql-migrator/mysql-migrator-1.1.0.119.zip
-
Migrate the database (I assume that the source is in /opt/sonarqube folder)
unzip mysql-migrator-1.1.0.119 ./mysql-migrator-1.1.0.119/bin/mysql-migrator -source /opt/sonarqube/conf/sonar.properties -target /opt/sonarqube-6.7.5/conf/sonar.properties
-
Delete the es5 data on the new sonarqube
rm -rf /opt/sonarqube-6.7.5/data/es5/*
-
Start the new sonarqube service
/opt/sonarqube-6.7.5/bin/linux86-64/sonar.sh start
-
Access the sonarqube setup menu
http://sonarqube_url/setup