Posted on 2012-04-10 17:19
Milo的海域 阅读(662)
评论(0) 编辑 收藏 所属分类:
MySQL
当innobackupex 做全备的时候(my version 1.6.5), 当备份到MyISAM数据时, innobackupex 会flush tables with read lock, 来禁止MyISAM的写操作. (假设没有--no-lock选项)
sub backup {
if (!$option_incremental && !$option_no_lock) {
# make a prep copy before locking tables, if using rsync
backup_files(1);
# flush tables with read lock
mysql_lockall();
}
if ($option_slave_info) {
write_slave_info();
}
}
sub mysql_lockall {
if (compare_versions($mysql_server_version, '4.0.22') == 0
|| compare_versions($mysql_server_version, '4.1.7') == 0) {
# MySQL server version is 4.0.22 or 4.1.7
mysql_send "COMMIT;";
mysql_send "FLUSH TABLES WITH READ LOCK;";
} else {
# MySQL server version is other than 4.0.22 or 4.1.7
mysql_send "FLUSH TABLES WITH READ LOCK;";
mysql_send "COMMIT;";
}
write_binlog_info;
} 但是如果备份的时候还有很重的workload, "flush tables with read lock" 可能会比较耗时. 这里参考了:
http://www.mysqlperformanceblog.com/2010/04/24/how-fast-is-flush-tables-with-read-lock/
看了下--no-lock的选项说明:
--no-lock
Use this option to disable table lock with "FLUSH TABLES WITH READ
LOCK". Use it only if ALL your tables are InnoDB and you DO NOT CARE
about the binary log position of the backup.
如果我们能保证workload仅仅是innodb相关的,我们可以使用这个选项。
记得在1.5版本的时候,使用--no-lock选项会导致xtrabackup_slave_info没有保存备份时的logfile & pos. 这个问题在1.6.5被解决了
if ($option_slave_info) {
write_slave_info();
}
xtrabackup_slave_info & xtrabackup_binlog_info文件在1.5版本是在
mysql_lockall函数里更新的。但是新版本已经把
write_slave_info提到
mysql_lockall外面了。