预算内的无停机 MySQL 备份

Chr*_*ian 14 mysql backup database-backup

我当前的 MySQL 备份方案是将我们的数据库复制到第二台服务器并在该服务器上运行 mysqldump 以消除表或行锁定中的任何停机时间。这运行良好,但第二台服务器的费用为每月 150 美元(澳大利亚托管比美国贵得多。)

我在这里阅读了很多关于此的问题,大多数人需要有关计划备份的帮助,而这不是我需要的。我需要在没有停机的情况下进行 mysqldump(最好每 4 小时一次)。数据库未压缩约 7GB,因此 mysqldump 可能需要一些时间,具体取决于服务器。

我考虑过复制到同一台机器上,但我不想让奴隶吃到急需的内存。我不确定我可以在每个数据库的基础上限制内存使用吗?无论哪种方式,这都会在转储数据库时给服务器带来负载。

我刚读了这个http://www.zmanda.com/quick-mysql-backup.html看起来不错,每年 300 美元就可以了,这为我节省了很多。

不幸的是,我无法复制到 Amazon 的 RDS,但我可以复制到微型 RC2 实例,但复制将通过网络进行,ping 约为 220 毫秒。

我在这里看到一些人在谈论 LVM 快照,这可能是一个不错的选择。我不太了解这个选项。

意见将不胜感激。

Mik*_*ike 10

如果使用 innodb 表,则可以使用

http://www.percona.com/docs/wiki/percona-xtrabackup:start

这将转储您的数据库,这些数据库也可以在不锁定的情况下由他们的工具导入。我相信如果您有 myisam 表,它会锁定这些表。


Jos*_*itt 5

如果您使用的是 innodb 或其他完全事务性的后端,则可以使用mysqldump --single-transaction .... 我已经在相当大的(~100GB)数据库上使用了它,结果很好;如果数据库负载很重,它可能需要几个小时,但它可以在不锁定表的情况下工作。复制通常更好,但有时您需要一个不错的可靠转储文件。请记住,您也可以转储 mysql 复制从站。

从 mysqldump 页面(注意有关将泄漏到事务中的操作的警告):

 ·   --single-transaction

   This option sends a START TRANSACTION SQL statement to the server
   before dumping data. It is useful only with transactional tables
   such as InnoDB, because then it dumps the consistent state of the
   database at the time when BEGIN was issued without blocking any
   applications.

   When using this option, you should keep in mind that only InnoDB
   tables are dumped in a consistent state. For example, any MyISAM or
   MEMORY tables dumped while using this option may still change
   state.

   While a --single-transaction dump is in process, to ensure a valid
   dump file (correct table contents and binary log coordinates), no
   other connection should use the following statements: ALTER TABLE,
   CREATE TABLE, DROP TABLE, RENAME TABLE, TRUNCATE TABLE. A
   consistent read is not isolated from those statements, so use of
   them on a table to be dumped can cause the SELECT that is performed
   by mysqldump to retrieve the table contents to obtain incorrect
   contents or fail.
Run Code Online (Sandbox Code Playgroud)