mydumper安装笔记
2016-06-30 20:21
267 查看
参考:http://www.tuicool.com/articles/2eAVVvN
mydumper备份的速度、myloader的恢复速度,比mysql自己的工具执行速度快很多,大大减少业务的处理时间。
myloader参数介绍:
mydumper输出文件说明:
![](http://s3.51cto.com/wyfs02/M01/83/85/wKioL1d1DkPA2ZPcAABZzRHloAI398.png)
![](http://s1.51cto.com/wyfs02/M00/83/85/wKioL1d1Dk2SyxWrAAAeRg10v6E222.png)
最后,附上一个mysqldump和mydumper的速度对比图。
mydumper备份的速度、myloader的恢复速度,比mysql自己的工具执行速度快很多,大大减少业务的处理时间。
# yum install glib2-develmysql-devel zlib-devel pcre-devel -y # wget https://launchpadlibrarian.net/225370879/mydumper-0.9.1.tar.gz # cmake ./ #make && make installmydumper参数介绍:
-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参数介绍:
-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输出文件说明:
metadata:元数据,记录备份开始和结束时间,以及binlog日志文件位置。 table data:每个表一个文件 table schemas:表结构文件 daemon mode:在这个模式下,有五个目录0,1,binlogs,binlog_snapshot,last_dump。 备份目录是0和1,间隔备份,如果mydumper因某种原因失败而仍然有一个好的快照, 当快照完成后,last_dump指向该备份。
mydumper用例
备份hellodb数据库到当前目录下# mydumper -uroot -proot -B hellodb -o ./ # ll 是每个表单独备份的
![](http://s3.51cto.com/wyfs02/M01/83/85/wKioL1d1DkPA2ZPcAABZzRHloAI398.png)
# cat metadata 可以看到
![](http://s1.51cto.com/wyfs02/M00/83/85/wKioL1d1Dk2SyxWrAAAeRg10v6E222.png)
以守护进程方式每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的速度对比图。
[root@db ~]# time mysqldump -uroot -proot -B Mobile > aa.sql real 0m1.863s user 0m1.571s sys 0m0.164s
[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要高很多。
相关文章推荐
- weka连接sqlserver2005
- linux --- TCPdump 工具
- beego任务定时执行,延迟执行
- Json 转 dynamic
- 框架组开发感想
- Codeforces Round #360 (Div. 2) C. NP-Hard Problem 水题
- 软件工程课设迭代开发第四天
- 音频管理器 AudioManager
- 将二叉搜索树转换成双向链表
- hdu_3549_Flow Problem(最大流)
- 开发restful风格的webservice
- nrf24L01接收端只触发一次中断解决办法
- hdu_3549_Flow Problem(最大流)
- 全文搜索原理简单解析
- JAVA多线程和并发基础面试问答
- 百度谷歌离线地图解决方案(离线地图下载)
- CXF实现webservice 解决list<map>类型转换
- 【Android开发经验】android:windowSoftInputMode属性详解
- SceneKit:简单的3D游戏场景搭建
- SceneKit:简单的3D游戏场景搭建