ㄴ이 문서는 Windows 환경에서 SonarQube 설치 가이드 문서를 제공한다.


설치 환경

버전 호환성 확인






JAVA 설치


Download

JAVA 설치파일 web site에 접속하여 JAVA를 Download한다.

설치파일 경로지정

설치 파일 구분을 위해 C:\curvc-install\java 폴더 생성 및 압축 해제한다.

환경 변수 등록

JAVA_HOME을 WIndows 시스템 환경 변수에 등록한다.








DB(PostgreSQL) 설치


Download

PostgreSQL 설치파일 web site에 접속하여 PostgreSQL을 Download한다.

설치파일 경로지정

설치 파일 구분을 위해 C:\curvc-install\postgresql-14 폴더 생성 및 압축 해제한다.


data directory 초기화

C:\curvc-install\postgresql-14\pgsql\bin\initdb.exe -U postgres -A password -W -E UTF8 -D C:\curvc-install\postgresql-14\pgsql\data



PostgreSQL 실행

C:\curvc-install\postgresql-14\pgsql\bin\pg_ctl -D C:\curvc-install\postgresql-14\pgsql\data -l C:\curvc-install\postgresql-14\pgsql\logs\server.log start



PostgreSQL 접속

C:\curvc-install\postgresql-14\pgsql\bin\psql -U postgres



DB 생성

SonarQube와 연동해야 할 DB를 구성 해 준다.

# 유저 생성
create role sonar with login password 'sonar';
 
# DB 생성(UTF8)
CREATE DATABASE sonar WITH OWNER sonar ENCODING 'UTF8' LC_COLLATE='en_US.utf8' LC_CTYPE='en_US.utf8' TEMPLATE=template0;
 
# 권한 설정
grant all privileges on DATABASE sonar to sonar;



PostgreSQL 서비스 등록

아래와 같이 Command로 실행하거나 Windows 서비스에서도 실행 가능하다.

PostgreSQL 서비스를 등록하기 전에 명령어로 실행한 PostgreSQL 를 종료해야 한다.


# 서비스 등록
cd C:\curvc-install\postgresql-14\pgsql\bin
pg_ctl register -N postgresql14 -D C:\curvc-install\postgresql-14\pgsql\data
 
# cmd 서비스 실행
net start postgresql14

등록 후 PostgreSQL 서비스가 정상적으로 실행되지 않을 경우, 다음 절차를 통해 삭제 후 재등록하여 실행한다.

  1. PostgreSQL 관련 모든 실행파일 종료
  2. 1~2분 텀을 두고 다음 명령어로 서비스 삭제
    sc delete postgresql14
  3. 위 과정을 통해 서비스 재등록 후 실행




Sonarqube 설치


Download

SonarQube의 web site 접속 하여 SonarQube를 Download 한다.


설치파일 경로지정

설치 파일 구분을 위해 C:\curvc-install\postgresql-14 폴더 생성 및 압축 해제한다.


Database 생성

SonarQube와 연동 해야 할 DB를 구성 해 준다.

psql
create role sonar with login password 'sonar';
create database sonar owner=sonar;
grant all privileges on DATABASE sonar to sonar;



Sonar 실행용 JAVA HOME 지정

// setx SONAR_JAVA_PATH "java.exe 경로"
setx SONAR_JAVA_PATH "C:\curvc-install\java\jdk-17\bin\java.exe"



sonar.properties 변경

경로 지정 한 sonarqube-10.5.1\conf\sonar.properties 파일을 변경 한다.



Windows Service 등록

경로 지정 한 sonarqube-10.5.1\bin\windows-x86-64 이동 한다.(운영체제가 32bit 경우 windows-x86-32 으로 이동한다.)

# 서비스 등록
\sonarqube\bin\windows-x84-64\StartService.bat install
 
# 서비스 실행
\sonarqube\bin\windows-x84-64\StartService.bat start


Website 접속

http://localhost:9000 or http://ipaddress:9000 으로 접속 한다.

ID / PW : admin / admin