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
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.
There is something incredibly tough you can try
As I mentioned earlier, you can house mysql on a DRBD mount.
Huh ??? How did MySQL Replication enter the picture
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
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 !!!