mydumper使用参考
admin
2023-04-20 00:22:09
0

mydumper导出和导入有诸多优点,特别是在并行方面,网上文章很多,不做过多解释,不过随着mysqlpump的发布和增强,mydumper在并行方面优势将不复存在,
以下为mydumper的日常使用,仅记录做参考:
mydumper下载地址,直接下载rpm包进行安装:
https://github.com/maxbube/mydumper/releases

以下下载地址已经不推荐:
https://launchpad.net/mydumper

rpm -ivh mydumper-0.9.5-2.el7.x86_64.rpm
查看安装后的文件路径:
[root@db1 soft]# rpm -ql mydumper
/usr/bin/mydumper
/usr/bin/myloader

导出指定的库:
mydumper -u root -h localhost -p MYsql#123 -e -B app --threads=18 -o /root/backup1/ --logfile=mydumper20180108.log
恢复导入:
myloader -u root -p MYsql#123 -h localhost -P 3306 -B app -d /root/backup/  --threads=8

导出指定的表:
mydumper -u root -h localhost -p MYsql#123 -e -B app -T t_bz_sys_users,t_bz_sys_gallery -o /root/backup1/

mydumper导出的文件分为如下几部分:
database_name-schema-create.sql  创建数据库脚本;
database_name.table_name-schema.sql  创建表的脚本
database_name.table_name.sql   具体的数据插入sql语句
metadata  SHOW MASTER STATUS信息,相当于mysqldump加上--single-transaction --master-data

mydumper和myloader详细的使用参数请加help:
[root@db2 backup]# mydumper --help
Usage:
  mydumper [OPTION?] multi-threaded MySQL dumping

Help Options:
  -?, --help                  Show help options

Application Options:
  -B, --database              Database to dump
  -T, --tables-list           Comma delimited table list to dump (does not exclude regex option)
  -O, --omit-from-file        File containing a list of database.table entries to skip, one per line (skips before applying regex option)
  -o, --outputdir             Directory to output files to
  -s, --statement-size        Attempted size of INSERT statement in bytes, default 1000000
  -r, --rows                  Try to split tables into chunks of this many rows. This option turns off --chunk-filesize
  -F, --chunk-filesize        Split tables into chunks of this output file size. This value is in MB
  -c, --compress              Compress output files
  -e, --build-empty-files     Build dump files even if no data available from table
  -x, --regex                 Regular expression for 'db.table' matching
  -i, --ignore-engines        Comma delimited list of storage engines to ignore
  -N, --insert-ignore         Dump rows with INSERT IGNORE
  -m, --no-schemas            Do not dump table schemas with the data
  -d, --no-data               Do not dump table data
  -G, --triggers              Dump triggers
  -E, --events                Dump events
  -R, --routines              Dump stored procedures and functions
  -W, --no-views              Do not dump VIEWs
  -k, --no-locks              Do not execute the temporary shared read lock.  WARNING: This will cause inconsistent backups
  --no-backup-locks           Do not use Percona backup locks
  --less-locking              Minimize locking time on InnoDB tables.
  -l, --long-query-guard      Set long query timer in seconds, default 60
  -K, --kill-long-queries     Kill long running queries (instead of aborting)
  -D, --daemon                Enable daemon mode
  -I, --snapshot-interval     Interval between each dump snapshot (in minutes), requires --daemon, default 60
  -L, --logfile               Log file name to use, by default stdout is used
  --tz-utc                    SET TIME_ZONE='+00:00' at top of dump to allow dumping of TIMESTAMP data when a server has data in different time zones or data is being moved between servers with different time zones, defaults to on use --skip-tz-utc to disable.
  --skip-tz-utc               
  --use-savepoints            Use savepoints to reduce metadata locking issues, needs SUPER privilege
  --success-on-1146           Not increment error count and Warning instead of Critical in case of table doesn't exist
  --lock-all-tables           Use LOCK TABLE for all, instead of FTWRL
  -U, --updated-since         Use Update_time to dump only tables updated in the last U days
  --trx-consistency-only      Transactional consistency only
  --complete-insert           Use complete INSERT statements that include column names
  -h, --host                  The host to connect to
  -u, --user                  Username with the necessary privileges
  -p, --password              User password
  -a, --ask-password          Prompt For User password
  -P, --port                  TCP/IP port to connect to
  -S, --socket                UNIX domain socket file to use for connection
  -t, --threads               Number of threads to use, default 4
  -C, --compress-protocol     Use compression on the MySQL connection
  -V, --version               Show the program version and exit
  -v, --verbose               Verbosity of output, 0 = silent, 1 = errors, 2 = warnings, 3 = info, default 2
  --defaults-file             Use a specific defaults file
  --ssl                       Connect using SSL
  --key                       The path name to the key file
  --cert                      The path name to the certificate file
  --ca                        The path name to the certificate authority file
  --capath                    The path name to a directory that contains trusted SSL CA certificates in PEM format
  --cipher                    A list of permissible ciphers to use for SSL encryption


[root@db2 backup]# myloader --help
Usage:
  myloader [OPTION?] multi-threaded MySQL loader

Help Options:
  -?, --help                        Show help options

Application Options:
  -d, --directory                   Directory of the dump to import
  -q, --queries-per-transaction     Number of queries per transaction, default 1000
  -o, --overwrite-tables            Drop tables if they already exist
  -B, --database                    An alternative database to restore into
  -s, --source-db                   Database to restore
  -e, --enable-binlog               Enable binary logging of the restore data
  -h, --host                        The host to connect to
  -u, --user                        Username with the necessary privileges
  -p, --password                    User password
  -a, --ask-password                Prompt For User password
  -P, --port                        TCP/IP port to connect to
  -S, --socket                      UNIX domain socket file to use for connection
  -t, --threads                     Number of threads to use, default 4
  -C, --compress-protocol           Use compression on the MySQL connection
  -V, --version                     Show the program version and exit
  -v, --verbose                     Verbosity of output, 0 = silent, 1 = errors, 2 = warnings, 3 = info, default 2
  --defaults-file                   Use a specific defaults file

相关内容

热门资讯

今日重大消息“道游联盟到底有挂... 您好:道游联盟这款游戏可以开挂,确实是有挂的,需要了解加客服微信【9752949】很多玩家在这款游戏...
金源智能取得电池焊接压装装置专... 国家知识产权局信息显示,惠州金源智能机器人有限公司取得一项名为“电池焊接压装装置及焊接设备”的专利,...
今日重磅消息“娱网皮球开挂器?... 网上科普关于“娱网皮球有没有挂”话题很是火热,小编也是针对娱网皮球作*弊开挂的方法以及开挂对应的知识...
广州在全国率先设立区级人工智能... 【环球网科技综合报道】12月29日消息,记者从广州海珠发布平台获悉,日前广州市海珠区人工智能发展局成...
玩家分享攻略“麦穗推筒子开挂器... 网上科普关于“麦穗推筒子有没有挂”话题很是火热,小编也是针对麦穗推筒子作*弊开挂的方法以及开挂对应的...
【第一资讯】“新好游炸/金/花... 有 亲,根据资深记者爆料新好游炸/金/花是可以开挂的,确实有挂(咨询软件...
今日重大消息“情怀娱乐究竟有挂... 有 亲,根据资深记者爆料情怀娱乐是可以开挂的,确实有挂(咨询软件无需打开...
今日重大发现“新版九哥开挂神器... 今日重大发现“新版九哥开挂神器?”(原来真的有挂)您好,新版九哥这个游戏其实有挂的,确实是有挂的,需...
今日重磅消息“海贝大厅牛牛有挂... 网上科普关于“海贝大厅牛牛有没有挂”话题很是火热,小编也是针对海贝大厅牛牛作*弊开挂的方法以及开挂对...
玩家攻略科普“飞驰娱乐到底是不... 有 亲,根据资深记者爆料飞驰娱乐是可以开挂的,确实有挂(咨询软件无需打开...