Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Rob Porter
Rob Porter

Posted on • Edited on

     

Creating a RAID-Z Drive for MySQL with ZFS on CentOS

Notes: I wrote this documentation around 2013 as internal documentation atWeever 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

  1. Installing ZFS on CentOS
  2. Creating a RAID-Z Drive for MySQL with ZFS on CentOS
  3. Setting up RAID-Z for use in a MySQL Master-Master Replicator Pattern
  4. Creating a ZFS Image of a MySQL Data Directory

Instructions

First, let's make sure we have ZFS installed.

sudosulsmod |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 tosudo su):

fdisk-l |grepGB

The following command will create a zpool calledsqlstorage and mount it to/etc/mysql:

zpool create-m /var/lib/mysql sqlstorage raidz-f sdc sdd sde sdf

Note that the minimum forraidz is two disks. For double-parityraidz known asraidz2, 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 |grepzfs

And to confirm the storage size:

df-h |grepsqlstorage

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)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Programmer, naturalist.
  • Location
    Hamilton, Ontario, Canada
  • Education
    McMaster University
  • Work
    Director of Engineering, Co-founder at Weever Apps
  • Joined

More fromRob Porter

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp