码迷,mamicode.com
首页 > 数据库 > 详细

mysql 5.5 mysqldump备份原理

时间:2016-12-27 22:38:46      阅读:208      评论:0      收藏:0      [点我收藏+]

标签:ati   nbsp   nap   rac   status   lob   snapshot   控制   master   

开启general_log日志,获取mysqldump执行语句

show VARIABLES like ‘general_log%‘
set GLOBAL general_log=on

执行备份命令

mysqldump --single-transaction -uroot -pdmysqlbadmin --master-data=2 -A  -R -E >/data/test.sql
得到general_log日志
161109 14:48:25	    8 Connect	root@localhost on 
		    8 Query	/*!40100 SET @@SQL_MODE=‘‘ */
		    8 Query	/*!40103 SET TIME_ZONE=‘+00:00‘ */
		    8 Query	FLUSH /*!40101 LOCAL */ TABLES
		    8 Query	FLUSH TABLES WITH READ LOCK
		    8 Query	SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ
		    8 Query	START TRANSACTION /*!40100 WITH CONSISTENT SNAPSHOT */
		    8 Query	SHOW MASTER STATUS
		    8 Query	UNLOCK TABLES
		    8 Query	SELECT LOGFILE_GROUP_NAME, FILE_NAME, TOTAL_EXTENTS, INITIAL_SIZE, ENGINE, EXTRA FROM INFORMATION_SCHEMA.FILES WHERE FILE_TYPE = ‘UNDO LOG‘ AND FILE_NAME IS NOT NULL GROUP BY LOGFILE_GROUP_NAME, FILE_NAME, ENGINE ORDER BY LOGFILE_GROUP_NAME
		    8 Query	SELECT DISTINCT TABLESPACE_NAME, FILE_NAME, LOGFILE_GROUP_NAME, EXTENT_SIZE, INITIAL_SIZE, ENGINE FROM INFORMATION_SCHEMA.FILES WHERE FILE_TYPE = ‘DATAFILE‘ ORDER BY TABLESPACE_NAME, LOGFILE_GROUP_NAME
		    8 Query	SHOW DATABASES
		    8 Init DB	accesslog
		    8 Query	SHOW CREATE DATABASE IF NOT EXISTS `accesslog`
		    8 Query	show tables
		    8 Query	show table status like ‘accesslog‘
		    8 Query	SET OPTION SQL_QUOTE_SHOW_CREATE=1
		    8 Query	SET SESSION character_set_results = ‘binary‘
		    8 Query	show create table `accesslog`
		    8 Query	SET SESSION character_set_results = ‘utf8‘
		    8 Query	show fields from `accesslog`
		    8 Query	SELECT /*!40001 SQL_NO_CACHE */ * FROM `accesslog`
		    8 Query	SET SESSION character_set_results = ‘binary‘
		    8 Query	use `accesslog`
		    8 Query	select @@collation_database
		    8 Query	SHOW TRIGGERS LIKE ‘accesslog‘		   
		    8 Query	SET SESSION character_set_results = ‘utf8‘
		    8 Query	show events
		    8 Query	use `accesslog`
		    8 Query	select @@collation_database
		    8 Query	SET SESSION character_set_results = ‘binary‘
		    8 Query	SHOW CREATE EVENT `E_delAccessLog`
		    8 Query	SET SESSION character_set_results = ‘utf8‘
		    8 Query	use `accesslog`
		    8 Query	select @@collation_database
		    8 Query	SET SESSION character_set_results = ‘binary‘
		    8 Query	SHOW FUNCTION STATUS WHERE Db = ‘accesslog‘
		    8 Query	SHOW PROCEDURE STATUS WHERE Db = ‘accesslog‘
		    8 Query	SHOW CREATE PROCEDURE `P_delAccessLog`
		    8 Query	SET SESSION character_set_results = ‘utf8‘

 测试方法,这里就不贴了,总结

1、非事务引擎表,有数据不一致风险,例如:myisam。
2、执行备份过程中,不允许有create table 及create database操作,事务里无法控制该类型语句,导致不一致备份。
3、如果之前有使用osc在线修改表结构,等它执行完后,再做备份。

 

mysql 5.5 mysqldump备份原理

标签:ati   nbsp   nap   rac   status   lob   snapshot   控制   master   

原文地址:http://www.cnblogs.com/dbcloud/p/6227660.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!