Percona tool kit for MySQL DBA's

25
1 Percona Tool kits For DBA’s

description

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.

Transcript of Percona tool kit for MySQL DBA's

Page 1: Percona tool kit for MySQL DBA's

1

Percona Tool kits For DBA’s

Page 2: Percona tool kit for MySQL 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

Page 3: Percona tool kit for MySQL DBA's

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

Page 4: Percona tool kit for MySQL DBA's

Percona Tool kit

• Pt-query-digest• Pt-table-checksum• Pt-table-sync• Pt-online-schema-change• Pt-kill

4

Page 5: Percona tool kit for MySQL DBA's

Pt-query-digest

5

Page 6: Percona tool kit for MySQL DBA's

Pt-query-digest

• Analyses the Queries.• Slow query log, Query logs.• Works on tcpdump too.

Other tools for Query logs1) Mysqldumpslow2) mysqlsla

6

Page 7: Percona tool kit for MySQL DBA's

Pt-query-digest

7

Page 8: Percona tool kit for MySQL DBA's

Pt-query-digest

8

Page 9: Percona tool kit for MySQL DBA's

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

Page 10: Percona tool kit for MySQL DBA's

Pt-table-checksum

10

Page 11: Percona tool kit for MySQL DBA's

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

Page 12: Percona tool kit for MySQL DBA's

Pt-table-checksum

12

Page 13: Percona tool kit for MySQL DBA's

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

Page 14: Percona tool kit for MySQL DBA's

Pt-table-sync

14

Page 15: Percona tool kit for MySQL DBA's

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

Page 16: Percona tool kit for MySQL DBA's

Pt-table-sync

• pt-table-sync --execute h=10.0.0.25,u=pttool,p=tool

--sync-to-master --print --databases world

16

Page 17: Percona tool kit for MySQL DBA's

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

Page 18: Percona tool kit for MySQL DBA's

Pt-Online-Schema-Change

18

Page 19: Percona tool kit for MySQL DBA's

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

Page 20: Percona tool kit for MySQL DBA's

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

Page 21: Percona tool kit for MySQL DBA's

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

Page 22: Percona tool kit for MySQL DBA's

Pt-Kill

22

Page 23: Percona tool kit for MySQL DBA's

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

Page 24: Percona tool kit for MySQL DBA's

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

Page 25: Percona tool kit for MySQL DBA's

THANKS FOR PARTICIPATION

remotemysqldba.blogspot.in

25