mydumper安装及安装故障汇总

简介:    mydumper是针对mysql数据库备份的一个轻量级第三方的开源工具,备份方式术语逻辑备份。它支持多线程,备份速度远高于原生态的mysqldump以及众多优异特性。


   mydumper是针对mysql数据库备份的一个轻量级第三方的开源工具,备份方式术语逻辑备份。它支持多线程,备份速度远高于原生态的mysqldump以及众多优异特性。因此该工具是DBA们的不二选择。本文主要描述该工具的安装及其出现异常的解决方法。


1、mydumper特性(直接参考readme)
  * Parallelism (hence, speed) and performance (avoids expensive character set conversion routines, efficient code overall)
  * Easier to manage output (separate files for tables, dump metadata, etc, easy to view/parse data)
  * Consistency - maintains snapshot across all threads, provides accurate master and slave log positions, etc
  * Manageability - supports PCRE for specifying database and tables inclusions and exclusions
  It does not support schema dumping and leaves that to 'mysqldump --no-data'


2、获取mydumper及安装方法
下载地址:
https://launchpad.net/mydumper
== How to build it? ==
Run:
 cmake .
 make

One needs to install development versions of required libaries (MySQL, GLib, ZLib, PCRE):
NOTE: you must use the correspondent mysql devel package.

* Ubuntu or Debian: apt-get install libglib2.0-dev libmysqlclient15-dev zlib1g-dev libpcre3-dev libssl-dev
* Fedora, RedHat and CentOS: yum install glib2-devel mysql-devel zlib-devel pcre-devel openssl-devel
* openSUSE: zypper install glib2-devel libmysqlclient-devel pcre-devel zlib-devel
* MacOSX: port install glib2 mysql5 pcre pkgconfig cmake
 (You may want to run 'port select mysql mysql5' afterwards)

One has to make sure, that pkg-config, mysql_config, pcre-config are all in $PATH

Binlog dump is disabled by default to compile with it you need to add -DWITH_BINLOG=ON to cmake options
###如果要使用binlog dump在编译的时候需要使用-DWITH_BINLOG=ON


3、快照工作原理
== How does consistent snapshot work? ==

This is all done following best MySQL practices and traditions:

* As a precaution, slow running queries on the server either abort the dump, or get killed
* Global write lock is acquired ("FLUSH TABLES WITH READ LOCK")
* Various metadata is read ("SHOW SLAVE STATUS","SHOW MASTER STATUS")
* Other threads connect and establish snapshots ("START TRANSACTION WITH CONSISTENT SNAPSHOT")
** On pre-4.1.8 it creates dummy InnoDB table, and reads from it.
* Once all worker threads announce the snapshot establishment, master executes "UNLOCK TABLES" and starts queueing jobs.

This for now does not provide consistent snapshots for non-transactional engines - support for that is expected in 0.2 :)


4、如何过滤数据库
== How to exclude (or include) databases? ==

Once can use --regex functionality, for example not to dump mysql and test databases:

 mydumper --regex '^(?!(mysql|test))'

Of course, regex functionality can be used to describe pretty much any list of tables.

== How to exclude MERGE or Federated tables ==

Use same --regex exclusion syntax. Again, engine-specific behaviors are targetted for 0.2


5、实际安装过程
# ls mydump*
mydumper-0.6.2.tar.gz
# tar -xvf mydumper-0.6.2.tar.gz
# cd mydumper-0.6.2
[root@GZ-APP-BAK01 mydumper-0.6.2]# cmake .
[root@GZ-APP-BAK01 mydumper-0.6.2]# make && make install


6、安装过程中的异常
错误1:
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
PCRE_INCLUDE_DIR (ADVANCED)
   used as include directory in directory /root/mydumper-0.6.2
PCRE_PCRE_LIBRARY (ADVANCED)
    linked by target "mydumper" in directory /root/mydumper-0.6.2
    linked by target "myloader" in directory /root/mydumper-0.6.2
###需要安装pcre-devel包,yum install pcre-devel  


错误2:
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
MYSQL_INCLUDE_DIR (ADVANCED)
   used as include directory in directory /home/robin/mydumper-0.6.2
   used as include directory in directory /home/robin/mydumper-0.6.2
   used as include directory in directory /home/robin/mydumper-0.6.2
###出现上述错误,是由于没有配置MYSQL_INCLUDE_DIR目录。
###如果是编译安装到非缺省路径,可以将mysql安装路径添加到/etc/profile或者家目录~/.bash_profile后source生效


错误3:
[root@GZ-APP-BAK01 ~]# mydumper --help|more
mydumper: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
[root@GZ-APP-BAK01 ~]# mydumper
mydumper: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
###出现上述错误,应考虑建立软链
# which libmysqlclient.so.18
/app/soft/mysql/lib/libmysqlclient.so.18
# ln -s  /app/soft/mysql/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18


错误4:
# mydumper -uusr1 -ppwd -B blos -o /tmp/bak
option parsing failed: Error parsing option -r, try --help
###参数和字符串不能连着写,笔者刚开始是也是丈二和尚摸不着头脑。

# mydumper --version
mydumper 0.6.2, built against MySQL 5.6.22


7、获取帮助
# mydumper --help|more
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, --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
  -m, --no-schemas            Do not dump table schemas with the data
  -k, --no-locks              Do not execute the temporary shared read lock.  WARNING: This will cause inconsistent backups
  --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
  -h, --host                  The host to connect to
  -u, --user                  Username with privileges to run the dump
  -p, --password              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

相关实践学习
每个IT人都想学的“Web应用上云经典架构”实战
本实验从Web应用上云这个最基本的、最普遍的需求出发,帮助IT从业者们通过“阿里云Web应用上云解决方案”,了解一个企业级Web应用上云的常见架构,了解如何构建一个高可用、可扩展的企业级应用架构。
MySQL数据库入门学习
本课程通过最流行的开源数据库MySQL带你了解数据库的世界。   相关的阿里云产品:云数据库RDS MySQL 版 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务,提供容灾、备份、恢复、迁移等方面的全套解决方案,彻底解决数据库运维的烦恼。 了解产品详情: https://www.aliyun.com/product/rds/mysql 
目录
相关文章
使用ruoyi-vue控制数据权限
使用ruoyi-vue控制数据权限
1899 0
|
数据可视化 数据挖掘 数据处理
R语言高级可视化技巧:使用Plotly与Shiny制作互动图表
【8月更文挑战第30天】通过使用`plotly`和`shiny`,我们可以轻松地创建高度互动的数据可视化图表。这不仅增强了图表的表现力,还提高了用户与数据的交互性,使得数据探索变得更加直观和高效。本文仅介绍了基本的使用方法,`plotly`和`shiny`还提供了更多高级功能和自定义选项,等待你去探索和发现。希望这篇文章能帮助你掌握使用`plotly`和`shiny`制作互动图表的技巧,并在你的数据分析和可视化工作中发挥更大的作用。
|
SQL 存储 关系型数据库
MySQL备份:mydumper 备份恢复工具生产实战
MySQL备份:mydumper 备份恢复工具生产实战
|
SQL 安全 Go
PHP在Web开发中的安全实践与防范措施###
【10月更文挑战第22天】 本文深入探讨了PHP在Web开发中面临的主要安全挑战,包括SQL注入、XSS攻击、CSRF攻击及文件包含漏洞等,并详细阐述了针对这些风险的有效防范策略。通过具体案例分析,揭示了安全编码的重要性,以及如何结合PHP特性与最佳实践来加固Web应用的安全性。全文旨在为开发者提供实用的安全指南,帮助构建更加安全可靠的PHP Web应用。 ###
292 1
|
SQL 存储 安全
如何防护SQL注入
在互联网中,SQL注入攻击是网站和应用面临的主要安全威胁之一。攻击者通过在输入字段中插入恶意SQL代码,企图非法访问或操控数据库。防范措施包括限制查询长度、使用参数化查询、采用ORM框架、遵循最小权限原则、定期更新系统以及使用SCDN等专业安全产品,以增强防护能力,保护数据安全。
|
机器学习/深度学习 人工智能 安全
SentinelOne监测中隔离的文件,人工如何取消隔离
SentinelOne 的 Agent 在终端设备上实时监测系统的活动,包括文件操作、网络通信、内存访问等, SentinelOne 使用人工智能和机器学习技术对监测到的活动进行行为分析,识别潜在的威胁,包括已知的恶意软件和未知的零日攻击。 基于行为分析和实时监测,SentinelOne 快速识别出可能的威胁,并进行准确的威胁分类,包括病毒、勒索软件、恶意脚本等。 SentinelOne 可以自动采取响应措施,如隔离受感染的设备、终止恶意进程、删除恶意文件等,以尽快减轻威胁带来的影响。当技术人员发现隔离的文件没有危害时,可以手动隔离。文章阐述了怎么手动撤销的过程。
1952 0
SentinelOne监测中隔离的文件,人工如何取消隔离
|
应用服务中间件 nginx 数据安全/隐私保护
Nginx实现Web页面用户认证配置
Nginx实现Web页面用户认证配置
416 0
|
计算机视觉 Python
OpenCV检测眼睛、猫脸、行人、车牌实战(附Python源码)
OpenCV检测眼睛、猫脸、行人、车牌实战(附Python源码)
646 0
|
JavaScript 前端开发 API
js实现拖拽功能
js实现拖拽功能
356 0