Notes: I wrote this documentation around 2013 as internal documentation at Weever Apps for setting up RAID-Z as a method of making very quick backups of MySQL. Since we no longer use this setup and the documentation will never be used again, I felt it might be a good idea to post it out there for those who might find some use in it. Using RAID-Z for MySQL was amazing, and never failed us, and allowed hourly snapshot-based backups with no downtime. We've since moved to AWS RDS instances though.
This will be part of multiple posts that combined will allow one to build a RAID-Z setup for MySQL. Or, at least it used to be able to! While this is geared towards Azure, I'm sure it would work anywhere.
As I add more parts over the next few days I'll add links here.
Article series
- Installing ZFS on CentOS
- Creating a RAID-Z Drive for MySQL with ZFS on CentOS
- Setting up RAID-Z for use in a MySQL Master-Master Replicator Pattern
- Creating a ZFS Image of a MySQL Data Directory
Instructions
First, let's make sure we have ZFS installed.
sudo su
lsmod | grep -i zfs
Next, in Azure, shut down the server then attach all the disks you'd like to use for RAID-Z; minimum should be a 2-core machine using the max 4 disks. All disks should be the same size, though this may not be a requirement for RAID-Z.
For this example, I'll be making 4 disks with 300 GB each. Give them names so it is clear that they are RAID-Z disks, by making sure raid-z is somewhere in the name.
Each disk should take about a minute to set up.
Start the machine up when the final disk is added.
Once booted back up, check the status of the disks (be sure to sudo su
):
fdisk -l | grep GB
The following command will create a zpool called sqlstorage
and mount it to /etc/mysql
:
zpool create -m /var/lib/mysql sqlstorage raidz -f sdc sdd sde sdf
Note that the minimum for raidz
is two disks. For double-parity raidz
known as raidz2
, you need a minimum of 3 disks. For triple, 4 disks are required. Use the highest level RAID-Z possible with the setup.
To check the zpool status:
zpool status
To make sure it's mounted:
mount | grep zfs
And to confirm the storage size:
df -h | grep sqlstorage
We also want to make sure the drive will mount on bootup:
echo "zfs mount sqlstorage" >> /etc/rc.local
Reboot, and you can then repeat the above checks to ensure it is working on boot.
Is something badly out of date? Did this work for you? Please post a comment to help others who might use this for guidance.
Top comments (0)