pt-archiver usage

1,199 views
Skip to first unread message

Krishna Prasad

unread,
May 13, 2014, 3:09:34 PM5/13/14
to percona-d...@googlegroups.com
Hi Team,

I have been working with pt-archiver (http://www.percona.com/doc/percona-toolkit/2.2/pt-archiver.html), but would like to know the options clearly where I need to use just purge without writing anything to a table or file and optimize the table once done.
pt-archiver --source h=host,D=db,t=child --purge \
  --where 'NOT EXISTS(SELECT * FROM parent WHERE col=child.col)'
--source  : It is just to be left like that or do we need to specify anything there
h=host    : localhost
D=db      : Database name
t=child   : Table name
--where : id<50

Will the above parameters work.

In case I would like to use a dry-run, could you please share some examples with the output if possible.

Do we need to execute the above pt-archiver from command prompt or mysql prompt. Because, how would it get connected without specifying the user credentials to login mysql.

Could you please help me out!

Best Regards,
Krishna Prasad

Bill Karwin

unread,
May 13, 2014, 5:36:32 PM5/13/14
to percona-d...@googlegroups.com
On May 13, 2014, at 12:09 PM, Krishna Prasad <kpb...@gmail.com> wrote:

Hi Team,

I have been working with pt-archiver (http://www.percona.com/doc/percona-toolkit/2.2/pt-archiver.html), but would like to know the options clearly where I need to use just purge without writing anything to a table or file and optimize the table once done.

Yes, the —purge option deletes data from the source DSN without writing the data to any destination. This means there is no recovering the data that you purge, so please be careful. In fact, make a backup before you run the purge, just in case you find that you need the data after all.

If you want the table to be optimized after purging is complete, you need to add the —optimize flag. 
Have you read the documentation?

In case I would like to use a dry-run, could you please share some examples with the output if possible.
pt-archiver supports an option “--dry-run” which makes no changes to the data, but shows you the SQL it would run. 

I recommend first trying in a test environment while you are learning any tool that deletes data!
 
Do we need to execute the above pt-archiver from command prompt or mysql prompt. Because, how would it get connected without specifying the user credentials to login mysql.

All Percona Toolkit tools are executed at the command prompt. None are run from a mysql prompt.

To specify user credentials, typically your source DSN includes arguments for user and password. For example:

$ pt-archiver --source h=host,D=db,t=child,u=scott,p=tiger …other options…

Refer to the reference documentation for DSN options:

--
Bill Karwin
Senior Knowledge Manager

Reply all
Reply to author
Forward
0 new messages