简体   繁体   English

备份MySQL数据库的有效方法

[英]Efficient way to backup MySQL database

I'm using mysqldump to backup my database. 我正在使用mysqldump备份数据库。 Since the database and webserver are on the same machine, the mysqldump takes all the CPU and the site 'goes down' until the mysqldump finishes. 由于数据库和Web服务器位于同一台机器上,因此mysqldump占用所有CPU,并且站点“关闭”,直到mysqldump完成。

Is the solution to move database to another machine and do backups on that machine? 是将数据库移动到另一台计算机并在该计算机上进行备份的解决方案吗? Are there other alternatives? 还有其他选择吗?

It might be a little too much, but I'll suggest to use replication. 可能有点太多,但是我建议使用复制。 There is a master-slave replication with MySQL. MySQL具有主从复制。 This will allow you to have and identical DB (read-only) on another machine at all times and doesn't require your machine to work too hard since it happens all the time. 这样一来,您就可以始终在另一台计算机上拥有相同的DB(只读)数据库,并且不需要您的计算机一直在努力工作,因为它总是在发生。 It's also pretty easy to set up. 设置也很容易。 You can read more about it here: mysql site description 您可以在此处了解更多信息: mysql网站说明

i use mysql administrator from the old mysql gui tools to create backup from my website to my pc. 我使用旧mysql gui工具中的mysql管理员从我的网站创建备份到我的PC。

~90 mb backup take less than 2 minutes 约90 mb的备份时间不到2分钟

If you want smooth backups (without interfering the production system) the master-slave replication is a very good way to do it. 如果要平滑备份(不影响生产系统),则主从复制是一种很好的方法。 However you might not want to reserve a server for a backup slave and indeed mysqldump is using a lot of resources. 但是,您可能不想为备份从属服务器保留服务器,而mysqldump确实在使用大量资源。

You can try Percona XtraBackup which is an open source tool. 您可以尝试使用Percona XtraBackup,它是一个开源工具。 Works on the file system level and much faster than mysqldump. 在文件系统级别上工作,并且比mysqldump快得多。 http://www.percona.com/doc/percona-xtrabackup/ You can even try it on your current setup as it doesn't put any locks on tables. http://www.percona.com/doc/percona-xtrabackup/您甚至可以在当前设置中尝试使用它,因为它不会对表施加任何锁定。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM