Mysql and Zfs
Mysql and Zfs
Martin MC Brown Technical Writer Database and Infrastructure Group, Sun Microsystems
Overview
ZFS Overview Using MySQL on ZFS Increasing Performance ZFS Tricks
Understanding ZFS
Filesystem/volume management in software Makes use of faster CPUs often sitting idle Flexible support compared to hardware RAID Enhanced range of features 128-bit throughout Integrated fault management, check-summing and copy-on-write
Pools
Logical collection of physical disks Everything in software Correctly sets disk metrics, caches Transparent use of SSDs Transparent use of different disks
Mirrored (RAID 1)
Mirrored (writes to N+1 disks) zpool create MYPOOL mirror c0t1d0 c0t2d0 To extend a mirror, you must add another mirror set:
> zpool add MYPOOL mirror c0t3d0 c0t4d0
c0t4d0
RAIDZ Extension
Extension possible Cant use a single disk Extend using same geometry:
> zpool add MYPOOL raidz c0t2d0 c0t3d0 > zpool add MYPOOL raidz2 c0t3d0 c0t4d0 c0t5d0
Filesystems
One Filesystem can have only One Pool But One Pool can have multiple filesystems Filesystem created automatically when you create pool All filesystems share the storage of the pool Each filesystem supports individual settings, even if they share the same pool
Specify multiple devices Can be mirrored Great for 10K/15K RPM disks or SSD
12 Sun Proprietary/Confidential: Internal Use Only
ZFS Cache
Caches provide extra layer between RAM and Disk for read-only ops ZFS supports exclusive device for cache:
> zpool create MYPOOL c0t1d0 c0t2d0 cache c0t3d0
Specify multiple devices to increase cache size Cannot be mirrored/striped Cache disk is considered volatile Great for 10K/15K RPM disks or SSD
13 Sun Proprietary/Confidential: Internal Use Only
Use a separate zpool for log files To increase RAM for MySQL, limit ARC:
> set zfs:zfs_arc_max = #bytes in /etc/system
Compression
Handled in software Filesystem level Sounds Bad However, using compression:
> Reduces read and write times > More systems have idle CPU but high disk contention > Takes up less space
ZFS Snapshots
Backups are a pain point Snapshots are quick and efficient
> zfs snapshot MYPOOL@snap1
Or over a network:
> zfs send MYPOOL@snap1 | ssh mybackuphost cat -
>snapshot
ZFS Replication
Not really replication Regular snapshots/restores between systems See coalface.mcslp.comzfs-replication-for-mysqldata <http://coalface.mcslp.com/2008/11/09/zfsreplication-for-mysql-data/>
Questions?
Martin MC Brown [email protected]