1.安装mysql
安装的mysql的percona分支;
文档:http://www.percona.com/doc/percona-server/5.6/
安装包:Percona-Server-5.6.21-70.0-r688-el6-x86_64-bundle.tar
百度云下载链接:https://pan.baidu.com/s/1Zp0ocOkr_rjXxizjvA1KaA 密码:e47f
首先安装cmake
yum -y install cmake
cd /usr/local/src/
cd mysql-percona/
rz 上传安装包
tar -xvf Percona-Server-5.6.21-70.0-r688-el6-x86_64-bundle.tar
rpm -ivh Percona-Server-shared-56-5.6.21-rel70.0.el6.x86_64.rpm
rpm -ivh Percona-Server-client-56-5.6.21-rel70.0.el6.x86_64.rpm
rpm -ivh Percona-Server-server-56-5.6.21-rel70.0.el6.x86_64.rpm
启动:
修改root密码:
mysqladmin -u root password "root"
登录:
mysql -uroot -proot
设置远程访问(使用root密码):
grant all privileges on *.* to 'root' @'%' identified by 'root';
防火墙打开3306端口
/sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
/etc/rc.d/init.d/iptables save
/etc/init.d/iptables status
2.创建数据库
在mysql中执行如下脚本创建数据库及mysql用户
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';
3.安装sonarqube
sonarqube5.5 百度云下载地址链接:https://pan.baidu.com/s/1dZm5jUZiGha0edPEsom2_g 密码:hq4u
解压sonarqube-5.5.zip
#unzip sonarqube-5.5.zip
编辑${SONAR_HOME}/conf/sonar.properties配置数据库:
sonar.jdbc.username:sonar
sonar.jdbc.password:sonar
sonar.jdbc.url: jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true
# Optional properties
sonar.jdbc.driverClassName: com.mysql.jdbc.Driver
启动服务
目录切换至sonar的<install_directory>/bin/linux-x86-64/目录,启动服务
#./sonar.sh start 启动服务
#./sonar.sh stop 停止服务
#./sonar.sh restart 重启服务
至此,sonar就安装好了
本机访问http://localhost:9000即可
4.分析maven项目
Edit the settings.xml file, located in $MAVEN_HOME/conf or ~/.m2, to set the plugin prefix and optionally the SonarQube server URL.
Example:
<settings> <pluginGroups> <pluginGroup>org.sonarsource.scanner.maven</pluginGroup> </pluginGroups> <profiles> <profile> <id>sonar</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <sonar.host.url> </sonar.host.url> </properties> </profile> </profiles> </settings> |
Analyzing a Maven project consists of running a Maven goal: sonar:sonar in the directory where the pom.xml file sits.
mvn clean verify sonar:sonar
# In some situation you may want to run sonar:sonar goal as a dedicated step. Be sure to use install as first step for multi-module projects mvn clean install mvn sonar:sonar
# Specify the version of sonar-maven-plugin instead of using the latest. See also 'How to Fix Version of Maven Plugin' below. mvn org.sonarsource.scanner.maven:sonar-maven-plugin:3.0.2:sonar |