Mysql管理必备工具Maatkit详解之九(mk-parallel-dump)
Mysql管理必备工具Maatkit详解之九(mk-parallel-dump)
2009年07月16日 作者: 大头刚
mk-parallel-dump - 顾名思义,并行mysqldump工具。安装方法可以参考
这里
。
mysqldump是单进程的,同时只能备份1个表。mk-parallel-dump它会同时并发4个mysqldump进程,同时备份4个表,默认是先备份大表,在备份小表。和mysqldump出来生成一个文件不同,它将每个表生成一个单独的文件。默认使用gzip对文件进行压缩。
使用mysqldump备份40G左右的数据,大概需要2小时。而使用mk-parallel-dump不到1小时能完成,效率能提高200%左右。
例如:
mk-parallel-dump -u-p-h--basedir /u01/backup/bk_mysql
default: 1 tables, 1 chunks, 1 successes,0 failures, 0.10 wall-clock time, 0.06 dump time
恢复的话,直接解压导入就可,和mysqldump的恢复一样。当然也可以用mk-parallel-restore进行恢复,这个工具将在
下一篇
进行介绍。
解释几个重要的参数文件。
–tab: 将数据备份成load data的形式,将生成一个load文本文件,一个建表sql文件。只能备份本地的MYSQL,不能远程。
–basedir: 备份到指定目录。
–gzip:是否压缩,默认是压缩。
OK,还有其他的一些参数,可以看下帮助文件。
mk-parallel-dump --help
mk-parallel-dump dumps sets of MySQL tables simultaneously via mysqldump or
SELECT INTO OUTFILE.For more details, please use the --help option, or try
'perldoc mk-parallel-dump' for complete documentation.
Usage: mk-parallel-dump options> [--] external args>
Options:
--age Dump only tables modified since this long ago, or not
dumped since this long ago.Optional suffix s=seconds,
m=minutes, h=hours, d=days; if no suffix, s is used.
--askpass Prompt for password for connections
--basedir Base directory for creating files
--binlogpos -bDump the master/slave position (default)
--charset -ADefault character set
--chunksize -CNumber of rows or data size to dump per file
--csv Do --tab dump in CSV format (implies --tab)
--databases -dDump only this comma-separated list of databases
--dbregex Dump only databases whose names match this pattern
--defaults-file -FOnly read mysql options from the given file
--defaultset When --sets given, dump tables not in any set
--flushlock -kUse FLUSH TABLES WITH READ LOCK (default)
--flushlog Execute FLUSH LOGS when getting binlog positions
--gzip Compress files with gzip (default 1)
--help Show this help message
--host -hConnect to host
--ignoredb -gIgnore this comma-separated list of databases
--ignoreengine-EDump no data for this comma-separated list of storage
engines (default FEDERATED,MRG_MyISAM)
--ignoretbl -nIgnore this comma-separated list of tables
--locktables Use LOCK TABLES (disables --flushlock)
--losslessfp -LConvert double and float to decimal with extra precision
so the reinserted values will be equal to the original
values.Requires --tab.
--numthread -mNumber of threads (default 4)
--password -pPassword to use when connecting
--port -PPort number to use for connection
--quiet -qQuiet output; disables --verbose
--setperdb Dump each database as a separate set
--sets Dump this comma-separated list of sets
--settable database.table where backup sets are stored
--setvars Set these MySQL variables (default wait_timeout=10000)
--socket -SSocket file to use for connection
--stopslave Issue STOP SLAVE on server before dumping data
--tab -TDump tab-separated (sets --umask 0)
--tables -tDump only this comma-separated list of tables
--tblregex Dump only tables whose names match this pattern
--test Print commands instead of executing them
--umask Set umask to this value, in octal
--user -uUser for login if not current user
--verbose -vBe verbose; can specify multiple times; default
--version Output version information and exit
--wait -wWait limit when server is down (default 5m).Optional
suffix s=seconds, m=minutes, h=hours, d=days; if no
suffix, s is used.
--locktables and --flushlock are mutually exclusive
--sets and --setperdb are mutually exclusive
--losslessfp requires --tab
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/111930/showart_2184923.html
页:
[1]