1. Pre-install jdk (1.7) and mysql
2. View mysql configuration
--Login: mysql -u root -p
--View engine: show engines;
--View the default storage engine: show variables like '%storage_engine%';
--exit mysql:exit
3. Modify the mysql configuration
--The current configuration is: cat /etc/my.cnf
--Modify related configuration
--default engine
default-storage-engine=INNODB
--innodb buffer size, the main cache index, data, etc., recommended for the operating system (70% memory)
innodb_buffer_pool_size=200M
--Enable and set the query cache size
query_cache_type=1
query_cache_size=32M
--View the configuration, the red box is for adding content
-- restart mysql service
service mysqld restart
4. Use the client to create a database
5. Download or upload by subcontract
cd / opt
--Unzip: unzip sonarqube-4.5.4.zip
--Double naming: mv sonarqube-4.5.4 sonarqube
--Modify the configuration file (open or modify the following configuration)
vi sonarqube/conf/sonar.properties
#mysql username and password
sonar.jdbc.username=root
sonar.jdbc.password=test
#mysql connection configuration (marked in red is the database name)
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonarqube?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance
#Accessible ip (0 is configured as unlimited, the default is this value)
sonar.web.host=0.0.0.0
#Access path
sonar.web.context=/sonarqube
#内部服务端口,本机此端口已被其他服务占用
sonar.search.port=9091
#web访问端口,本机此端口已被其他服务占用
sonar.web.port=9090
--开启防火墙中的端口过滤
vi /etc/sysconfig/iptables
追加:-A INPUT -m state --state NEW -m tcp -p tcp --dport 9090 -j ACCEPT
重启服务:service iptables restart
--启动服务,查看启动日志(标红为linux的位数,本机为32位操作系统)
./sonarqube/bin/linux-x86-32/sonar.sh start
tail -f sonarqube/logs/sonar.log
--第一次启动会自动创建所需的表及初始化数据,可能会有点慢
--访问测试(默认用户名和密码都是:admin)
http://192.168.0.206:9090/sonarqube
注意事项:
1、当前版本与JDK1.7兼容,在update center中的插件都是针对最新版本的sonar进行插件集成,所以需要单独编译相关插件包或者直接将下载好对应版本的插件包放置在插件目录(/opt/sonarqube/extensions/plugins)
2、在eclipse中执行maven-sonar命令:sonar:sonar,需要在settings.xml的profiles加入配置
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<!-- Example for MySQL-->
<sonar.jdbc.url>jdbc:mysql://192.168.0.206:3306/sonarqube?useUnicode=true&characterEncoding=utf8</sonar.jdbc.url>
<sonar.jdbc.username>root</sonar.jdbc.username>
<sonar.jdbc.password>test</sonar.jdbc.password>
<!-- Optional URL to server. Default value is http://localhost:9000 -->
<sonar.host.url>http://192.168.0.206:9090/sonarqube</sonar.host.url>
</properties>
</profile>
3、介于当前版本问题,需要指定分析器插件的版本,在运行工程的pom文件中
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>2.3</version>
</plugin>
</plugins>
</build>