In Percona XtraDB Cluster (PXC) I often run across users who are fearful of SSTs on their clusters. I’ve always maintained that if you can’t cope with a SST, PXC may not be right for you, but that doesn’t change the fact that SSTs with multiple Terabytes of data can be quite costly.
SST, by current definition, is a full backup of a Donor to Joiner. The most popular method is Percona XtraBackup, so we’re talking about a donor node that must:
So, I’ve been interested in alternative ways to work around state transfers and I want to present one way I’ve found that may be useful to someone out there.
It is possible to use Percona XtraBackup Full and Incremental backups to build a datadir that might possibly SST. First we’ll focus on the mechanics of the backups, preparing them and getting the Galera GTID and then later discuss when it may be viable for IST.
Suppose I have fairly recent full Xtrabackup and and one or more incremental backups that I can apply on top of that to get VERY close to realtime on my cluster (more on that ‘VERY’ later).
|
1 2 3 4 5 |
# innobackupex --no-timestamp /backups/full ... sometime later ... # innobackupex --incremental /backups/inc1 --no-timestamp --incremental-basedir /backups/full ... sometime later ... # innobackupex --incremental /backups/inc2 --no-timestamp --incremental-basedir /backups/inc1 |
In my proof of concept test, I now have a full and two incrementals:
|
1 2 3 4 5 |
# du -shc /backups/* 909M full 665M inc1 812M inc2 2.4G total |
To recover this data, I follow the normal Xtrabackup incremental apply process:
|
1 2 3 4 5 6 7 8 9 10 11 |
# cp -av /backups/full /backups/restore # innobackupex --apply-log --redo-only --use-memory=1G /backups/restore ... xtrabackup: Recovered WSREP position: 1663c027-2a29-11e5-85da-aa5ca45f600f:35694784 ... # innobackupex --apply-log --redo-only /backups/restore --incremental-dir /backups/inc1 --use-memory=1G # innobackupex --apply-log --redo-only /backups/restore --incremental-dir /backups/inc2 --use-memory=1G ... xtrabackup: Recovered WSREP position: 1663c027-2a29-11e5-85da-aa5ca45f600f:46469942 ... # innobackupex --apply-log /backups/restore --use-memory=1G |
I can see that as I roll forward on my incrementals, I get a higher and higher GTID. Galera’s GTID is stored in the Innodb recovery information, so Xtrabackup extracts it after every batch it applies to the datadir we’re restoring.
We now have a datadir that is ready to go, we need to copy it into the datadir of our joiner node and setup a grastate.dat. Without a grastate, starting the node would force an SST no matter what.
|
1 2 3 4 5 6 7 8 9 10 |
# innobackupex --copy-back /backups/restore # ... copy a grastate.dat from another running node ... # cat /var/lib/mysql/grastate.dat # GALERA saved state version: 2.1 uuid: 1663c027-2a29-11e5-85da-aa5ca45f600f seqno: -1 cert_index: # chown -R mysql.mysql /var/lib/mysql/ |
If I start the node now, it should see the grastate.dat with the -1 seqo and run –wsrep_recover to extract the GTID from Innodb (I could have also just put that directly into my grastate.dat).
This will allow the node to startup from merged Xtrabackup incrementals with a known Galera GTID.
That’s the question. IST happens when the selected donor has all the transactions the joiner needs to get it fully caught up inside of the donor’s gcache. There are several implications of this:
All that being said, we’re still talking about backups here. The above method will only work if and only if:
Resources
RELATED POSTS
I just worked on nearly the same.
One idea we realized is that you _never_ have to make a full backup again (if all works fine):
1) make full backup to dir “1”
2) make incrementalt to dir “n”
3) if “n” > n-max end!
4) make full backup by an restore run to an archive (complete roll forwards, step by step…)
(not mentioned to pause between incremental backup runs…)
5) the result is also a “full backup” stored (full prepare) in dir “1”
This also works fine by using qpress (which you _should_ use due to filesize and restoring speed)
I scripted something like a robot, which runs on all nodes which copies its data to a central fileserver/storage.
I found out there are some things to know:
– if your data changes once a day (many updates), the incremental steps could be as big as a full backup which depends on the frequency of backups (pause time)
– if you got a extremly large database but which data not changes much, incremental backup is best you could do
‘@Reiner — you can chain backups forever sure, but then you run a risk where any link in that chain breaking means you can’t restore.
I didn’t mention in the post, but I used innodb_track_changed_pages available in PS and PXC to make the incrementals a lot faster. https://www.percona.com/doc/percona-server/5.6/management/changed_page_tracking.html However, this would not help much if the churn in the database is high.