Running mysql on a separate XFS volume
This article explains setting up mysql on a separate XFS volume.
You could change the mysql data dir post installation to point to newly created volume/disk, and start mysql service. Pretty straight forward, only thing to worry would be to keep track of configuration changes of mysql. I would have followed the same approach too.
Here's another way to do the same. Lets begin with a fresh installation of mysql db.
sudo apt-get install -y xfsprogs mysql-server
Create an XFS file system and mount it as /data
grep -q xfs /proc/filesystems || sudo modprobe xfs
sudo mkfs.xfs /dev/sdx
Note: `/dev/sdx` refers to the newly attached volume, you can confirm this using `fdisk -l`.
echo "/dev/sdx /data xfs noatime 0 0 " | sudo tee -a /etc/fstab
sudo mkdir -m 000 /data
sudo mount /data
We have now mounted the volume under /data
with an XFS file system, and it will be automatically mounted upon reboots.
Configure MySQL to use the new volume
Stop the MySQL server
sudo service mysql stop
We will now move the existing database files to the new volume and point MySQL to the correct database files using mount bind.
sudo mkdir /data/etc /data/lib /data/log
# Move existing data files
sudo mv /etc/mysql /data/etc
sudo mv /var/lib/mysql /data/lib
sudo mv /var/log/mysql /data/log
# Create mount points
sudo mkdir /etc/mysql /var/lib/mysql /var/log/mysql
# Update fstab
echo "/data/etc/mysql /etc/mysql none bind" | sudo tee -a /etc/fstab
sudo mount /etc/mysql
echo "/data/lib/mysql /var/lib/mysql none bind" | sudo tee -a /etc/fstab
sudo mount /var/lib/mysql
echo "/data/log/mysql /var/log/mysql none bind" | sudo tee -a /etc/fstab
sudo mount /var/log/mysql
Restart the MySQL server
sudo service mysql start
Perfect! We are now running MySQL with all of the data and binary files stored on newly created XFS volume!
\m/