make a mirror script like on phpclasses.org

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
goranrakic
Forum Newbie
Posts: 3
Joined: Thu Dec 26, 2002 8:48 am
Location: Serbia (Yugoslavia)
Contact:

make a mirror script like on phpclasses.org

Post by goranrakic »

How to make an advance mirror script that will check for updates of mysql data and script, transfer traffic from one mirror to other and so on... like on phpcalsses.org. I donow have any idea how to make this, so i will be thankfull for any clue.

Bye,
Goran
User avatar
BigE
Site Admin
Posts: 139
Joined: Fri Apr 19, 2002 9:49 am
Location: Missouri, USA
Contact:

Post by BigE »

Your probably going to have to compare timestamps or something. I suppose you could also count rows. I'm not totally sure how to do this either, seeing as I've never done it before.
kcomer
Forum Contributor
Posts: 108
Joined: Tue Aug 27, 2002 8:50 am

Post by kcomer »

MySQL has a feature called binary logging. It logs all INSERT, DELETE, UPDATE etc... commands that are made to the databases(can limit to only certain db's aswell), this file is then used to replicate the data to all the slave mysql servers, but you could just as easily write a php script to parse the binary log file and execute the sql commands on the other mysql servers. This will save you the hassle of setting up mysql replication, which isn't too hard though, and will give you some of the same functionality. All this relys on you having your own mysql servers though, or an admin who will work with you to set this up. I don't know of any php scripts that can parse this but it could be done. Also, you'll want to use the mysql program mysqlbinlog to export the binary-log to a text file, this will make it easier to parse.

Another way could be to duplicate the mysql bonary-log function by writing your php scripts to write the sql command to a text file after it executes it in the database. Then ftp(or whatever) the file to another server and run a php script to parse the file and execute the commands.

I hope this has given you some ideas. Let me know if you want more help with this. You have sparked my interest and I can think of some uses for this myself. Here is a good link on mysql's site. http://www.mysql.com/doc/en/Replication.html

Keith
goranrakic
Forum Newbie
Posts: 3
Joined: Thu Dec 26, 2002 8:48 am
Location: Serbia (Yugoslavia)
Contact:

Post by goranrakic »

I was thinking about storing some kind of changelog of site on server. Every 1 hour, mirrors can parse it (xml for example) and make a replication of site from main site. But how to make reverse process (to make a replication of partly chacged mirror to master site). I thouth that someone of you have some ready2use idea, but if you donot know, i will think about it when i need it (in next 2 months) and than I will present you a solution.

Bye,
Goran
Post Reply