Panel | ||||
---|---|---|---|---|
| ||||
Table of Contents
|
The Sonar 데이터베이스 복제 도구(Sonar DB Copy Tool is provided as part of the )은 SonarQube Enterprise Edition of SonarQube . The goal of this tool is to help you on the migration process from one DB vendor to another one. Let's imagine you used to have your SonarQube instance running on Oracle and you want to migrate to MySQL without loosing all your historical analysis. In that context the Sonar DB Copy Tool is there for you. In the following lines we will talk about source and target SonarQube database instances. The source instance is the one running the DB vendor you want to discard and the target the one running the new DB.
The Sonar DB Copy Tool will basically run as follows:
- connect to the source and target database
- read the data of the source database table by table
- save the data into the target database table by table
- recreate the sequences, index, ... on the target database
Installation
The Sonar DB Copy Tool is provided as a standalone JAR file. It must not be installed on your source or target SonarQube instance. Put the JAR wherever your want in your machine, the only prerequisites is that this machine must be authorized to access your source and target SonarQube database.
DB Copy Preparation Phase
The goal is to ask your SonarQube Server to create for you the tables (without content) and to have at the end a database schema equals on the source and target database.
- Your source and target database must be up and running
- Your SonarQube instance must be temporary stopped during the preparation and the running phase
On your target database, create an empty schema (without the tables)
Configure your SonarQube instance so it connects to the target database. (change properties in your conf/sonar.properties)
- Start your SonarQube that is going to connect to your empty target database
- Once your instance is up and running, you MUST stop it
- At this step, you have on your source and target database the exact same list of tables.
- Refresh the Database Statistics on the target database before restarting SonarQube
SonarQube version
If using a separate SonarQube instance for steps #4, #5 and #6, make sure it runs the same SonarQube version as the original one.
DB Copy Running Phase
Execute the Command Oracle 데이터베이스를 사용하던 SonarQube 인스턴스를 히스토리 데이터의 누락없이 MySQL 데이터베이스로 이전한다고 가정하면 , Sonar 데이터베이스 복제 도구는 매우 유용합니다. 다음 절에서 source 및 target SonarQube 데이터베이스 인스턴스에 대해 이야기합니다. source 인스턴스는 사용을 중지하고자 하는 데이터베이스를 사용하는 인스턴스이며, target 인스턴스는 새로운 데이터베이스를 사용하는 인스턴스입니다.
Sonar 데이터베이스 복제 도구는 다음과 같이 동작합니다:
- source 데이터베이스와 target 데이터베이스를 연결합니다.
- source 데이터베이스를 테이블 단위로 읽습니다.
- target 데이터베이스에 테이블 단위로 기록합니다.
- target 데이터베이스에 sequences, index 등의 정보를 다시 생성합니다.
설치
Sonar DB Copy Tool은 독립적인 JAR 파일로 제공됩니다. Source 혹은 Target SonarQube 인스턴스에 해당 파일을 설치하지 않도록 주의합니다. Sonar DB Copy Tool JAR 파일을 임의의 머신에 복사한 후, 해당 머신이 source 및 target SonarQube 인스턴스에 접근 가능하도록 합니다.
데이터베이스 복제 준비 단계
이 과정을 통해 SonarQube 서버가 테이블(컨텐츠가 없는)을 생성하고, source 및 target 데이터베이스가 동일한 데이터베이스 스키마를 가지도록 합니다.
- Source/Target 데이터베이스가 설치되어 실행 중이어야 합니다.
- SonarQube 인스턴스는 데이터베이스 복제 준비 및 실행 단계에서 일시 정지되어 있어야 합니다.
Target 데이터베이스에 빈 스키마를 생성합니다(테이블 없음).
SonarQube 인스턴스가 target 데이터베이스에 연결되도록 설정합니다(
conf/sonar.properties
속성 변경).- SonarQube를 실행해 비어있는 target 데이터베이스에 접속하도록 합니다.
- SonarQube 인스턴스가 실행된 후, SonarQube 인스턴스를 반드시 종료합니다.
- 이 단계에서 source/target 데이터베이스에는 완전히 동일한 테이블 리스트가 존재합니다.
- SonarQube를 재시작하기 전에 target 데이터베이스의 데이터베이스 통계를 초기화합니다.
SonarQube 버전
위의 4, 5, 6 단계를 분리된 SonarQube 인스턴스에서 수행한 경우, 최초의 SonarQube 버전과 동일한 버전을 사용했는지 확인합니다.
데이터베이스 복제 실행 단계
다음 명령어를 실행합니다:
|
Parameters파라미터:
Name | Value | Required ? | Description |
---|---|---|---|
-driverDest | <jdbc driver> |
선택 | target 데이터베이스의 JDBC Driver |
-driverSrc | <jdbc driver> |
선택 | source 데이터베이스의 JDBC Driver |
-help |
parameter help 출력 | |
-urlSrc | <jdbc url> |
필수 | source 데이터베이스의 JDBC URL |
-userSrc | <login> |
필수 |
source |
데이터베이스의 username | |
-pwdSrc | <password> |
필수 |
source |
데이터베이스의 password | |
-urlDest | <jdbc url> |
필수 | target 데이터베이스의 JDBC URL |
-userDest | <login> |
필수 |
target |
데이터베이스의 username | |
-pwdDest | <password> |
필수 |
target |
데이터베이스의 password | |
-T |
Example of Execution
First선택 | 마이그레이션 대상 테이블 (,로 구분) |
실행 예시
가장 먼저, sonar-db-copy
verifies if URLs can be reached and the database versions 명령어는 입력한 URL에 대한 접근 가능 여부 및 데이터베이스 버전을 확인합니다:
When the versions are different: the application stops버전이 다른 경우: 어플리케이션은 중지됩니다.
Sometime
when you have restarted the copy, the destination database version is 0 : this is not a problem, the copy will continue복제를 재시작하는 경우, target 데이터베이스 버전은 0이 됩니다: 오류 상황은 아니며, 복제는 계속됩니다.
Then it searches tables in source and destination database이후 source 및 target(destination) 데이터베이스의 테이블을 검색합니다:
If
there are missing tables, you will read this log누락된 테이블이 존재하는 경우, 다음 로그를 표시합니다:
Second 다음으로, sonar-db-copy truncates tables in target database and indicates the number of tables purged는 target 데이터베이스의 테이블의 길이를 줄이고, 제거한 테이블 수를 표시합니다:
Of course, the tables missing can not be purged물론, 누락된 테이블은 제거하지 않습니다:
Third다음으로, sonar-db-copy reproduces data from source to destination and adjusts the sequence of destination database after the copycopy는 source 데이터베이스의 데이터를 target 데이터베이스로 복제하고, 복제 후 target 데이터베이스의 순서를 조정합니다:
If
there are some missing tables누락된 테이블이 존재하는 경우:
If some errors appears during the copy it will NOT stop but displays
복제 중 오류가 발생하는 경우, 오류 메시지를 표시하고 복제를 진행합니다:
At the end 마지막으로 sonar-db-copy resume the difference between source and destination databasecopy는 source 데이터베이스와 target 데이터베이스의 차이를 표시합니다.