Download - Percona tool kit for MySQL DBA's
1
Percona Tool kits For DBA’s
2
• P.R.Karthik• 3 Years plus experience in MySQL as a DBA.• Worked for various e-commerce companies in INDIA.• Currently in one of biggest MySQL server farms.• remotemysqldba.blogspot.in
About me
Percona Tool kit
• Maintained by Percona Team.• Originated from Aspersa and Maakit.• Initially Designed by Baron Schwartz.• Designed for MySQL and its forks.• Works on all Linux Platforms.• Matured and proven tool.• Set of 33 cmd line tools.• Latest version 2.2.5 ( 16-10-2013)
3
Percona Tool kit
• Pt-query-digest• Pt-table-checksum• Pt-table-sync• Pt-online-schema-change• Pt-kill
4
Pt-query-digest
5
Pt-query-digest
• Analyses the Queries.• Slow query log, Query logs.• Works on tcpdump too.
Other tools for Query logs1) Mysqldumpslow2) mysqlsla
6
Pt-query-digest
7
Pt-query-digest
8
Pt-query-digest
• It collects the queries and rank them based on the usage stats.
• The queries collected can be analyzed easily.
Query Analyzers:
Pt-Visual-explain and Visual Explain ( MySQL 5.6 Workbench )
9
Pt-table-checksum
10
Pt-table-checksum
It helps in checking the replication integrity of mysql.
Need to check:
• Direct writes on slave.• Skipping the events.• Many others.
11
Pt-table-checksum
12
Pt-table-checksum
How it works :
1) Check for replication lag2) Takes data in small chunks.3) Make checksum on chunk with replace into
select.4) Displays the output.
Note: It has more safety options.
13
Pt-table-sync
14
Pt-table-sync
Synchronizes the data between the master and slave servers.
It is a very effective tool and it can be used along with pt-table-checksum to make the data sync.
15
Pt-table-sync
• pt-table-sync --execute h=10.0.0.25,u=pttool,p=tool
--sync-to-master --print --databases world
16
Pt-table-sync
How it works :
1) Check for replication lag and delay.2) Takes data in small chunks.3) Make the data check based on Pk or
Unique index most cases.4) Then synchronizes the data.
Note: It is a read/write tool, precautions must be taken.
17
Pt-Online-Schema-Change
18
Pt-OSC
Helps in modifying the table structure without much locking.
Need to alter:
• Adding an index for performance.• Modifying a column.• Adding a column.• Altering the engine
19
Pt-OSC
How it works :
1) Create a new table with modified structure.2) Creates triggers for data changes.3) Copies data in small chunks.4) Swaps the table.5) Drop the old table and triggers.
20
Pt-OSC
Adding a column:
pt-online-schema-change --execute --user=pttool --pass=tool --alter "add column region char(30)" D=world,t=page_city
Adding a Index:
pt-online-schema-change --execute --user=pttool --pass=tool --alter "add index idx_dist (District)" D=world,t=page_city
Altering Engine :
pt-online-schema-change --execute --user=pttool –pass=tool --alter "engine=innodb" D=world,t=hio_city
21
Pt-Kill
22
Pt-kill
It helps to kill queries based on the filter input.
Repetitive and mass killing
Need to Kill:• Application not closing the connection
properly• Ill framed resource consuming queries • Too many bad queries running in parallel.
23
Pt-kill
For sleep queries:
pt-kill --user kill --ask-pass --socket=/tmp/mysql.sock --database test --match-command Sleep --kill --print --victims all --interval 15
For user specific:
pt-kill --user kill --ask-pass --socket=/tmp/mysql.sock --print --match-user benchmark --kill --victims all
For pattern match:
pt-kill --user kill --ask-pass --socket=/tmp/mysql.sock --kill-query --victims all --database test --match-info 'SELECT DISTINCT c from sbtest'
24
THANKS FOR PARTICIPATION
remotemysqldba.blogspot.in
25