MySQL:InnoDB 表的自动增量备份
我知道在 SO 和其他地方也有类似/相关的问题,而且我至少认为我理解各种选择。
我们有一个带有 InnoDB 表的大型 MySQL(社区版)数据库。我想每天拍摄数据库快照以进行异地备份。目前我正在使用由 cron.daily 运行的 mysqldump 脚本。然而,写出文案需要3个小时。所以——它必须是增量的。
由于我们是社区版,买不起企业版,因此我们没有 InnoDB 热复制,这将是一个可行的解决方案,因为它是非阻塞的。另一个选项是打开二进制日志记录并进行增量更新。但这似乎是一个巨大的痛苦,并且容易出错:刷新和旋转日志、记录时间戳等。建议似乎是尽可能避免这种情况。
因此,最后的选择是使用主从配置设置复制。我已经扫描了文档,但不清楚什么构成“主”以及什么构成“从”。那么有几个问题:
- 从属设备是一个单独的 mysqld 进程吗?
- Slave可以和Master运行在同一台机器上吗?
- 一旦设置并运行,是否需要任何干预,或者主将忠实地推送所有更新?
- 为了在不影响主服务器的情况下进行备份,大概我可以在从服务器上运行 mysqldump 吗?
- 最后,这是维护异地复制备份的合理解决方案吗?
谢谢理查德
I know there have been similar/related questions on SO and elsewhere, and I at least think I understand the various options.
We have a largish MySQL (community edition) db with InnoDB tables. I would like to take daily shapshots of the DB to be backed up off-site. Currently I am using a mysqldump script that gets run by cron.daily. However it takes 3 hours to write out the copy. So - incremental it must be.
As we are community edition and cannot afford Enterprise we don't have InnoDB hotcopy which would be a viable solution as it is non-blocking. The other option is turning on binary logging and taking incremental updates. But this seems like a colossal pain and prone to error: flushing and rotating logs, recording timestamps etc. The advice seems to be avoid this if possible.
So the final option is setting up replication with a Master-Slave configuration. I've scanned the docs but am not clear what constitutes a "Master" and what constitutes a "Slave". So a few questions:
- Is a slave a separate mysqld process?
- Can the slave run on the same machine as the Master?
- Once set up and running is any intervention required or will the Master faithfully push all updates?
- To make my backups without impacting the Master, presumably I can just run mysqldump on the slave?
- And finally, is this a reasonable solution to maintaining a backup for copying off-site?
Thanks Richard
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
无需使用单独的 mysql 守护进程,
在 master 中启用二进制日志
在slave中配置relay-bin,以及master上的相关信息
(参见http://dev.mysql.com/doc/refman /5.0/en/replication-howto.html)
是的,但是不要这样做,
因为一旦机器崩溃,
你的主人和奴隶都走了
(排版)
master将忠实推送所有更新,master 将写入的 sql 记录到二进制日志中,
并且从属应该获取二进制日志(正如@Johan所解释的,它从主控中提取)
但是,
您可以将复制视为允许所有sql的方法在主机上执行,
复制到从站,
并按照接收顺序再次执行
(这就是二进制日志的作用)
当然,这就是拥有slave的目的
但是,会有一些延迟...
当您转储数据时,
您可能会阻止表写入(假设 innodb 影响较小),
而master可以继续进一步的写作
是的,这被认为是mysql灾难恢复
there is no need to using separate mysql daemon,
in master you enable the binary log
in slave you configure relay-bin, and the relevant information on master
(see http://dev.mysql.com/doc/refman/5.0/en/replication-howto.html)
Yes, but don't do this ,
because once the machine crashed,
both your master and slave is gone
(DTP)
master will faithfully push all updates,master log the write sqls into binary log,
and slave should obtains the binary log (as @Johan explained, it pull from master)
however,
you can treat replication is just a method that allow ALL the sqls execute on master,
copy over to slave,
and execute again in the receiving order
(this is what binary log does)
Of course, this is the purpose of having slave
However, there will be some delay ...
when you are dumping the data,
you might blocking table for write (assuming innodb has lesser impact),
while master could be carry on further writing
yes, this is consider as a mysql disaster recovery
可以,但更常见的是安装在不同机器上的单独 MySQL 服务器。
是的,如果必须的话,只需为其分配不同的端口号和不同的 server_id。
请注意,如果它位于同一台计算机上,那么它就不算备份。
主服务器不
推送
任何内容,从服务器拉取
更新。是的,但是如果主服务器和从服务器在同一台计算机上运行,则运行 mysqldunmp 会减慢该服务器的速度。
是的,场外是此处的关键字。
我会将从属设备放置在异地,这比将从属设备放在同一台机器上更有意义。
这是一个教程
http://www.howtoforge.com/mysql_master_master_replication
It can be, but it is more commonly a separate MySQL server installed on a different machine.
Yes, if you must, just assign it a different port number and different server_id.
Note that it's not much of a backup if it's on the same machine.
The master does not
push
anything, the slavepulls
the updates.Yes, but if master and slave are running on the same machine, running mysqldunmp will slow down that server.
Yes, off site is the keyword here.
I would place the slave off-site, that make way more sense than having the slave on the same machine.
Here is a tutorial
http://www.howtoforge.com/mysql_master_master_replication