溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶(hù)服務(wù)條款》

Linux sonarqube8.2的安裝步驟

發(fā)布時(shí)間:2020-05-25 15:43:35 來(lái)源:億速云 閱讀:359 作者:鴿子 欄目:云計(jì)算

社區(qū)版下載地址:https://www.sonarqube.org/downloads/

環(huán)境介紹:(本文使用Oracle jdk 11.0.6,postgreSQL 12)

1、解壓縮包

unzip sonarqube-8.2.0.32929.zip

Linux sonarqube8.2的安裝步驟

2、創(chuàng)建postgreSQL用戶(hù)

安裝完后會(huì)自動(dòng)創(chuàng)建postgres用戶(hù) su - postgres切換進(jìn)去

psql                     #進(jìn)入命令行模式

create database sonar;    #創(chuàng)建sonar數(shù)據(jù)庫(kù)

create user sonar;        #創(chuàng)建sonar用戶(hù)

alter user sonar with password 'postgres';           #設(shè)置sonar用戶(hù)密碼(否則會(huì)導(dǎo)致連不上數(shù)據(jù)庫(kù))

alter role sonar createdb;alter role sonar superuser;alter role sonar createrole;    #給sonar授權(quán)

alter database sonar owner to sonar;      #更改sonar數(shù)據(jù)庫(kù)擁有者(這一步是必須的,否則會(huì)sonarqube會(huì)連接失敗)

psql進(jìn)入命令行模式

\l查看數(shù)據(jù)庫(kù)

\du 查看用戶(hù)

Linux sonarqube8.2的安裝步驟

3、修改系統(tǒng)配置

  1. 不能用root起!

  2. 切換用戶(hù)必須 su - username

  3. 切換好用戶(hù)千萬(wàn)別忘記給這個(gè)用戶(hù)授權(quán)你的sonarQube根目錄

  4. 更改一些系統(tǒng)配置

根據(jù)需要執(zhí)行下述命令以使內(nèi)核參數(shù)符合sonar安裝需求

#可以使用以下命令查看這些值:

sysctl vm.max_map_count

sysctl fs.file-max

ulimit -n

Linux sonarqube8.2的安裝步驟

#可以通過(guò)以root身份運(yùn)行以下命令來(lái)為當(dāng)前會(huì)話動(dòng)態(tài)設(shè)置:

sysctl -w vm.max_map_count=262144

sysctl -w fs.file-max=65536

ulimit -n 65536

#為了更永久設(shè)置這些值,則必須修改/etc/sysctl.d/99-sonarqube.conf(或/etc/sysctl.conf文件)

#文件末尾添加下述兩行

vi /etc/sysctl.conf

vm.max_map_count=262144

fs.file-max=65536

#在/etc/profile文件末尾添加ulimit -n 65536

vi /etc/profile

ulimit -n 65536           #保存后運(yùn)行#source /etc/profile 使其生效

source /etc/profile

創(chuàng)建sonar用戶(hù)

useradd sonar

passwd sonar

密碼自己設(shè)置。

目錄授權(quán)

chown -R sonar:sonar /usr/local/sonarqube-8.2.0.32929/

4、設(shè)置對(duì)數(shù)據(jù)庫(kù)的訪問(wèn)

vim  /usr/local/sonarqube-8.2.0.32929/conf/sonar.properties

Linux sonarqube8.2的安裝步驟

Linux sonarqube8.2的安裝步驟

配置自己機(jī)器的IP跟端口,保存退出即可

5、配置Elasticsearch存儲(chǔ)路徑

默認(rèn)情況下,Elasticsearch數(shù)據(jù)存儲(chǔ)在$ SONARQUBE-HOME / data中,但不建議將其用于生產(chǎn)實(shí)例。相反,您應(yīng)該將此數(shù)據(jù)存儲(chǔ)在其他位置,最好是在具有快速I(mǎi) / O的專(zhuān)用卷中。除了保持可接受的性能外,這樣做還可以簡(jiǎn)化SonarQube的升級(jí)

vim /usr/local/sonarqube-8.2.0.32929/conf/sonar.properties

Linux sonarqube8.2的安裝步驟

用于啟動(dòng)SonarQube的用戶(hù)必須具有對(duì)這些目錄的讀寫(xiě)權(quán)限

mkdir -p /data/sonarqube/data

mkdir -p /data/sonarqube/temp

chown -R sonar:sonar /data/

6、Sonar-Scanner掃描器安裝及使用方法

光弄SonarQube是沒(méi)法掃描項(xiàng)目的,所以還需要裝一下sonar-scanner

官方下載地址:https://docs.sonarqube.org/latest/analysis/scan/sonarscanner/

#丟到/usr/local/下面解壓

unzip sonar-scanner-cli-4.2.0.1873-linux.zip

cd sonar-scanner-4.2.0.1873-linux/

vim conf/sonar-scanner.propertie          #改下配置

Linux sonarqube8.2的安裝步驟

保存退出后,創(chuàng)建軟連接,將sonar-scanner改為全局即可使用

ln -s /usr/local/sonar-scanner-4.2.0.1873-linux/bin/sonar-scanner /usr/bin/sonar-scanner

7、啟動(dòng)服務(wù)

su - sonar 別忘了切用戶(hù)

cd /usr/local/sonarqube-8.2.0.32929/

bin/linux-x86-64/sonar.sh

Linux sonarqube8.2的安裝步驟

訪問(wèn)web界面

Linux sonarqube8.2的安裝步驟

賬戶(hù)密碼:admin/admin

安裝中文版,然后點(diǎn)擊從新啟動(dòng)

Linux sonarqube8.2的安裝步驟


向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI