So, if this happens with your MySQL server, what do you do? You can setup new servers in a new data centre and hope you have an up-to-date backup. But unless you had remote slaves these backups probably won't be as current as they could be. When you get to the point where you have many servers keeping slaves for every one just for backups can be difficult to maintain. Many DBAs have different backup strategies to cover this potential problem.
This is where the new mydumper 0.5.0 comes in. It has a new 'daemon' mode which lets it run in the background. When in daemon mode it will take multi-threaded consistent snapshots on a regular basis (60 minutes by default) whilst also pretending to be a MySQL slave and continuously retrieving a local copy of binary logs. This can, in-theory, give an up-to-the-second backup of your server. Right up until the point where you need to fire the tea-lady. As an example you can use it in this mode as follows to make snapshots every 2 hours and constantly retrieve the binary logs:
mydumper --daemon --snapshot-interval=120 --logfile=mydumper.log --user=mydumper_user
--password=mydumper_password --host=mysql_server
A maximum of 2 snapshots are retained, one for the previous snapshot and one for the current one in case a failure happens during the current snapshot. A symbolic link inside the dump directory will always point to the last good snapshot. Each snapshot contains the binary log positions from that snapshot so at any given time the snapshot can be loaded in using myloader (a multi-threaded restoration tool bundled with mydumper) and then the log applied from that point using mysqlbinlog. In later versions I plan to have myloader handle the binary logs too.
Mydumper 0.5.0 is currently considered in an 'alpha' stage (0.2.3 is the latest stable version but this will only take single snapshots). This means there are probably bugs I haven't spotted yet and there is still a little bit of work to do (such as better myloader support for the daemon mode snapshots). You can download it from Launchpad here.
[...] more details please see LinuxJedi’s blog post on the release here. News ← Mydumper 0.2.3 [...]
ReplyDeleteVery, very cool, sir! I look forward to wreaking havoc on it soon : )
ReplyDeleteGoing to have a beta test suite for you to check out later this week!
Hats off for all the cool toys you're giving the world.
Thanks Patrick,
ReplyDeleteLooking forward to you breaking it ;)
Aah yet another tool that I'll have to pack for Gentoo ... thanks!
ReplyDeleteIndeed :)
ReplyDeleteI'm trying to arrange Ubuntu packaging in the form of a PPA and will probably do RPM based packaging myself at some point soon.
Could be interesting with xtrabackup too... grabbing binlogs for incremental backup...hrm...
ReplyDeleteI'm working on a binlog library in the background which could be used to do this :)
ReplyDeleteI would not fire the tea-lady but rather the sysadmins or operators who requested to drink tea in the server room !
ReplyDeletehehe, a very good point. I have seen data centres that really should be shut down before :)
ReplyDelete