推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
seanlook
V2EX  ›  Python

让 mysqldump 变成并发导出导入的魔法

  •  
  •   seanlook · Dec 1, 2016 · 3799 views
    This topic created in 3474 days ago, the information mentioned may be changed or developed.

    mydumper 和 mysqlpump 在特定场景下会有些限制,于是自己用 python 封装 mysqldump ,实现以多线程的方式导出库表的操作,再以 mysql 命令多线程导入新库,用于成倍加快导出,特别是导入的速度。这一切只需要在 mysqldump 或 mysql 命令前面加上 mypumpkin.py 即可。

    Github 项目地址 https://github.com/seanlook/mypumpkin

    介绍和使用见 http://seanlook.com/2016/11/17/python-mysqldump-out-in-concurrency-magic/

    5 replies    2016-12-02 15:34:22 +08:00
    xi_lin
        1
    xi_lin  
       Dec 1, 2016
    veelog
        2
    veelog  
       Dec 1, 2016 via Android
    有没有可以限制 mysqldump 速度的??现在执行 sqldump 整个数据库操作非常慢
    seanlook
        3
    seanlook  
    OP
       Dec 1, 2016
    @veelog 限流这个倒蛮新颖的,我这个工具一开起来基本上能把带宽或磁盘打满,源数据库 IO 会特别高。

    mydumper 可以做到表上的多并发,可以每次 select chunk sleep 几毫秒来实现...
    seanlook
        4
    seanlook  
    OP
       Dec 1, 2016
    @xi_lin 欢迎提建议...
    julyclyde
        5
    julyclyde  
       Dec 2, 2016
    限流(不基于数据语义)可以用 pv 工具
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2646 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 15:42 · PVG 23:42 · LAX 08:42 · JFK 11:42
    ♥ Do have faith in what you're doing.