Alfie John > MySQL-Replication > MySQL::Replication

Download:
MySQL-Replication-0.0.2.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  0
View/Report Bugs
Module Version: 0.0.2   Source  

NAME ^

MySQL::Replication - Decentralised, peer-to-peer, multi-master MySQL replication

DESCRIPTION ^

What is MySQL::Replication

MySQL::Replication is a replacement for MySQL's built-in replication. The reason for this module is that there are a number of issues with MySQL's built-in replication:

How Does MySQL::Replication Work

A MySQL::Replication replication topology is made up of:

MySQL::Replication Servers

A MySQL master runs a MySQL::Replication server, which serves queries from its local binlogs e.g.:

  db1.example.com:~$ MySQLReplicationServer.pl --binlog db1:/var/lib/mysql/binlogs/mysql-bin.index

The server running on db1.example.com will serve queries from the binlogs listed in mysql-bin.index.

See MySQLReplicationServer.pl for more information on servers.

MySQL::Replication Clients

A MySQL slave runs the MySQL::Replication client e.g.:

  db2.example.com:~$ MySQLReplicationClient.pl --srchost db1.example.com --srcbinlog db1

The client running on db2.example.com will:

  +-----------------+       +-----------------+
  | db1.example.com | ----> | db2.example.com |
  +-----------------+       +-----------------+

To replicate from multiple masters, run multiple instances of the client e.g.:

  db2.example.com:~$ MySQLReplicationClient.pl --srchost db1.example.com --srcbinlog db1
  db2.example.com:~$ MySQLReplicationClient.pl --srchost db3.example.com --srcbinlog db3

  +-----------------+       +-----------------+       +-----------------+
  | db1.example.com | ----> | db2.example.com | <---- | db3.example.com |
  +-----------------+       +-----------------+       +-----------------+

Note that there is no restriction on where the client and server run. e.g. having all databases replication to and from each other is possible:

  +-----------------+       +-----------------+       +-----------------+
  | db1.example.com | <---> | db2.example.com | <---> | db3.example.com |
  +-----------------+       +-----------------+       +-----------------+
           ^                                                   ^
           |                                                   |
           +---------------------------------------------------+

See MySQLReplicationClient.pl for more information on clients.

MySQL::Replication Relays

A MySQL::Replication relay acts as a proxy cache. In a multi-layer replication topology, middle layers run a MySQL::Replication relay e.g.:

  relay.example.com:~$ MySQLReplicationRelay.pl

The relay running on relay.example.com will:

  +-----------------+       +-------------------+       +-----------------+
  | db1.example.com | ----> | relay.example.com | ----> | db2.example.com |
  +-----------------+       +-------------------+       +-----------------+

By using relays:

Note that there is no restriction on the number of layers of relays e.g. a tree of relays is possible:

  +-----------------+
  | db2.example.com | <---------------+
  +-----------------+                 |
                                      |
  +-----------------+       +--------------------+       
  | db3.example.com | <---- | relay2.example.com | <----------------+ 
  +-----------------+       +--------------------+                  | 
                                                                    |
                                                         +--------------------+       +-----------------+
                                                         | relay1.example.com | <---- | db1.example.com |
                                                         +--------------------+       +-----------------+
                                                                    |
  +-----------------+       +--------------------+                  |
  | db4.example.com | <---- | relay3.example.com | <----------------+ 
  +-----------------+       +--------------------+       
                                      |
  +-----------------+                 |
  | db5.example.com | <---------------+
  +-----------------+ 

See MySQLReplicationRelay.pl for more information on relays.

FAQs

What Happens If There Is A Race Condition On A Record

e.g. An insert to the users table occurs on two seperate databases at the same time for the username 'alfie'. The problem here is that username is the primary key. Since the inserts happened at the same time, both inserts succeeded. It is only when they replicate will a primary key constraint fail. If this happens, replication will stop and manual intervention is necessary.

The only way to prevent this is to avoid the race in the first place:

BUGS ^

SEE ALSO ^

AUTHOR ^

Alfie John, alfiej@opera.com

LICENSE AND COPYRIGHT ^

Copyright (c) 2011, Opera Software Australia Pty. Ltd. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  * Redistributions of source code must retain the above copyright notice,
    this list of conditions and the following disclaimer.
  * Redistributions in binary form must reproduce the above copyright notice,
    this list of conditions and the following disclaimer in the documentation
    and/or other materials provided with the distribution.
  * Neither the name of the copyright holder nor the names of its contributors
    may be used to endorse or promote products derived from this software
    without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

syntax highlighting: