Keep your slave warm

By | 2013-10-11

Keep your slave warm

pt-query-digest 2.2.x had removed this function.

# pt-query-digest –version
pt-query-digest 2.1.9


              filter select sql                 replay sql on slave
   | master |------------------->| text file |---------------------->| slave |

1. capture select statement on master server, and save result into text file.

pt-query-digest  --charset=utf8 --processlist h=,u=book_user,p='xxxxxx',P=3306,D=dbname \
 --interval=1 --run-time=30s --filter '$event->{arg} =~ m/^select/i' --print --no-report

2. replay select sql statement on slave server.

pt-query-digest master_select.log \
 --charset=utf8 --execute-throttle 70,30,5 --no-report --statistics \
 --execute h=,P=3306,u=book_user,p='xxxxxx',D=dbname 

use one statement instead:

pt-query-digest --charset=utf8 --processlist h=,u=book_user,p='xxxxxx',P=3306,D=dbname --interval=1 --run-time=30s --filter 
 '$event->{arg} =~ m/^select/i' --execute h=,P=3306,D=dbname,u=book_user,p='xxxxxx' --execute-throttle 70,30,5 --no-report

interval: How frequently to poll the processlist, default is .1 (means 100ms), and .01 means 10ms, .001 means 1ms.

Compare to percona playback.
     playback is usefull for warm your server, but don’t run it on the production server,because playback will run both SELECT and DML queries.
read more:

Leave a Reply

Your email address will not be published. Required fields are marked *