为了技术,我不会停下学习的脚步,我相信我还能走二十年。
分类:
2012-07-24 16:17:37
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: 备份到指定目录。
–[no]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 --[no]binlogpos -b Dump the master/slave position (default) --charset -A Default character set --chunksize -C Number of rows or data size to dump per file --csv Do --tab dump in CSV format (implies --tab) --databases -d Dump only this comma-separated list of databases --dbregex Dump only databases whose names match this pattern --defaults-file -F Only read mysql options from the given file --[no]defaultset When --sets given, dump tables not in any set --[no]flushlock -k Use FLUSH TABLES WITH READ LOCK (default) --[no]flushlog Execute FLUSH LOGS when getting binlog positions --[no]gzip Compress files with gzip (default 1) --help Show this help message --host -h Connect to host --ignoredb -g Ignore this comma-separated list of databases --ignoreengine -E Dump no data for this comma-separated list of storage engines (default FEDERATED,MRG_MyISAM) --ignoretbl -n Ignore this comma-separated list of tables --[no]locktables Use LOCK TABLES (disables --flushlock) --losslessfp -L Convert double and float to decimal with extra precision so the reinserted values will be equal to the original values. Requires --tab. --numthread -m Number of threads (default 4) --password -p Password to use when connecting --port -P Port number to use for connection --quiet -q Quiet 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 -S Socket file to use for connection --stopslave Issue STOP SLAVE on server before dumping data --tab -T Dump tab-separated (sets --umask 0) --tables -t Dump 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 -u User for login if not current user --verbose -v Be verbose; can specify multiple times; default --version Output version information and exit --wait -w Wait 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