MySQL slave with LVM
From Lolly's Wiki
UNFINISHED first few lines...
Create LVM snapshot
Get the data mount
# df -h $(mysql --batch --skip-column-names -e "show variables like 'datadir'" | awk '{print $NF;}')
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg--mysql-mysql--data 138G 78G 55G 59% /var/lib/mysql
Enough space for a snapshot?
# vgs vg-mysql
VG #PV #LV #SN Attr VSize VFree
vg-mysql 2 3 1 wz--n- 199,99g 20,00g
Create a concsistent snapshot
master # mysql -e "FLUSH TABLES WITH READ LOCK; SHOW MASTER STATUS;" > /var/lib/mysql/master_status.$(date "+%Y%m%d_%H%M%S")
master # lvcreate -l50%FREE -s -n mysql-data-snap /dev/vg-mysql/mysql-data
master # mysql -e "UNLOCK TABLES;"
master # mount /dev/vg-mysql/mysql-data-snap /mnt
master # cat /mnt/master_status.20151002_225659
File Position Binlog_Do_DB Binlog_Ignore_DB
mysql-bin.002366 263911913
master # mysql --batch --skip-column-names -e "show variables like 'innodb_data_file_path'"
innodb_data_file_path ibdata1:5G;ibdata2:5G;ibdata3:5G;ibdata4:50M:autoextend
Set the innodb_data_file_path to the same value on the slave.
Copy the data to the slave
slave# ssh -c blowfish master "cd /mnt ; tar cSpzf - ." | ( cd /var/lib/mysql ; tar xlvSpzf - )