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. Karmada v1.2发布:开启全文本搜索新纪元

    摘要:Karmada v1.2 版本对调度器能力做了较大增强,初步提供了分布式搜索引擎支持,此外还借助聚合API提供了诸如 logs, watch等实用的命令行工具,资源解释器(Resource In ...

  2. 高性能 Jsonpath 框架,Snack3 3.2.57 发布

    Snack3,一个高性能的 JsonPath 框架 借鉴了 Javascript 所有变量由 var 申明,及 Xml dom 一切都是 Node 的设计.其下一切数据都以ONode表示,ONode也 ...

  3. Solon v1.9.1,让 Java 快速启动

    相对于 Spring Boot 和 Spring Cloud 的项目: 启动快 5 - 10 倍. (更快) qps 高 2- 3 倍. (更高) 运行时内存节省 1/3 ~ 1/2. (更少) 打包 ...

  4. Linux 创建新用户

    添加用户组[root@VipSoft ~]#groupadd admin 添加用户[root@VipSoft ~]#useradd jimmy -m -d /home/jimmy -g admin 修 ...

  5. PlayWright安装及使用

    PlayWright是由业界大佬微软(Microsoft)开源的端到端 Web 测试和自动化库,可谓是大厂背书,功能满格,虽然作为无头浏览器,该框架的主要作用是测试 Web 应用,但事实上,无头浏览器 ...

  6. 在Flutter中使用SetState无效?可能是忽略了这个!

    这次是Flutter开发技术分享,解决的问题点来自本人实际的开发经历. 首先描述一下问题:在某个组件中调用setState()方法更新该组件状态,结果是无法做到更新效果,组件仍然维持原状. 下面我们用 ...

  7. .NET Moq mock internal类型

    问题 Can not create proxy for type xxx because type xxx is not accessible. Make it public, or internal ...

  8. 【ToolChains】CLion(VS2019) + CMake + Vcpkg 的使用

    参考博客: https://blog.51cto.com/u_15075510/4201238 http://t.csdn.cn/pADDU https://zhuanlan.zhihu.com/p/ ...

  9. #2102:A计划(DFS和BFS剪枝搜索)

    题意: 有几个比较坑的地方总结一下, 很容易误解: 遇到#就必须走 #不消耗时间 #对面如果也是#也不能走, 要不然无限循环了 最短路径剪枝时, 发现不能走的#是要把两步都标注为-1并跳出 题解: 一 ...

  10. 全国城市地级市区县sql

    全国城市地级市区县sql CREATE TABLE `region` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `title` varchar( ...