MYSQL使用mydumper备份恢复操作简介


1. 环境准备


第一步是进行下载安装包的操作. 在github以及官网上面有相关的安装介质.

官网为:

http://www.mydumper.org/

建议也可以使用 github上面的 mydumper 下载相关的文件.

注意我本次下载了三个文件:

-rw-r--r-- 1 root root 2588180 7月   9 14:28 mydumper-0.10.7-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 2667695 7月 9 14:28 mydumper-0.10.7-1.el8.x86_64.rpm
-rw-r--r-- 1 root root 71615 7月 9 14:28 mydumper-0.10.7.tar.gz

第二步进行简单的安装

经过简单验证, 不同的centos7和centos8可以直接使用进行安装.

安装完成之后会自动形成至少两个命令

mydumper和myloader


2.备份操作


备份操作比较简单

time mydumper -u root -p 'yourpassword!' -h 127.0.0.1 -P 3306 -B yourdatabasename -o /home/yourdirectory/

3. 恢复操作

注意第一步需要先创建相关的数据库

创建数据库的操作为:

create database yourdatabasename;
create user 'yourdatabasename'@'%' identified WITH mysql_native_password by 'yourpassword';
grant all privileges on *.* to 'yourdatabasename'@'%' with grant option;
flush privileges ;

为了 提高恢复速度可以暂时设置如下参数:

set global innodb_flush_log_at_trx_commit=0;
set sql_log_bin = off;

注意这些参数 恢复完建议立即关闭,或者是重启一遍数据库使之取消生效.

执行恢复相关操作

注意 这里面发现部分 视图可能有问题. 需要再次确认.

time myloader -u root -p 'yourpassword' -h yourserverip -P 3306 -B yourdatabasename -d /home/yourdatabasename/

4. 相关参数

mydumper 相关参数 

Application Options:
-B, --database Database to dump
-T, --tables-list Comma delimited table list to dump (does not exclude regex option)
-O, --omit-from-file File containing a list of database.table entries to skip, one per line (skips before applying regex option)
-o, --outputdir Directory to output files to
-s, --statement-size Attempted size of INSERT statement in bytes, default 1000000
-r, --rows Try to split tables into chunks of this many rows. This option turns off --chunk-filesize
-F, --chunk-filesize Split tables into chunks of this output file size. This value is in MB
-c, --compress Compress output files
-e, --build-empty-files Build dump files even if no data available from table
-x, --regex Regular expression for 'db.table' matching
-i, --ignore-engines Comma delimited list of storage engines to ignore
-N, --insert-ignore Dump rows with INSERT IGNORE
-m, --no-schemas Do not dump table schemas with the data
-M, --table-checksums Dump table checksums with the data
-d, --no-data Do not dump table data
--order-by-primary Sort the data by Primary Key or Unique key if no primary key exists
-G, --triggers Dump triggers
-E, --events Dump events
-R, --routines Dump stored procedures and functions
-W, --no-views Do not dump VIEWs
-k, --no-locks Do not execute the temporary shared read lock. WARNING: This will cause inconsistent backups
--no-backup-locks Do not use Percona backup locks
--less-locking Minimize locking time on InnoDB tables.
--long-query-retries Retry checking for long queries, default 0 (do not retry)
--long-query-retry-interval Time to wait before retrying the long query check in seconds, default 60
-l, --long-query-guard Set long query timer in seconds, default 60
-K, --kill-long-queries Kill long running queries (instead of aborting)
-D, --daemon Enable daemon mode
-X, --snapshot-count number of snapshots, default 2
-I, --snapshot-interval Interval between each dump snapshot (in minutes), requires --daemon, default 60
-L, --logfile Log file name to use, by default stdout is used
--tz-utc SET TIME_ZONE='+00:00' at top of dump to allow dumping of TIMESTAMP data when a server has data in different time zones or data is being moved between servers with different time zones, defaults to on use --skip-tz-utc to disable.
--skip-tz-utc
--use-savepoints Use savepoints to reduce metadata locking issues, needs SUPER privilege
--success-on-1146 Not increment error count and Warning instead of Critical in case of table doesn't exist
--lock-all-tables Use LOCK TABLE for all, instead of FTWRL
-U, --updated-since Use Update_time to dump only tables updated in the last U days
--trx-consistency-only Transactional consistency only
--complete-insert Use complete INSERT statements that include column names
--set-names Sets the names, use it at your own risk, default binary
-z, --tidb-snapshot Snapshot to use for TiDB
--sync-wait WSREP_SYNC_WAIT value to set at SESSION level
--where Dump only selected records.
-h, --host The host to connect to
-u, --user Username with the necessary privileges
-p, --password User password
-a, --ask-password Prompt For User password
-P, --port TCP/IP port to connect to
-S, --socket UNIX domain socket file to use for connection
-t, --threads Number of threads to use, default 4
-C, --compress-protocol Use compression on the MySQL connection
-V, --version Show the program version and exit
-v, --verbose Verbosity of output, 0 = silent, 1 = errors, 2 = warnings, 3 = info, default 2
--defaults-file Use a specific defaults file
--ssl Connect using SSL
--ssl-mode Desired security state of the connection to the server: DISABLED, PREFERRED, REQUIRED, VERIFY_CA, VERIFY_IDENTITY
--key The path name to the key file
--cert The path name to the certificate file
--ca The path name to the certificate authority file
--capath The path name to a directory that contains trusted SSL CA certificates in PEM format
--cipher A list of permissible ciphers to use for SSL encryption
--tls-version Which protocols the server permits for encrypted connections myloader 相关参数 Usage:
myloader [OPTION?] multi-threaded MySQL loader Help Options:
-?, --help Show help options Application Options:
-d, --directory Directory of the dump to import
-q, --queries-per-transaction Number of queries per transaction, default 1000
-o, --overwrite-tables Drop tables if they already exist
-B, --database An alternative database to restore into
-s, --source-db Database to restore
-e, --enable-binlog Enable binary logging of the restore data
--innodb-optimize-keys Creates the table without the indexes and it adds them at the end
--set-names Sets the names, use it at your own risk, default binary
-L, --logfile Log file name to use, by default stdout is used
--purge-mode This specify the truncate mode which can be: NONE, DROP, TRUNCATE and DELETE
--sync-before-add-index If --innodb-optimize-keys is used, this option will force all the data threads to complete before starting the create index phase
--disable-redo-log Disables the REDO_LOG and enables it after, doesn't check initial status
-h, --host The host to connect to
-u, --user Username with the necessary privileges
-p, --password User password
-a, --ask-password Prompt For User password
-P, --port TCP/IP port to connect to
-S, --socket UNIX domain socket file to use for connection
-t, --threads Number of threads to use, default 4
-C, --compress-protocol Use compression on the MySQL connection
-V, --version Show the program version and exit
-v, --verbose Verbosity of output, 0 = silent, 1 = errors, 2 = warnings, 3 = info, default 2
--defaults-file Use a specific defaults file
--ssl Connect using SSL
--ssl-mode Desired security state of the connection to the server: DISABLED, PREFERRED, REQUIRED, VERIFY_CA, VERIFY_IDENTITY
--key The path name to the key file
--cert The path name to the certificate file
--ca The path name to the certificate authority file
--capath The path name to a directory that contains trusted SSL CA certificates in PEM format
--cipher A list of permissible ciphers to use for SSL encryption
--tls-version Which protocols the server permits for encrypted connections

MYSQL使用mydumper备份恢复操作简介的更多相关文章

  1. mysql之6备份恢复

    基本意义: 将数据另存到其他设备,以便于出现问题时恢复数据     为什么要备份: 灾难恢复:需求改变:测试     几个事先需要考虑的问题: 可以容忍丢失多长时间的数据?恢复要在多长时间内完成?是否 ...

  2. 基于MySQL MEB的备份恢复

    MEB(MySQL Enterprise Backup)是MySQL商业版中提供的备份工具,属于物理备份. 同XtraBackup一样,mysqlbackup的使用过程同样包含如下三个步骤: 备份(- ...

  3. 转 基于MySQL MEB的备份恢复

    几种备份方式的介绍 mysqlbackup是一个热备份工具.也就是说它不像mysqldump那样给表上一个全局锁,由于mysqldump上了这个锁,所以就造成客户端只能对 数据库进行读操作不能写,这也 ...

  4. MySQL实时在线备份恢复方案

    开源Linux 长按二维码加关注~ 上一篇:2020年MySQL数据库面试题总结 快照和复制技术的结合可以保证我们得到一个实时的在线MySQL备份解决方案. 当主库发生误操作时,只需要恢复备库上的快照 ...

  5. mysql日志与备份恢复

    一.mysql日志: mysql的日志种类有很多,常见的有二进制日志,一般查询日志,满查询日志,中继日志,事务日志等,具体信息可以通过 mysql> SHOW GLOBAL VARIABLES ...

  6. mysql之 mysqldump 备份恢复详解

    mysqldump是MySQL用于转存储数据库的客户端程序.转储包含创建表和/或装载表的SQL语句 ,用来实现轻量级的快速迁移或恢复数据库,是mysql数据库实现逻辑备份的一种方式. mysqldum ...

  7. 一文搞懂│mysql 中的备份恢复、分区分表、主从复制、读写分离

    目录 mysql 的备份和恢复 mysql 的分区分表 mysql 的主从复制读写分离 mysql 的备份和恢复 创建备份管理员 创建备份管理员,并授予管理员相应的权限 备份所需权限:select,r ...

  8. centos6.5 mysql安装+远程访问+备份恢复+基本操作+卸载

    参考博文: Linux学习之CentOS(十三)--CentOS6.4下Mysql数据库的安装与配置 MySQL修改root密码的多种方法 MySQL的备份与还原 解决mysql导入还原时乱码的问题 ...

  9. mysql 命令行 备份 恢复数据

    找到mysql启动位置 whereis mysql 备份指定数据库 包括表结构和数据 使用命令mysqldump 数据库名 -u 用户名 -p > 存储文件路径 [root@izm5e16gjd ...

  10. MySQL另类的备份恢复方法——innodb可传输表空间

      Preface       There're many ways in backing up or migrating data from one server to another one.Lo ...

随机推荐

  1. 云小课|GaussDB(DWS)数据存储尽在掌控,冷热数据切换自如

    阅识风云是华为云信息大咖,擅长将复杂信息多元化呈现,其出品的一张图(云图说).深入浅出的博文(云小课)或短视频(云视厅)总有一款能让您快速上手华为云.更多精彩内容请单击此处. 摘要: GaussDB( ...

  2. 3个轻量级物联网新品实验,带您深度体验IoT开发

    摘要:一键创建实验环境,开发者通过实验手册指导,快速体验华为云IoT服务,在云端即可实现云服务的实践.调测和验证等开发流程. 本文分享自华为云社区<物联网云上实验上新,带您深度体验华为云IoT服 ...

  3. 基于Serverless的端边云一体化媒体网络

    摘要:视频在边缘的创新方向在哪?下一代视频云平台什么样? 本文分享自华为云社区<探讨视频云与边缘云平台的竞争力--基于Serverless的端边云一体化媒体网络>,作者/卢志航,整理 / ...

  4. Spring 太肥、太慢?你受不了?那 Solon Java Framework 就是你的西施

    Solon 是什么? Java 生态型应用开发框架.它从零开始构建,有自己的标准规范与开放生态(历时五年,已有全球第二级别的生态规模).与其他框架相比,它解决了两个重要的痛点:启动慢,费内存.2023 ...

  5. Java 全新生态的框架,Solon v1.10.12 发布

    一个更现代感的 Java 应用开发框架:更快.更小.更自由.没有 Spring,也没有 Servlet,独立的生态.主框架仅 0.1 MB.Helloworld: @Controller public ...

  6. 熔断、限流、降级 —— SpringCloud Alibaba Sentinel

    Sentinel 简介 Sentinel 是阿里中间件团队开源的,面向分布式服务架构的高可用流量防护组件,主要以流量为切入点,从限流.流量整形.熔断降级.系统负载保护.热点防护等多个维度来帮助开发者保 ...

  7. Python中字符前添加r,b,u,f前缀的含义

    1.在python字符串前添加r,意思为消除转义字符 2.在python字符串前添加f,意思为支持大括号内的python 表达式. 3.在python字符串前添加b,意思为字符串类型为byte类型,在 ...

  8. Spark面试题(六)——Spark资源调优

    Spark系列面试题 Spark面试题(一) Spark面试题(二) Spark面试题(三) Spark面试题(四) Spark面试题(五)--数据倾斜调优 Spark面试题(六)--Spark资源调 ...

  9. Qt做大型软件开发技术选型Part2:Qt调用C#编写的COM组件

    Qt做大型软件开发技术选型Part2:Qt调用C#编写的COM组件 之前有提到过我们项目部现在正在用Qt重构一个大型软件,现在的情景是这样的: 原先的软件是通过一个C++(CLR)的主程序,调用各种用 ...

  10. 定期发送邮件功能-outlook与腾讯邮箱

    一.背景:定期发送邮件功能挺好用的,可以帮忙我们在特殊的时间点发送邮件,以及实现无人推送的功能 二.outlook的实现1.首先编辑好邮件保存至草稿 2.选项-延迟传递,设置不早于传递的时间,点击发送 ...