Step 1 基础环境
rm -rf /etc/yum.repos.d/epel* yum install postgresql-devel python3-devel postgresql-devel python-devel
Step 2安装setuptools
(1) 下载 setuptools-39.2.0.zip (2) 解压安装 python setup.py build python setup.py install
step 3 安装pip
(1) 下载 pip-1.5.4.tar.gz (2) 安装 python setup.py install
step 4 安装MySQL-python
yum install MySQL-python
2.报错缺少pt-archiver工具
sh: pt-archiver: command not found
解决方案:
下载percona-toolkit-3.2.1_x86_64.tar.gz,安装,并且设置个软连接。
例如:
ln -s /data/mysql_archiver/percona-toolkit-3.2.1/bin/pt-archiver /usr/local/bin/pt-archiver
3.缺少文档
<type 'exceptions.Exception'> [Errno 2] No such file or directory: u'/software/python_script/db_archive_XXXXdb_XXXtablename.log'
解决方案:
创建文档:/software/python_script
4.字符集问题
Character set mismatch: --source DSN uses utf8, table uses utf8mb4. You can disable this check by specifying --no-check-charset.
解决方案:
修改db_archive_exec.py可执行文件,针对pt-archiver添加参数--no-check-charset
5.参数设置报错
Usage: pt-archiver [OPTIONS] --source DSN --where WHERE Errors in command-line arguments: * --txn-size and --commit-each are mutually exclusive. pt-archiver nibbles records from a MySQL table. The --source and --dest arguments use DSN syntax; if COPY is yes, --dest defaults to the key's value from --source. For more details, please use the --help option, or try 'perldoc /usr/local/bin/pt-archiver' for complete documentation.
解决方案:
pt-archiver去掉参数--commit-each
6.Cannot find encoding "utf8mb4"
报错信息:
Cannot find encoding "utf8mb4" at /usr/local/bin/pt-archiver line 6711.
解决方案:
pt-archiver去掉参数 --bulk-insert --bulk-delete
四.主要参考资料
1.MySQL数据归档实战-Python和pt-archiver的强强结合
https://blog.csdn.net/n88lpo/article/details/78905528?utm_medium=distribute.pc_relevant.none-task-blog-baidulandingword-14&spm=1001.2101.3001.4242
2.MySQL数据归档小工具
https://github.com/dbarun/mysql_archiver#readme
3.在linux下安装MySQLdb及基本操作
https://www.cnblogs.com/blogsme/archive/2012/12/12/2814588.html
4.pt工具之pt-archiver
https://www.cnblogs.com/yhq1314/p/10601801.html
5.linux下pip的安装步骤及使用详解
http://1000zx.cn/article/118035.htm
6.Percona-Toolkit 之 pt-archiver 总结
https://www.cnblogs.com/dbabd/p/10721857.html
到此这篇关于MySQL数据归档小工具mysql_archiver详解的文章就介绍到这了,更多相关MySQL数据归档内容请搜索
更多相关Mysql内容来自木庄网络博客
标签:Mysql
相关阅读 >>
更多相关阅读请进入《mysql》频道 >>
数据库系统概念 第6版
本书主要讲述了数据模型、基于对象的数据库和XML、数据存储和查询、事务管理、体系结构等方面的内容。