SonarQube可以连接Azure SQL数据库吗? [英] Can SonarQube connect Azure SQL Database?

查看:72
本文介绍了SonarQube可以连接Azure SQL数据库吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的SonarQube在Microsoft Azure的VM实例上运行.现在,SonarQube的数据库是MySQL,并且我正尝试将MySQL更改为Azure SQL数据库,但是SonarQube无法通过ActiveRecord组件上发生的某些错误来连接Azure SQL数据库.我知道SonarQube不正式支持Azure SQL数据库,也不支持下面的SQL Server,但是Azure SQL数据库与SQL Server兼容,因此可以连接Azure SQL数据库. 如果有人知道,请告诉我如何连接Azure SQL数据库.

My SonarQube is running on VM instance of Microsoft Azure. Now the SonarQube's database is MySQL, and I'm trying to change MySQL to Azure SQL Database, but SonarQube couldn't connect Azure SQL Database by some erroes which occured at ActiveRecord component. I know SonarQube doesn't support Azure SQL Database officially and support SQL Server below, nevertheless Azure SQL Database is compatible with SQL Server, so It's may possible to connect Azure SQL Database. Please tell me how to connect Azure SQL Database if anybody knows.

SonarQube的支持数据库

sonar.properties:

sonar.properties:

sonar.jdbc.username=sonar@<server>
sonar.jdbc.password=<password>
sonar.jdbc.driverClassName=net.sourceforge.jtds.jdbc.Driver
jdbc:jtds:sqlserver://<server>.database.windows.net:1433/<databasename>;ssl=require

错误跟踪:

org.jruby.rack.RackInitializationException: no connection available
    from arjdbc/jdbc/RubyJdbcConnection.java:517:in `set_native_database_types'
    from /opt/sonar/web/WEB-INF/gems/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/jdbc/connection.rb:61:in `initialize'
    from /opt/sonar/web/WEB-INF/gems/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/jdbc/adapter.rb:31:in `initialize'
    from /opt/sonar/web/WEB-INF/gems/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/jdbc/connection_methods.rb:6:in `jdbc_connection'
    from org/jruby/RubyKernel.java:2227:in `send'
    from /opt/sonar/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_pool.rb:223:in `new_connection'
    from /opt/sonar/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_pool.rb:245:in `checkout_new_connection'
    from /opt/sonar/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_pool.rb:188:in `checkout'
    from org/jruby/RubyKernel.java:1519:in `loop'
    from /opt/sonar/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_pool.rb:184:in `checkout'
    from jar:file:/opt/sonar/web/WEB-INF/lib/jruby-complete-1.7.9.jar!/META-INF/jruby.home/lib/ruby/1.8/monitor.rb:191:in `mon_synchronize'
    from /opt/sonar/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_pool.rb:183:in `checkout'
    from /opt/sonar/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_pool.rb:98:in `connection'
    from /opt/sonar/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_pool.rb:326:in `retrieve_connection'
    from /opt/sonar/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_specification.rb:123:in `retrieve_connection'
    from /opt/sonar/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_specification.rb:115:in `connection'
    from /opt/sonar/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:440:in `initialize'
    from /opt/sonar/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:401:in `up'
    from /opt/sonar/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:383:in `migrate'
    from /opt/sonar/web/WEB-INF/lib/database_version.rb:62:in `upgrade_and_start'
    from /opt/sonar/web/WEB-INF/lib/database_version.rb:74:in `automatic_setup'
    from /opt/sonar/web/WEB-INF/config/environment.rb:239:in `(root)'
    from org/jruby/RubyKernel.java:1094:in `load'
    from file:/opt/sonar/web/WEB-INF/lib/jruby-rack-1.1.13.2.jar!/jruby/rack/rails/environment2.rb:1:in `(root)'
    from file:/opt/sonar/web/WEB-INF/lib/jruby-rack-1.1.13.2.jar!/jruby/rack/rails/environment2.rb:25:in `load_environment'
    from file:/opt/sonar/web/WEB-INF/lib/jruby-rack-1.1.13.2.jar!/jruby/rack/rails_booter.rb:79:in `load_environment'

    at org.jruby.rack.RackInitializationException.wrap(RackInitializationException.java:29)
    at org.jruby.rack.RackApplicationFactoryDecorator.init(RackApplicationFactoryDecorator.java:98)
    at org.jruby.rack.RackServletContextListener.contextInitialized(RackServletContextListener.java:50)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.jruby.exceptions.RaiseException: (ConnectionNotEstablished) no connection available
    at arjdbc.jdbc.RubyJdbcConnection.set_native_database_types(arjdbc/jdbc/RubyJdbcConnection.java:517)
    at RUBY.initialize(/opt/sonar/web/WEB-INF/gems/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/jdbc/connection.rb:61)
    at RUBY.initialize(/opt/sonar/web/WEB-INF/gems/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/jdbc/adapter.rb:31)
    at RUBY.jdbc_connection(/opt/sonar/web/WEB-INF/gems/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/jdbc/connection_methods.rb:6)
    at org.jruby.RubyKernel.send(org/jruby/RubyKernel.java:2227)
    at RUBY.new_connection(/opt/sonar/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_pool.rb:223)
    at RUBY.checkout_new_connection(/opt/sonar/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_pool.rb:245)
    at RUBY.checkout(/opt/sonar/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_pool.rb:188)
    at org.jruby.RubyKernel.loop(org/jruby/RubyKernel.java:1519)
    at RUBY.checkout(/opt/sonar/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_pool.rb:184)
    at RUBY.mon_synchronize(jar:file:/opt/sonar/web/WEB-INF/lib/jruby-complete-1.7.9.jar!/META-INF/jruby.home/lib/ruby/1.8/monitor.rb:191)
    at RUBY.checkout(/opt/sonar/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_pool.rb:183)
    at RUBY.connection(/opt/sonar/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_pool.rb:98)
    at RUBY.retrieve_connection(/opt/sonar/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_pool.rb:326)
    at RUBY.retrieve_connection(/opt/sonar/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_specification.rb:123)
    at RUBY.connection(/opt/sonar/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_specification.rb:115)
    at RUBY.initialize(/opt/sonar/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:440)
    at RUBY.up(/opt/sonar/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:401)
    at RUBY.migrate(/opt/sonar/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:383)
    at RUBY.upgrade_and_start(/opt/sonar/web/WEB-INF/lib/database_version.rb:62)
    at RUBY.automatic_setup(/opt/sonar/web/WEB-INF/lib/database_version.rb:74)
    at RUBY.(root)(/opt/sonar/web/WEB-INF/config/environment.rb:239)
    at org.jruby.RubyKernel.load(org/jruby/RubyKernel.java:1094)
    at RUBY.(root)(file:/opt/sonar/web/WEB-INF/lib/jruby-rack-1.1.13.2.jar!/jruby/rack/rails/environment2.rb:1)
    at RUBY.load_environment(file:/opt/sonar/web/WEB-INF/lib/jruby-rack-1.1.13.2.jar!/jruby/rack/rails/environment2.rb:25)
    at RUBY.load_environment(file:/opt/sonar/web/WEB-INF/lib/jruby-rack-1.1.13.2.jar!/jruby/rack/rails_booter.rb:79)

谢谢

推荐答案

在这个问题上花了6个令人沮丧的小时之后,我才发现.以下是我遇到的问题以及针对每个问题提出的解决方案:

It's possible, I just discovered, after spending 6 pretty frustrating hours on this issue. Here are the issues I encountered and the solutions I came up with for each:

  1. 无法连接到Azure SQL Server数据库-连接将超时.解决方案是在连接URL中添加; ssl = require",并添加-Djsse.enableCBCProtection = false(请参见

  1. Couldn't connect to the Azure SQL Server database -- connection would just time out. The solution was to add ";ssl=require" to the connection URL and -Djsse.enableCBCProtection=false (see Connecting to Azure SQL DB via JTDS on an Android device) to the server's java parameters (in conf/wrapper.conf). Here's what my database configuration looks like:

sonar.jdbc.username=<username>@SERVER
sonar.jdbc.password=<password>
sonar.jdbc.url=jdbc:jtds:sqlserver://SERVER.database.windows.net:1433/DATABASE;ssl=require;SelectMethod=Cursor

我还将extensions/jdbc-driver/mssql中的jTDS驱动程序从1.2.8升级到1.3.1,但这可能不是必需的.

I also upgraded the jTDS driver in extensions/jdbc-driver/mssql from 1.2.8 to 1.3.1, but that might not be necessary.

SonarQube创建了一些没有聚集索引的表,而Azure SQL Server不支持这些聚集索引(请参阅

SonarQube creates some tables without clustered indexes, which Azure SQL Server doesn't support (see Tables without a clustered index are not supported in this version of SQL Server). To solve that issue, I needed to install SonarQube locally using a local SQL Server Express instance. After doing that I ran the following DDL to convert the problematic tables to use clustered indexes:

CREATE UNIQUE CLUSTERED INDEX Idx_schema_migrations ON dbo.schema_migrations(version);
CREATE UNIQUE CLUSTERED INDEX Idx_groups_users ON dbo.groups_users(user_id,group_id);

最后,现在该数据库与Azure兼容,在SSMS内,我右键单击该数据库,选择任务/将数据库部署到SQL Azure,然后将其部署到我的Azure服务器".

Finally, now that the database is Azure-compatible, inside SSMS I right-clicked on the database, selected Tasks/Deploy Database to SQL Azure, and deployed it to my Azure server.

SonarQube的数据库升级程序不支持SQL Server 2014(从4.3升级到4.4时,您会收到此版本的SQL Server不支持不推荐使用的功能'具有两部分名称的DROP INDEX"错误) ).我必须重新安装才能解决该问题,尽管您可能自己找出必要的升级DML/DDL或升级SonarQube的ActiveRecord JDBC MSSQL适配器(希望他们在下一个版本中可以做到).

SonarQube's database upgrader doesn't support SQL Server 2014 (you get a "Deprecated feature 'DROP INDEX with two-part name' is not supported in this version of SQL Server" error while it's upgrading from 4.3 to 4.4). I had to do a fresh install to get around that issue, though it's probably possible to either figure out the necessary upgrade DML/DDL yourself or upgrade SonarQube's ActiveRecord JDBC MSSQL adapter (hoping they'll do that in their next version).

简单吧? :p

这篇关于SonarQube可以连接Azure SQL数据库吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆