Comments - Historical data, nightly snapshots

9 years, 9 months ago Sergei Golubchik

If you have a snapshot of innodb tablespaces, they weren't properly closed, so they look like they were a result of a crash. The first time you start innodb on these files, it will perform a crash recovery, then the tables will be usable.

So, you can do the following:

  • start another mariadb on your snapshot, let innodb do its crash recovery.
  • export tablespaces using FLUSH TABLES FOR EXPORT.
  • copy them into your running mariadb and import them there.

after that you can use these tables in the running mariadb instance

And, of course, you don't really need to copy multi-GB files, you can just move or hard-link them in place.

 
9 years, 8 months ago BJ Quinn

Thanks! I could probably do a flush tables for export before taking the snapshot and then the snapshot ought to be clean, I would think. So now I have a snapshot full of (hopefully clean) tables that I need to add to MariaDB -- how do I actually do the import? Can I create the empty table structures based only off the .cfg files and then discard the tablespace and then link in the ibd files from the snapshot? And the snapshots would be read only, can I point to an innodb table that's read only as long as I don't intend to make any changes to it?

 
9 years, 8 months ago Sergei Golubchik

We've got the import process from MySQL and haven't fixed it yet. It's a bit cumbersome. It involves creating a table with exactly the same structure, and then two ALTER TABLE statements. See http://dev.mysql.com/doc/refman/5.6/en/tablespace-copying.html for details.

 
9 years, 8 months ago BJ Quinn

Cool thx. So, can I create a table of the exact same structure with the help of the .cfg file? I can imagine a scenario where I have a bunch of existing snapshots that I'd like to make available to read (let's say I was careful about doing the FLUSH TABLES FOR EXPORT before taking each snapshot), but of course table structure can change over time. Is there a way to work up a CREATE statement based on the .cfg file?

Thanks!

 
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.