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 |
# innobackupex --no-timestamp /backups/full<br>... sometime later ...<br># innobackupex --incremental /backups/inc1 --no-timestamp --incremental-basedir /backups/full<br>... sometime later ...<br># innobackupex --incremental /backups/inc2 --no-timestamp --incremental-basedir /backups/inc1<br> |
In my proof of concept test, I now have a full and two incrementals:
|
1 |
# du -shc /backups/*<br>909M full<br>665M inc1<br>812M inc2<br>2.4G total<br> |
To recover this data, I follow the normal Xtrabackup incremental apply process:
|
1 |
# cp -av /backups/full /backups/restore<br># innobackupex --apply-log --redo-only --use-memory=1G /backups/restore<br>...<br>xtrabackup: Recovered WSREP position: 1663c027-2a29-11e5-85da-aa5ca45f600f:35694784<br>...<br># innobackupex --apply-log --redo-only /backups/restore --incremental-dir /backups/inc1 --use-memory=1G<br># innobackupex --apply-log --redo-only /backups/restore --incremental-dir /backups/inc2 --use-memory=1G<br>...<br>xtrabackup: Recovered WSREP position: 1663c027-2a29-11e5-85da-aa5ca45f600f:46469942<br>...<br># innobackupex --apply-log /backups/restore --use-memory=1G<br> |
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 |
# innobackupex --copy-back /backups/restore<br># ... copy a grastate.dat from another running node ...<br># cat /var/lib/mysql/grastate.dat<br># GALERA saved state<br>version: 2.1<br>uuid: 1663c027-2a29-11e5-85da-aa5ca45f600f<br>seqno: -1<br>cert_index:<br> <br># chown -R mysql.mysql /var/lib/mysql/<br> |
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