NYCPHP Meetup

NYPHP.org

[nycphp-talk] Seeking recommendations for resources on LAMP best practices

Tim Sailer sailer at bnl.gov
Tue Oct 15 11:29:46 EDT 2002


On Tue, Oct 15, 2002 at 11:17:00AM -0400, DeWitt, Michael wrote:
> 	3. what is the best way to setup and maintain a backup "hot"
> apache/mysql server? 
> 
> 	Can this be practically done with standard linux installs and the
> capabilites of the OS and server daemons?

The way I do this is first, get two web servers running, configured
identical. Keeping them that way can be a chore, but that's another question.
Use rsync between them to keep your content current. One hole this leaves
is log files, which, to e-commerce sites, may be more important than
content, so I'd look at mysql logging from apache, os that ilk. Mysql
is simple. You can set up 2 replicated servers, but the best way
is to have 3 servers, with the master being where all the writes are
going, and replicated to the slaves, where the reads are done. Now, in
your database code, when you try to attach to your primary slave server,
if that fails, simply try to attach to your 'hot spare' server.

I know this is Perl and LDAP, but it will work the same way in PHP/Mysql.
I just happen to have this code open in my editor:

$ldap=Net::LDAP->new('ldapA.bnl.gov') or $ldap=Net::LDAP->new('ldapB.bnl.gov') or $ldap=Net::LDAP->new('ldapC.bnl.gov') or die "$@";

This way, one call should almost always yield a database connection.

Tim

-- 
Tim Sailer <sailer at bnl.gov> 
Application Services
Information Technology Division
Brookhaven National Laboratory  (631) 344-3001



More information about the talk mailing list