我希望在热备的情况下,我导下来的数据是事务完整的。
有好的实现吗?
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
如果要确保事务的完整性(ACID),在使用 mysqldump 进行备份时可以添加 --single-transaction 选项,
--single-transaction
Creates a consistent snapshot by dumping all tables in a
single transaction. Works ONLY for tables stored in
storage engines which support multiversioning (currently
only InnoDB does); the dump is NOT guaranteed to be
consistent for other storage engines. While a
--single-transaction dump is in process, to ensure a
valid dump file (correct table contents and binary log
position), no other connection should use the following
statements: ALTER TABLE, DROP TABLE, RENAME TABLE,
TRUNCATE TABLE, as consistent snapshot is not isolated
from them. Option automatically turns off --lock-tables.
http://dev.mysql.com/doc/refman/5.6/en/mysqldump.html#option_mysqldump_single-transaction
使用--single-transaction选项进行备份时,且事务分离级别设定为“REPEATABLE READ”时,
MySQL支持InnoDB表同时写入,但由此会消耗一部分系统资源,因此备份时间会比不使用该选项的时间长。
如果要使用该选项,建议备份时间安排在相对空闲的时间段。
另外需要注意的是只有InnoDB和NDB存储引擎支持事务