Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have been using one EC2 instance with EBS, php abd MySQL installed. I would like to use a load balance.

I was wondering how I can share the data in MySQL database between EC2 instances Thanks in advance.

share|improve this question

migrated from stackoverflow.com Nov 15 '11 at 3:30

This question came from our site for professional and enthusiast programmers.

2 Answers 2

up vote 2 down vote accepted

It's not entirely clear what you are asking, but here's a standard setup:

  • One instance running MySQL.

  • One or more instances running your web server and app software.

  • Load balancer pointing to the front end web servers.

Here's an article I wrote a while back describing the community's best practices for running MySQL with EBS:

Running MySQL on Amazon EC2 with EBS
http://aws.amazon.com/articles/1663

You'll need to make sure that MySQL is listening on 0.0.0.0 and not 127.0.0.1 (bind-address in /etc/my.cnf).

You'll also want to make sure that nobody on the Internet can connect to your MySQL server on the database port (generally 3306). Your security group should be configured so that only your application servers can connect to the database server.

You should also consider simply using Amazon RDS (Relational Database Server). No need to manage MySQL yourself if Amazon's setup works for you.

share|improve this answer
    
Thanks for your answer. Another question is how I can access the MySQL EC2 instance from the web server EC2 instance. I was using php to take HTTP POST variable and get data from local MySQL server. If I change the architecture as you mentioned then do I add php scripts on MySQL EC2 instance and send another request to the EC2 instance from web server instance? I think this is a basic question but I am a newbie to AWS and server side programming. I really appreciate your help. Thanks. –  LCYSoft Nov 14 '11 at 6:15

You can't do this by normal replication. Suppose the SQL servers contain bank balances. I connect to one server and transfer $1,000 to Jack. A split-second later, I connect to the other server and transfer the same $1,000 to Jill. How can the two SQL servers now share their data?

You really have two basic choices. You can implement an application-specific solution. (What's your application? There might be a simple one.) Or you can use a clustering database like MySQL Cluster.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.