3

已经有几个线程讨论了这个问题,我已经尝试实施 Elastic Beanstalk -> RDS connection error using Grails中讨论的建议。

  • 我还在我的 EC2 实例中打开了端口以接受来自 ICMP、TCP 和 UDP 的“全部”连接。

  • 我已确保我的 RDS 和 EC2 实例位于同一区域(东部)

  • 我还在 RDS 默认安全组中添加了“elasticbeanstalk-default”安全组

  • 我已经在 RDS CIDR 设置中添加了我的本地机器的 IP 地址,并且我能够从我的机器通过 SQLYog 连接到 RDS。

但是当我尝试从 Elastic Beanstalk 连接我的 RDS 实例时,我收到以下异常

Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:310)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:176)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:163)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:384)
at java.net.Socket.connect(Socket.java:546)
at java.net.Socket.connect(Socket.java:495)
at java.net.Socket.<init>(Socket.java:392)
at java.net.Socket.<init>(Socket.java:235)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:256)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:293)
... 18 more

Jun 1, 2011 5:12:41 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
Jun 1, 2011 5:12:41 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [] startup failed due to previous errors
Jun 1, 2011 5:12:41 AM org.apache.catalina.core.StandardContext listenerStop
SEVERE: Exception sending context destroyed event to listener instance of class         org.codehaus.groovy.grails.web.context.GrailsContextLoaderListener
 org.springframework.beans.factory.BeanCreationException: Error creating bean with name.....
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:636)

我的 DataSource.groovy 参数如下。

production {
    dataSource {
        pooled = true
        dbCreate = "update" // one of 'create', 'create-drop','update'
        url = "jdbc:mysql://[MyEndPoint]:3306/*****"
        username = "*****"
        password = "*****"
        dialect = org.hibernate.dialect.MySQL5InnoDBDialect
        properties {
            validationQuery = "SELECT 1"
            testOnBorrow = true
            testOnReturn = true
            testWhileIdle = true
            timeBetweenEvictionRunsMillis = 1000 * 60 * 30
            numTestsPerEvictionRun = 3
            minEvictableIdleTimeMillis = 1000 * 60 * 30
        }
    }
}
4

1 回答 1

1

我解决了它,虽然很愚蠢的答案。

我一直觉得(认为)在为 NetBeans 中的 Grails 项目构建新的WAR文件时,它是在“生产”环境中创建的,但事实并非如此。我必须转到项目属性并将“活动 grails 环境”设置更改为“生产”,这修复了它。

简而言之,Amazon Web Services Elastic Beanstalk 试图连接到我的开发环境数据库“localhost”。

于 2011-06-02T09:28:23.677 回答