Setup Postgresql Server
Use "cross distribution packages" postgres_9.2.4-1.i386.openscg.deb and install it on Mint 14. This kind of installer can be installed without GUI environment, suitable for Ubuntu Server. Installer of Postgresql is much smaller than its mysql counterpart.
You can follow the instructions at OpenSCG to setup server and manipulate data.
-
Download "cross distribution packages" postgres_9.2.4-1.i386.openscg.deb;
-
install it with
dpkg -i
; -
start service:
/etc/init.d/postgres-9.2-openscg start
; -
verify service:
invoke-rc.d postgres-9.2-openscg status
, andsu postgres
to verify if user postgres has been created; -
. /opt/postgres/9.2/pg92-openscg.env
-
verify connection:
psql
, then you can see the postgresql prompt "postgres=#", use "\l" to list all databases;
Setup Connection between Sonar and Postgresql database
-
build sonar database in Postgresql
i. create user sonar:
postgres=# create user sonar with password 'sonar';
, notice you must ";" at end of command,i. verify:
postgres=# \du
;i. create database:
postgres-# create database sonar with owner sonar encoding 'UTF8';
i. verify:
postgres=# \l
; -
modify sonar jdbc url: modify "sonar.jdbc.url" as "jdbc:postgresql://localhost/sonar" in file $SONAR_HOME/conf/sonar.properties (remember comment out default h2 jdbc url);
-
start sonar server:
$SONAR_HOME/bin/sonar.sh console
; -
verify:
psql -h localhost -d sonar -U sonar
, thensonar=> select table_name from information_schema.tables where table_schema='public';
, you can see "49 rows" at the bottom of the output;
Note 2: When upgrade or reinstall SonarQube, and after modifying configuration file, you have to goto http://10.0.2.74:9000/setup to upgrade database manually, or you will see "sonar is under maintenance. please check back later".
Enable Remote Access to Postgresql Server(unnecessary for Sonar)
(updated at 2013.12.23: The following operation is very dangerous and not preferred.
Ref: http://serverfault.com/questions/110154/whats-the-default-superuser-username-password-for-postgres-after-a-new-install/325596#325596
-
setup password for user postgres:
sudo passwd postgres
; -
login as postgres:
su postgres
(the $HOME on Ubuntu should be /etc/postgres/9.2); -
add a line in data/pg_hba.conf: "host all all 0.0.0.0/0 md5";
-
modify listen_addresses="127.0.0.1" to "*" in data/postgresql.conf;
-
verify(on client machine):
psql -h 10.21.3.31 -U postgres -d postgres
(-U means username, -d means database);
or use squirrel-sql client: download driver jar postgresql-9.2-1002.jdbc4.jar at jdbc.postgresql.org and copy to $SQUIRREL_HOME/lib, start squirrel-sql, create a connection with url="jdbc:postgresql://10.21.3.31/postgres", username="postgres" and password="...";