在实时数据库上运行mysqldump

在实时数据库上运行mysqldump

问题描述:

只想知道在实时数据库上运行mysqldump有什么风险?有没有数据库损坏的机会? mysqldump似乎锁定了整个数据库.

Just wanted to know what are the risks of running a mysqldump on a live database? Are there any chances of database corruption? mysqldump seems to lock the entire database.

您的数据库表使用什么引擎?如果您使用的是事务表,则可以使用单一交易"选项进行转储,这将以一致的状态转储您的表.如果使用的是非事务型的表,例如MyISAM,则不应有任何数据库损坏问题.但是,如果您遇到竞争情况,则可能会有不一致的数据问题.无论哪种情况,在发生转储时,您都将极大地减慢数据库响应时间.最好的选择是对从属服务器运行转储,或者在运行转储之前等待站点处于静态状态.

What engine are your database tables using? If you are using transactional tables you can dump using the option "single-transaction", which will dump your tables in a consistent state. If you are using tables like MyISAM, which are non transactional, you should not have any DB corruption issues. You may have inconsistent data problems however, if you get into a race scenario. In either case, you will be dramatically slowing down DB response time while the dump occurs. Best bet is to run the dump against a slave or to wait for the site to be quiescent before running the dump.