Skip to content

MySQL-Backups mit ZFS

ZFS ist ein "relativ" neues Filesystem, von SUN Microsystems. Es beinhaltet nicht nur Filesystem mit Volume Manager.
Daher ist es naheliegend, Datenbanken auch auf so ein Filesystem zu legen und Snapshots zu machen um damit Backups zu "erstellen".

Meine Idee war zuerst den Snapshot zu kreieren, ein mysqldump drauf loszulassen und die entstehenden Dump-Daten ins Backup zu schieben.
Nachdem ich aber gesehen habe dass mylvmbackup von Lenz Grimme auch "nur" .tar.gz-Dateien erstellt dachte ich fange ich mit folgendem Einzeiler auf der Shell an:


mysql -ufoo -h localhost -p mysql -e "flush tables with read lock" && \
zfs snapshot $pool/$volume@backup1 && \
mysql -ufoo -p mysql "unlock tables" && \
cd /$pool/$volume/.zfs/snapshot/backup/root/$datadir && \
tar cvf /backup/backup1.tar . && \
zfs destroy $pool/$volume@backup1


Natürlich kann man den destroy weglassen und den Snapshot behalten (und das ganze damit stagen). Ob und wie das performed werde ich mal nächstens testen.

**Update** Kris sagt mir gerade dass der flush tables with read lock nur bis zum Disconnect gilt - was natürlich doof ist. Also werde ich das ganze in Perl bauen müssen. mylvmbackup umbauen viellkeicht; wobei das deutlich mehr macht (weil lvm mehr Handling braucht).

Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

Kristian Köhntopp on :

I> rince,
I> mach es bitte wie mylvmbackup
I> 1. flush tables
I> das mimimiert die puffer
I> 2. flush tables with read lock
I> das flusht die puffer und sperrt die db
I> 3. snapshot
I> 4. unlock tables.
I> 5. snap mounten und sichern
I> andernfalls ist der snapshot nicht konsistent
I> und rince, du musst es in einem perl-script o.a. machen,
I> als shell geht das nicht, denn
I> flush tables with read lock
I> haelt die locks bis zum unlock tables oder disconnect
I> und der snapshot muss gelockt erfolgen,
I> aber ein shellscript kann die verbindung nicht halten

Rince on :

So wie im Update bereits beschrieben. Ich werde wohl mylvmbackup erweitern; Lenz hatte ich dafür schon angefragt. zfs ist ein wenig "aktiver" als lvm; man muss nicht mit devices arbeiten und man muss sie nicht extra mounten... aber das mache ich dann.

Florian Laws on :

Schau auch mal da:
http://blogs.digitar.com/jjww/?itemid=56
Da hat schon einer ein Backupskript für MySQL auf ZFS geschrieben.

(via c0t0d0s0)

Add Comment

E-Mail addresses will not be displayed and will only be used for E-Mail notifications.
To leave a comment you must approve it via e-mail, which will be sent to your address after submission.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.
Form options