sonarqube 安装使用

Prerequisite

# download jre11 rpm package
# install jre11 rpm
rpm -i jdk-11.0.5_linux-x64_bin.rpm
  • Linux installation prerequisite
# If you're running on Linux, you must ensure that:

* vm.max_map_count is greater or equals to 262144
* fs.file-max is greater or equals to 65536
* the user running SonarQube can open at least 65536 file descriptors
* the user running SonarQube can open at least 4096 threads

# You can see the values with the following commands:
sysctl vm.max_map_count
sysctl fs.file-max
ulimit -n
ulimit -u

# You can set them dynamically for the current session by running the following commands as root:
sysctl -w vm.max_map_count=262144
sysctl -w fs.file-max=65536
ulimit -n 65536
ulimit -u 4096

# To set these values more permanently, you must update either /etc/sysctl.d/99-sonarqube.conf (or /etc/sysctl.conf as you wish) to reflect these values.
# Install the repository RPM
yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

# Install the client packages:
yum install postgresql11

# Optionally install the server packages:
yum install postgresql11-server

# Optionally initialize the database and enable automatic start:

/usr/pgsql-11/bin/postgresql-11-setup initdb
systemctl enable postgresql-11\
systemctl start postgresql-11

# PostgreSQL会自动创建postgres用户, 创建数据库之前, 要用postgres用户或root用户登录并重置postgres用户密码.
su -l postgres

# 连接数据库, psql命令会激活PostgreSQL数据库终端:
psql

# 会输出下列说明连接进入了PostgreSQL数据库:
-bash-4.2$ psql
psql (11.5)
Type "help" for help.
postgres=# help
You are using psql, the command-line interface to PostgreSQL.
Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with psql commands
       \g or terminate with semicolon to execute query
       \q to quit

# 重置postgres用户密码:
postgres=# \password

# 开启远程访问
    vim /var/lib/pgsql/11/data/postgresql.conf
    修改#listen_addresses = 'localhost'  为  listen_addresses=‘*'

# 信任远程连接
    vim /var/lib/pgsql/11/data/pg_hba.conf
    修改如下内容,信任指定服务器连接

    # IPv4 local connections:
    host    all            all      127.0.0.1/32      trust
    host    all            all      10.xx.xx.6/32(需要连接的服务器IP)  trust

# 重启数据库生效
systemctl restart postgresql-11

# 创建新用户
CREATE USER sonarqube  WITH PASSWORD 'Wood!nHo13';

# 创建数据库
CREATE SCHEMA sonar_schema;
ALTER USER sonarqube SET search_path to sonarqube;
CREATE DATABASE sonarqube OWNER sonarqube;
GRANT ALL PRIVILEGES ON DATABASE sonarqube to sonarqube;
DROP DATABASE sonarqube;

PostgreSQL 设置
if you want to use a custom schema and not the default "public" one, the PostgreSQL search_path property must be set:

ALTER USER sonarqube SET search_path to sonarqube;

Installing the Web Server

  • download from here

SonarQube cannot be run as root on Unix-based systems, so create a dedicated user account to use for SonarQube if necessary.

useradd sonar
  • Setting the Access to the Database

$SONARQUBE-HOME (below) refers to the path to the directory where the SonarQube distribution has been unzipped.

Edit $SONARQUBE-HOME/conf/sonar.properties to configure the database settings.

Templates are available for every supported database. Just uncomment and configure the template you need and comment out the lines dedicated to H2:

Example for PostgreSQL

sonar.jdbc.username=sonarqube
sonar.jdbc.password=mypassword
sonar.jdbc.url=jdbc:postgresql://localhost/sonarqube
  • Adding the JDBC Driver

Drivers for the supported databases (except Oracle) are already provided. Do not replace the provided drivers; they are the only ones supported.

  • Configuring the Elasticsearch storage path

By default, Elasticsearch data is stored in $SONARQUBE-HOME/data, but this is not recommended for production instances. Instead, you should store this data elsewhere, ideally in a dedicated volume with fast I/O. Beyond maintaining acceptable performance, doing so will also ease the upgrade of SonarQube.

Edit$SONARQUBE-HOME/conf/sonar.properties to configure the following settings:

sonar.path.data=/var/sonarqube/data
sonar.path.temp=/var/sonarqube/temp

The user used to launch SonarQube must have read and write access to those directories.

chown sonarqube:sonarqube /var/sonarqube/data
chown sonarqube:sonarqube /var/sonarqube/temp
  • SonarQube中文界面

下载中文语言包 sonar-l10n-zh-plugin.jar
然后,将其放入sonar安装目录的 extensions/plugins 目录下
https://search.maven.org/search?q=sonar-l10n-zh-plugin

Starting the Web Server

The default port is "9000" and the context path is "/". These values can be changed in $SONARQUBE-HOME/conf/sonar.properties:

sonar.web.host=xxx.xxx.xxx.xxx
sonar.web.port=80
sonar.web.context=/sonarqube

Execute the following script to start the server:

bin//sonar.sh start

You can now browse SonarQube at http://localhost:9000 (the default System administrator credentials are admin/admin).

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 201,552评论 5 474
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 84,666评论 2 377
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 148,519评论 0 334
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,180评论 1 272
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,205评论 5 363
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,344评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,781评论 3 393
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,449评论 0 256
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,635评论 1 295
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,467评论 2 317
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,515评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,217评论 3 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,775评论 3 303
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,851评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,084评论 1 258
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,637评论 2 348
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,204评论 2 341

推荐阅读更多精彩内容