Take the 2-minute tour ×
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. It's 100% free, no registration required.

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
add comment

1 Answer 1

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

DRBD_VERSION=8.3
DRBD_SUBVERSION=0
DRBD_VERSION_NUMBER=${DRBD_VERSION}.${DRBD_SUBVERSION}
cd
rm -rf drbdinstall
mkdir drbdinstall
cd drbdinstall
wget http://oss.linbit.com/drbd/${DRBD_VERSION}/drbd-${DRBD_VERSION_NUMBER}.tar.gz
gzip -d drbd-${DRBD_VERSION_NUMBER}.tar.gz
tar -xvf drbd-${DRBD_VERSION_NUMBER}.tar
cd drbd-${DRBD_VERSION_NUMBER}
make rpm
rpm -Uvh dist/RPMS/x86_64/drbd-*

You can go to www.drbd.org to find out the latest version number and update the aforemtioned script

Give it a Try !!!

share|improve this answer
add comment

Your Answer

 
discard

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.