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.

So I have three rack servers here, the main one connected to the WWW and has a public ip, its running HAProxy set up to point to the other two servers.

The other two are running apache which a cron rsync job is downloading the web files to them from a directory on the master controller server.

It all works fine but, I'm currently running MySQL on the control server but I want it to work like the apache and haproxy system is. What are the way to do this?

Also say if a user is on wordpress and uploads a file/image for a post, it is only stored on the local server which the files get overwritten by rsync every 1min. How do I do a merge of directories?

btw, All three servers are Ubuntu 10.04 server

Thanks.

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

In any situation where you have more than 1 web server, you'll need a central location to store file uploads and session data.

If the files are not too big, you might consider storing them directly in your MySQL database, otherwise you can setup an NFS-share directory on one of your servers, and mount it on the others. This way when a user uploads a file, no matter what server he's on, the file will be accessible.

The downside to this is if the NFS server (or web server with NFS share) crashes or becomes unavailable, all your file uploads will disappear.. so you should plan to backup those files regularly and modify your web application to access the files from the backup location if the NFS is unavailable.

As for load-balancing MySQL, I've written an article for that a few years ago: http://www.alexwilliams.ca/blog/2009/08/10/using-haproxy-for-mysql-failover-and-redundancy/index.html

I also wrote a book with different load-balancing and scaling infrastructures if that might help you: http://scalingexperts.com/books/

share|improve this answer
add comment

I might suggest that a distributed filesystem such as Gluster will accomplish much of what you need. Set up replicated bricks between the servers (since you are only using 3, replicated would be safer), and each server will see the files of all other servers as being 'local' - even if one server fails, the files have been replicated to the other servers.

You can also run MySQL on a Gluster volume - so that your databases are shared between multiple servers - it does have some advantages over straight replication. If you are using InnoDB tables, you will have to delay locking, but it should work with both MyISAM and InnoDB.

Gluster will maintain the file synchronization across volumes (bricks), and has 'self-healing' capabilities that will deal with any inconsistencies due to one server being offline. Should help with your directory merging, and is fairly easy to setup.

share|improve this answer
    
Gluster looks like what i need, thanks –  dx282 Jul 9 '11 at 17:24
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.