mydumper⼯具安装的错误处理以及使⽤
前⾔
⼤家对于MySQL的逻辑备份⼯具mysqldump应该都⽐较了解,相对于mysqldump,本⽂介绍⼀款由MySQL ,Facebook 等公司的开发维护另外⼀套逻辑备份恢复⼯具---⽬前已经开发到0.9.1 版本。
mydumper 具有如下特性
1 ⽀持多线程导出数据,速度⽐mysqldump快。
2 ⽀持⼀致性备份,使⽤FTWRL(FLUSH TABLES WITH READ LOCK)会阻塞DML语句,保证备份数据的⼀致性。
3 ⽀持将导出⽂件压缩,节约空间。
4 ⽀持多线程恢复。
5 ⽀持以守护进程模式⼯作,定时快照和连续⼆进制⽇志
6 ⽀持按照指定⼤⼩将备份⽂件切割。
7 数据与建表语句分离。
原理
参考⼀张图 介绍mydumper的⼯作原理
mydumper的主要⼯作步骤
1 主线程 FLUSH TABLES WITH READ LOCK, 施加全局只读锁,以阻⽌DML语句写⼊,保证数据的⼀致性
2 读取当前时间点的⼆进制⽇志⽂件名和⽇志写⼊的位置并记录在metadata⽂件中,以供即使点恢复使⽤
3 START TRANSACTION WITH CONSISTENT SNAPSHOT; 开启读⼀致事务
4 启⽤N个(线程数可以指定,默认是4)dump线程导出表和表结构
5 备份⾮事务类型的表
6 主线程 UNLOCK TABLES,备份完成⾮事务类型的表之后,释放全局只读锁
7 dump InnoDB tables, 基于事物导出InnoDB表
8 事物结束
mydumper⼯具安装的错误处理
1. 安装mysqldumper之前需要安装⼀下依赖,mysql-devel会依赖mariadb-libs,mariadb-libs存在启动mysql服务就启动不起来,所
以不要这个依赖
2.
. yum install glib2-devel zlib-devel pcre-devel zlib gcc-c++ gcc cmake -y
4. 下载
. wget launchpadlibrarian/225370879/mydumper-0.9.
tar -zxvf mydumper-0.9.
cd mydumper-0.9.1/
. 执⾏cmake .        .表⽰源⽂件路径
7. cmake参考路径CMake
. [root@localhost mydumper-0.9.1]# cmake .
-- The C compiler identification is GNU 4.8.5
-- The CXX compiler identification is GNU 4.8.5
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-
- Detecting CXX compiler ABI info - done
-- MySQL not found.
-- Found ZLIB: /usr/lib64/libz.so (found version "1.2.7")
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.27.1")
-- checking for one of the modules 'glib-2.0'
-- checking for one of the modules 'gthread-2.0'
-- checking for module 'libpcre'
--  found libpcre, version 8.32
-- Found PCRE: /usr/include
CMake Warning at :9 (message):
Unable to find Sphinx documentation generator
-
- ------------------------------------------------
-- MYSQL_CONFIG = MYSQL_CONFIG-NOTFOUND
-- CMAKE_INSTALL_PREFIX = /usr/local
-- BUILD_DOCS = ON
-- WITH_BINLOG = OFF
-- RUN_CPPCHECK = OFF
-- Change a values with: cmake -D<Variable>=<Value>
-- ------------------------------------------------
--
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 /usr/local/mydumper-0.9.1
used as include directory in directory /usr/local/mydumper-0.9.1
used as include directory in directory /usr/local/mydumper-0.9.1
-- Configuring incomplete, errors occurred!
See also "/usr/local/mydumper-0.9.1/CMakeFiles/CMakeOutput.log".
9. 错误信息如下:
0. 我安装mysql的⽅式为⼆进制包安装
. 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 /usr/local/mydumper-0.9.1
used as include directory in directory /usr/local/mydumper-0.9.1
used as include directory in directory /usr/local/mydumper-0.9.1
2. 出现上述错误,是由于没有配置MYSQL_INCLUDE_DIR⽬录。
3. 如果是编译安装到⾮缺省路径,可以将mysql安装路径添加到/etc/profile(全局级别)或者家⽬录~/.bash_profile(⽤户级别)后
source⽣效
. 配置MySQL的⽬录就可以解决
vim /etc/profile
export MYSQL_INCLUDE_DIR=/usr/local/mysql-5.7.18
export PATH=$MYSQL_INCLUDE_DIR/bin:$PATH
source /etc/profile
5. 编译安装
. make && make install
17. 查看版本报错
. [root@localhost mydumper-0.9.1]# mydumper -V
mydumper: error while loading shared libraries: libmysqlclient.so.20: cannot open shared object file: No such file or directory . 解决⽅法, ldd是list, dynamic, dependencies的缩写,意思是,列出动态库依赖关系
. ldd /usr/local/bin/mydumper
1. 显⽰
2.
. LD_DEBUG=libs /usr/local/bin/mydumper -v
4.
5. 没有到 libmysqlclient.so.18
26.
mysql下载libs包的网址27.
8. linux中locate命令可以快速定位我们需要查的⽂件,但是在yum中,locate的安装包名为mlocate(yum list | grep locate可以查
看),安装⽅法:
9. yum -y install mlocate
0. updatedb
1. locate ⽂件名
32.
. locate libmysqlclient.so.20
4.
5.
6. 然后将/usr/local/mysql-5.
7.18/lib/libmysqlclient.so.20.3.5 软件接到/usr/lib/下就⾏了
7. 建⽴软连接就⾏了
8. ln -s 源⽂件  ⽬标⽂件
9. ln -s /usr/local/mysql-5.7.18/lib/libmysqlclient.so.20.3.5  /usr/lib/libmysqlclient.so.20
0.
1. 在次执⾏
2. mydumper -V    如果还是报错的话就执⾏ldconfig命令之后在执⾏mydumper -V就⾏了
3.
4. ⼯具安装完之后就开始使⽤了
mydumper和myloader的使⽤
1. mydumper参数

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。