Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When it comes to setting up DRBD and MySQL, is the following possible?

  • Set up DRBD on an active MySQL server
  • Set up DRBD with no downtime allowed
share|improve this question

Unfortunately, it is not possible to do either one.

Once you create /dev/drbd0 on both DB Servers, you have to mount the DRBD Primary on a folder. That folder cannot have anything with active file handles. The protocol I use is:

drbdadm primary drbd0
mount /dev/drbd0 /var/lib/mysql
service mysql start

You want DRBD to house MySQL Data. Here is what you must do instead

service mysql stop
mv /var/lib/mysql /var/lib/mysql_old
mkdir /var/lib/mysql
chown mysql:mysql /var/lib/mysql
drbdadm primary drbd0
mount /dev/drbd0 /var/lib/mysql
cp -R /var/lib/mysql_old /var/lib/mysql
chown -R mysql:mysql /var/lib/mysql
service mysql start

As shown, stopping mysqld is mandatory.

UPDATE 2013-03-16 21:46 EDT

There is something incredibly tough you can try

  • Given ServerDB1 with MySQL Running
  • Given ServerDB2 to introduce as DRBD partner

STEP 01) Setup DRBD on Separate ServerDB2

As I mentioned earlier, you can house mysql on a DRBD mount.

STEP 02) Setup MySQL Replication

Huh ??? How did MySQL Replication enter the picture

  • You need to mysqldump everything in ServerDB1
  • Load the mysqldump into MySQL running in ServerDB2
  • Setup Replication so all changes are migrated since loading of ServerDB2 was done

STEP 03) Failover Your Application

In simple English, use the IP address of ServerDB2 in your application instead of ServerDB1

You should wait and make sure you have a low peak time to do this failover

STEP 04) Setup DRBD on Separate ServerDB1

  • Setup DRBD
  • drbdadm secondary drbd0
  • drbdadm coonect drbd0

This is an oversimplified description but you can look up the actual code to sync a DRBD pair

Here is my old DRBD download-and-install script

rm -rf drbdinstall
mkdir drbdinstall
cd drbdinstall
gzip -d drbd-${DRBD_VERSION_NUMBER}.tar.gz
tar -xvf drbd-${DRBD_VERSION_NUMBER}.tar
make rpm
rpm -Uvh dist/RPMS/x86_64/drbd-*

You can go to to find out the latest version number and update the aforemtioned script

Give it a Try !!!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.