Hi Everyone,
We are migrating our sonarqube from one server (CentOS 7) to other server(Oracle Linux 8)
For migration we are using docker compose which has a dependency on db (postgresql)to connect with the database we are using sonar as user
====
Version on existing server
Sonarqube : 9.8.0-community
Java version - openjdk version “1.8.0_412”
Docker Copmose version - 1.29.2, build 5becea4c
OS version: NAME=“CentOS Linux” VERSION=“7 (Core)”
====
Versions on new server
Sonarqube : 9.8.0-community
Java version - openjdk version “1.8.0_442”
Docker Compose version: v2.32.4
Postgresql - 12
OS version - NAME=“Oracle Linux Server”, VERSION=“8.10”
below is docker compose file
version: "3"
services:
sonarqube:
image: sonarqube:9.8.0-community
depends_on:
- db
environment:
SONAR_JDBC_URL: jdbc:postgresql://db:5432/sonar
SONAR_JDBC_USERNAME: <jdbc_user>
SONAR_JDBC_PASSWORD: <jdbc_password>
volumes:
- sonarqube_data:/opt/sonarqube/data
- sonarqube_extensions:/opt/sonarqube/extensions
- sonarqube_logs:/opt/sonarqube/logs
ports:
- "9000:9000"
db:
image: postgres:12
environment:
POSTGRES_USER: <user>
POSTGRES_PASSWORD: <password>
volumes:
- postgresql:/var/lib/postgresql
- postgresql_data:/var/lib/postgresql/data
volumes:
sonarqube_data:
sonarqube_extensions:
sonarqube_logs:
postgresql:
postgresql_data:
Sonarqube is up an running on existing server, however,when we try to replicate same on new server, DB container is coming up but sonarqube container is getting exited after few seconds
Steps:
- Based on the docker compose configuration we are trying to create 2 containers (sonarqube and postgres)
- Creating a backup of postgresql in .sql and .tar format, do we need to stop container before taking a backup ?
- using scp, sending backup of postgresql to other server
- restoring backup (.sql)
Note :
- we took backup in .sql and .tar and try to restore, in .sql we observed that all the table, keys and other DB objects seems duplicate - how to cleanup and restore fresh ?
- but for .tar file restoration, DB restoration is happening, sonarqube container is not coming up afterwards
Below is the error
cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘jdk.internal.loader.ClassLoaders$AppClassLoader@5ffd2b27-org.sonar.server.platform.serverid.ServerIdManager’: Initialization of bean failed; nested exception is org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 2
2025.02.03 05:40:47 ERROR web[o.s.s.p.Platform] Background initialization failed. Stopping SonarQube
Please suggest, if these are the appropriate migration steps or something is missed ?
Do let us know if you need more information ?
PS: Please share documents, if any