Amazon RDS和Elastic Beanstalk连接

时间:2011-06-01 05:24:12

标签: grails amazon-rds elastic-beanstalk

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

  • 我还打开了端口,接受来自“All”的连接,用于我的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
        }
    }
}

1 个答案:

答案 0 :(得分:1)

我解决了它,但是非常愚蠢的回答。

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

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