美文网首页
MySQL-备份类型day10

MySQL-备份类型day10

作者: 我要笑 | 来源:发表于2019-09-28 20:20 被阅读0次

备份类型

1.冷备 cold backup

业务停止或数据库关闭,进行备份,业务影响最大。

2.温备 warm backup

锁表备份,只读备份,阻塞所有的变更的操作,只能读。

3.热备 hot backup

不锁表备份,只能针对事务型引擎的表(例如:InnoDB)业务的影响最小。

4.备份工具

4.1 mysqldump MDP

        逻辑备份工具
        备份出来都是SQL语句 
        可读性较强
        便于二次处理
        文本格式,压缩比高
        自带工具

劣势:相对较慢,从磁盘调取数据--->内存--->转换成SQL---->xx.sql
不能做增量

Xtrabackup(percona) XBK,PBX

MySQL Enterpise Backup ,MEB 企业版
物理备份工具,备份的数据文件(类似cp)
优势:备份速度快
支持热备
自带了增量备份功能。

劣势:
可读性比较差
不便于处理
压缩比低

选择建议:

小于100G :MDP,XBK
100G-1T :XBK
超过TB级别:XBK,MDP

5.备份策略

备份方式:
全备:全库备份,备份所有数据
增量:备份变化的数据
逻辑备份=mysqldump+binlog
物理备份=XBK_full+xtrabcakup_incr_binlog或者xtrabackup_full+binlog
备份周期:
根据数据量设计备份周期
比如:周日全备,周1-周6增量

6.mysqldump逻辑备份工具使用

6.1 客户端通用的参数

-u
-p
-h
-P
-S

6.2基础备份参数

-A --all-databases 全库备份

[root@db01 ~]# mysqldump -uroot -p123456 -A > /backup/full.sql
mysqldump: [Warning] Using a password on the command line interface can be insecure.
Warning: A partial dump from a server that has GTIDs will by default include the GTIDs of all transactions, even those that changed suppressed parts of the database. If you don't want to restore GTIDs, pass --set-gtid-purged=OFF. To make a complete dump, pass --all-databases --triggers --routines --events. 
[root@db01 ~]# 

-B 单库或多库备份
例子:只备份world和test两个库

[root@db01 ~]# mysqldump -uroot -p123456 -B world test > /backup/db.sql
mysqldump: [Warning] Using a password on the command line interface can be insecure.
Warning: A partial dump from a server that has GTIDs will by default include the GTIDs of all transactions, even those that changed suppressed parts of the database. If you don't want to restore GTIDs, pass --set-gtid-purged=OFF. To make a complete dump, pass --all-databases --triggers --routines --events. 
[root@db01 ~]# 

单表或多表备份

[root@db01 ~]# mysqldump -uroot -p123456 world city country >/backup/table.sql
mysqldump: [Warning] Using a password on the command line interface can be insecure.
Warning: A partial dump from a server that has GTIDs will by default include the GTIDs of all transactions, even those that changed suppressed parts of the database. If you don't want to restore GTIDs, pass --set-gtid-purged=OFF. To make a complete dump, pass --all-databases --triggers --routines --events. 

6.3特殊功能参数

  1. -R --triggers -E 数据库特殊对象备份参数
    -R 存储过程,函数
    --triggers 触发器
    -E 事件

  2. --master-data=2
    1.以注释形式,记录备份时binlog文件名和position号(截取二进制日志的起点)
    2.自动锁表功能,加--single-transaction,可以减少锁表,
    3.--single-transaction
    快照备份,热备。

  3. --set-gtid-purged=OFF(GTID模式独有的参数。)
    作用,去除gtid所有信息,在日常备份恢复时可加。
    做主从复制应用的时候,不能加此参数。

5.--max-allowed-packet=512M
备份例子

mysqldump -uroot -p123 -A --master-data=2 --single-transaction -R -E --triggers --set-gtid-purged=OFF --max-allowed-packet=256M > /backup/full.sql

相关文章

  • MySQL-备份类型day10

    备份类型 1.冷备 cold backup 业务停止或数据库关闭,进行备份,业务影响最大。 2.温备 warm b...

  • mysql-备份

    2020/09/031、备份表、表结构、表内容、备份库 前提:数据库和数据表要存在(已经被创建)1、导出数据库 -...

  • MySQL-备份恢复

    如果您对数据库感兴趣,可以添加 DBA解决方案QQ群:855439640 0. mysql备份介绍 0.1 备份是...

  • mysql-备份-导入

    2020/09/031、备份表、表结构、表内容、备份库 #############################...

  • MySql的四种备份(基本备份)

    数据的备份类型 数据的备份类型根据其自身的特性主要分为以下几组完全备份部分备份完全备份指的是**备份整个数据集( ...

  • Mysql-数据类型

    title: mysql-数据类型date: 2016-12-28 17:42:45tags:categories...

  • MYSQL-数据类型优化

    MYSQL-数据类型优化 优化数据类型 MySQL支持的数据类型非常多,选择正确的数据类型对获得高性能至关重要。选...

  • 项目中常用的19条MySQL优化技巧

    **声明一下:下面的优化方案都是基于 “ Mysql-索引-BTree类型 ”。 ** 一 善用EXPLAIN 做...

  • Mysql-备份恢复问题

    问题一: 在之前的工作中是如何对数据库进行备份的呢??? 物理备份和逻辑备份: image 备份方式: image...

  • 5. MySQL 备份和恢复

    1 MySQL备份和恢复 1.1 备份类型 完全备份, 部分备份 完全备份: 整个数据集, 备份一整...

网友评论

      本文标题:MySQL-备份类型day10

      本文链接:https://www.haomeiwen.com/subject/uiicuctx.html