`
sillycat
  • 浏览: 2539395 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

Code SonarQube 2019(1)Installation with default H2

 
阅读更多
Code SonarQube 2019(1)Installation with default H2

We can find the downloads from here https://www.sonarqube.org/downloads/
And we can find scanner https://docs.sonarqube.org/latest/analysis/scan/sonarscanner/

Source Codes
https://github.com/SonarSource/sonarqube
https://github.com/SonarSource/sonar-scanner-cli

Download the file from these versions
> wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-7.9.1.zip
> wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.0.0.1744.zip

Unzip and file and place to the working directories
> unzip sonarqube-7.9.1.zip
> mv sonarqube-7.9.1 ~/tool/

> unzip sonar-scanner-cli-4.0.0.1744.zip
> mv sonar-scanner-4.0.0.1744 ~/tool/

> sudo ln -s /home/carl/tool/sonarqube-7.9.1 /opt/sonarqube-7.9.1
> sudo ln -s /opt/sonarqube-7.9.1 /opt/sonarqube

> sudo ln -s /home/carl/tool/sonar-scanner-4.0.0.1744 /opt/sonar-scanner-4.0.0
> sudo ln -s /opt/sonar-scanner-4.0.0 /opt/sonar-scanner


Check Java version
> java -version
java version "1.8.0_171"

According to https://blog.51cto.com/dadapeng/1934568
Need Database MySQL
> sudo apt update
> sudo apt install mysql-server
> sudo apt install mysql-client

Default root User
https://stackoverflow.com/questions/33991228/what-is-the-default-root-pasword-for-mysql-5-7

Check the root password
> sudo cat /etc/mysql/debian.cnf
# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host     = localhost
user     = debian-sys-maint
password = ddHulNSEFzhUFvS1
socket   = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host     = localhost
user     = debian-sys-maint
password = ddHulNSEFzhUFvS1
socket   = /var/run/mysqld/mysqld.sock


> mysql -u debian-sys-maint -pddHulNSEFzhUFvS1

Prepare Database Information
> CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci;

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

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

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

> FLUSH PRIVILEGES;

Then I can use this command to connect to that
> mysql -h localhost -u sonar -psonar

Configure sonarque configuration
> cd /opt/sonarqube

> vi conf/sonar.properties
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
sonar.sorceEncoding=UTF-8
sonar.login=admin
sonar.password=admin


Add this to the ClassPath
export SONAR_HOME=/opt/sonarqube
export SONAR_RUNNER_HOME=/opt/sonar-scanner
export PATH="$PATH:$SONAR_HOME/bin:$SONAR_RUNNER_HOME/bin"

Start the Service
> bin/linux-x86-64/sonar.sh start

Check the logging and I get this error
WrapperSimpleApp: Encountered an error running main: java.lang.IllegalStateException: SonarQube requires Java 11+ to run
java.lang.IllegalStateException: SonarQube requires Java 11+ to run
        at org.sonar.application.App.checkJavaVersion(App.java:93)
        at org.sonar.application.App.start(App.java:56)
        at org.sonar.application.App.main(App.java:98)


Solutions:
http://www.jenv.be/

Install jENV on Ubuntu
> git clone https://github.com/gcuisinier/jenv.git ~/.jenv
> echo 'export PATH="$HOME/.jenv/bin:$PATH"' >> ~/.bash_profile
> echo 'eval "$(jenv init -)"' >> ~/.bash_profile

> . ~/.bash_profile

Check installation
> jenv versions
* system (set by /home/carl/.jenv/version)

> jenv --version
jenv 0.5.2-4-gd8ffd5b

I manually install JDK8 so
>  jenv add /opt/jdk-1.8.0-171
oracle64-1.8.0.171 added
1.8.0.171 added
1.8 added

Download JDK 11 and JDK 12
https://www.oracle.com/technetwork/java/javase/downloads/jdk12-downloads-5295953.html

Then I get file
jdk-11.0.4_linux-x64_bin.tar.gz
jdk-12.0.2_linux-x64_bin.tar.gz

Put all these in the working directory
> sudo ln -s /home/carl/tool/jdk-11.0.4 /opt/jdk-11.0.4
> sudo ln -s /home/carl/tool/jdk-12.0.2 /opt/jdk-12.0.2

> jenv add /opt/jdk-11.0.4
> jenv add /opt/jdk-12.0.2

> jenv versions
* system (set by /home/carl/.jenv/version)
  11.0
  11.0.4
  12.0
  12.0.2
  1.8
  1.8.0.171
  oracle64-11.0.4
  oracle64-12.0.2
  oracle64-1.8.0.171

> jenv global 11.0

Check java version
> java -version
java version "11.0.4" 2019-07-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.4+10-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.4+10-LTS, mixed mode)


Start Sonar again
> bin/linux-x86-64/sonar.sh start

Exception:
2019.07.22 13:08:01 WARN  app[][o.s.a.p.AbstractManagedProcess] Process exited with exit value [es]: 143

Solution:
https://stackoverflow.com/questions/49128166/sonarqube-exits-with-143
Move out all the plugins
> cd /opt/sonarqube
> mv plugins/* ~/install/plugins/

Then it is working fine now
>  bin/linux-x86-64/sonar.sh status
SonarQube is running (30432)

After few seconds, it stoped again…..
https://community.sonarsource.com/t/installing-sq-7-9-on-ubuntu-14-04-exit-value-es-143/11478

Cleaned the data and logs directories, still not working.
Does this matters in es.log
2019.07.22 14:53:42 DEBUG es[][i.n.u.i.CleanerJava9] java.nio.ByteBuffer.cleaner(): unavailable
java.lang.UnsupportedOperationException: sun.misc.Unsafe unavailable
        at io.netty.util.internal.CleanerJava9.<clinit>(CleanerJava9.java:68) [netty-common-4.1.32.Final.jar:4.1
.32.Final]

https://blog.csdn.net/qq_35981283/article/details/81072852
> ulimit -Hn
65536

> sudo sysctl -p
vm.max_map_count = 262144
net.ipv4.ip_nonlocal_bind = 1

Try one older version
> wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-7.6.zip
> sudo ln -s /home/carl/tool/sonarqube-7.6 /opt/sonarqube-7.6
> sudo ln -s /opt/sonarqube-7.6 /opt/sonarqube

> vi conf/sonar.properties
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
sonar.sorceEncoding=UTF-8
sonar.login=admin
sonar.password=admin

It seems that it has something to do with the MySQL drivers. If I use default database setting H2 I guess, it will work.
Check document from here
https://docs.sonarqube.org/7.9/requirements/requirements/
https://docs.sonarqube.org/6.7/Requirements.html

It seems old version support MySQL, new version does not.
After all these, we can visit the page here
http://ubuntu-master:9000/about

We can login with default username and password admin/admin

After I create a sample JAVA project there, it asked me to run the maven command
> mvn sonar:sonar -Dsonar.projectKey=sillycat-websocket -Dsonar.host.url=http://ubuntu-master:9000 -Dsonar.login=adf305363a2cec4fa4311ea89317229ddd691991

It will scan and get a feeling about my JAVA codes.

Try the sample project
https://github.com/luohuazju/sillycat-jwtphp

For PHP project, we can have something similar
> sonar-scanner -Dsonar.projectKey=sillycat-jwtphp -Dsonar.sources=.   -Dsonar.host.url=http://ubuntu-master:9000 -Dsonar.login=8118a943f3eb997399ecd9ad0891c3c7f46f8e21


On Mac OS, we can install the scanner as well.
> wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.0.0.1744.zip

Unzip and place that in the working directory
> mv sonar-scanner-4.0.0.1744 ~/tool/

> sudo ln -s /Users/hluo/tool/sonar-scanner-4.0.0.1744 /opt/sonar-scanner-4.0.0
> sudo ln -s /opt/sonar-scanner-4.0.0 /opt/sonar-scanner

Add to the path
export PATH=/opt/sonar-scanner/bin:$PATH

Check installation
> sonar-scanner --version
INFO: Scanner configuration file: /Users/hluo/tool/sonar-scanner-4.0.0.1744/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarQube Scanner 4.0.0.1744
INFO: Java 1.8.0_161 Oracle Corporation (64-bit)
INFO: Mac OS X 10.14.5 x86_64

Same command, works pretty well.

References:
https://www.jianshu.com/p/50496b75a7b0
https://www.jianshu.com/p/9766f0129581
https://blog.csdn.net/zdyueguanyun/article/details/79447701
https://blog.51cto.com/dadapeng/1934568




分享到:
评论

相关推荐

    Begin to Code with Python

    Begin to Code with Python By 作者: Rob Miles ISBN-10 书号: 1509304525 ISBN-13 书号: 9781509304523 Edition 版本: 1 出版日期: 2017-12-18 pages 页数: 1463 $39.99 This full-color book will inspire you to ...

    SonarQube中文使用手册Release.pdf

    1. **SonarQube服务器**:SonarQube的核心组成部分,包括Web服务器、基于Elasticsearch的搜索服务器以及计算引擎服务器。Web服务器负责处理用户界面的请求,Elasticsearch搜索服务器用于索引和搜索数据,计算引擎...

    SonarQube检测出的bug、漏洞以及异味的修复整理

    SonarQube是一款强大的静态代码分析工具,用于检测软件中的bug、漏洞和异味(Code Smell)。通过分析项目源代码,SonarQube能够帮助开发者找出潜在的问题,并提供修复建议,以提高代码质量和可维护性。以下是...

    myeclipse2019.4+CodeMix3.0 crack包

    1、官网下载myeclipse2019.4安装包 2、安装myeclipse 3、下载解压crack包 4、将解压后的crack包中patch文件夹下的内容全部拷贝到myeclipse安装路径下的plugin文件夹下(默认的路径为C:\Users\username\AppData\Local...

    Get Programming - Learn to code with Python.epub

    Lesson 1 - Why should you learn how to program? Lesson 2 - Basic principles of learning a programming language UNIT 1 - VARIABLES, TYPES, EXPRESSIONS, AND STATEMENTS Lesson 3 - Introducing Python: a ...

    sonarqube质量分析工具

    1. **静态代码分析**:SonarQube能够对多种编程语言(如Java、C#、Python等)的源代码进行深度扫描,查找语法错误、不规范的编码习惯、潜在的性能瓶颈以及可能的安全隐患。 2. **代码异味检测**:SonarQube可以识别...

    sonarqube-9.1.zip

    SonarQube是一款开源的代码质量管理工具,它用于检测代码中的漏洞、代码异味(Code Smells)和复杂性,以提升软件的质量和安全性。在给定的“sonarqube-9.1.zip”文件中,包含的是SonarQube 9.1版本的相关资源,该...

    windos版本的sonarqube-7.8.rar

    1. **SonarQube概述** SonarQube由SonarSource公司开发,它提供了代码质量的持续监控,包括代码异味(Code Smell)、漏洞(Bug)、代码复杂度(Complexity)等方面的检查。7.8版本是在其历史版本的基础上进行改进和...

    sonarqube-6.0.zip

    SonarQube的核心功能在于它的静态代码分析,它可以检测出代码中的各种问题,如潜在的bug、代码异味(code smell)、安全漏洞以及不一致的编码风格。通过集成在开发流程中,SonarQube可以在代码提交前或构建过程中...

    SonarQube 6.7.7

    1. **代码分析**:SonarQube能够对多种编程语言(如Java、Python、C#、JavaScript等)进行静态代码分析,找出可能存在的安全漏洞、错误、坏味道(code smell)和设计问题。 2. **度量标准**:SonarQube提供了一系列...

    SonarQube4.5.4_part2

    1. **静态代码分析**:SonarQube可以对多种编程语言(如Java、C#、Python等)进行源代码扫描,检测出潜在的bug、代码异味(Code Smell)、漏洞和复杂性等问题,帮助开发者提升代码质量。 2. **度量和可视化**:...

    sonarqube-8.7.0.41497.zip

    1. **SonarQube服务器**:这是整个平台的核心,负责接收分析请求,处理数据,并展示结果。 2. **数据库**:SonarQube需要一个数据库来存储项目信息、代码度量和其他元数据。默认使用H2内存数据库,但在生产环境中...

    Code.Generation.with.Roslyn.epub

    Code Generation with Rosyln is the first book to cover this new capability. You will learn how these techniques can be used to simplify systems integration so that if one system already defines ...

    sonarqube-7.4官方版本.zip

    这款工具支持多种编程语言,包括但不限于Java、C#、JavaScript、Python等,能够对代码进行深度分析,找出潜在的bug、代码异味(code smell)、漏洞和复杂性问题。 SonarQube的核心组件包括以下几个方面: 1. **...

    Working Effectively With Legacy Code

    Working Effectively With Legacy Code

Global site tag (gtag.js) - Google Analytics