首页 > 其他分享 >mydumper学习总结

mydumper学习总结

时间:2023-01-31 18:22:53浏览次数:66  
标签:总结 mydumper dump -- 备份 devel 学习 dbname

0简介

mydumper 是一款社区开源的逻辑备份工具。该工具主要由 C 语言编写,目前由 MySQL 、Facebook 等公司人员开发维护。

  • mydumper  负责导出 MySQL 数据库的一致备份
  • myloader  从 mydumper 读取备份,连接到目标数据库并导入备份。

1 安装

  1.1下载

      下载地址:Releases · mydumper/mydumper (github.com),此网站有各个版本的安装包,目前最新版本是v0.14.0-2

       可以先下载后传到服务器,也可以使用wget命令来直接下载。

wget https://github.com/mydumper/mydumper/releases/download/v0.14.0-2/mydumper-0.14.0-2.el7.x86_64.rpm

 

  1.2安装

安装依赖:

# ubuntu
yum install glib2-devel mysql-devel gcc gcc-c++ zlib-devel pcre-devel openssl-devel libicu-dev cmake -y
# centos8
yum install glib2-devel mysql-devel gcc gcc-c++ zlib-devel pcre-devel openssl-devel cmake -y

安装rpm包

rpm -ivh mydumper-0.14.0-2.el7.x86_64.rpm

也可以直接安装线上版本

yum install wget https://github.com/mydumper/mydumper/releases/download/v0.14.0-2/mydumper-0.14.0-2.el7.x86_64.rpm

 

 1.3卸载

[root@gip 3308]# yum list installed |grep mydumper
mydumper.x86_64                         0.14.0-2                       installed
[root@gip 3308]# yum remove mydumper.x86_64

 

2 使用

备份命令 mydumper

常用重要选项

Filter Options
-x, --regex Regular expression for 'db.table' matching -T, --tables-list Comma delimited table list to dump (does not exclude regex option). Table name must include database name.
-B, --database                   Database to dump
-O, --omit-from-file             File containing a list of database.table entries to skip
Lock Options
-k, --no-locks                   Do not execute the temporary shared read lock.  WARNING: This will cause inconsistent backups
--less-locking                   Minimize locking time on InnoDB tables.
If long query running found
-l, --long-query-guard           Set long query timer in seconds, default 60
-K, --kill-long-queries          Kill long running queries (instead of aborting)
Job Options
-r, --rows                       Try to split tables into chunks of this many rows.
--split-partitions               Dump partitions into separate files. This options overrides the --rows option for partitioned tables.
Objects Options
-m, --no-schemas                 Do not dump table schemas with the data and triggers
-d, --no-data                    Do not dump table data
-G, --triggers Dump triggers. By default, it do not dump triggers
-E, --events Dump events. By default, it do not dump events
-R, --routines Dump stored procedures and functions. By default, it do not dump stored procedures nor functions
--views-as-tables Export VIEWs as they were tables
-W, --no-views Do not dump VIEWs
Application Options:
-o, --outputdir Directory to output files to
--stream It will stream over STDOUT once the files has been written. Since v0.12.7-1, accepts NO_DELETE, NO_STREAM_AND_NO_DELETE and TRADITIONAL which is the default value
-L, --logfile Log file name to use, by default stdout is used
--disk-limits Set the limit to pause and resume if determines there is no enough disk space.Accepts values like: '<resume>:<pause>' in MB.For instance: 100:500 will pause when there is only 100MB free and willresume if 500MB are available
-t, --threads Number of threads to use, default 4

导出后文件命名规则大致如下:

dbname-schema-create.sql:建库语句。
dbname-schema-post.sql:包含事件、存储过程及函数创建语句(若存在则有该文件)。
dbname.tbname.metadata:记录这个表的行数。
dbname.tbname-schema.sql:此表的创建语句。
dbname.tbname-schema-triggers.sql:创建触发器语句(若该表存在触发器 则有此文件)。
dbname.tbname.sql:该表的插入数据语句(若该表为空 则不存在此文件)。
dbname.viewname-schema.sql:创建视图语句(只列举出视图字段)。
dbname.viewname-schema-view.sql:创建视图的真正语句。
metadata:记录开始及结束备份的时间以及二进制日志位置。

 

使用举例:

备份指定表

备份指定库

备份所有表结构

备份所有表数据

备份整个实例

172.17.140.158 -

  

 

导入命令myloader

 

使用举例

 

3 特点

  1. 支持多线程导出数据,速度更快。
  2. 支持一致性备份。
  3. 支持将导出文件压缩,节约空间。
  4. 支持多线程恢复。
  5. 支持以守护进程模式工作,定时快照和连续二进制日志。
  6. 支持按照指定大小将备份文件切割。
  7. 数据与建表语句分离。

 

 

 

   

标签:总结,mydumper,dump,--,备份,devel,学习,dbname
From: https://www.cnblogs.com/JennyYu/p/17080154.html

相关文章

  • 有关类型判断的总结
    1.判断是否为(String)类型isString=o=>Object.prototype.toString.call(o)==='[objectString]'2.判断是否为(Number)类型isNumber=o=>Object.prototype.toString.cal......
  • JRE和JDK总结
    一、JDK是什么?有哪些内容组成?JDK是Java开发工具包1.JVM虚拟机:Java程序运行的地方2.核心类库:Java写好的东西,可以直接调用3.开发工具:javac(编译工具)、jav......
  • android手机调试--命令行学习--亲测OK
    https://cloud.tencent.com/developer/article/2069572以我的华为mate10为例子--亲测OK需求:关闭系统更新提醒--亲测OKhttps://blog.csdn.net/hu1010037197/article/deta......
  • Jmeter学习:JDBC链接池配置
    功能:通过该元件,我们可以给数据源配置不同的连接池,供后续JDBC采样器使用。使用场景:该元件配置通常与JDBC采样器一同使用。Jmeter默认采用DBCP连接池。1.下载驱......
  • 【Matlab学习2.2】矩阵变换
    对角阵对角阵:只有对角线上有非零元素的矩阵。 数量矩阵:对角线上的元素相等的对角矩阵。 单位矩阵:对角线上的元素都为1的对角矩阵。提取矩阵的对角线元素diag(A):提取矩......
  • mysql查询sql总结
    连表查询一文搞定MySQL多表查询中的表连接(join)SELECT a.id, b.server_idfrom release_recordasa JOINrelease_detailsasb ona.id=b.release_id解析:......
  • Linux操作命令大全总结
    系统信息arch显示机器的处理器架构(1)uname-m显示机器的处理器架构(2)uname-r显示正在使用的内核版本dmidecode-q显示硬件系统部件-(SMBIOS/DMI)hdparm-i......
  • PostgreSQL学习笔记-3.基础知识:CROSS、INNER、LEFT OUTER、RIGHT OUTER、FULL OUTER、
    PostgreSQLJOIN子句用于把来自两个或多个表的行结合起来,基于这些表之间的共同字段。在PostgreSQL中,JOIN有五种连接类型:CROSSJOIN:交叉连接INNERJOIN:内连接LEFTOU......
  • JNDI学习总结(三):tomcat下使用c3p0数据库连接池配置JNDI数据源
    tomcat是apache的,所以它的JNDI数据源默认使用commons组件的DBCP连接池来配置。如果想使用c3p0来配置数据源,就需要修改<Resource>标签里的部分配置选项,操作如下: 1.肯定......
  • 《Vue.js 设计与实现》读书笔记 - 第6章、原始值的响应式方案 & 响应式总结
    第6章、原始值的响应式方案6.1引入ref的概念既然原始值无法使用Proxy我们就只能把原始值包裹起来。functionref(val){constwrapper={value:val,}......