实验:
停掉 mysql
移除
ib_logfile0
ib_logfile1
ibdata1
重启mysql以后,自动重建了 ib_logfile redo 日志文件 和 ibdata 数据字典文件。
能在数据库里面看到表,但 select * from 的时候,却说找不到表。。哈哈。因为我没有移除掉 innodb 的 *.frm 结构文件
而新建的 ibdata 里面又真的没有 这个表的信息。
我把 ibdata1 mv 回到 原位置。重启 mysql
一切又正常了。 而 bi_logfile日志文件我就没移回去,一样正常,因为这个是 事务恢复日志,如果不是服务器crash 的话,一般没啥事务要redo。
看手册怎么说物理备份innodb 的,看过了就明白innodb 的物理关系了
If you are able to shut down your MySQL server, you can make a binary backup that consists of all files used by InnoDB to manage its tables. Use the following procedure:
-
Shut down the MySQL server and make sure that it stops without errors.
-
Copy all
InnoDBdata files (ibdatafiles and.ibdfiles) into a safe place. -
Copy all the
.frmfiles forInnoDBtables to a safe place. -
Copy all
InnoDBlog files (ib_logfilefiles) to a safe place. -
Copy your
my.cnfconfiguration file or files to a safe place
看下ib_logfile 是如何被用上的
To recover from a crash of your MySQL server, the only requirement is to restart it. InnoDB automatically checks the logs and performs a roll-forward of the database to the present. InnoDB automatically rolls back uncommitted transactions that were present at the time of the crash
本文通过一次实验展示了MySQL Innodb存储引擎的数据恢复过程。在停掉MySQL服务并移除部分日志文件后,发现虽然数据库能看见表,但无法查询数据。进一步验证得知是因为未移除*.frm文件,而新的ibdata文件中缺失表信息。最终通过恢复ibdata文件解决了问题,并深入探讨了InnoDB的物理备份方法。
762

被折叠的 条评论
为什么被折叠?



