使用 MySql 设置声纳

Sonar setup with MySql(使用 MySql 设置声纳)

本文介绍了使用 MySql 设置声纳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将声纳 Qube 5.5 默认数据库更改为 Mysql.但它仍在连接到默认 H2 DB.

Iam trying to change the sonar Qube 5.5 default database to Mysql.But it is still connecting to default H2 DB.

配置如下.

我已经在 Mysql DB 中运行了以下脚本

I have run the below scripts in Mysql DB

# Create SonarQube database and user.
#
# Command: mysql -u root -p < create_database.sql
#

    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;

取消注释 Mysql 的 sonar.jdbc.url,我无法看到 H2 DB 的配置来注释它.

uncommented the sonar.jdbc.url for Mysql,Iam not able to see the configuration for H2 DB to comment it.

  # Property values can:                                                                                                                               
    # - reference an environment variable, for example sonar.jdbc.url= ${env:SONAR_JDBC_URL}                                                             
    # - be encrypted. See http://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.                                                         

# User credentials.                                                                                                                                  
# Permissions to create tables, indices and triggers must be granted to JDBC user.                                                                   
# The schema must be created first.                                                                                                                  
sonar.jdbc.username=sonar                                                                                                                            
sonar.jdbc.password=sonar                                                                                                                            

#----- Embedded Database (default)                                                                                                                   
# H2 embedded database server listening port, defaults to 9092                                                                                       
#sonar.embeddedDatabase.port=9092                                                                                                                    

#----- MySQL 5.x                                                                                                                                     
# Only InnoDB storage engine is supported (not myISAM).                                                                                              
# Only the bundled driver is supported. It can not be changed.                                                                                       
sonar.jdbc.url=jdbc:mysql://10.9.153.6:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance

然后我从 Administration->system -> Systeminfo 重新启动了服务器.

Then I restarted the server from Administration->system -> Systeminfo.

使用命令行重启后出现此错误:

After restart using cmd line getting this error:

2017.07.20 22:32:54 WARN  web[o.s.p.ProcessEntryPoint] Fail to start web                                                                             
java.lang.IllegalStateException: Webapp did not start                                                                                                
        at org.sonar.server.app.EmbeddedTomcat.isUp(EmbeddedTomcat.java:84) ~[sonar-server-5.5.jar:na]                                               
        at org.sonar.server.app.WebServer.isUp(WebServer.java:48) [sonar-server-5.5.jar:na]                                                          
        at org.sonar.process.ProcessEntryPoint.launch(ProcessEntryPoint.java:105) ~[sonar-process-5.5.jar:na]                                        
        at org.sonar.server.app.WebServer.main(WebServer.java:69) [sonar-server-5.5.jar:na]                                                          
2017.07.20 22:32:54 INFO  web[o.a.c.h.Http11NioProtocol] Pausing ProtocolHandler ["http-nio-0.0.0.0-9000"]                                           
2017.07.20 22:32:55 INFO  web[o.a.c.h.Http11NioProtocol] Stopping ProtocolHandler ["http-nio-0.0.0.0-9000"]                                          
2017.07.20 22:32:55 INFO  web[o.a.c.h.Http11NioProtocol] Destroying ProtocolHandler ["http-nio-0.0.0.0-9000"]                                        
2017.07.20 22:32:55 INFO  web[o.s.s.a.TomcatAccessLog] Web server is stopped  

推荐答案

您似乎做出了正确的配置更改,但您所做的 UI 内重启并不是完全"重启.从命令行重新启动,您的实例应该连接到您配置的数据库.

You appear to have made the correct configuration changes, but the in-UI restart you did is not a "full" restart. Do a restart from the command line and your instance should connect to your configured database.

这篇关于使用 MySql 设置声纳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:使用 MySql 设置声纳

基础教程推荐