ㄴ이 문서는 Windows 환경에서 SonarQube 설치 가이드 문서를 제공한다.
설치 환경
- OS : Windows 10 Pro(64bit)
- SonarQube: v10.5.1
- JAVA: OpenJDK17 OpenJDK Downloads | Download Java JDK 8, 11, 17, & 21 | OpenLogic
- DB: PostgreSQL14 EDB: Open-Source, Enterprise Postgres Database Management (enterprisedb.com)
버전 호환성 확인
JAVA 설치
Download
JAVA 설치파일 web site에 접속하여 JAVA를 Download한다.
설치파일 경로지정
설치 파일 구분을 위해 C:\curvc-install\java 폴더 생성 및 압축 해제한다.
환경 변수 등록
JAVA_HOME을 WIndows 시스템 환경 변수에 등록한다.
- windows 검색창에서 '시스템 환경 변수 편집' 검색 → 시스템 속성 → 환경변수 → 시스템 변수 새로 만들기
- 변수이름: JAVA_HOME
- 변수 값: C:\curvc-install\java\jdk-17
- 시스템 속성→ 시스템 변수 → 'Path' 편집 → 새로 만들기
- %JAVA_HOME%\bin 추가
- %JAVA_HOME%\bin 추가
- cmd를 통해 java 설치 확인
java -version
DB(PostgreSQL) 설치
Download
PostgreSQL 설치파일 web site에 접속하여 PostgreSQL을 Download한다.
설치파일 경로지정
설치 파일 구분을 위해 C:\curvc-install\postgresql-14 폴더 생성 및 압축 해제한다.
data directory 초기화
-U postgres
: 데이터베이스 superuser 이름 지정.-A password
: 로컬 연결 시 인증 방법을 비밀번호로 설정.-W
: 새 superuser의 비밀번호를 묻는 메시지 설정.-E UTF8
: 데이터베이스의 인코딩을 UTF8로 설정.-D C:\curvc-install\postgresql-14\pgsql\data
: 데이터베이스 파일이 저장될 디렉터리를 지정.
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 실행
- 명령어 실행 전, logs 폴더 미리 생성 필요.
- pg_ctl: Postgresql 서버 제어용 실행 파일.
- -D: 구성 파일, 데이터베이스 파일저장 디렉토리 지정.
- -l: 기록될 로그 파일을 지정.
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 서비스가 정상적으로 실행되지 않을 경우, 다음 절차를 통해 삭제 후 재등록하여 실행한다.
- PostgreSQL 관련 모든 실행파일 종료
- 1~2분 텀을 두고 다음 명령어로 서비스 삭제
sc delete postgresql14 - 위 과정을 통해 서비스 재등록 후 실행
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 지정
- 설정이 적용을 위해 session 재실행 필요.
- setx 설정은 서버 부팅 이후에도 계속 적용된다.
// 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