Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configuration of Sonarqube with postgresql

I'm struggling to install sonarqube (v7.6) using postgresql as database. I have followed the instructions of the sonar website : https://docs.sonarqube.org/latest/setup/install-server/

But I'm stuck with this vague error :

sh /opt/sonarqube/bin/linux-x86-64/sonar.sh console
Running SonarQube...
wrapper | --> Wrapper Started as Console
wrapper | Launching a JVM...
jvm 1 | Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
jvm 1 | Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved.
jvm 1 | 
jvm 1 | 2019.02.12 07:18:55 INFO app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /opt/sonarqube/temp
jvm 1 | 2019.02.12 07:18:55 INFO app[][o.s.a.es.EsSettings] Elasticsearch listening on /127.0.0.1:9001
jvm 1 | 2019.02.12 07:18:55 INFO app[][o.s.a.p.ProcessLauncherImpl] Launch process[[key='es', ipcIndex=1, logFilenamePrefix=es]] from [/opt/sonarqube/elasticsearch]: /opt/sonarqube/elasticsearch/bin/elasticsearch -Epath.conf=/opt/sonarqube/temp/conf/es
jvm 1 | 2019.02.12 07:18:56 INFO app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
jvm 1 | 2019.02.12 07:18:56 INFO app[][o.e.p.PluginsService] no modules loaded
jvm 1 | 2019.02.12 07:18:56 INFO app[][o.e.p.PluginsService] loaded plugin [org.elasticsearch.transport.Netty4Plugin]
jvm 1 | 2019.02.12 07:19:10 INFO app[][o.s.a.SchedulerImpl] Process[es] is up
jvm 1 | 2019.02.12 07:19:10 INFO app[][o.s.a.p.ProcessLauncherImpl] Launch process[[key='web', ipcIndex=2, logFilenamePrefix=web]] from [/opt/sonarqube]: /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djava.io.tmpdir=/opt/sonarqube/temp -Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -cp ./lib/common/*:/opt/sonarqube/lib/jdbc/postgresql/postgresql-42.2.5.jar org.sonar.server.app.WebServer /opt/sonarqube/temp/sq-process7062216312618470165properties
jvm 1 | 2019.02.12 07:19:19 INFO app[][o.s.a.SchedulerImpl] Process [web] is stopped
jvm 1 | 2019.02.12 07:19:19 INFO app[][o.s.a.SchedulerImpl] Process [es] is stopped
jvm 1 | 2019.02.12 07:19:19 WARN app[][o.s.a.p.AbstractProcessMonitor] Process exited with exit value [es]: 143
jvm 1 | 2019.02.12 07:19:19 INFO app[][o.s.a.SchedulerImpl] SonarQube is stopped
wrapper | <-- Wrapper Stopped

Here is my installation procedure :

# System config :
sysctl -w vm.max_map_count=262144
ulimit -n 65536

# Postgresql install (v9.6.10)
apt-get install -y postgresql
su - postgres
psql
CREATE USER sonar ;
ALTER USER sonar WITH PASSWORD 'PASSWORD';
CREATE DATABASE sonardb WITH ENCODING 'UTF8';
ALTER DATABASE sonardb OWNER TO sonar;
ALTER USER sonar SET search_path TO sonardb;

# Sonar install
apt-get install -y unzip
wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-7.6.zip
unzip sonarqube-7.6.zip
mv sonarqube-7.6 /opt/sonarqube

# Add sonar user
adduser sonar
chown -R sonar /opt/sonarqube

And finally add the postgresql conf in /opt/sonarqube/conf/sonar.properties :

sonar.jdbc.username=sonar
sonar.jdbc.password=PASSWORD
sonar.jdbc.url=jdbc:postgresql://localhost:5432/sonardb

I have tried a lot of different setups. But I'm always ending with the same error. I assume that the problem comes from my postgresql setup because the default H2 database works fine. I think my error is pretty dumb, but I can't figure it out.

Can someone point out my mistake?

like image 704
Oreste Viron Avatar asked Feb 12 '19 08:02

Oreste Viron


People also ask

Which database is best for SonarQube?

If you want to install a DB for your own self, for learning, I would recommend MySQL.


1 Answers

I finally found additional error logs in /opt/sonarqube/logs/web.log

The problem is that I mixed up postgresql "database" and "schema" :

ALTER USER sonar SET search_path TO sonardb;

The search_path must point to the schema, not the database. But the default schema is public, so removing this line in the install script should do the job.

like image 80
Oreste Viron Avatar answered Sep 28 '22 20:09

Oreste Viron