2

我有一个 Grails (2.2.1) 应用程序,我正在尝试为其配置 MySQL 复制。这些设置可以通过“grails run-app”正常工作,但在通过 Tomcat 运行时会失败:

dataSource {
    dbCreate = "update"
    url = "jdbc:mysql:replication://app1-db.cykm5cykm5.us-east-1.rds.amazonaws.com,app1-db-rr1.cykm5cykm5.us-east-1.rds.amazonaws.com/app1_production?useUnicode=true&characterEncoding=UTF-8"
    driverClassName = "com.mysql.jdbc.ReplicationDriver"

    username = "Username"
    password = "Password"

    properties {
        defaultReadOnly = false
        initialSize = 10
        maxActive = 110
        maxIdle = 60
        minIdle = 10
        maxWait = 10000
    }
}

抛出的异常是:

Caused by: java.sql.SQLException: Must specify at least one slave host to connect to for master/slave replication load-balancing functionality
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1075)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:984)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:929)
        at com.mysql.jdbc.NonRegisteringDriver.connectReplicationConnection(NonRegisteringDriver.java:393)
        at com.mysql.jdbc.NonRegisteringReplicationDriver.connect(NonRegisteringReplicationDriver.java:52)
        at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
        at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:582)
        at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1556)
        at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1545)
        ... 8 more

知道为什么我会看到这个异常,以及为什么它在运行 grails 开发服务器时没有出现吗?

提前致谢。

4

1 回答 1

0

事实证明这是定义第二个数据源的问题。正在为两个数据源加载复制驱动程序,即使第二个数据源具有非复制连接字符串。

使用复制友好的连接字符串配置第二个数据源解决了该问题。

于 2013-06-07T23:12:04.073 回答