이 문서는 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
: 데이터베이스 파일이 저장될 디렉터리를 지정.
<postgresql/install/directory>\pgsql\bin\initdb.exe -U postgres -A password -W -E UTF8 -D <postgresql/install/directory>\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: 기록될 로그 파일을 지정
<postgresql/install/directory>\pgsql\bin\pg_ctl -D <postgresql/install/directory>\pgsql\data -l <postgresql/install/directory>\pgsql\logs\server.log start
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 접속
<postgresl/install/directory>\pgsql\bin\psql -U postgres
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 서비스 등록
# 서비스 등록 cd C:\curvc-install\postgresql-14\pgsql\bin pg_ctl register -N postgresql14 -D d:\pgsql\data # cmd 서비스 실행(Window service 창에서 클릭하여 실행도 가능.) cd C:\WINDOWS\system32 net start 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 지정
// setx SONAR_JAVA_PATH "java.exe 경로" setx SONAR_JAVA_PATH "C:\Program Files\java_home\bin\java.exe"
Sonar.properties 변경
경로 지정 한 sonarqube-6.4\conf\sonar.properties 파일을 변경 한다.
Windows Service 등록
경로 지정 한 sonarqube-6.4\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