SonarQube 설치(with PostgreSQL)

luna·2025년 4월 15일

guide

목록 보기
7/10

PostgreSQL 설치

https://www.postgresql.org/download/linux/ubuntu/

https://www.postgresql.org/docs/release/15.12/

# Import the repository signing key:
sudo apt install curl ca-certificates
sudo install -d /usr/share/postgresql-common/pgdg
sudo curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc

# Create the repository configuration file:
sudo sh -c 'echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'

# Update the package lists:
sudo apt update

PostgreSQL 15 설치

sudo apt install postgresql-15 -y

버전 확인

psql --version
psql (PostgreSQL) 15.12 (Ubuntu 15.12-1.pgdg22.04+1)

서비스 시작 및 자동 부팅 설정

sudo systemctl start postgresql
sudo systemctl enable postgresql

SonarQube용 DB와 사용자 생성

sudo -u postgres psql

-- 아래 SQL 입력
CREATE DATABASE sonarqube;
CREATE USER sonar WITH ENCRYPTED PASSWORD 'Luna@2025';
GRANT ALL PRIVILEGES ON DATABASE sonarqube TO sonar;

ALTER SCHEMA public OWNER TO sonar;
GRANT ALL ON SCHEMA public TO sonar;

\q  # 종료

conf 파일 수정

postgresql.conf

sudo vim /etc/postgresql/15/main/postgresql.conf 

#------------------------------------------------------------------------------
# CONNECTIONS AND AUTHENTICATION
#------------------------------------------------------------------------------

# - Connection Settings -

listen_addresses = '*'          # what IP address(es) to listen on;

pg_hba.conf

sudo vim /etc/postgresql/15/main/pg_hba.conf

local   replication     all                                     peer
host    replication     all             127.0.0.1/32            scram-sha-256
host    replication     all             ::1/128                 scram-sha-256

# 아래 내용추가 
host    all             all             0.0.0.0/0               md5

SonarQube 설치

https://www.sonarsource.com/open-source-editions/sonarqube-community-edition/

https://community.sonarsource.com/t/sonarqube-lts-is-now-sonarqube-lta/113837

https://community.sonarsource.com/t/will-the-lta-release-for-sonarqube-10-community-build-be-dropped-formerly-community-edition/130646

커뮤니티 버전 설치

cd ~/luna-workspace
wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-25.3.0.104237.zip
unzip sonarqube-25.3.0.104237.zip
mv sonarqube-25.3.0.104237 sonarqube

db connection 수정

vim ~/luna_workspace/sonarqube/conf/sonar.properties

# User credentials.
# Permissions to create tables, indices and triggers must be granted to JDBC user.
# The schema must be created first.
sonar.jdbc.username=sonar
sonar.jdbc.password=Luna@2025
sonar.jdbc.url=jdbc:postgresql://localhost:5432/sonarqube

sonar.web.host=0.0.0.0

# 포트 수정
sonar.web.port=9002

vm.max_map_count 설정

echo "vm.max_map_count=262144" | sudo tee -a /etc/sysctl.conf

설정 적용

sudo sysctl -p

방화벽 설정

sudo ufw allow 9002/tcp
sudo ufw status
  • id: admin
  • pw: admin
    • Lunashp@2025

SonarQube 재시작

${sonarqube_설치폴더}/bin/linux-x86-64/

# 먼저 중지
./sonar.sh stop

# 다시 시작
./sonar.sh start

# 상태 확인
./sonar.sh status

0개의 댓글