Could not open localhost:9000/sonar/ - ubuntu server 16.04.3

January 9, 2018 5.3k views
Elasticsearch Ubuntu 16.04

I implement below steps for Sonarqube installation but localhost i.e 192.168.0.111:9000/sonar/ does not display any page.

root@storage:~/Downloads# mysql -u root -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 7

Server version: 5.7.20-0ubuntu0.16.04.1 (Ubuntu)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

mysql> CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci;

Query OK, 1 row affected (0.00 sec)

mysql> CREATE USER 'sonar' IDENTIFIED BY 'sonar';

Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL ON sonar.* TO 'sonar'@'%' IDENTIFIED BY 'sonar';

Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> GRANT ALL ON sonar.* TO 'sonar'@'localhost' IDENTIFIED BY 'sonar';

Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> FLUSH PRIVILEGES;

Query OK, 0 rows affected (0.00 sec)

mysql>

root@storage:~/Downloads# wget https://sonarsource.bintray.com/Distribution/sonarqube/sonarqube-6.7.1.zip

root@storage:~/Downloads# unzip sonarqube-6.7.1.zip

root@storage:~/Downloads# mv sonarqube-6.7.1 /opt/sonar

root@storage:~/Downloads# 

Edit sonar.properties 

Open /opt/sonar/conf/sonar.properties with your favourite text editor, and modify it.

MySQL settings

Uncomment the user credentials and the MySQL related settings:

sonar.jdbc.username=sonar

sonar.jdbc.password=sonar

# Only the bundled driver is supported. It can not be changed.

sonar.jdbc.url=jdbc:mysql://storage.example.com:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false

Web Server settings

The following settings allow you to run the server on page http://localhost:9000/sonar

 # By default, ports will be used on all IP addresses associated with the server.

sonar.web.host=192.168.0.111

# The default value is root context (empty value).

sonar.web.context=/sonar

# TCP port for incoming HTTP connections. Default value is 9000.

sonar.web.port=9000

Implement SonarQube server as a service [optional]

Copy sonar.sh to etc/init.d/sonar and modify it according to your platform.

root@storage:~/Downloads# sudo cp /opt/sonar/bin/linux-x86-64/sonar.sh /etc/init.d/sonar

root@storage:~/Downloads#

root@storage:~/Downloads# vi /etc/init.d/sonar

root@storage:~/Downloads#

Insert two new lines:

# Adding below two new lines manually

SONAR_HOME=/opt/sonar

PLATFORM=linux-x86-64

Modify the following lines:

WRAPPER_CMD="${SONAR_HOME}/bin/${PLATFORM}/wrapper"

WRAPPER_CONF="${SONAR_HOME}/conf/wrapper.conf"

...

PIDDIR="/var/run"

To

# Wrapper

#WRAPPER_CMD="./wrapper"

#WRAPPER_CONF="../../conf/wrapper.conf"

WRAPPER_CMD="${SONAR_HOME}/bin/${PLATFORM}/wrapper"

WRAPPER_CONF="${SONAR_HOME}/conf/wrapper.conf"

# Location of the pid file.

#PIDDIR="."

PIDDIR="/var/run"

Register as a Linux service:

root@storage:~/Downloads# sudo update-rc.d -f sonar remove

insserv: warning: script 'K01youtrack' missing LSB tags and overrides



root@storage:~/Downloads# sudo chmod 755 /etc/init.d/sonar

root@storage:~/Downloads# sudo update-rc.d sonar defaults

insserv: warning: script 'K01youtrack' missing LSB tags and overrides



root@storage:~/Downloads#

Create Desktop icons [optional]

Install gnome-panel if missing:

root@storage:~/Downloads# sudo apt-get install gnome-panel --no-install-recommends

Open Dialog for creating new item for starting SonarQube:

 root@storage:~/Downloads# sudo gnome-desktop-item-edit /usr/share/applications/ --create-new

Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.

root@storage:~/Downloads#

GUI will open where you can type as following

Type : Application in Terminal

Name : SonarQube Start

Command : sudo /etc/init.d/sonar start

Comment: Start SonarQube Service

Copy the item to the Desktop:

root@storage:~/Downloads# sudo cp /usr/share/applications/SonarQube\ Start.desktop /home/example/Desktop/

root@storage:~/Downloads#

Open Dialog for creating new item for stopping SonarQube:

root@storage:~/Downloads# sudo gnome-desktop-item-edit /usr/share/applications/ --create-new

GUI will open, Type following or copy paste :

Type : Application in Terminal

Name : SonarQube Stop

Command: sudo /etc/init.d/sonar stop

Comment: Stop SonarQube Service

Copy the item to the Desktop:

root@storage:~/Downloads# sudo cp /usr/share/applications/SonarQube\ Stop.desktop /home/example/Desktop/

root@storage:~/Downloads#

sudo /etc/init.d/sonar start

Run SonarQube server

Start SonarQube server either by typing the direct command:

root@storage:~/Downloads# sudo /opt/sonar/bin/linux-x86-64/sonar.sh start

Starting SonarQube...

Started SonarQube.

root@storage:~/Downloads#

or by typing the service command:

sudo /etc/init.d/sonar start

or by clicking on the SonarQube Start icon which was created before (with password).

Visit SonarQube web page at http://storage.example.com:9000/sonar

Stop SonarQube server either by typing the direct command:

Stop SonarQube server either by typing the direct command:

root@storage:~/Downloads# sudo /opt/sonar/bin/linux-x86-64/sonar.sh stop

Stopping SonarQube...

SonarQube was not running.

or start by typing the service command:

root@storage:~/Downloads# sudo /etc/init.d/sonar start

Starting SonarQube...

Started SonarQube.

root@storage:~/Downloads#

You can confirm the status for Sonar by following

root@storage:~/Downloads# sudo systemctl start sonar

root@storage:~/Downloads# sudo systemctl status sonar

â— sonar.service - SYSV: Test Wrapper Sample Application

   Loaded: loaded (/etc/init.d/sonar; bad; vendor preset: enabled)

   Active: active (exited) since Sun 2018-01-07 15:32:47 +0545; 17s ago

     Docs: man:systemd-sysv-generator(8)

  Process: 18388 ExecStart=/etc/init.d/sonar start (code=exited, status=0/SUCCESS)

Jan 07 15:32:47 storage systemd[1]: Starting SYSV: Test Wrapper Sample Application...

Jan 07 15:32:47 storage sonar[18388]: Starting SonarQube...

Jan 07 15:32:47 storage sonar[18388]: Started SonarQube.

Jan 07 15:32:47 storage systemd[1]: Started SYSV: Test Wrapper Sample Application.

root@storage:~/Downloads#

Make Sure mysql is running

root@storage:~/Downloads# sudo systemctl status mysql

â— mysql.service - MySQL Community Server

   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)

   Active: active (running) since Sun 2018-01-07 14:30:22 +0545; 1h 4min ago

 Main PID: 9044 (mysqld)

    Tasks: 28

   Memory: 149.8M

      CPU: 2.618s

   CGroup: /system.slice/mysql.service

           └─9044 /usr/sbin/mysqld



Jan 07 14:30:21 storage systemd[1]: Starting MySQL Community Server...

Jan 07 14:30:22 storage systemd[1]: Started MySQL Community Server.

root@storage:~/Downloads#

Make Sure you install Apache2

root@storage:~/Downloads# sudo apt-get install apache2

Enable mod_proxy.

root@storage:~/Downloads# sudo a2enmod proxy

Enabling module proxy.

To activate the new configuration, you need to run:

  service apache2 restart

root@storage:~/Downloads# service apache2 restart

root@storage:~/Downloads# sudo a2enmod proxy_http

Considering dependency proxy for proxy_http:

Module proxy already enabled

Enabling module proxy_http.

To activate the new configuration, you need to run:

  service apache2 restart

root@storage:~/Downloads#

root@storage:~/Downloads# service apache2 restart

root@storage:~/Downloads#

 Create a new virtual host.

 root@storage:~/Downloads# sudo vi /etc/apache2/sites-available/sonar.example.com.conf

 <VirtualHost *:80>

    ServerName sonar.example.com

    ServerAdmin example@gmail.com

    ProxyPreserveHost On

    ProxyPass / http://192.168.0.111:9000/

    ProxyPassReverse / http://192.168.0.111:9000/

    TransferLog /var/log/apache2/sonar.example.com_access.log

    ErrorLog /var/log/apache2/sonar.example.com_error.log

</VirtualHost>

 Enable the virtual host.

sudo a2ensite sonar.example.com.conf

Start Apache and enable it to start automatically at boot time:

root@storage:~/Downloads# sudo systemctl start apache2

root@storage:~/Downloads# sudo systemctl enable apache2

apache2.service is not a native service, redirecting to systemd-sysv-install

Executing /lib/systemd/systemd-sysv-install enable apache2

insserv: warning: script 'K01sonar' missing LSB tags and overrides



 If your server is already running, restart it using:

root@storage:~/Downloads# sudo systemctl restart apache2

root@storage:~/Downloads#

Step 6: Finish install

 Start the SonarQube service:

root@storage:~/Downloads# sudo systemctl start sonar

 SonarQube is installed on your server, access the dashboard at the following address.


Just incase if you wanted to check log output then please check below

root@storage:/opt/sonar/logs# ls -ltr total 116 -rw-r--r-- 1 root root 42640 Jan 7 18:12 es.2018-01-07.log -rw-r--r-- 1 root root 5330 Jan 8 16:39 es.2018-01-08.log -rw-r--r-- 1 root root 21320 Jan 9 16:42 es.log -rw-r--r-- 1 root root 30319 Jan 9 16:42 sonar.log root@storage:/opt/sonar/logs#

https://drive.google.com/file/d/1dh60U8z5NZNBxU6U2hAoEZ9sjsSsdpFm/view?usp=sharing

https://drive.google.com/file/d/1iFc5ibZRtAe8TtggI0gb87oJxv_Wtqpo/view?usp=sharing

NMAP Output

root@storage:/opt/sonar/logs# nmap -v -p 9000 192.168.0.227

Starting Nmap 7.01 ( https://nmap.org ) at 2018-01-09 16:54 +0545 Initiating SYN Stealth Scan at 16:54 Scanning storage.bsaitechnosales.com (192.168.0.227) [1 port] Completed SYN Stealth Scan at 16:54, 0.22s elapsed (1 total ports) Nmap scan report for storage.example.com (192.168.0.227) Host is up (0.000041s latency). PORT STATE SERVICE 9000/tcp closed cslistener

Read data files from: /usr/bin/../share/nmap Nmap done: 1 IP address (1 host up) scanned in 0.32 seconds Raw packets sent: 1 (44B) | Rcvd: 2 (84B)

ES LOG OUTPUT 2018.01.09 09:21:25 ERROR es[][o.e.b.Bootstrap] Exception java.lang.RuntimeException: can not run elasticsearch as root at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:106) ~[ elasticsearch-5.6.3.jar:5.6.3] at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:195) ~[elasticsearc h-5.6.3.jar:5.6.3] at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:342) [elasticsearch- 5.6.3.jar:5.6.3]

SONAR.LOG Output

root@storage:/opt/sonar/logs# more sonar.log
Wrapper Started as Daemon
Launching a JVM...
Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved.

2018.01.07 15:23:08 INFO app[][o.s.a.AppFileSystem] Cleaning or creating temp directory
/opt/sonar/temp
2018.01.07 15:23:08 INFO app[][o.s.a.es.EsSettings] Elasticsearch listening on /127.0.0.
1:9001
2018.01.07 15:23:08 INFO app[][o.s.a.p.ProcessLauncherImpl] Launch process[[key='es', ip
cIndex=1, logFilenamePrefix=es]] from [/opt/sonar/elasticsearch]: /opt/sonar/elasticsearc
h/bin/elasticsearch -Epath.conf=/opt/sonar/temp/conf/es
2018.01.07 15:23:08 INFO app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up a
nd running
2018.01.07 15:23:08 INFO app[][o.e.p.PluginsService] no modules loaded
2018.01.07 15:23:08 INFO app[][o.e.p.PluginsService] loaded plugin [org.elasticsearch.tr
ansport.Netty4Plugin]
2018.01.07 15:23:08 WARN app[][o.s.a.p.AbstractProcessMonitor] Process exited with exit
value [es]: 1
2018.01.07 15:23:08 INFO app[][o.s.a.SchedulerImpl] Process [es] is stopped
2018.01.07 15:23:08 INFO app[][o.s.a.SchedulerImpl] SonarQube is stopped
Wrapper Stopped
Be the first one to answer this question.