Amazon Web Services - RDS IP Address and Tomcat
I am planning to use AWS (Amazon Web Services) to build a portal using Tomcat and MySQL. For Tomcat I would be using an EC2 instance and for MySQL I would be using RDS (Relational Database Service).
When an RDS instance is started it's assigned an IP address. How can I get this IP address in the Tomcat EC2 instance and use it in the JDBC URL? How does this work with and without Static IP开发者_运维技巧 Addresses?
Thanks, Praveen
Using the AWS command line tools. Ask for a listing of RDS instances to get their endpoints.
Or you can just log in to your AWS account, navigate to "My DB Instances" and click on the database of interest. You will then see the properties of the instance, including the endpoint. Just copy and paste it. It will look something like this:
String url = "jdbc:mysql://dbname.foo.us-east-1.rds.amazonaws.com:3306/";
That is the exact url String format I use to access my RDS instance. Hope that helps :)
Go to the ec2 console panel,and find the [NETWORK & SECURITY] ,and click [Network Interfaces],then you will see the mysql network interface,and it's private ip, hope for help
You could do this manually by using elasticfox, right-clicking on the instance, getting the internal ip and using it on the tomcat instance.
You can use the "Endpoint" DNS name. It will resolve to the internal IP when used within EC2 and resolves to a public ip when used outside. You should never use the actual IP address because the way the RDS works it could possibly change in the future. If you ping it from your EC2 server you can verify this.
精彩评论