AMI MySQL cluster database access

One of the challenges when deploying MySQL databases and clusters on Amazon EC2 AMIs is that the IP address of the AMIs are assigned dynamically. If your topology involves only a single instance then you can simply use localhost to access your MySQL server.

Cloud Foundry solves this problem by ensuring that ‘dbmaster’ always resolves to the IP address of the MySQL server or lets you launch the application with system property that specifies the MySQL server hostname.

Using the JVM option “-DdbHostName=${databasePrivateDnsName}” sets the the system property’dbHostName’ to the MySQL server’s host name. A Spring/Java application can then use a PropertyPlaceholderConfigurer bean to substitute this value into the database url, e.g. jdbc:mysql://${dbHostName}:3306/.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s