This is a very, very complex subject, and not one that can be covered in a little text box. Start here with a simple overview:
Data Replication in Distributed System[
^] and then follow some Google links:
distributed database replication - Google Search[
^]
This is not a trivial project, not even slightly, and it is one that requires serious thought before you start implementing it as the database has to be designed from the start to support this. Will you find "available source code" that will exactly fill your needs? No, almost certainly not!