Sonar

Revision as of 09:58, 10 September 2014 by WikiFreak (talk | contribs) (Created page with "Category:Development Category:Linux The following instructions are for Ubuntu 14.04 LTS. You can find all these instructions and more on the Official how-to: http:/...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


The following instructions are for Ubuntu 14.04 LTS.


You can find all these instructions and more on the Official how-to: http://sonar-pkg.sourceforge.net/


Requirements

You need to have a MySQL server available.


Installation (Ubuntu)

Get package

vim /etc/apt/sources.list


Add a new repository

deb http://downloads.sourceforge.net/project/sonar-pkg/deb binary/


Update packages list and install sonar

apt-get update
apt-get install sonar


Create SONAR database

SONAR needs to work with a database.

You can create a new MySQL database + MySQL user for it.


Step 1: Login to MySQL as ROOT

mysql -u root -p
Enter password:


Step 2: Create the Database

mysql > create database sonar;


Step 3: Verify that it’s there

mysql > show databases;


Step 4: Create the User

mysql > create user sonar;


Step 5: Grant privileges while assigning the password

mysql > grant all on sonar.* to 'sonar'@'localhost' identified by 'sonar';



Configure SONAR

=

vim /opt/sonar/conf/sonar.properties


Adjust port number and context

  1. sonar.web.host: 0.0.0.0  line 21
  2. sonar.web.port: 9000

sonar.web.context: /sonar

Disable embedded H2DB and enable MySQL database sonar.jdbc.username: sonar  line 41 sonar.jdbc.password: sonar

  1. sonar.jdbc.url: jdbc:h2:tcp://localhost:9092/sonar  line 49

sonar.jdbc.url: jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true

Start Sonar

  1. /etc/init.d/sonar start

… wait for some times on 1st start (5 to 7 mn) !!

Check that Sonar is up

  1. netstat -pl --numeric | grep 9000

You should have: tcp 0 0 0.0.0.0:9000 0.0.0.0:* LISTEN xxxxx/java


Add apache2 proxy rule Sonar access will be done through Apache2 server To use the proxy rule, the target /sonar must match the root URL (see sonar.properties)

  1. vim /etc/apache2/mods-enabled/proxy.conf

Add:

       # Service SONAR runs on a different port
       ProxyPass /sonar http://localhost:9000/sonar
       ProxyPassReverse /sonar http://localhost:9000/sonar

Test Sonar Navigate to http://myServer:9000/sonar or http://myServer/sonar

The default user and password are “admin” and “admin“.

Logs Sonar logs are in: /opt/sonar/logs/sonar.log

Upgrade Sonar Sometimes when there are a lot of changes the new sonar version required some database change. The service will not be available until you go to http://myServer/sonar/setup You have to agree to the terms and upgrade database