针对我的SonarQube 4.1实例在声纳示例项目上运行 sonar-runner 失败。在堆栈跟踪中,我注意到它出现以下错误:
引起:java.sql.SQLException:用户'声纳'的访问被拒绝@'172.23.48.129'
那个ip是我的本地机器IP。我的SonarQube服务器位于不同的盒子上。
我的sonar-runner.properties和sonar-project.properties文件没有将jdbc设置为该IP(或解析为该IP的主机名)。甚至下面的INFO级别日志也将证明这一点。
奇怪的是,我可以在同一个示例项目上运行sonar-runner,同时指向SonarQube 4.5的测试实例并且分析成功运行。
错误输出并提供以下输出:
sonar-runner -X
SonarQube Runner 2.4
Java 1.7.0_79 Oracle Corporation (64-bit)
Mac OS X 10.10.3 x86_64
INFO: Error stacktraces are turned on.
INFO: Runner configuration file: /Users/senatori/Documents/sonar-runner-2.4/conf/sonar-runner.properties
INFO: Project configuration file: /Users/senatori/Documents/sonar-examples/projects/languages/groovy/groovy-sonar-runner/sonar-project.properties
INFO: Default locale: "en_US", source code encoding: "UTF-8"
INFO: Work directory: /Users/senatori/Documents/sonar-examples/projects/languages/groovy/groovy-sonar-runner/./.sonar
INFO: SonarQube Server 4.1.1
18:10:05.102 INFO - Load batch settings
18:10:05.121 DEBUG - Download: http://sonar.redac.dev/batch_bootstrap/properties?dryRun=false (no proxy)
18:10:05.298 INFO - User cache: /Users/senatori/.sonar/cache
18:10:05.311 INFO - Install plugins
18:10:05.311 DEBUG - Download index of plugins
18:10:05.311 DEBUG - Download: http://sonar.redac.dev/deploy/plugins/index.txt (no proxy)
18:10:05.648 INFO - Install JDBC driver
18:10:05.648 DEBUG - Download index of jdbc-driver
18:10:05.648 DEBUG - Download: http://sonar.redac.dev/deploy/jdbc-driver.txt (no proxy)
18:10:05.699 INFO - Create JDBC datasource for jdbc:mysql://sonardb001.redac.dev:3306/sonar?useUnicode=true&characterEncoding=utf8
18:10:06.282 DEBUG - To prevent a memory leak, the JDBC Driver [com.mysql.jdbc.Driver] has been forcibly deregistered
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 2.173s
Final Memory: 9M/123M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
at java.security.AccessController.doPrivileged(Native Method)
at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
at org.sonar.runner.api.Runner.execute(Runner.java:100)
at org.sonar.runner.Main.executeTask(Main.java:70)
at org.sonar.runner.Main.execute(Main.java:59)
at org.sonar.runner.Main.main(Main.java:53)
Caused by:
为清晰起见,省略了一些堆栈跟踪
Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user 'sonar'@'172.23.48.129' (using password: YES))
at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388)
at org.apache.commons.dbcp.BasicDataSource.getLogWriter(BasicDataSource.java:1098)
at org.apache.commons.dbcp.BasicDataSourceFactory.createDataSource(BasicDataSourceFactory.java:350)
at org.sonar.core.persistence.DefaultDatabase.initDatasource(DefaultDatabase.java:142)
at org.sonar.core.persistence.DefaultDatabase.start(DefaultDatabase.java:75)
... 32 more
Caused by: java.sql.SQLException: Access denied for user 'sonar'@'172.23.48.129' (using password: YES)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1078)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4190)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4122)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:927)
at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1709)
知道为什么会这样做吗? 感谢
答案 0 :(得分:1)
消息Access denied for user 'sonar'@'172.23.48.129'
告诉您用户sonar
无法从您的计算机连接到SonarQube 4.1实例的数据库架构(IP地址为172.23.48.129)。
请检查此架构的权限,以便顺利进行操作,例如:
GRANT USAGE ON `sonar`.<your sonar db> TO 'sonar'@'%' IDENTIFIED BY PASSWORD '*XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
GRANT ALL PRIVILEGES ON `sonar`.<your sonar db> TO 'sonar'@'%'
...或某些相关的IP地址范围,而不是'%'
。