MySQL Synchronous Replication on Ubuntu 12.04 with DRBD
I would suggest you to use active-passive cluster with drbd. Active-Active leads to more problems then it solves especially if you use MySQL as database because you can't run 2 MySQL Daemons on the same Database!

Creating drbd cluster is simple. You have to do the following steps on both servers.


Create a partition for share
Create a drbd config with the partition, this brings you a new block device
Start the Cluster with one as Master and the other as slave
Create and Mount a filesystem (ext4, xfs or on the block device on the master
Copy the database to the new filesystem and start db and you are done.


Thats the concept.

Here a short overview of the commands to use:

Server1 and Server2:
Create a partition for the complete Harddisk sdb

fdisk /dev/sdb
n
p
&lt;enter&gt;
&lt;enter&gt;
w


Install drbd

apt-get install drbd8-utils


Create a config file at /etc/drbd.conf:

common {
  syncer { 
    rate 100M; 
  }
}

resource r0 {
  # Protokoll-Version
  protocol C;

  startup {
    wfc-timeout         0;
    degr-wfc-timeout  120;
  }
  disk {
    on-io-error detach;
  }
  on server1 {
    device     /dev/drbd0;
    disk       /dev/sdb1;
    address    &lt;IPSERVER1&gt;:7788;
    meta-disk  internal;                 
  }
  on server2 {
    device     /dev/drbd0;
    disk       /dev/sdb1;
    address    &lt;IPSERVER2&gt;:7788;
    meta-disk  internal;                 
  }
}


Create the drbd device on both servers

drbdadm create-md r0
drbdadm up r0


Check the state

cat /proc/drbd


There should be a line with "cs:Connected ro:Secondary/Secondary"
The first "Secondary" is the server you are logged in and the 2nd "Secondary" is the other server.

Now make the first server to the master and override all data on the server2

drbdadm primary --force r0


You could watch this process in /proc/drbd

No you can mount your new drbd device on the master:

mount /dev/drbd0 /mnt


if you like to switch master and slave you can use the commands:

drbdadm primary r0


or

drbdadm secondary r0


Based on the server where you are logged in. But remember only one server could be primary.

For Active-Active scenario you need a cluster file system like ocfs2.

Use this manual with caution because this could delete your data.

You will find more information at drbd.org: http://www.drbd.org/users-guide-8.4/

A complete alternative is to use the DRBD MC - the Management console created by LINBIT, its a java application running on a workstation and connects to the servers over ssh and make the configuration for you.
http://www.drbd.org/mc/lcmc/