Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save zhadowz99/8ad2f4cf13407c0a0409f518387cfb14 to your computer and use it in GitHub Desktop.
Save zhadowz99/8ad2f4cf13407c0a0409f518387cfb14 to your computer and use it in GitHub Desktop.
Migrating sonarqube 6.7.x db from mysql to postgresql 10 on ubuntu 16.04

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

  1. Add PostgreSQL APT Repositories

    echo 'deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main' >> /etc/apt/sources.list.d/pgdg.list
  2. Import repositories key

    wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
  3. Install PostgreSQL

    sudo apt-get update
    sudo apt-get install postgresql-10
  4. 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;
    
  5. 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
  6. Stop the old sonarqube service

    /opt/sonarqube/bin/linux86-64/sonar.sh stop
  7. Start the new sonarqube service

    /opt/sonarqube-6.7.5/bin/linux86-64/sonar.sh start
  8. Stop the new sonarqube service

    /opt/sonarqube-6.7.5/bin/linux86-64/sonar.sh stop
  9. Download MySQL Migrator

    wget https://binaries.sonarsource.com/Distribution/mysql-migrator/mysql-migrator-1.1.0.119.zip
  10. 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
  11. Delete the es5 data on the new sonarqube

    rm -rf /opt/sonarqube-6.7.5/data/es5/*
  12. Start the new sonarqube service

    /opt/sonarqube-6.7.5/bin/linux86-64/sonar.sh start
  13. Access the sonarqube setup menu

    http://sonarqube_url/setup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment