- 論壇徽章:
- 0
|
Mysql管理必備工具Maatkit詳解之九(mk-parallel-dump)
2009年07月16日 作者: 大頭剛
mk-parallel-dump - 顧名思義,并行mysqldump工具。安裝方法可以參考
這里
。
mysqldump是單進程的,同時只能備份1個表。mk-parallel-dump它會同時并發(fā)4個mysqldump進程,同時備份4個表,默認是先備份大表,在備份小表。和mysqldump出來生成一個文件不同,它將每個表生成一個單獨的文件。默認使用gzip對文件進行壓縮。
使用mysqldump備份40G左右的數(shù)據(jù),大概需要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進行恢復,這個工具將在
下一篇
進行介紹。
解釋幾個重要的參數(shù)文件。
–tab: 將數(shù)據(jù)備份成load data的形式,將生成一個load文本文件,一個建表sql文件。只能備份本地的MYSQL,不能遠程。
–basedir: 備份到指定目錄。
–[no]gzip:是否壓縮,默認是壓縮。
OK,還有其他的一些參數(shù),可以看下幫助文件。
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
本文來自ChinaUnix博客,如果查看原文請點:http://blog.chinaunix.net/u3/111930/showart_2184923.html |
|