Mysql&Mariadb

MySQL备份恢复

2017-12-30  本文已影响0人  显卡hg

备份重要性

备份场景

mysqldump

select outfile + awk

mysqldump,mysqlpump原理

  1. flush tables; #可以拿到metadata lock
  2. flush tables with read lock; #整个实例只读
  3. set session transaction isolation repeatable read; #可重复读
  4. start transaction /*!40100 with consistent snapshot */; #开启事务快照,/*!NNNNN */的意思是大于NNN版本的才生效中间的语句,否则不生效
  5. show @@global.gtid_executed;
  6. show master status;
  7. dump non-InnoDB tables,首先导出非事务引擎表
  8. unlock tables;
  9. show databases;
  10. show create database if not exists 'dbname';
  11. savepoint sp; #还原点,特殊语法,如果下面东西出错可以回到这个点上
  12. show table status like 'tb_xx';
  13. set session character_set_results='binary'; #以二进制格式存储表结构
  14. show create table 'tb_xx';
  15. set session character_set_results='utf8'; #以utf8格式备份表数据
  16. select /*!40100 SQL_NO_CACHE */ * from tb_xx;
  17. rollback to savepoint sp; #回到断点处,备份下一张表
  18. ...
  19. 最后是:rollback to savepoint sp; RELEASE SAVEPOINT sp #释放断点

mydumper

如何从一个mysqldump文件中提取其中一个表

InnoDB Crash Recovery

innobase crash recovery
crash
innodb-plugin fast crash recovery
LOG
---
Log sequence number 2565545
Log flushed up to   2565545
Pages flushed up to 2565545
Last checkpoint at  2565536
0 pending log flushes, 0 pending chkp writes
10 log i/o's done, 0.00 log i/o's/second

xtrabackup

xtrabackup备份

xtrabackup实现原理

xtrabackup增量原理

上一篇下一篇

猜你喜欢

热点阅读