前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >mydumper安装笔记

mydumper安装笔记

作者头像
保持热爱奔赴山海
发布2019-09-18 09:55:53
1.2K0
发布2019-09-18 09:55:53
举报
文章被收录于专栏:数据库相关数据库相关

参考:http://www.tuicool.com/articles/2eAVVvN

mydumper备份的速度、myloader的恢复速度,比mysql自己的工具执行速度快很多,大大减少业务的处理时间。

代码语言:javascript
复制
# yum install glib2-develmysql-devel zlib-devel pcre-devel -y
# wget https://launchpadlibrarian.net/225370879/mydumper-0.9.1.tar.gz
# cmake ./
#make && make install

mydumper参数介绍:

代码语言:javascript
复制
 -B, --database             Database to dump
  -T,--tables-list           Comma delimitedtable list to dump (does not exclude regex option)
 -o, --outputdir            Directory to output files to
  -s,--statement-size        Attempted size ofINSERT statement in bytes, default 1000000
  -r,--rows                  Try to splittables into chunks of this many rows. This option turns off --chunk-filesize
  -F,--chunk-filesize        Split tables intochunks of this output file size. This value is in MB
  -c,--compress              Compress outputfiles
  -e,--build-empty-files     Build dump fileseven if no data available from table
  -x,--regex                 Regularexpression for 'db.table' matching
  -i,--ignore-engines        Comma delimitedlist of storage engines to ignore
 -m, --no-schemas            Do notdump table schemas with the data
 -d, --no-data               Do notdump table data
  -G,--triggers              Dump triggers
  -E,--events                Dump events
  -R,--routines              Dump storedprocedures and functions
  -k,--no-locks              Do not executethe temporary shared read lock.  WARNING:This will cause inconsistent backups
 --less-locking             Minimize locking time on InnoDB tables.
  -l,--long-query-guard      Set long querytimer in seconds, default 60
  -K,--kill-long-queries     Kill long runningqueries (instead of aborting)
 -D, --daemon                Enabledaemon mode
 -I, --snapshot-interval    Interval between each dump snapshot (in minutes), requires --daemon, default60
  -L,--logfile               Log file name touse, by default stdout is used
 --tz-utc                    SETTIME_ZONE='+00:00' at top of dump to allow dumping of TIMESTAMP data when aserver has data in different time zones or data is being moved between serverswith different time zones, defaults to on use --skip-tz-utc to disable.
 --skip-tz-utc               
 --use-savepoints            Usesavepoints to reduce metadata locking issues, needs SUPER privilege
 --success-on-1146           Not increment error count and Warning insteadof Critical in case of table doesn't exist
 --lock-all-tables           UseLOCK TABLE for all, instead of FTWRL
  -U,--updated-since         Use Update_timeto dump only tables updated in the last U days
  --trx-consistency-only      Transactional consistency only
  -h,--host                  The host toconnect to
  -u,--user                  Username withprivileges to run the dump
  -p,--password              User password
  -P,--port                  TCP/IP port toconnect to
  -S,--socket                UNIX domainsocket file to use for connection
 -t, --threads               Numberof threads to use, default 4
  -C,--compress-protocol     Use compressionon the MySQL connection
  -V,--version               Show the programversion and exit
  -v,--verbose               Verbosity ofoutput, 0 = silent, 1 = errors, 2 = warnings, 3 = info, default 2

myloader参数介绍:

代码语言:javascript
复制
  -d,--directory                   Directoryof the dump to import导入备份目录
  -q,--queries-per-transaction     Number ofqueries per transaction, default 1000
  -o,--overwrite-tables            Drop tablesif they already exist如果表存在删除表
  -B,--database                    Analternative database to restore into需要还原的库
  -s,--source-db                   Database torestore
  -e,--enable-binlog               Enablebinary logging of the restore data
  -h,--host                        The host toconnect to
  -u,--user                        Usernamewith privileges to run the dump
  -p,--password                    Userpassword
  -P,--port                        TCP/IP portto connect to
  -S,--socket                      UNIX domainsocket file to use for connection
  -t,--threads                     Number ofthreads to use, default 4使用的线程数量,默认4
 
  -C,--compress-protocol           Usecompression on the MySQL connection
  -V,--version                     Show theprogram version and exit
  -v,--verbose                     Verbosityof output, 0 = silent, 1 = errors, 2 = warnings, 3 = info, default 2

mydumper输出文件说明:

代码语言:javascript
复制
metadata:元数据,记录备份开始和结束时间,以及binlog日志文件位置。
table data:每个表一个文件
table schemas:表结构文件
daemon mode:在这个模式下,有五个目录0,1,binlogs,binlog_snapshot,last_dump。
备份目录是0和1,间隔备份,如果mydumper因某种原因失败而仍然有一个好的快照,
当快照完成后,last_dump指向该备份。

mydumper用例

备份hellodb数据库到当前目录下

代码语言:javascript
复制
# mydumper -uroot -proot -B hellodb -o ./
# ll  是每个表单独备份的
wKioL1d1DkPA2ZPcAABZzRHloAI398.png
wKioL1d1DkPA2ZPcAABZzRHloAI398.png
代码语言:javascript
复制
# cat metadata  可以看到
wKioL1d1Dk2SyxWrAAAeRg10v6E222.png
wKioL1d1Dk2SyxWrAAAeRg10v6E222.png
代码语言:javascript
复制
以守护进程方式每30分钟备份一次
# mydumper -uroot -proot -B hellodb-o /home/data/bak -D -I 30
 

数据库的还原覆盖操作
# myloader -o -B hellodb -o -d/home/data/bak/last_dump

最后,附上一个mysqldump和mydumper的速度对比图。

代码语言:javascript
复制
[root@db ~]# time mysqldump -uroot -proot -B Mobile > aa.sql
real     0m1.863s
user     0m1.571s
sys      0m0.164s
代码语言:javascript
复制
[root@db ~]# time mydumper -u root -p root -B Mobile -o /db/backup/mobile/ 
real     0m0.851s
user     0m0.735s
sys      0m0.101s

很明显地可以看出mydumper的效率比mysqldump要高很多。

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2016/06/30 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • mydumper用例
相关产品与服务
云数据库 SQL Server
腾讯云数据库 SQL Server (TencentDB for SQL Server)是业界最常用的商用数据库之一,对基于 Windows 架构的应用程序具有完美的支持。TencentDB for SQL Server 拥有微软正版授权,可持续为用户提供最新的功能,避免未授权使用软件的风险。具有即开即用、稳定可靠、安全运行、弹性扩缩等特点。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档