kubernetes實踐之三十: SonarQube和SonarQube Runner
一:簡介
Sonar 是一個用於程式碼質量管理的開放平臺。透過外掛機制,Sonar 可以整合不同的測試工具,程式碼分析工具,以及持續整合工具。比如pmd-cpd、checkstyle、findbugs、Jenkins。透過不同的外掛對這些結果進行再加工處理,透過量化的方式度量程式碼質量的變化,從而可以方便地對不同規模和種類的工程進行程式碼質量管理。同時 Sonar 還對大量的持續整合工具提供了介面支援,可以很方便地在持續整合中使用 Sonar。
此外,Sonar 的外掛還可以對 Java 以外的其他程式語言(支援的語言包括:Java、PHP、C#、C、Cobol、PL/SQL、Flex等)提供支援,對國際化以及報告文件化也有良好的支援。可以說Sonar是目前最強大的程式碼質量管理工具之一。
SonarQube框架包含以下四個部分:
Project: 是需要被分析的原始碼,如我們的app工程原始碼,SonarQube支援多種語言和多種工程結構.
SonarQube Scanner:是用於執行程式碼分析的工具,在Project的根目錄下執行.
SonarQube Database: 支援MySql,Oracle等
二:安裝與配置
1.相關資訊
作業系統:Centos 7.0
軟體版本:sonarqube-6.7.3.zip sonar-runner-dist-2.4.zip
2.前置條件
jdk1.8, mysql 5.6(必須是5.6以上版本)
3.解壓縮sonarqube-6.7.3.zip sonar-runner-dist-2.4.zip 到/usr/local
unzip sonarqube-6.7.3.zip -d /usr/local
unzip sonar-runner-dist-2.4.zip -d /usr/local
4.環境變數設定
vi /etc/profile
source /etc/profile
5.配置sonar.properties(/usr/local/sonarqube-6.7.3/conf/)
6.配置sonar-runner.properties(/usr/local/sonar-runner-2.4/conf)
7.建立sonar-project.properties(/usr/local/sonar-runner-2.4/conf)
8.設定elasticsearch.yml(/usr/local/sonarqube-6.7.3/elasticsearch/config)
三:啟動
1.用root無法啟動lSonarQube,需要另外新建普通使用者來啟動
useradd esadmin
chown -R esadmin.esadmin /usr/local/sonarqube-6.7.3
2.檔案控制程式碼配置
vim /etc/security/limits.conf
3.vm.max_map_count 配置
vim /etc/sysctl.conf
新增下面配置:
vm.max_map_count=655360
sysctl -p
4.啟動
以之前建立的esadmin使用者執行命令
./usr/local/sonarqube-6.7.3/bin/linux-x86-64/sonar.sh
監控 sonar.log es.log web.log
三:驗證
1.sonarque UI介面
2.UI 介面漢化
下載sonar-l10n-zh-plugin-1.19.jar 到 /usr/local/sonarqube-6.7.3/extensions/plugins
重啟sonarqube
3.啟動sonar-runner 對desktop專案程式碼進行分析, 分析結果透過UI介面可以看到。
./usr/local/sonar-runner-2.4/bin/sonar-runner -e -X
Sonar 是一個用於程式碼質量管理的開放平臺。透過外掛機制,Sonar 可以整合不同的測試工具,程式碼分析工具,以及持續整合工具。比如pmd-cpd、checkstyle、findbugs、Jenkins。透過不同的外掛對這些結果進行再加工處理,透過量化的方式度量程式碼質量的變化,從而可以方便地對不同規模和種類的工程進行程式碼質量管理。同時 Sonar 還對大量的持續整合工具提供了介面支援,可以很方便地在持續整合中使用 Sonar。
此外,Sonar 的外掛還可以對 Java 以外的其他程式語言(支援的語言包括:Java、PHP、C#、C、Cobol、PL/SQL、Flex等)提供支援,對國際化以及報告文件化也有良好的支援。可以說Sonar是目前最強大的程式碼質量管理工具之一。
SonarQube框架包含以下四個部分:
Project: 是需要被分析的原始碼,如我們的app工程原始碼,SonarQube支援多種語言和多種工程結構.
SonarQube Scanner:是用於執行程式碼分析的工具,在Project的根目錄下執行.
SonarQube支援多種工程構建方式的配置,也對應需要用不同的Scanner來執行分析過程:
- Ant
- Maven
- MSBuild(Microsoft Build Engine)
- Gradle
- Sonar Runner
SonarQube Database: 支援MySql,Oracle等
二:安裝與配置
1.相關資訊
作業系統:Centos 7.0
軟體版本:sonarqube-6.7.3.zip sonar-runner-dist-2.4.zip
2.前置條件
jdk1.8, mysql 5.6(必須是5.6以上版本)
3.解壓縮sonarqube-6.7.3.zip sonar-runner-dist-2.4.zip 到/usr/local
unzip sonarqube-6.7.3.zip -d /usr/local
unzip sonar-runner-dist-2.4.zip -d /usr/local
4.環境變數設定
vi /etc/profile
點選(此處)摺疊或開啟
-
JAVA_HOME=/usr/local/jdk1.8
-
export SONAR_HOME=/usr/local/sonarqube-6.7.3
-
export SONAR_RUNNER_HOME=/usr/local/sonar-runner-2.4
-
PATH=$JAVA_HOME/bin:$SONAR_HOME/bin:$SONAR_RUNNER_HOME/bin:$PATH
-
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
- export JAVA_HOME PATH CLASSPATH
5.配置sonar.properties(/usr/local/sonarqube-6.7.3/conf/)
點選(此處)摺疊或開啟
-
# Property values can:
-
# - reference an environment variable, for example sonar.jdbc.url= ${env:SONAR_JDBC_URL}
-
# - be encrypted. See https://redirect.sonarsource.com/doc/settings-encryption.html
-
-
#--------------------------------------------------------------------------------------------------
-
# DATABASE
-
#
-
# IMPORTANT:
-
# - The embedded H2 database is used by default. It is recommended for tests but not for
-
# production use. Supported databases are MySQL, Oracle, PostgreSQL and Microsoft SQLServer.
-
# - Changes to database connection URL (sonar.jdbc.url) can affect SonarSource licensed products.
-
-
# User credentials.
-
# Permissions to create tables, indices and triggers must be granted to JDBC user.
-
# The schema must be created first.
-
sonar.jdbc.username=root
-
sonar.jdbc.password=password
-
-
#----- Embedded Database (default)
-
# H2 embedded database server listening port, defaults to 9092
-
#sonar.embeddedDatabase.port=9092
-
-
#----- MySQL 5.6 or greater
-
# Only InnoDB storage engine is supported (not myISAM).
-
# Only the bundled driver is supported. It can not be changed.
-
sonar.jdbc.url=jdbc:mysql://112.74.53.213:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false
-
-
-
#----- Oracle 11g/12c
-
# The Oracle JDBC driver must be copied into the directory extensions/jdbc-driver/oracle/.
-
# Only the thin client is supported, and only the versions 11.2.x or 12.2.x must be used. See
-
# https://jira.sonarsource.com/browse/SONAR-9758 for more details.
-
# If you need to set the schema, please refer to http://jira.sonarsource.com/browse/SONAR-5000
-
#sonar.jdbc.url=jdbc:oracle:thin:@localhost:1521/XE
-
-
-
#----- PostgreSQL 8.x or greater
-
# If you don't use the schema named "public", please refer to
-
#sonar.jdbc.url=jdbc:postgresql://localhost/sonar
-
-
-
#----- Microsoft SQLServer 2014/2016 and SQL Azure
-
# A database named sonar must exist and its collation must be case-sensitive (CS) and accent-sensitive (AS)
-
# Use the following connection string if you want to use integrated security with Microsoft Sql Server
-
# Do not set sonar.jdbc.username or sonar.jdbc.password property if you are using Integrated Security
-
# For Integrated Security to work, you have to download the Microsoft SQL JDBC driver package from
-
#
-
# and copy sqljdbc_auth.dll to your path. You have to copy the 32 bit or 64 bit version of the dll
-
# depending upon the architecture of your server machine.
-
#sonar.jdbc.url=jdbc:sqlserver://localhost;databaseName=sonar;integratedSecurity=true
-
-
# Use the following connection string if you want to use SQL Auth while connecting to MS Sql Server.
-
# Set the sonar.jdbc.username and sonar.jdbc.password appropriately.
-
#sonar.jdbc.url=jdbc:sqlserver://localhost;databaseName=sonar
-
-
-
#----- Connection pool settings
-
# The maximum number of active connections that can be allocated
-
# at the same time, or negative for no limit.
-
# The recommended value is 1.2 * max sizes of HTTP pools. For example if HTTP ports are
-
# enabled with default sizes (50, see property sonar.web.http.maxThreads)
-
# then sonar.jdbc.maxActive should be 1.2 * 50 = 60.
-
#sonar.jdbc.maxActive=60
-
-
# The maximum number of connections that can remain idle in the
-
# pool, without extra ones being released, or negative for no limit.
-
#sonar.jdbc.maxIdle=5
-
-
# The minimum number of connections that can remain idle in the pool,
-
# without extra ones being created, or zero to create none.
-
#sonar.jdbc.minIdle=2
-
-
# The maximum number of milliseconds that the pool will wait (when there
-
# are no available connections) for a connection to be returned before
-
# throwing an exception, or <= 0 to wait indefinitely.
-
#sonar.jdbc.maxWait=5000
-
-
#sonar.jdbc.minEvictableIdleTimeMillis=600000
-
#sonar.jdbc.timeBetweenEvictionRunsMillis=30000
-
-
-
-
#--------------------------------------------------------------------------------------------------
-
# WEB SERVER
-
# Web server is executed in a dedicated Java process. By default heap size is 512Mb.
-
# Use the following property to customize JVM options.
-
# Recommendations:
-
#
-
# The HotSpot Server VM is recommended. The property -server should be added if server mode
-
# is not enabled by default on your environment:
-
#
-
#
-
# Startup can be long if entropy source is short of entropy. Adding
-
# -Djava.security.egd=file:/dev/./urandom is an option to resolve the problem.
-
# See
-
#
-
sonar.web.javaOpts=-Xmx512m -Xms512m -XX:+HeapDumpOnOutOfMemoryError
-
-
# Same as previous property, but allows to not repeat all other settings like -Xmx
-
#sonar.web.javaAdditionalOpts=
-
-
# Binding IP address. For servers with more than one IP address, this property specifies which
-
# address will be used for listening on the specified ports.
-
# By default, ports will be used on all IP addresses associated with the server.
-
sonar.web.host=0.0.0.0
-
-
# Web context. When set, it must start with forward slash (for example /sonarqube).
-
# The default value is root context (empty value).
-
#sonar.web.context=
-
# TCP port for incoming HTTP connections. Default value is 9000.
-
sonar.web.port=9000
-
-
-
# The maximum number of connections that the server will accept and process at any given time.
-
# When this number has been reached, the server will not accept any more connections until
-
# the number of connections falls below this value. The operating system may still accept connections
-
# based on the sonar.web.connections.acceptCount property. The default value is 50.
-
#sonar.web.http.maxThreads=50
-
-
# The minimum number of threads always kept running. The default value is 5.
-
#sonar.web.http.minThreads=5
-
-
# The maximum queue length for incoming connection requests when all possible request processing
-
# threads are in use. Any requests received when the queue is full will be refused.
-
# The default value is 25.
-
#sonar.web.http.acceptCount=25
-
-
# By default users are logged out and sessions closed when server is restarted.
-
# If you prefer keeping user sessions open, a secret should be defined. Value is
-
# HS256 key encoded with base64. It must be unique for each installation of SonarQube.
-
# Example of command-line:
-
# echo -n "type_what_you_want" | openssl dgst -sha256 -hmac "key" -binary | base64
-
#sonar.auth.jwtBase64Hs256Secret=
-
-
# The inactivity timeout duration of user sessions, in minutes. After the configured
-
# period of time, the user is logged out.
-
# The default value is set to 3 days (4320 minutes)
-
# and cannot be greater than 3 months. Value must be strictly positive.
-
#sonar.web.sessionTimeoutInMinutes=4320
-
-
# A passcode can be defined to access some web services from monitoring
-
# tools without having to use the credentials of a system administrator.
-
# Check the Web API documentation to know which web services are supporting this authentication mode.
-
# The passcode should be provided in HTTP requests with the header "X-Sonar-Passcode".
-
# By default feature is disabled.
-
#sonar.web.systemPasscode=
-
-
-
#--------------------------------------------------------------------------------------------------
-
# SSO AUTHENTICATION
-
-
# Enable authentication using HTTP headers
-
#sonar.web.sso.enable=false
-
-
# Name of the header to get the user login.
-
# Only alphanumeric, '.' and '@' characters are allowed
-
#sonar.web.sso.loginHeader=X-Forwarded-Login
-
-
# Name of the header to get the user name
-
#sonar.web.sso.nameHeader=X-Forwarded-Name
-
-
# Name of the header to get the user email (optional)
-
#sonar.web.sso.emailHeader=X-Forwarded-Email
-
-
# Name of the header to get the list of user groups, separated by comma (optional).
-
# If the sonar.sso.groupsHeader is set, the user will belong to those groups if groups exist in SonarQube.
-
# If none of the provided groups exists in SonarQube, the user will only belong to the default group.
-
# Note that the default group will always be set.
-
#sonar.web.sso.groupsHeader=X-Forwarded-Groups
-
-
# Interval used to know when to refresh name, email and groups.
-
# During this interval, if for instance the name of the user is changed in the header, it will only be updated after X minutes.
-
#sonar.web.sso.refreshIntervalInMinutes=5
-
-
-
#--------------------------------------------------------------------------------------------------
-
# COMPUTE ENGINE
-
# The Compute Engine is responsible for processing background tasks.
-
# Compute Engine is executed in a dedicated Java process. Default heap size is 512Mb.
-
# Use the following property to customize JVM options.
-
# Recommendations:
-
#
-
# The HotSpot Server VM is recommended. The property -server should be added if server mode
-
# is not enabled by default on your environment:
-
#
-
#
-
#sonar.ce.javaOpts=-Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError
-
-
# Same as previous property, but allows to not repeat all other settings like -Xmx
-
#sonar.ce.javaAdditionalOpts=
-
-
-
#--------------------------------------------------------------------------------------------------
-
# ELASTICSEARCH
-
# Elasticsearch is used to facilitate fast and accurate information retrieval.
-
# It is executed in a dedicated Java process. Default heap size is 512Mb.
-
#
-
# --------------------------------------------------
-
# Word of caution for Linux users on 64bits systems
-
# --------------------------------------------------
-
# Please ensure Virtual Memory on your system is correctly configured for Elasticsearch to run properly
-
# (see for details).
-
#
-
# When SonarQube runs standalone, a warning such as the following may appear in logs/es.log:
-
# "max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]"
-
# When SonarQube runs as a cluster, however, Elasticsearch will refuse to start.
-
#
-
-
# JVM options of Elasticsearch process
-
#sonar.search.javaOpts=-Xms512m \
-
# -Xmx512m \
-
# -XX:+HeapDumpOnOutOfMemoryError
-
-
# Same as previous property, but allows to not repeat all other settings like -Xmx
-
#sonar.search.javaAdditionalOpts=
-
-
# Elasticsearch port. Default is 9001. Use 0 to get a free port.
-
# As a security precaution, should be blocked by a firewall and not exposed to the Internet.
-
#sonar.search.port=9001
-
-
# Elasticsearch host. The search server will bind this address and the search client will connect to it.
-
# Default is loopback address.
-
# As a security precaution, should NOT be set to a publicly available address.
-
#sonar.search.host=
-
-
-
#--------------------------------------------------------------------------------------------------
-
# UPDATE CENTER
-
-
# Update Center requires an internet connection to request
-
# It is enabled by default.
-
#sonar.updatecenter.activate=true
-
-
# HTTP proxy (default none)
-
#http.proxyHost=
-
#http.proxyPort=
-
# HTTPS proxy (defaults are values of http.proxyHost and http.proxyPort)
-
#https.proxyHost=
-
#https.proxyPort=
-
-
# NT domain name if NTLM proxy is used
-
#http.auth.ntlm.domain=
-
-
# SOCKS proxy (default none)
-
#socksProxyHost=
-
#socksProxyPort=
-
-
# Proxy authentication (used for HTTP, HTTPS and SOCKS proxies)
-
#http.proxyUser=
-
#http.proxyPassword=
-
-
-
#--------------------------------------------------------------------------------------------------
-
# LOGGING
-
-
# SonarQube produces logs in 4 logs files located in the same directory (see property sonar.path.logs below),
-
# one per process:
-
# Main process (aka. App) logs in sonar.log
-
# Web Server (aka. Web) logs in web.log
-
# Compute Engine (aka. CE) logs in ce.log
-
# Elasticsearch (aka. ES) logs in es.log
-
#
-
# All 4 files follow the same rolling policy (see sonar.log.rollingPolicy and sonar.log.maxFiles) but it applies
-
# individually (eg. if sonar.log.maxFiles=4, there can be at most 4 of each files, ie. 16 files in total).
-
#
-
# All 4 files have logs in the same format:
-
# 1 2 3 4 5 6
-
# |-----------------| |---| |-|--------------------||------------------------------| |------------------------------------------------------------------------------------------------------------------------------|
-
# 2016.11.16 16:47:00 INFO ce[AVht0dNXFcyiYejytc3m][o.s.s.c.t.CeWorkerCallableImpl] Executed task | project=org.sonarqube:example-java-maven | type=REPORT | id=AVht0dNXFcyiYejytc3m | submitter=admin | time=1699ms
-
#
-
# 1: timestamp. Format is YYYY.MM.DD HH:MM:SS
-
# YYYY: year on 4 digits
-
# MM: month on 2 digits
-
# DD: day on 2 digits
-
# HH: hour of day on 2 digits in 24 hours format
-
# MM: minutes on 2 digits
-
# SS: seconds on 2 digits
-
# 2: log level.
-
# Possible values (in order of descending criticality): ERROR, WARN, INFO, DEBUG and TRACE
-
# 3: process identifier. Possible values: app (main), web (Web Server), ce (Compute Engine) and es (Elasticsearch)
-
# 4: SQ thread identifier. Can be empty.
-
# In the Web Server, if present, it will be the HTTP request ID.
-
# In the Compute Engine, if present, it will be the task ID.
-
# 5: logger name. Usually a class canonical name.
-
# Package names are truncated to keep the whole field to 20 characters max
-
# 6: log payload. Content of this field does not follow any specific format, can vary in length and include line returns.
-
# Some logs, however, will follow the convention to provide data in payload in the format " | key=value"
-
# Especially, log of profiled pieces of code will end with " | time=XXXXms".
-
-
# Global level of logs (applies to all 4 processes).
-
# Supported values are INFO (default), DEBUG and TRACE
-
#sonar.log.level=INFO
-
-
# Level of logs of each process can be controlled individually with their respective properties.
-
# When specified, they overwrite the level defined at global level.
-
# Supported values are INFO, DEBUG and TRACE
-
#sonar.log.level.app=INFO
-
#sonar.log.level.web=INFO
-
#sonar.log.level.ce=INFO
-
#sonar.log.level.es=INFO
-
-
# Path to log files. Can be absolute or relative to installation directory.
-
# Default is /logs
-
#sonar.path.logs=logs
-
-
# Rolling policy of log files
-
# - based on time if value starts with "time:", for example by day ("time:yyyy-MM-dd")
-
# or by month ("time:yyyy-MM")
-
# - based on size if value starts with "size:", for example "size:10MB"
-
# - disabled if value is "none". That needs logs to be managed by an external system like logrotate.
-
#sonar.log.rollingPolicy=time:yyyy-MM-dd
-
-
# Maximum number of files to keep if a rolling policy is enabled.
-
# - maximum value is 20 on size rolling policy
-
# - unlimited on time rolling policy. Set to zero to disable old file purging.
-
#sonar.log.maxFiles=7
-
-
# Access log is the list of all the HTTP requests received by server. If enabled, it is stored
-
# in the file {sonar.path.logs}/access.log. This file follows the same rolling policy as other log file
-
# (see sonar.log.rollingPolicy and sonar.log.maxFiles).
-
#sonar.web.accessLogs.enable=true
-
-
# Format of access log. It is ignored if sonar.web.accessLogs.enable=false. Possible values are:
-
# - "common" is the Common Log Format, shortcut to: %h %l %u %user %date "%r" %s %b
-
# - "combined" is another format widely recognized, shortcut to: %h %l %u [%t] "%r" %s %b "%i{Referer}" "%i{User-Agent}"
-
# - else a custom pattern. See
-
# The login of authenticated user is not implemented with "%u" but with "%reqAttribute{LOGIN}" (since version 6.1).
-
# The value displayed for anonymous users is "-".
-
# The SonarQube's HTTP request ID can be added to the pattern with "%reqAttribute{ID}" (since version 6.2).
-
# If SonarQube is behind a reverse proxy, then the following value allows to display the correct remote IP address:
-
#sonar.web.accessLogs.pattern=%i{X-Forwarded-For} %l %u [%t] "%r" %s %b "%i{Referer}" "%i{User-Agent}" "%reqAttribute{ID}"
-
# Default value (which was "combined" before version 6.2) is equivalent to "combined + SQ HTTP request ID":
-
#sonar.web.accessLogs.pattern=%h %l %u [%t] "%r" %s %b "%i{Referer}" "%i{User-Agent}" "%reqAttribute{ID}"
-
-
-
#--------------------------------------------------------------------------------------------------
-
# OTHERS
-
-
# Delay in seconds between processing of notification queue. Default is 60 seconds.
-
#sonar.notifications.delay=60
-
-
# Paths to persistent data files (embedded database and search index) and temporary files.
-
# Can be absolute or relative to installation directory.
-
# Defaults are respectively /data and /temp
-
#sonar.path.data=data
-
#sonar.path.temp=temp
-
-
# Telemetry - Share anonymous SonarQube statistics
-
# By sharing anonymous SonarQube statistics, you help us understand how SonarQube is used so we can improve the product to work even better for you.
-
# We don't collect source code or IP addresses. And we don't share the data with anyone else.
-
# To see an example of the data shared: login as a global administrator, call the WS api/system/info and check the Statistics field.
-
#sonar.telemetry.enable=true
-
-
-
#--------------------------------------------------------------------------------------------------
-
# DEVELOPMENT - only for developers
-
# The following properties MUST NOT be used in production environments.
-
-
# Elasticsearch HTTP connector
- #sonar.search.httpPort=-1
點選(此處)摺疊或開啟
-
#Configure here general information about the environment, such as SonarQube DB details for example
-
#No information about specific project should appear here
-
-
#----- Default SonarQube server
-
sonar.host.url=http://ip:9000
-
-
#----- PostgreSQL
-
#sonar.jdbc.url=jdbc:postgresql://localhost/sonar
-
-
#----- MySQL
-
sonar.jdbc.url=jdbc:mysql://mysqlip:3306/sonar?useUnicode=true&;characterEncoding=utf8
-
-
#----- Oracle
-
#sonar.jdbc.url=jdbc:oracle:thin:@localhost/XE
-
-
#----- Microsoft SQLServer
-
#sonar.jdbc.url=jdbc:jtds:sqlserver://localhost/sonar;SelectMethod=Cursor
-
-
#----- Global database settings
-
sonar.jdbc.username=root
-
sonar.jdbc.password=password
-
-
#----- Default source code encoding
-
#sonar.sourceEncoding=UTF-8
-
-
#----- Security (when 'sonar.forceAuthentication' is set to 'true')
-
sonar.login=admin
- sonar.password=password
點選(此處)摺疊或開啟
-
# must be unique in a given SonarQube instance
-
sonar.projectKey=donkey
-
# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1.
-
sonar.projectName=desktop
-
sonar.projectVersion=0.0.1
-
- # Path is relative to the sonar-project.properties file. Replace "\" by "/
點選(此處)摺疊或開啟
-
# ---------------------------------- Network -----------------------------------
-
#
-
# Set the bind address to a specific IP (IPv4 or IPv6):
-
#
-
network.host: ip
-
#
-
# Set a custom port for HTTP:
-
#
-
http.port: 9200
-
#
- # For more information, consult the network module documentation.
三:啟動
1.用root無法啟動lSonarQube,需要另外新建普通使用者來啟動
useradd esadmin
chown -R esadmin.esadmin /usr/local/sonarqube-6.7.3
2.檔案控制程式碼配置
vim /etc/security/limits.conf
點選(此處)摺疊或開啟
-
# End of file
-
root soft nofile 65535
-
root hard nofile 65535
-
esadmin soft nofile 262144
-
esadmin hard nofile 262144
-
* soft nofile 65535
- * hard nofile 65535
vim /etc/sysctl.conf
新增下面配置:
vm.max_map_count=655360
sysctl -p
4.啟動
以之前建立的esadmin使用者執行命令
./usr/local/sonarqube-6.7.3/bin/linux-x86-64/sonar.sh
監控 sonar.log es.log web.log
點選(此處)摺疊或開啟
-
018.05.04 16:00:17 INFO app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /usr/local/sonarqube-6.7.3/temp
-
2018.05.04 16:00:18 INFO app[][o.s.a.es.EsSettings] Elasticsearch listening on /127.0.0.1:9001
-
2018.05.04 16:00:19 INFO app[][o.s.a.p.ProcessLauncherImpl] Launch process[[key='es', ipcIndex=1, logFilenamePrefix=es]] from [/usr/local/sonarqube-6.7.3/elasticsearch]: /usr/local/sonarqube-6.7.3/elasticsearch/bin/elasticsearch -Epath.conf=/usr/local/sonarqube-6.7.3/temp/conf/es
-
2018.05.04 16:00:19 INFO app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
-
2018.05.04 16:00:25 INFO app[][o.e.p.PluginsService] no modules loaded
-
2018.05.04 16:00:25 INFO app[][o.e.p.PluginsService] loaded plugin [org.elasticsearch.transport.Netty4Plugin]
-
2018.05.04 16:01:44 INFO app[][o.s.a.SchedulerImpl] Process[es] is up
- 2018.05.04 16:01:44 INFO app[][o.s.a.p.ProcessLauncherImpl] Launch process[[key='web', ipcIndex=2, logFilenamePrefix=web]] from [/usr/local/sonarqube-6.7.3]: /usr/local/jdk1.8/jre/bin/java -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djava.io.tmpdir=/usr/local/sonarqube-6.7.3/temp -Xmx512m -Xms512m -XX:+HeapDumpOnOutOfMemoryError -cp ./lib/common
三:驗證
1.sonarque UI介面
2.UI 介面漢化
下載sonar-l10n-zh-plugin-1.19.jar 到 /usr/local/sonarqube-6.7.3/extensions/plugins
重啟sonarqube
3.啟動sonar-runner 對desktop專案程式碼進行分析, 分析結果透過UI介面可以看到。
./usr/local/sonar-runner-2.4/bin/sonar-runner -e -X
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28624388/viewspace-2153847/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- kubernetes實踐之三十二:Jenkins和SonarQube整合Jenkins
- .net持續整合sonarqube篇之sonarqube基本操作(二)
- SonarQube學習(六)- SonarQube之掃描報告解析
- .net持續整合sonarqube篇之sonarqube安裝與基本配置
- .net持續整合sonarqube篇之 sonarqube與jenkins整合(命令模式)Jenkins模式
- sonarqube配置全指南,sonarqube踩坑記錄
- .net持續整合sonarqube篇之 sonarqube與jenkins整合(外掛模式)Jenkins模式
- SonarQube系列三、Jenkins整合SonarQube(dotnetcore篇)JenkinsNetCore
- SonarQube學習(一)- 使用Docker安裝SonarQube(親測可用)Docker
- SonarQube搭建手記
- 使用docker搭建sonarqubeDocker
- 程式碼稽核之搭建 SonarQube 環境
- SonarQube 安裝配置使用
- 搭建sonarqube分析golang程式碼Golang
- SonarQube整合gitlab/jenkinsGitlabJenkins
- SonarQube在CentOS上的安裝CentOS
- 程式碼質量管理平臺之SonarQube安裝部署
- 如何使用Tin安裝SonarQube(史上最快)
- 使用 SonarQube 追蹤程式碼問題
- SonarQube 的 Quality Gate 是指什麼?
- CentOS6.8安裝配置sonarqube6.4CentOS
- SonarQube系列一、Linux安裝與部署Linux
- k8s 快速部署 sonarqube 詳解K8S
- 持續整合工具之jenkins+sonarqube做程式碼掃描Jenkins
- SonarQube學習(三)- 專案程式碼掃描
- .net持續整合sonarqube篇之專案管理與使用者管理專案管理
- SonarQube系列二、分析dotnet core/C#程式碼C#
- 手把手教你SonarQube入門安裝與使用
- Framework專案持續整合(jenkins)及集合SonarQubeFrameworkJenkins
- SonarQube 5.0 釋出,程式碼質量管理平臺
- 基於SonarQube程式碼質量檢查工具總結
- 有手就行10——Jenkins+SonarQube程式碼審查Jenkins
- kubernetes實踐之十一:EFK
- kubernetes實踐之五十二:Helm
- kubernetes實踐之五十七:PodPreset
- kubernetes實踐之五十八:CronJob
- kubernetes實踐之十七:架構架構
- kubernetes實踐之十九:API概述API