Difference between revisions of "Sonar"
(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:/...") |
|||
Line 82: | Line 82: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | |||
+ | Step 6: Apply changes | ||
+ | |||
+ | <syntaxhighlight lang="bash"> | ||
+ | mysql > flush privileges; | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | |||
+ | Step 7: exit | ||
+ | |||
+ | <syntaxhighlight lang="bash"> | ||
+ | mysql > quit; | ||
+ | </syntaxhighlight> | ||
Line 87: | Line 100: | ||
==Configure SONAR== | ==Configure SONAR== | ||
− | + | Edit SONAR configuration file | |
− | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
Line 96: | Line 108: | ||
Adjust port number and context | Adjust port number and context | ||
− | #sonar.web.host: 0.0.0.0 | + | |
+ | <syntaxhighlight lang="bash"> | ||
+ | #sonar.web.host: 0.0.0.0 line 21 | ||
#sonar.web.port: 9000 | #sonar.web.port: 9000 | ||
sonar.web.context: /sonar | sonar.web.context: /sonar | ||
+ | </syntaxhighlight> | ||
+ | |||
Disable embedded H2DB and enable MySQL database | Disable embedded H2DB and enable MySQL database | ||
− | sonar.jdbc.username: sonar | + | |
+ | <syntaxhighlight lang="bash"> | ||
+ | sonar.jdbc.username: sonar line 41 | ||
sonar.jdbc.password: sonar | sonar.jdbc.password: sonar | ||
− | # sonar.jdbc.url: jdbc:h2:tcp://localhost:9092/sonar line 49 | + | # sonar.jdbc.url: jdbc:h2:tcp://localhost:9092/sonar line 49 |
sonar.jdbc.url: | sonar.jdbc.url: | ||
jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true | jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | |||
+ | Restart Sonar | ||
+ | |||
+ | <syntaxhighlight lang="bash"> | ||
+ | /etc/init.d/sonar start | ||
+ | </syntaxhighlight"> | ||
+ | |||
+ | ... wait for some times on 1st start (5 to 7 mn) !! | ||
− | |||
− | |||
− | |||
Check that Sonar is up | Check that Sonar is up | ||
− | + | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | netstat -pl --numeric | grep 9000 | ||
+ | </syntaxhighlight> | ||
You should have: | You should have: | ||
+ | <syntaxhighlight lang="bash"> | ||
tcp 0 0 0.0.0.0:9000 0.0.0.0:* LISTEN xxxxx/java | tcp 0 0 0.0.0.0:9000 0.0.0.0:* LISTEN xxxxx/java | ||
+ | </syntaxhighlight> | ||
+ | |||
Revision as of 10:01, 10 September 2014
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/
Contents
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';
Step 6: Apply changes
mysql > flush privileges;
Step 7: exit
mysql > quit;
Configure SONAR
Edit SONAR configuration file
vim /opt/sonar/conf/sonar.properties
Adjust port number and context
#sonar.web.host: 0.0.0.0 line 21
#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
# 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
Restart Sonar
/etc/init.d/sonar start
</syntaxhighlight">
... wait for some times on 1st start (5 to 7 mn) !!
Check that Sonar is up
<syntaxhighlight lang="bash">
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)
- 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