fr3nd.net fr3nd.net

  • rss
  • home
  • fotos
  • invaders
  • projects
  • quien soy

mysqlpdump

Description

MySQL Parallel Dump

Multi threaded mysqldump is not an utopia any more. mysqlpdump can dump all your tables and databases in parallel so it can be much faster in systems with multiple cpu’s.

It stores each table in a different file by default. It can also generate the dump to stdout although this is not recommended because it can use all the memory in your system if your tables are big.

History

I saw an interesting post on MySQL Performance Blog with some suggestions to improve mysqldump.

Here is my effort to implement some of that suggestions.

Download

  • mysqlpdump 0.5
  • mysqlpdump 0.4
  • mysqlpdump 0.3
  • mysqlpdump 0.2
  • mysqlpdump 0.1

Requeriments

  • Python 2.4
  • MySQL-python module

Usage

Simplest usage (will save a file for each table):

mysqlpdump.py -u root -p password

Save compressed files (gzip) to /tmp/dumps and pass “–skip-opt” to mysqldump

mysqlpdump.py -u root -p password -d /tmp/dumps/ -g -P "--skip-opt"

Output to stdout and use 20 threads:

mysqlpdump.py -u root -p password -stdout -t 20

Be more “verbose”:

mysqlpdump.py -u root -p password -v

Exclude “mysql” and “test” table from dumping:

mysqlpdump.py -u root -p password -e mysql -e test

Only dump “mysql” table:

mysqlpdump.py -u root -p password -i mysql

Links

  • mysqlpdump at freshmeat
  • Original article in MySQL Performance blog
  • mysql-paralel-dump (similar script from the autor of MySQL Toolkit)

Changelog

  • 0.5
    • Compress 00_master_data.sql file if specified
    • bugfix: when it’s called without a terminal or a logged user, it uses “nobody”.
    • bugfix: destination now works with 00_master_data.sql
  • 0.4
    • Made it compatible with python 2.4
    • Can include and exclude specified databases.
  • 0.3
    • Fixed a bug that prevented the tables of being dumped because of a lock
    • Added –master-data option to write “CHANGE MASTER TO ” statement
  • 0.2
    • Store dumps to files directly instead to stdout
    • Can compress files
    • Dump each table in its own file
    • Can pass parameters directly to mysqldump
  • 0.1
    • First version

License

mysqlpdump uses GNU/GPL License.

Comments rss
Comments rss

16 responses

di4blo | 24/5/2007 | 4:55 pm

interessant, pero et recomano que posis la llicéncia dins d’aquesta web, és l’habitual no?

Devis | 5/6/2007 | 1:06 pm

I suppose we need Python 2.5 installed, isn’t it ?

fr3nd | 5/6/2007 | 1:30 pm

Devis: That’s true. Python 2.5 is necessary because I’m using some functions in the Queue module that are only available in 2.5.

Devis | 5/6/2007 | 1:56 pm

Hi fr3nd, it’s pity because Debian will release 2.5 in 2070… So for the moment I cannot use this script, hope for the future… Do you think it is possible to remove the 2.5 instructions, like queue.join ?
Anyway, thank you!

fr3nd | 5/6/2007 | 2:00 pm

Devis, I’ll try it… I just need to find some safe way to substitute .join()

Let me check it.

fr3nd | 5/6/2007 | 3:32 pm

Devis: I made it compatible with python 2.4. It was easier than I thought actually. I’ve also added two more options to specify what databases to dump and what databases not to dump. See usage for examples.

Devis | 5/6/2007 | 3:51 pm

Wonderful, it works! 10M Kudos to you!
Surely I will follow the script evolution and if I can help just write me :-)
Thank you!

Devis | 6/6/2007 | 12:37 pm

Hi fr3nd I’ve put mysqlpdump in a cron job but I am having little problems:

——-
Traceback (most recent call last):
File “mysqlpdump.py”, line 241, in ?
main()
File “mysqlpdump.py”, line 187, in main
parser.add_option(“-u”, “–user”, action=”store”, dest=”user”, type=”string”, default=os.getlogin(), help=”User for login.”)
OSError: [Errno 25] Inappropriate ioctl for device
——-

It is caused by “os.getlogin()” in combination with cron, as there isn’t any terminal or logged user.
For the moment I’ve substitued this with ‘root’ and it works for me.

fr3nd | 7/6/2007 | 9:26 am

Devis: version 0.5 fixes that bug. Thanks for the bug report!

danielj | 13/9/2007 | 7:09 am

This sounds very interesting and promising; but I think it will not be possible to create a consistent dump that way? Or how should locking be handled?

Devis | 13/9/2007 | 7:19 am

Hi danielj, to create a consistent dump you need to lock *all* tables before the dump.

Peter Zaitsev | 13/9/2007 | 9:52 am

Thank you !

Too bad MySQL does not have support for several connections sharing same transactional context so the only way you can get consistent backup is setting low priority updates and locking all the tables. As you have multiple threads you may have no luck locking all of them otherwise.

Monty Taylor | 13/9/2007 | 6:56 pm

Thanks for the tool! I love it. I used it and blogged about it yesterday, and then today I wrote a restore tool for it (http://mysql-ha.com/2007/09/13/mysqlprestore-for-parallel-restores/)
Please feel free to grab the file and incorporate it however you like. I tried to do it in such a way that the two could be merged pretty well, I think.

fr3nd | 14/9/2007 | 8:24 am

This tool automatically locks all tables before starting the dump, so there is no need to lock them manually. It’ll create a consistent dump.

About the restore tool, I don’t think it’s needed… Restoring is as easy as doing:

cat *.sql | mysql

dani | 19/11/2008 | 11:37 pm

surts referiat a la segona edicio del “High Performance MySQL” pero veient qui et comenta més amunt, no m’extranya

fr3nd | 20/11/2008 | 9:35 am

Que bò, havia llegit alguns capitols del llibre, pero no tot… suposo que hauré de fer-li una repassada més intensa :)
Merci per avisar

Leave a comment

You can use these tags : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Randompic

Black_smoke
06-05-2010 a las 00:00

Ver todos

Songs

July 2010

  • Devo - Fresh

June 2010

  • The Drums - Let's Go Surfing
  • Empire of the Sun - We Are the People

All Songs

Proyectos

  • Learn Japanese
  • DS Go 2
  • Clearlooks-NeXT
  • apache-top
  • Third Age
  • ssshell
  • mysqlpdump
  • pyproctools
  • splitdump
  • Don Simon
  • Nis Gaim Theme
  • Gaim Popupwin

Comentarios

Comentarios recientes:
  • shawn: Thanks for this project its great.. What we need for update is - spacebar refresh Also, is their a active...

  • Max Hodges: Would like to contact you. Could you email me? I couldn’t find your mail address on the site....

  • Judy: I have a picture in my living room that my husbands GrandMother made many years ago. She embroidered a picture...

  • ^ShErE^: Hola!! Soy ^ShErE^ del zanatorio, navegando, he dado por casualidad con tu pagina, me ha hecho gracia saber...

  • RkRRa: Pues aqui tienes un Space Invader mas que encontre el viernes pasado por barcelona!!...

Categorias

  • abc música! (11)
  • Art (8)
  • Dublin (7)
  • fr3nd.net (8)
  • friki (13)
  • gadgets (8)
  • General (63)
  • Informática (13)
  • Informática Retro (5)
  • Internet (17)
  • Irlanda (2)
  • Japan (19)
  • Libros (4)
  • Linux (9)
  • Música (15)
  • Personal (40)
  • pixel (15)
  • Projects (6)
  • space-invaders (25)
  • thoughts (7)
  • travel (6)
  • Viaje a Japón (10)
  • work (3)
  • ZonaDance (3)

Links

  • friends

    • Adria Garcia
    • ag0ny
    • eunice popcorn
    • fr3nd’s home
    • if i shrink will I shrink?
    • Mundodisea
    • Ojete Cable
    • Sushi’s web
    • t4bLeT
    • tetrins.com
    • uRi
    • [aMc]
  • Web presence

    • delicious
    • Facebook
    • flickr
    • JapanDict Japanese dictionary
    • last.fm
    • Learn Japanese (Twitter)
    • LinkedIn
    • twitter
    • Visited Countries
    • YouTube
  • Archivos

    • July 2010 (1)
    • June 2010 (1)
    • February 2010 (2)
    • December 2009 (1)
    • October 2009 (2)
    • July 2009 (1)
    • June 2009 (1)
    • May 2009 (1)
    • March 2009 (1)
    • January 2009 (3)
    • December 2008 (4)
    • November 2008 (3)

    Ver todos los archivos

    Search


    Creative Commons License

    :wq