为了技术,我不会停下学习的脚步,我相信我还能走二十年。
分类:
2012-07-24 16:17:41
mk-parallel-restore - Load files into MySQL in parallel. 安装方法可以参考。
在介绍了mk-parallel-dump并行备份,会把mysql的按照database模式,每个表都生成一个单独的备份文件,并统一在你指定的目录。
mk-parallel-restore其实就是mk-parallel-dump的反向操作,也会同时启用4个mysql进程去进行恢复,默认优先恢复大表。
使用起来很简单。例如:
mk-parallel-restore -u -p -h /u01/backup/bk_mysql_20090724
如果dump的时候指定了–tab,这里也加上–tab参数
mk-parallel-restore -u -p -h –tab /u01/backup/bk_mysql_20090724
这里需要注意一下,恢复的时候,如果恢复库没有备份库的database需要提前手工创建,mk-parallel-restore不会自动创建。否则会报错
gzip: stdout: Broken pipe
Issuing rollback() for database handle being DESTROY’d without explicit disconnect().
DBD::mysql::db do failed: Unknown database ‘xxxxxx’ at /usr/bin/mk-parallel-restore line 1778.
ok,在看下其他的参数。
mk-parallel-restore --help mk-parallel-restore loads files into MySQL in parallel. For more details, please use the --help option, or try 'perldoc mk-parallel-restore' for complete documentation. Usage: mk-parallel-restore <options> PATH [PATH...] Options: --askpass Prompt for a password when connecting to MySQL --[no]atomicresume Treat chunks as atomic when resuming restore (default yes) --basedir Directory where FIFO files will be created --[no]biggestfirst Restore the biggest tables first for highest concurrency (default yes) --binlog Set SQL_LOG_BIN to 1 or 0 to enable or disable binary logging (default 1) --bulkinsbufsize Set bulk_insert_buffer_size before each LOAD DATA INFILE --charset -A Sets the connection, database, and LOAD DATA INFILE character set (default BINARY) --commit Commit after each load via LOAD DATA INFILE --createdb Create databases if they don't exist --csv Files are in CSV format (implies --tab) --database -D Load all files into this database --databases -d Restore only this comma-separated list of databases --dbregex Restore only databases whose names match this regex --decompress Command used to decompress and print .gz files to STDOUT (like zcat). (default gzip -d -c) --defaults-file -F Only read mysql options from the given file. You must give an absolute pathname. --[no]disablekeys Execute ALTER TABLE DISABLE KEYS before each table --[no]fifo Stream files into a FIFO for --tab (default yes) --help Show this help message --host -h Connect to host --ignore -i Adds the IGNORE modifier to LOAD DATA INFILE --ignoredb -g Ignore this comma-separated list of databases --ignoretbl -n Ignore this comma-separated list of table names --local -L Uses the LOCAL option to LOAD DATA INFILE --[no]locktables Lock tables before LOAD DATA INFILE --[no]noautovalon0 Set SQL NO_AUTO_VALUE_ON_ZERO before LOAD DATA INFILE --[no]noforeignkeys Set FOREIGN_KEY_CHECKS=0 before LOAD DATA INFILE --noresume Do not resume restore --[no]nouniquechecks Set UNIQUE_CHECKS=0 before LOAD DATA INFILE --numthread -m Specifies the number of parallel processes to run --password -p Password to use when connecting --port -P Port number to use for connection --progress Display progress messages --quiet -q Sets --verbose to 0 --replace -r Adds the REPLACE modifier to LOAD DATA INFILE --setvars Set these MySQL variables (default wait_timeout=10000) --socket -S Socket file to use for connection --tab -T Load tab-separated files with LOAD DATA INFILE --tables -t Restore only this comma-separated list of table names --tblregex Restore only tables whose names match this regex --test Print commands instead of executing them --truncate Run TRUNCATE TABLE before LOAD DATA INFILE --umask Set the program's umask to this octal value --user -u User for login if not current user --verbose -v Verbosity; can specify multiple times (default 1) --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. Options and values after processing arguments: --askpass FALSE --atomicresume TRUE --basedir /root/cron --biggestfirst TRUE --binlog 1 --bulkinsbufsize (No value) --charset BINARY --commit FALSE --createdb FALSE --csv FALSE --database (No value) --databases (No value) --dbregex (No value) --decompress gzip -d -c --defaults-file (No value) --disablekeys FALSE --fifo TRUE --help TRUE --host (No value) --ignore FALSE --ignoredb --ignoretbl --local FALSE --locktables FALSE --noautovalon0 FALSE --noforeignkeys FALSE --noresume FALSE --nouniquechecks FALSE --numthread 4 --password (No value) --port (No value) --progress FALSE --quiet FALSE --replace FALSE --setvars wait_timeout=10000 --socket (No value) --tab FALSE --tables (No value) --tblregex (No value) --test FALSE --truncate FALSE --umask 0 --user (No value) --verbose 1 --version FALSE --wait 300