Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

Init DRBD

Both Nodes

cat << EOL >/etc/drbd.d/varlibmysql.res
resource varlibmysql {
        meta-disk internal;
        disk   /dev/sdb1;
        device /dev/drbd1;
on node1 {
        address  192.168.1.1:7788;
 }
on node2 {
        address  192.168.1.1:7788;
 }
}
EOL
drbdadm create-md varlibmysql
modprobe drbd
drbdadm up all

Node1

drbdadm primary --force varlibmysql
watch cat /proc/drbd

Both Nodes

 

mkfs.ext4 /dev/drbd1
umount /mnt
mount /dev/drbd1 /mnt
df -h | grep drbd


umount /mnt
mount /dev/drbd1 /mnt
df -h | grep drbd 

I-O Error Fix

You want to be able to mount - unmount and remount the DRBD to know its working, I find I get an I-O Error 2nd remount and drbdadm up fixes it

drbdadm up varlibmysql
watch cat /proc/drbd
umount /mnt
mount /dev/drbd1 /mnt
df -h | grep drbd 

After Successfully Mounting & Unmounting & Remounting - Unmount on Both

umount /mnt

Migrate Data

Both Nodes

systemctl disable mariadb.service
service mariadb stop

Node1

mount /dev/drbd1 /mnt
df -h | grep drbd
systemctl start mariadb
cp -Ra /var/lib/mysql/* /mnt
mysql_install_db --datadir=/mnt --user=mysql
umount /mnt
systemctl stop mariadb

Both Nodes

rm /var/lib/mysql/* -R
ls -la /var/lib/mysql
cat << EOL > /etc/my.cnf
[mysqld]
symbolic-links=0
bind_address            = 0.0.0.0
datadir                 = /var/lib/mysql
pid_file                = /var/run/mariadb/mysqld.pid
socket                  = /var/run/mariadb/mysqld.sock

[mysqld_safe]
bind_address            = 0.0.0.0
datadir                 = /var/lib/mysql
pid_file                = /var/run/mariadb/mysqld.pid
socket                  = /var/run/mariadb/mysqld.sock

!includedir /etc/my.cnf.d
EOL
  • No labels