Sonar & Postgresql install to the Ubuntu

This is the first  experience of the usage of Postgresql & SonarQube.

It takes me a long time to deploying the environment.

Here is the stop. 

The purpose is to install the Sonar to analysis the my code. 

So the first  step is downloading SonarQube.   

https://www.sonarqube.org/downloads/

unzip the file, and configure sonar.

vi sonarqube-6.7.3/conf/sonar.properties 

#----- Embedded Database (default)
# H2 embedded database server listening port, defaults to 9092
#sonar.embeddedDatabase.port=9092
Change 
Change #sonar.embeddedDatabase.port=9092 to 
sonar.embeddedDatabase.port=9092

Then, run script: sonarqube-6.7.3/bin/linux-x86-64/sonar.sh console

Very good, It works.

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    | 2018.05.05 17:12:53 INFO  app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /home/fish/work/tools/sonarqube-6.7.3/temp
jvm 1    | 2018.05.05 17:12:53 INFO  app[][o.s.a.es.EsSettings] Elasticsearch listening on /127.0.0.1:9001
jvm 1    | 2018.05.05 17:12:53 INFO  app[][o.s.a.p.ProcessLauncherImpl] Launch process[[key='es', ipcIndex=1, logFilenamePrefix=es]] from [/home/fish/work/tools/sonarqube-6.7.3/elasticsearch]: /home/fish/work/tools/sonarqube-6.7.3/elasticsearch/bin/elasticsearch -Epath.conf=/home/fish/work/tools/sonarqube-6.7.3/temp/conf/es
jvm 1    | 2018.05.05 17:12:53 INFO  app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
jvm 1    | 2018.05.05 17:12:53 INFO  app[][o.e.p.PluginsService] no modules loaded
jvm 1    | 2018.05.05 17:12:53 INFO  app[][o.e.p.PluginsService] loaded plugin [org.elasticsearch.transport.Netty4Plugin]
jvm 1    | 2018.05.05 17:12:59 INFO  app[][o.s.a.SchedulerImpl] Process[es] is up
jvm 1    | 2018.05.05 17:12:59 INFO  app[][o.s.a.p.ProcessLauncherImpl] Launch process[[key='web', ipcIndex=2, logFilenamePrefix=web]] from [/home/fish/work/tools/sonarqube-6.7.3]: /usr/lib/jvm/jdk1.8.0_171/jre/bin/java -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djava.io.tmpdir=/home/fish/work/tools/sonarqube-6.7.3/temp -Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -cp ./lib/common/*:./lib/server/*:/home/fish/work/tools/sonarqube-6.7.3/lib/jdbc/h2/h2-1.3.176.jar org.sonar.server.app.WebServer /home/fish/work/tools/sonarqube-6.7.3/temp/sq-process1112594729594608571properties
jvm 1    | 2018.05.05 17:13:19 INFO  app[][o.s.a.SchedulerImpl] Process[web] is up
jvm 1    | 2018.05.05 17:13:19 INFO  app[][o.s.a.p.ProcessLauncherImpl] Launch process[[key='ce', ipcIndex=3, logFilenamePrefix=ce]] from [/home/fish/work/tools/sonarqube-6.7.3]: /usr/lib/jvm/jdk1.8.0_171/jre/bin/java -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djava.io.tmpdir=/home/fish/work/tools/sonarqube-6.7.3/temp -Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -cp ./lib/common/*:./lib/server/*:./lib/ce/*:/home/fish/work/tools/sonarqube-6.7.3/lib/jdbc/h2/h2-1.3.176.jar org.sonar.ce.app.CeServer /home/fish/work/tools/sonarqube-6.7.3/temp/sq-process4707071496014359227properties
jvm 1    | 2018.05.05 17:13:23 INFO  app[][o.s.a.SchedulerImpl] Process[ce] is up
jvm 1    | 2018.05.05 17:13:23 INFO  app[][o.s.a.SchedulerImpl] SonarQube is up

Open the web site, showing that it is not recommend to use the default database.

So, install a Database, Postgresql, Let's go!

sudo apt install postgreqsql 
/etc/init.d/postgresql start

After all, Let's learn how to use the database.

sudo -u postgres
postgres@fishd:~$ psql 
psql (9.5.12)
Type "help" for help.

postgres=# ALTER USER postgres PASSWORD 'admin';  #Set a password. Don't miss ';'
ALTER ROLE
postgres=# 

In the file "sonarqube-6.7.3/conf/sonar.properties ", We can get the database name of PostgreSql is "sonar".

So quit the psql; and create a database named sonar

postgres=# 
postgres=# \q
postgres@fishd:~$ createdb sonar 

Have a test,

psql -U postgres -h 127.0.0.1 
Password for user postgres: 
psql: FATAL:  password authentication failed for user "postgres"
FATAL:  password authentication failed for user "postgres"

Oh no, something wrong, have a google.

# DO NOT DISABLE!
# If you change this first entry you will need to make sure that the
# database superuser can access the database using some other method.
# Noninteractive access to all databases is required during automatic
# maintenance (custom daily cronjobs, replication, and similar tasks).
#
# Database administrative login by Unix domain socket
local   all             postgres                              peer # Change To  trust

Save and restart postgresql, and login success. Then write the user name and password to the sonar configuration.

# User credentials.
# Permissions to create tables, indices and triggers must be granted to JDBC user.
# The schema must be created first.
sonar.jdbc.username=postgres
sonar.jdbc.password=admin


Restart sonar, OK.



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值