This was my second presentation taken on MySQL User Camp ( Bangalore ) held on Nov-08 2013. I have a made a presentation about the percona tools mostly used percona tools.
2. About me
•
•
•
•
•
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
2
3. 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
9. 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
11. 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
13. Pt-table-checksum
How it works :
1)
2)
3)
4)
Check for replication lag
Takes data in small chunks.
Make checksum on chunk with replace into select.
Displays the output.
Note: It has more safety options.
13
15. 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
17. 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
19. 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
20. Pt-OSC
How it works :
1)
2)
3)
4)
5)
Create a new table with modified structure.
Creates triggers for data changes.
Copies data in small chunks.
Swaps the table.
Drop the old table and triggers.
20
21. 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
23. 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
24. Pt-kill
For sleep queries:
pt-kill --user kill --ask-pass --socket=/tmp/mysql.sock --database test --matchcommand 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