SonarQube 8.4.2.36762 最新版在 Ubuntu 下的安装配置

Stella981
• 阅读 558

        SonarQube 是一个开源工具,可以进行自动代码审查,可帮助进行代码质量分析和报告。它会扫描您的源代码以查找潜在的错误,漏洞和可维护性问题,然后将结果显示在报告中,该报告将使您能够识别应用程序中的潜在问题。

        一、下载最新版本的安装包

   一般都直接上官网下载,打开官网链接   https://www.sonarqube.org/downloads/     如下图所示:

SonarQube 8.4.2.36762 最新版在 Ubuntu  下的安装配置

可以看到 FREE & OPEN SOURCE ,然后点击下载按钮,跳到下载页面,显示    Thank you for downloading SonarQube Community Edition ,Copy 下载链接,在终端上直接下载即可,如下图所示:

   SonarQube 8.4.2.36762 最新版在 Ubuntu  下的安装配置

       二、准备安装配置

       SonarQube 软件安装需要 java 环境,java 环境的配置在此就忽略默认都配置好了,直接安装下面需要的数据库环境,最新版本目前就只支持如下的3种数据库,如想使用 MySQL 数据库的,那只能下载旧的 7.7 版本或以前的 7.6、7.5 版本了。

SonarQube 8.4.2.36762 最新版在 Ubuntu  下的安装配置

我要安装最新版本,就选 PostgreSQL  数据库进行安装,在线直接命令行执行安装。

sudo apt-get -y install postgresql postgresql-contrib

[sudo] password for scm:

Reading package lists... Done

Building dependency tree

Reading state information... Done

The following additional packages will be installed:

libpq5 libsensors4 postgresql-10 postgresql-client-10 postgresql-client-common postgresql-common ssl-cert sysstat

Suggested packages:

lm-sensors postgresql-doc locales-all postgresql-doc-10 libjson-perl openssl-blacklist isag

The following NEW packages will be installed:

libpq5 libsensors4 postgresql postgresql-10 postgresql-client-10 postgresql-client-common postgresql-common postgresql-contrib ssl-cert

sysstat

0 upgraded, 10 newly installed, 0 to remove and 163 not upgraded.

Need to get 5,353 kB of archives.

After this operation, 21.1 MB of additional disk space will be used.

Get:1 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libpq5 amd64 10.14-0ubuntu0.18.04.1 [107 kB]

Get:2 http://archive.ubuntu.com/ubuntu bionic/main amd64 libsensors4 amd64 1:3.4.0-4 [28.8 kB]

Get:3 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 postgresql-client-common all 190ubuntu0.1 [29.6 kB]

Get:4 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 postgresql-client-10 amd64 10.14-0ubuntu0.18.04.1 [941 kB]

Get:5 http://archive.ubuntu.com/ubuntu bionic/main amd64 ssl-cert all 1.0.39 [17.0 kB]

Get:6 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 postgresql-common all 190ubuntu0.1 [157 kB]

Get:6 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 postgresql-common all 190ubuntu0.1 [157 kB]

Get:7 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 postgresql-10 amd64 10.14-0ubuntu0.18.04.1 [3,766 kB]

Get:7 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 postgresql-10 amd64 10.14-0ubuntu0.18.04.1 [3,766 kB]

Get:8 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 postgresql all 10+190ubuntu0.1 [5,884 B]

Get:9 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 postgresql-contrib all 10+190ubuntu0.1 [5,896 B]

Get:10 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 sysstat amd64 11.6.1-1ubuntu0.1 [295 kB]

Fetched 5,130 kB in 6min 55s (12.4 kB/s)

Preconfiguring packages ...

Selecting previously unselected package libpq5:amd64.

(Reading database ... 67010 files and directories currently installed.)

Preparing to unpack .../0-libpq5_10.14-0ubuntu0.18.04.1_amd64.deb ...

Unpacking libpq5:amd64 (10.14-0ubuntu0.18.04.1) ...

Selecting previously unselected package libsensors4:amd64.

Preparing to unpack .../1-libsensors4_1%3a3.4.0-4_amd64.deb ...

Unpacking libsensors4:amd64 (1:3.4.0-4) ...

Selecting previously unselected package postgresql-client-common.

Preparing to unpack .../2-postgresql-client-common_190ubuntu0.1_all.deb ...

Unpacking postgresql-client-common (190ubuntu0.1) ...

Selecting previously unselected package postgresql-client-10.

Preparing to unpack .../3-postgresql-client-10_10.14-0ubuntu0.18.04.1_amd64.deb ...

Unpacking postgresql-client-10 (10.14-0ubuntu0.18.04.1) ...

Selecting previously unselected package ssl-cert.

Preparing to unpack .../4-ssl-cert_1.0.39_all.deb ...

Unpacking ssl-cert (1.0.39) ...

Selecting previously unselected package postgresql-common.

Preparing to unpack .../5-postgresql-common_190ubuntu0.1_all.deb ...

Adding 'diversion of /usr/bin/pg_config to /usr/bin/pg_config.libpq-dev by postgresql-common'

Unpacking postgresql-common (190ubuntu0.1) ...

Selecting previously unselected package postgresql-10.

Preparing to unpack .../6-postgresql-10_10.14-0ubuntu0.18.04.1_amd64.deb ...

Unpacking postgresql-10 (10.14-0ubuntu0.18.04.1) ...

Selecting previously unselected package postgresql.

Preparing to unpack .../7-postgresql_10+190ubuntu0.1_all.deb ...

Unpacking postgresql (10+190ubuntu0.1) ...

Selecting previously unselected package postgresql-contrib.

Preparing to unpack .../8-postgresql-contrib_10+190ubuntu0.1_all.deb ...

Unpacking postgresql-contrib (10+190ubuntu0.1) ...

Selecting previously unselected package sysstat.

Preparing to unpack .../9-sysstat_11.6.1-1ubuntu0.1_amd64.deb ...

Unpacking sysstat (11.6.1-1ubuntu0.1) ...

Processing triggers for ureadahead (0.100.0-21) ...

Setting up ssl-cert (1.0.39) ...

Setting up libpq5:amd64 (10.14-0ubuntu0.18.04.1) ...

Processing triggers for libc-bin (2.27-3ubuntu1) ...

Setting up postgresql-client-common (190ubuntu0.1) ...

Processing triggers for systemd (237-3ubuntu10.24) ...

Setting up postgresql-common (190ubuntu0.1) ...

Adding user postgres to group ssl-cert

 

Creating config file /etc/postgresql-common/createcluster.conf with new version

Building PostgreSQL dictionaries from installed myspell/hunspell packages...

Removing obsolete dictionary files:

Created symlink /etc/systemd/system/multi-user.target.wants/postgresql.service → /lib/systemd/system/postgresql.service.

Setting up libsensors4:amd64 (1:3.4.0-4) ...

Processing triggers for man-db (2.8.3-2ubuntu0.1) ...

Setting up postgresql-client-10 (10.14-0ubuntu0.18.04.1) ...

update-alternatives: using /usr/share/postgresql/10/man/man1/psql.1.gz to provide /usr/share/man/man1/psql.1.gz (psql.1.gz) in auto mode

Setting up sysstat (11.6.1-1ubuntu0.1) ...

 

Creating config file /etc/default/sysstat with new version

update-alternatives: using /usr/bin/sar.sysstat to provide /usr/bin/sar (sar) in auto mode

Created symlink /etc/systemd/system/multi-user.target.wants/sysstat.service → /lib/systemd/system/sysstat.service.

Setting up postgresql-10 (10.14-0ubuntu0.18.04.1) ...

Creating new PostgreSQL cluster 10/main ...

/usr/lib/postgresql/10/bin/initdb -D /var/lib/postgresql/10/main --auth-local peer --auth-host md5

The files belonging to this database system will be owned by user "postgres".

This user must also own the server process.

 

The database cluster will be initialized with locale "en_US.UTF-8".

The default database encoding has accordingly been set to "UTF8".

The default text search configuration will be set to "english".

 

Data page checksums are disabled.

 

fixing permissions on existing directory /var/lib/postgresql/10/main ... ok

creating subdirectories ... ok

selecting default max_connections ... 100

selecting default shared_buffers ... 128MB

selecting default timezone ... Etc/UTC

selecting dynamic shared memory implementation ... posix

creating configuration files ... ok

running bootstrap script ... ok

performing post-bootstrap initialization ... ok

syncing data to disk ... ok

 

Success. You can now start the database server using:

 

/usr/lib/postgresql/10/bin/pg_ctl -D /var/lib/postgresql/10/main -l logfile start

 

Ver Cluster Port Status Owner    Data directory              Log file

10  main    5432 down   postgres /var/lib/postgresql/10/main /var/log/postgresql/postgresql-10-main.log

update-alternatives: using /usr/share/postgresql/10/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode

Setting up postgresql (10+190ubuntu0.1) ...

Setting up postgresql-contrib (10+190ubuntu0.1) ...

Processing triggers for ureadahead (0.100.0-21) ...

Processing triggers for systemd (237-3ubuntu10.24) ...

Processing triggers for libc-bin (2.27-3ubuntu1) ...

如上的显示结果,就说明 PostgreSQL 数据库已安装完成,查看一下已安装的数据库版本信息。

 

~$ /usr/lib/postgresql/10/bin/ postgres -V

postgres (PostgreSQL) 10.14 (Ubuntu 10.14-0ubuntu0.18.04.1)

PostgreSQL 数据库安装完后会自动创建 postgres 用户,此时,也可以查看一下系统用户是否有 postgres 用户存在。

SonarQube 8.4.2.36762 最新版在 Ubuntu  下的安装配置

PostgreSQL 数据库顺利安装完成后,系统会自动启动服务,也可以查看一下启动状态。

SonarQube 8.4.2.36762 最新版在 Ubuntu  下的安装配置

数据库也正常启动运行,下面接着创建 SonarQube 系统所需要的数据库。

首先,登录 PostgreSQL 数据库,默认是没有设置登录密码的,可以直接登录进去。

SonarQube 8.4.2.36762 最新版在 Ubuntu  下的安装配置

\h  查看帮助,可以列出很多指令来,需要的可以查看帮助说明。

开始创建 sonar 数据库

SonarQube 8.4.2.36762 最新版在 Ubuntu  下的安装配置

\l  查看一下创建的数据库,sonar 数据库已顺利创建好。

接着创建 sonar 用户

SonarQube 8.4.2.36762 最新版在 Ubuntu  下的安装配置

\du  查看创建的用户,也都顺利创建完成。

postgres=# alter database sonar owner to sonar;   #更改 sonar  数据库拥有者 (这一步是必须的,否则会 sonarqube 会连接失败)

设置 sonar 用户密码 (否则会导致连不上数据库)  接着在执行3条指令,给 sonar 用户授权。

#给 sonar 用户授权

#给 sonar 用户授权

#给 sonar 用户授权

SonarQube 8.4.2.36762 最新版在 Ubuntu  下的安装配置

上面的步骤对  PostgreSQL 数据库配置也就完成了。

三、安装配置 SonarQube

解压安装包,放到自己喜欢的目录下,我的安装目录如下:

SonarQube 8.4.2.36762 最新版在 Ubuntu  下的安装配置

会修改系统配置文件,所以要先备份好原始配置文件,然后在去修改配置文件。

主要就是修改  sonar.properties  配置文件

SonarQube 8.4.2.36762 最新版在 Ubuntu  下的安装配置

修改如下绿框标识的几个地方

SonarQube 8.4.2.36762 最新版在 Ubuntu  下的安装配置

继续往下修改如下几个地方

SonarQube 8.4.2.36762 最新版在 Ubuntu  下的安装配置

修改完成,保存修改的配置文件。然后到 bin 目录下去启动系统。

SonarQube 8.4.2.36762 最新版在 Ubuntu  下的安装配置

此时可以看到系统已经启动了,查看一下系统启动的服务,看看系统端口号是否正常。

SonarQube 8.4.2.36762 最新版在 Ubuntu  下的安装配置

此时可以访问页面,看看系统运行的真面目吧。

SonarQube 8.4.2.36762 最新版在 Ubuntu  下的安装配置

拉到系统页底,就可以看到安装系统的版本信息。

总结如下:

1、SonarQube 系统不能使用系统的 root 账户启动! SonarQube 系统不能使用系统的 root 账户启动! SonarQube 系统不能使用系统的 root 账户启动!

2、新创建个其他用户,切换到新创建的用户账户,用新账户来启动 SonarQube  系统即可。

3、依据你安装的操作系统, 系统内核需符合 sonar 安装需求,不然启动后会有报错。

      使用 root 账户,执行下面的两条指令

sysctl -w vm.max_map_count=262144

sysctl -w fs.file-max=65536

点赞
收藏
评论区
推荐文章
blmius blmius
2年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
Jacquelyn38 Jacquelyn38
2年前
2020年前端实用代码段,为你的工作保驾护航
有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )
皕杰报表之UUID
​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为
Stella981 Stella981
2年前
KVM调整cpu和内存
一.修改kvm虚拟机的配置1、virsheditcentos7找到“memory”和“vcpu”标签,将<namecentos7</name<uuid2220a6d1a36a4fbb8523e078b3dfe795</uuid
Easter79 Easter79
2年前
Twitter的分布式自增ID算法snowflake (Java版)
概述分布式系统中,有一些需要使用全局唯一ID的场景,这种时候为了防止ID冲突可以使用36位的UUID,但是UUID有一些缺点,首先他相对比较长,另外UUID一般是无序的。有些时候我们希望能使用一种简单一些的ID,并且希望ID能够按照时间有序生成。而twitter的snowflake解决了这种需求,最初Twitter把存储系统从MySQL迁移
Wesley13 Wesley13
2年前
mysql设置时区
mysql设置时区mysql\_query("SETtime\_zone'8:00'")ordie('时区设置失败,请联系管理员!');中国在东8区所以加8方法二:selectcount(user\_id)asdevice,CONVERT\_TZ(FROM\_UNIXTIME(reg\_time),'08:00','0
Wesley13 Wesley13
2年前
00:Java简单了解
浅谈Java之概述Java是SUN(StanfordUniversityNetwork),斯坦福大学网络公司)1995年推出的一门高级编程语言。Java是一种面向Internet的编程语言。随着Java技术在web方面的不断成熟,已经成为Web应用程序的首选开发语言。Java是简单易学,完全面向对象,安全可靠,与平台无关的编程语言。
Stella981 Stella981
2年前
Django中Admin中的一些参数配置
设置在列表中显示的字段,id为django模型默认的主键list_display('id','name','sex','profession','email','qq','phone','status','create_time')设置在列表可编辑字段list_editable
Wesley13 Wesley13
2年前
MySQL部分从库上面因为大量的临时表tmp_table造成慢查询
背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_
Python进阶者 Python进阶者
2个月前
Excel中这日期老是出来00:00:00,怎么用Pandas把这个去除
大家好,我是皮皮。一、前言前几天在Python白银交流群【上海新年人】问了一个Pandas数据筛选的问题。问题如下:这日期老是出来00:00:00,怎么把这个去除。二、实现过程后来【论草莓如何成为冻干莓】给了一个思路和代码如下:pd.toexcel之前把这