主页 > 知识库 > 如何用mysqldump进行全量和时间点备份

如何用mysqldump进行全量和时间点备份

热门标签:地图标注客户付款 石家庄400电话办理公司 咸阳防封电销卡 申请400电话电话价格 临沂做地图标注 许昌外呼增值业务线路 宜宾全自动外呼系统厂家 广东400企业电话申请流程 新乡智能外呼系统好处

mysqldump在mysql中用于逻辑备份,虽然速度不快,但非常灵活,有很多功能,灵活使用的化绝对是利器。

首先思考一个问题,mysql为什么要备份,主要还是数据安全性,比如主库挂了,数据不小心被删除了,所以全量备份非常重要。

是从主库还是副库进行全量备份呢?

1:从主库

主库比较重要,但其实备份的时候并不会影响数据库

mysqldump --host= --user= --password= --single-transaction --master-data=1 --flush-logs --databases >~/db.log

—single-transaction 参数能够报纸一致性读,不会锁表,也就是备份的时候不影响数据更新。

it dumps the consistent state of the database at the time when START TRANSACTION was issued without blocking any applications.

因为一致性读,能够保证coordinates点的位置,即使备份时间很久,也能得出正确的同步位置点。

While a —single-transaction dump is in process, to ensure a valid dump file (correct table contents and binary log coordinates)

—master-data参数也很重要,导出的语句会包含CHANGE MASTER TO语句,包括备份语句同步到的二进制文件和位置点。

Use this option to dump a master replication server to produce a dump file that can be used to set upanother server as a slave of the master. It causes the dump output to include a CHANGE MASTER TO statement that indicates the binary log coordinates (file name and position) of the dumped server. These are the master server coordinates from which the slave should start replicating after you load the dump file into the slave.

—flush-logs会强制重新生成一个新的二进制文件,这样恢复的时候会比较方便。

2:从副库

感觉上从副库备份更安全。

mysqldump --host=--user= --password= --dump-slave=1 --flush-logs --apply-slave-statements --include-master-host-port --databases >~/db.log;

— dump-slave和—master-data参数很类似:

This option is similar to —master-data except that it is used to dump a replication slave server to produce a dump file that can be used to set up another server as a slave that has the same master as the dumped server. It causes the dump output to include a CHANGE MASTER TO statement that indicates the binary log coordinates (file name and position) of the dumped slave's master. These are the master server coordinates from which the slave should start replicating.

记住一点它获取的是主库的bin log coordinates(不是备份库的)

—dump-slave causes the coordinates from the master to be used rather than those of the dumped server

dump出来的语句会包含 — Position to start replication or point-in-time recovery from。

—apply-slave-statements会让dump语句中自动包含start和stop slave语句。—include-master-host-port包含主库的连接信息。

必须记住一点,即使有—single-transaction语句,—dump-slave也会暂停mysql同步,也就是备份库的数据是落后于主库的,所以一般自动化脚本在备份的时候会先摘除备份库。

This option causes mysqldump to stop the slave SQL thread before the dump and restart it again after.

3:如何进行时间点恢复

没有实战过,首先基于最近的一次全量备份进行恢复,然后将后续的binlog文件导入(如果这些文件还在的话),所以副库最好也备份binlog语句。

如果数据被误删除了,将备份点(—flush-logs发挥作用了)到今天凌晨的binlog语句导入进来,或者找到安全的binlog位置点进行恢复。至于如何跳过“危险语句”是比较难控制的。

以上就是如何用mysqldump进行全量和时间点备份的详细内容,更多关于mysqldump进行全量和时间点备份的资料请关注脚本之家其它相关文章!

您可能感兴趣的文章:
  • mysqldump你可能不知道的参数
  • MySQL5.7 mysqldump备份与恢复的实现
  • linux使用mysqldump+expect+crontab实现mysql周期冷备份思路详解
  • MySql使用mysqldump 导入与导出方法总结
  • MySQL之mysqldump的使用详解
  • docker 使用mysqldump命令备份导出项目中的mysql数据
  • MySQL数据迁移使用MySQLdump命令
  • PHP定时备份MySQL与mysqldump语法参数详解
  • mysql备份脚本 mysqldump使用方法详解
  • 详解 linux mysqldump 导出数据库、数据、表结构
  • 详谈mysqldump数据导出的问题
  • MySQL官方导出工具mysqlpump的使用

标签:阜新 北京 鹰潭 合肥 镇江 日照 贵州 台湾

巨人网络通讯声明:本文标题《如何用mysqldump进行全量和时间点备份》,本文关键词  如,何用,mysqldump,进行,全量,;如发现本文内容存在版权问题,烦请提供相关信息告之我们,我们将及时沟通与处理。本站内容系统采集于网络,涉及言论、版权与本站无关。
  • 相关文章
  • 下面列出与本文章《如何用mysqldump进行全量和时间点备份》相关的同类信息!
  • 本页收集关于如何用mysqldump进行全量和时间点备份的相关信息资讯供网民参考!
  • 企业400电话

    智能AI客服机器人
    15000

    在线订购

    合计11份范本:公司章程+合伙协议+出资协议+合作协议+股权转让协议+增资扩股协议+股权激励+股东会决议+董事会决议

    推荐文章