安装sonarqube

###安装sonarqube
参考文档:http://docs.sonarqube.org/display/SONAR/Installing;jsessionid=3289FBBED467184DA557AA365695A5AE
1. 下载
sonarqube-5.1.zip
  链接:http://www.sonarqube.org/downloads/
解压后目录路径$SONAR_HOME

2. 系统需求和存储数据库优化
要求jdk 7u55+,mysql 5.1,5.5,5.6,5.7; 5.0版本数据库测试ok
http://www.percona.com/blog/2007/11/01/innodb-performance-optimization-basics/
mysql的my.cnf中配置
#这个参数的优化配置是70-80% of memory,sonar至少需要15Mb
innodb_buffer_pool_size=512M

3. 创建sonar数据库和帐号
CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER 'sonar' IDENTIFIED BY 'sonar';
GRANT ALL PRIVILEGES ON sonar.* TO 'sonar'@'%' IDENTIFIED BY 'sonar' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON sonar.* TO 'sonar'@'localhost' IDENTIFIED BY 'sonar' WITH GRANT OPTION;
FLUSH PRIVILEGES;

4. sonar参数配置
vim $SONAR_HOME/conf/sonar.properties
#数据库连接
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
sonar.jdbc.url=jdbc:mysql://10.10.72.143:3306/sonar?useUnicode=true&characterEncoding=utf8
#web服务
sonar.web.host=10.10.72.143
sonar.web.port=80
sonar.web.context=/

5. sonar启动配置
vim $SONAR_HOME/conf/sonar.properties
#jdk
wrapper.java.command=/opt/java/jdk1.7.0_75/jre/bin/java

6. 启动
$SONAR_HOME/bin/<YOUR OS>/sonar.sh start
对于linux 64位系统,<YOUR OS>选择linux-x86-64
访问方法
http://10.10.72.143/

###分析客户端,maven配置
maven的settings.xml中增加
<settings>
    <profiles>
        <profile>
            <id>sonar</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <sonar.jdbc.url>
                  jdbc:mysql://10.10.72.143:3306/sonar?useUnicode=true&amp;characterEncoding=utf8
                </sonar.jdbc.url>
                <sonar.jdbc.username>****</sonar.jdbc.username>
                <sonar.jdbc.password>****</sonar.jdbc.password>

                <!-- Optional URL to server. Default value is http://localhost:9000 -->
                <sonar.host.url>
                  http://10.10.72.143
                </sonar.host.url>
            </properties>
        </profile>
     </profiles>
</settings>
设置maven的环境变量
linux:
export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=128m"
windows:
set MAVEN_OPTS=-Xmx512m -XX:MaxPermSize=128m


###插件安装
1. 以管理员帐号登陆admin:adminadmin1+1
2. settings->system->update center->available plugins打开可选插件列表
3. 选择安装LOCALIZATION->chinese pack

###分析
执行mvn sonar:sonar

删除工程---在相应工程里的配置最后一项进行删除

你可能感兴趣的:(Sonar)