MYSQL使用mydumper备份恢复操作简介
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备份恢复操作简介的更多相关文章
- mysql之6备份恢复
基本意义: 将数据另存到其他设备,以便于出现问题时恢复数据 为什么要备份: 灾难恢复:需求改变:测试 几个事先需要考虑的问题: 可以容忍丢失多长时间的数据?恢复要在多长时间内完成?是否 ...
- 基于MySQL MEB的备份恢复
MEB(MySQL Enterprise Backup)是MySQL商业版中提供的备份工具,属于物理备份. 同XtraBackup一样,mysqlbackup的使用过程同样包含如下三个步骤: 备份(- ...
- 转 基于MySQL MEB的备份恢复
几种备份方式的介绍 mysqlbackup是一个热备份工具.也就是说它不像mysqldump那样给表上一个全局锁,由于mysqldump上了这个锁,所以就造成客户端只能对 数据库进行读操作不能写,这也 ...
- MySQL实时在线备份恢复方案
开源Linux 长按二维码加关注~ 上一篇:2020年MySQL数据库面试题总结 快照和复制技术的结合可以保证我们得到一个实时的在线MySQL备份解决方案. 当主库发生误操作时,只需要恢复备库上的快照 ...
- mysql日志与备份恢复
一.mysql日志: mysql的日志种类有很多,常见的有二进制日志,一般查询日志,满查询日志,中继日志,事务日志等,具体信息可以通过 mysql> SHOW GLOBAL VARIABLES ...
- mysql之 mysqldump 备份恢复详解
mysqldump是MySQL用于转存储数据库的客户端程序.转储包含创建表和/或装载表的SQL语句 ,用来实现轻量级的快速迁移或恢复数据库,是mysql数据库实现逻辑备份的一种方式. mysqldum ...
- 一文搞懂│mysql 中的备份恢复、分区分表、主从复制、读写分离
目录 mysql 的备份和恢复 mysql 的分区分表 mysql 的主从复制读写分离 mysql 的备份和恢复 创建备份管理员 创建备份管理员,并授予管理员相应的权限 备份所需权限:select,r ...
- centos6.5 mysql安装+远程访问+备份恢复+基本操作+卸载
参考博文: Linux学习之CentOS(十三)--CentOS6.4下Mysql数据库的安装与配置 MySQL修改root密码的多种方法 MySQL的备份与还原 解决mysql导入还原时乱码的问题 ...
- mysql 命令行 备份 恢复数据
找到mysql启动位置 whereis mysql 备份指定数据库 包括表结构和数据 使用命令mysqldump 数据库名 -u 用户名 -p > 存储文件路径 [root@izm5e16gjd ...
- MySQL另类的备份恢复方法——innodb可传输表空间
Preface There're many ways in backing up or migrating data from one server to another one.Lo ...
随机推荐
- 一个合格的CloudNative应用:程序当开源软件编写,应用配置外置
摘要:对于一个合格的CloudNative应用,应该把自己的程序当做开源软件来编写的,不该将数据库连接信息和密码放在代码里,一定要将配置外置. 对于一个合格的CloudNative应用,应该把自己的程 ...
- DevUI开源经验分享:从0到1开始运营你的开源项目
摘要:DevUI是面向企业中后台产品的开源前端解决方案,于2019年6月正式在GitHub开源,从当时的无人问津到去年8月累计1000 Star,再到现如今上千名社区成员.上百位贡献者.达成了3000 ...
- CWE4.6标准中加入 OWASP 2021 TOP10
摘要: 新发布的CWE4.6标准,加入了OWASP 2021 TOP10的视图. 本文分享自华为云社区<CWE 4.6 和 OWAPS TOP10(2021)>,作者: Uncle_Tom ...
- SAST + SCA: 结合使用安全升级
据 SAP 称,当今85%的安全攻击针对的是软件应用程序,因此一些列应用程序安全测试工具也应运而生.为了避免这些恶意攻击,企业通常使用应用程序安全测试工具来去缓解和解决安全风险,而不同的工具对应的使用 ...
- 火山引擎VeDI最新分享:消费行业的数据飞轮从“四更”开始
更多技术交流.求职机会,欢迎关注字节跳动数据平台微信公众号,回复[1]进入官方交流群 数据飞轮,正在为消费行业的数字化升级提供一套全新模式. 在刚刚结束的<全链路增长:数据飞轮转动消费新生力 ...
- 【scikit-learn基础】--『监督学习』之 层次聚类
层次聚类算法是机器学习中常用的一种无监督学习算法,它用于将数据分为多个类别或层次.该方法在计算机科学.生物学.社会学等多个领域都有广泛应用. 层次聚类算法的历史可以追溯到上世纪60年代,当时它主要被用 ...
- Win10家庭/企业/教育版均可升级到专业版
升级前,先备份现有KEY: cmd中输入 regedit 打开注册表,根据下面路径找到 BackupProductKeyDefault 计算机\HKEY_LOCAL_MACHINE\SOFTWARE\ ...
- IntelliJ IDEA 2024年最新下载、安装使用教程、亲测可用
本文讲的是2023.3最新版本IntelliJ IDEA破解.IntelliJ IDEA激活码.IntelliJ IDEA安装.IntelliJ IDEA永久激活码的最新永久激活教程,本文有mac和w ...
- 华东交通大学2019年ACM 双基 程序设计竞赛 个人题解(A - K)
目前先放几道题面,等晚上做完实验补 Update:A ~ D,更新剩余的题面(题面复制会有链接水印,懒得一一去除.直接截图) A.签到 真·签到题 输出祝贺祖国成立70周年!即可 B.欧涛的烦恼 思路 ...
- 又一创新!阿里云 Serverless 调度论文被云计算顶会 ACM SoCC 收录
近日,阿里云函数计算产品团队撰写的关于 Serverless 调度的创新性论文,被云计算领域 ACM SoCC 国际会议长文录用. 去年阿里云函数计算团队首个提出在 FaaS 场景下的去中心化快速镜像 ...