SlideShare a Scribd company logo
1 of 38
Download to read offline
Percona Toolkit
(It's Basically Magic)
SDPHP | Business.com | 05-28-14
Notes:
Who Am I?
https://twitter.com/robertswisher
https://plus.google.com/+RobertSwisher
https://www.linkedin.com/in/robertswisher
robert@business.com
Notes:
Percona Toolkit
(It's Basically Magic)
SDPHP | Business.com | 05-28-14
Notes:
Who Am I?
https://twitter.com/robertswisher
https://plus.google.com/+RobertSwisher
https://www.linkedin.com/in/robertswisher
robert@business.com
Notes:
Percona?
Who the hell are they?!
Notes:
Formerly known as Maatkit & Aspersa
Baron Shwartz literally wrote the book on MySQL
Open-source collection of scripts to help common
tasks that every DBA and developer has to do.
- Development
- Profiling
- Configuration
- Monitoring
- Replication
- Same code, same developers, new branding
- Source now on LaunchPad (like Percona Server)
(https://launchpad.net/percona-toolkit)
What is Percona Toolkit?
(You should use Percona Server too!)
Notes:
Percona?
Who the hell are they?!
Notes:
Formerly known as Maatkit & Aspersa
Baron Shwartz literally wrote the book on MySQL
Open-source collection of scripts to help common
tasks that every DBA and developer has to do.
- Development
- Profiling
- Configuration
- Monitoring
- Replication
- Same code, same developers, new branding
- Source now on LaunchPad (like Percona Server)
(https://launchpad.net/percona-toolkit)
What is Percona Toolkit?
(You should use Percona Server too!)
Notes:
Basically anyone using running MySQL who has lots of data
Who Uses It?
(Or anyone smart and lazy like all of us)
Notes:
InstallationAs of writing current version is 2.2.7
Yum
Apt
or source
Notes:
Basically anyone using running MySQL who has lots of data
Who Uses It?
(Or anyone smart and lazy like all of us)
Notes:
InstallationAs of writing current version is 2.2.7
Yum
Apt
or source
Notes:
Tools
Notes:
What Do You Use It For?
- Schema changes
- Data archival
- Query optimization
- Data consistency
- Performance debugging
- General maintenance
Notes:
Tools
Notes:
What Do You Use It For?
- Schema changes
- Data archival
- Query optimization
- Data consistency
- Performance debugging
- General maintenance
Notes:
Schema Changes
- Always creates a copy of table before 5.6
(except fast index creation in 5.5 or 5.1 with innodb plugin)
- Table is locked during the change
- BIG tables = BIG TROUBLE (millions of rows take hours or more)
- Used to require trickery like ALTER on slave, promote to master,
ALTER on old master, promote to master again
(Gets really ugly with master-master or tiered replication)
Notes:
pt-online-schema-change
Triggers are trouble, but can be handled (dropped by default)
Foreign keys are trouble, but can be handled (dropped and rebuilt)
Takes longer than ALTER TABLE (up to 4x)
ALWAYS backup first
Notes:
Schema Changes
- Always creates a copy of table before 5.6
(except fast index creation in 5.5 or 5.1 with innodb plugin)
- Table is locked during the change
- BIG tables = BIG TROUBLE (millions of rows take hours or more)
- Used to require trickery like ALTER on slave, promote to master,
ALTER on old master, promote to master again
(Gets really ugly with master-master or tiered replication)
Notes:
pt-online-schema-change
Triggers are trouble, but can be handled (dropped by default)
Foreign keys are trouble, but can be handled (dropped and rebuilt)
Takes longer than ALTER TABLE (up to 4x)
ALWAYS backup first
Notes:
pt-online-schema-change
-- dry-run and --execute mutually exclusive
Use nohup with -- password `cat /tmp/pass`
Tune --max-lag and --max load for busy systems
Example:
nohup pt-online-schema-change --dry-run 
--alter 'CHANGE `foo` 
`foo` varchar(24) COLLATE 'latin1_bin' NULL AFTER `bar`' 
--password `cat /tmp/pass` --print --nocheck-replication-filters 
--max-load "Threads_connected:60,Threads_running:20" 
D=your_db,t=really_big_table &
Notes:
Notes:
pt-online-schema-change
-- dry-run and --execute mutually exclusive
Use nohup with -- password `cat /tmp/pass`
Tune --max-lag and --max load for busy systems
Example:
nohup pt-online-schema-change --dry-run 
--alter 'CHANGE `foo` 
`foo` varchar(24) COLLATE 'latin1_bin' NULL AFTER `bar`' 
--password `cat /tmp/pass` --print --nocheck-replication-filters 
--max-load "Threads_connected:60,Threads_running:20" 
D=your_db,t=really_big_table &
Notes:
Notes:
Notes:
Data Archival
- LOTS of writing to BIG tables = BAD
- Pruning BIG tables to only frequently accessed data = GOOD
- BIG tables more prone to corruption
- Deleting from BIG tables = SLOOOOOOW
- Long running transactions = REALLY SLOOOOOOOOOW
- DELETE locks MyISAM
Notes:
Notes:
Data Archival
- LOTS of writing to BIG tables = BAD
- Pruning BIG tables to only frequently accessed data = GOOD
- BIG tables more prone to corruption
- Deleting from BIG tables = SLOOOOOOW
- Long running transactions = REALLY SLOOOOOOOOOW
- DELETE locks MyISAM
Notes:
pt-archiver
Create destination table first
--dry-run exists, but --execute doesn't
If you use an auto-increment column, edit the schema
--limit is good for sequential data, but be careful if bouncing around
Use --progress to track
May want to archive from slave, then purge from master
ALWAYS backup first
Notes:
Notes:
pt-archiver
Create destination table first
--dry-run exists, but --execute doesn't
If you use an auto-increment column, edit the schema
--limit is good for sequential data, but be careful if bouncing around
Use --progress to track
May want to archive from slave, then purge from master
ALWAYS backup first
Notes:
Notes:
pt-archiver
Slave:
pt-archiver --dry-run --ask-pass --progress 5000 
--statistics --bulk-insert --no-delete 
--limit 5000 --source D=your_db,t=big_table 
--dest D=your_db,t=big_table_archive 
--where "timestamp < '2013-01-01'"
Master:
pt-archiver --dry-run --ask-pass --progress 5000 
--statistics --bulk-delete --purge 
--limit 5000 --source D=your_db,t=big_table 
--where "timestamp < '2013-01-01'"
Notes:
Notes:
pt-archiver
Slave:
pt-archiver --dry-run --ask-pass --progress 5000 
--statistics --bulk-insert --no-delete 
--limit 5000 --source D=your_db,t=big_table 
--dest D=your_db,t=big_table_archive 
--where "timestamp < '2013-01-01'"
Master:
pt-archiver --dry-run --ask-pass --progress 5000 
--statistics --bulk-delete --purge 
--limit 5000 --source D=your_db,t=big_table 
--where "timestamp < '2013-01-01'"
Notes:
Notes:
Query Optimization
Notes:
Query Optimization
--filter perl code that must return true for query to appear
--limit shows only the top % of worst queries
Notes:
Query Optimization
Notes:
Query Optimization
--filter perl code that must return true for query to appear
--limit shows only the top % of worst queries
Notes:
# Query 1: 0.00 QPS, 0.01x concurrency, ID 0x76F9EC92751F314A at byte 80096643
# This item is included in the report because it matches --limit.
# Scores: V/M = 188.68
# Time range: 2012-02-01 09:20:24 to 2013-10-04 10:47:56
# Attribute pct total min max avg 95% stddev median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count 1 490
# Exec time 14 384617s 9s 4869s 785s 1292s 385s 833s
# Lock time 2 11s 169us 6s 22ms 6ms 290ms 316us
# Rows sent 0 711.60k 0 4.82k 1.45k 4.27k 1.44k 685.39
# Rows examine 10 30.01G 0 123.80M 62.71M 117.57M 44.73M 75.78M
# Rows affecte 0 0 0 0 0 0 0 0
# Rows read 0 711.60k 0 4.82k 1.45k 4.27k 1.44k 685.39
# Bytes sent 0 21.90M 0 167.52k 45.77k 143.37k 52.07k 8.46k
# Tmp tables 8 1.91k 2 4 3.99 3.89 0.16 3.89
# Tmp disk tbl 0 0 0 0 0 0 0 0
# Tmp tbl size 3 3.36G 0 7.98M 7.02M 7.65M 1.26M 7.65M
# Query size 0 471.35k 982 986 985.03 964.41 0 964.41
# String:
# Databases bdc_ccm
# Hosts
# InnoDB trxID 13E9F1B2 (1/0%), 1402493D (1/0%)... 488 more
# Last errno 0
# Users semuser (488/99%), jackie.lam (1/0%)... 1 more
# Query_time distribution
# 1us
# 10us
# 100us
# 1ms
# 10ms
# 100ms
# 1s #
# 10s+ ################################################################
# Tables
# SHOW TABLE STATUS FROM `bdc_ccm` LIKE 'click_log_inbound'G
# SHOW CREATE TABLE `bdc_ccm`.`click_log_inbound`G
# SHOW TABLE STATUS FROM `bdc_ccm` LIKE 'click_log_outbound_tp'G
# SHOW CREATE TABLE `bdc_ccm`.`click_log_outbound_tp`G
# SHOW TABLE STATUS FROM `bdc_ccm` LIKE 'click_log_outbound'G
# SHOW CREATE TABLE `bdc_ccm`.`click_log_outbound`G
# EXPLAIN /*!50100 PARTITIONS*/
selectdate(a.timestamp), a.referrer, count(b.inbound_id), sum(b.cpc), 'AS' astag
from click_log_inbound a, click_log_outbound_tp b
wherea.id = b.inbound_id
and a.timestamp between '2012-02-08 00:00:00' and '2012-02-09 23:59:59'
and b.partner like'adsense'
and b.flag = 0
group by date(a.timestamp), a.referrer
union all
selectdate(a.timestamp), a.referrer, count(b.inbound_id), sum(b.cpc) , 'FL' astag
from click_log_inbound a, click_log_outbound b
wherea.id = b.inbound_id
and a.timestamp between '2012-02-08 00:00:00' and '2012-02-09 23:59:59'
and flag = 0
group by date(a.timestamp), a.referrer
union all
selectdate(a.timestamp), a.referrer, count(b.inbound_id), sum(b.cpc), 'TP' astag
from click_log_inbound a, click_log_outbound_tp b
wherea.id = b.inbound_id
and a.timestamp between '2012-02-08 00:00:00' and '2012-02-09 23:59:59'
and b.partner in ('capterra', 'bdc_network')
and b.flag = 0
group by date(a.timestamp), a.referrerG
Notes:
Data Consistency
- Replication isn't perfect
- Replication filters
- master-master replication
- 1062 “DUPLICATE KEY ERROR”
- Server crashes
- Non-deterministic (aka not idempotent) writes
Notes:
# Query 1: 0.00 QPS, 0.01x concurrency, ID 0x76F9EC92751F314A at byte 80096643
# This item is included in the report because it matches --limit.
# Scores: V/M = 188.68
# Time range: 2012-02-01 09:20:24 to 2013-10-04 10:47:56
# Attribute pct total min max avg 95% stddev median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count 1 490
# Exec time 14 384617s 9s 4869s 785s 1292s 385s 833s
# Lock time 2 11s 169us 6s 22ms 6ms 290ms 316us
# Rows sent 0 711.60k 0 4.82k 1.45k 4.27k 1.44k 685.39
# Rows examine 10 30.01G 0 123.80M 62.71M 117.57M 44.73M 75.78M
# Rows affecte 0 0 0 0 0 0 0 0
# Rows read 0 711.60k 0 4.82k 1.45k 4.27k 1.44k 685.39
# Bytes sent 0 21.90M 0 167.52k 45.77k 143.37k 52.07k 8.46k
# Tmp tables 8 1.91k 2 4 3.99 3.89 0.16 3.89
# Tmp disk tbl 0 0 0 0 0 0 0 0
# Tmp tbl size 3 3.36G 0 7.98M 7.02M 7.65M 1.26M 7.65M
# Query size 0 471.35k 982 986 985.03 964.41 0 964.41
# String:
# Databases bdc_ccm
# Hosts
# InnoDB trxID 13E9F1B2 (1/0%), 1402493D (1/0%)... 488 more
# Last errno 0
# Users semuser (488/99%), jackie.lam (1/0%)... 1 more
# Query_time distribution
# 1us
# 10us
# 100us
# 1ms
# 10ms
# 100ms
# 1s #
# 10s+ ################################################################
# Tables
# SHOW TABLE STATUS FROM `bdc_ccm` LIKE 'click_log_inbound'G
# SHOW CREATE TABLE `bdc_ccm`.`click_log_inbound`G
# SHOW TABLE STATUS FROM `bdc_ccm` LIKE 'click_log_outbound_tp'G
# SHOW CREATE TABLE `bdc_ccm`.`click_log_outbound_tp`G
# SHOW TABLE STATUS FROM `bdc_ccm` LIKE 'click_log_outbound'G
# SHOW CREATE TABLE `bdc_ccm`.`click_log_outbound`G
# EXPLAIN /*!50100 PARTITIONS*/
selectdate(a.timestamp), a.referrer, count(b.inbound_id), sum(b.cpc), 'AS' astag
from click_log_inbound a, click_log_outbound_tp b
wherea.id = b.inbound_id
and a.timestamp between '2012-02-08 00:00:00' and '2012-02-09 23:59:59'
and b.partner like'adsense'
and b.flag = 0
group by date(a.timestamp), a.referrer
union all
selectdate(a.timestamp), a.referrer, count(b.inbound_id), sum(b.cpc) , 'FL' astag
from click_log_inbound a, click_log_outbound b
wherea.id = b.inbound_id
and a.timestamp between '2012-02-08 00:00:00' and '2012-02-09 23:59:59'
and flag = 0
group by date(a.timestamp), a.referrer
union all
selectdate(a.timestamp), a.referrer, count(b.inbound_id), sum(b.cpc), 'TP' astag
from click_log_inbound a, click_log_outbound_tp b
wherea.id = b.inbound_id
and a.timestamp between '2012-02-08 00:00:00' and '2012-02-09 23:59:59'
and b.partner in ('capterra', 'bdc_network')
and b.flag = 0
group by date(a.timestamp), a.referrerG
Notes:
Data Consistency
- Replication isn't perfect
- Replication filters
- master-master replication
- 1062 “DUPLICATE KEY ERROR”
- Server crashes
- Non-deterministic (aka not idempotent) writes
Notes:
pt-table-checksum
Requires STATEMENT based replication for tiered replication
Replication filters are dangerous because a failed query can
break replication
May want to use nohup since it can be slow
Notes:
Notes:
pt-table-checksum
Requires STATEMENT based replication for tiered replication
Replication filters are dangerous because a failed query can
break replication
May want to use nohup since it can be slow
Notes:
Notes:
pt-table-sync
Notes:
pt-table-sync
--dry-run and --execute mutually exclusive
ALWAYS backup first
In a tiered replication setup or master-master
take extra care to think through what will be done
Run on master to sync all slaves
pt-table-sync --execute --replicate test.checksum master1
Run on master for slaves individually to sync to master
pt-table-sync --execute --sync-to-master slave1
Notes:
pt-table-sync
Notes:
pt-table-sync
--dry-run and --execute mutually exclusive
ALWAYS backup first
In a tiered replication setup or master-master
take extra care to think through what will be done
Run on master to sync all slaves
pt-table-sync --execute --replicate test.checksum master1
Run on master for slaves individually to sync to master
pt-table-sync --execute --sync-to-master slave1
Notes:
pt-table-sync
Notes:
Notes:
pt-table-sync
Notes:
Notes:
Performance Debugging
- Problems can be random
- Problems only last for a few seconds,
you can't connect and observe fast enough
- Problems like to happen at odd hours;
ETL, rollups, reporting, etc
- You can't ALWAYS log on
Notes:
pt-stalk
- Creates a lot of files
- Output inspected with pt-sift
Notes:
Performance Debugging
- Problems can be random
- Problems only last for a few seconds,
you can't connect and observe fast enough
- Problems like to happen at odd hours;
ETL, rollups, reporting, etc
- You can't ALWAYS log on
Notes:
pt-stalk
- Creates a lot of files
- Output inspected with pt-sift
Notes:
pt-stalk
Run as root
--daemonize fork and run in the background
-- sleep length to sleep between collects
-- cycles the number of cycles the var must be true to collect
--variable Threads_running and Execution_time are good ones
--disk-bytes-free don't collect if this threshold is hit
(best practice would be to set --log and --dest to a different disk
than your data lives on the same as other mysql logs)
Notes:
Notes:
pt-stalk
Run as root
--daemonize fork and run in the background
-- sleep length to sleep between collects
-- cycles the number of cycles the var must be true to collect
--variable Threads_running and Execution_time are good ones
--disk-bytes-free don't collect if this threshold is hit
(best practice would be to set --log and --dest to a different disk
than your data lives on the same as other mysql logs)
Notes:
Notes:
pt-sift
Pass it the path to the dir used with --data
(default /var/lib/pt-stalk)
Interactive program
Lots of data points collected from the time of the incident
Notes:
Notes:
pt-sift
Pass it the path to the dir used with --data
(default /var/lib/pt-stalk)
Interactive program
Lots of data points collected from the time of the incident
Notes:
Notes:
General Admin / Maintenance
pt-slave-restart - try to restart a slave skipping errors
if replication fails
pt-summary - gives a general summary of the MySQL instance
pt-upgrade - tests logged queries against a new MySQL version
pt-config-diff - show formatted diff of my.cnf files
pt-heartbeat - update table on master with heartbeat data from slaves
pt-kill - kill MySQL threads according to filters
pt-index-usage - report on index structure and usage
pt-variable-advisor - looks at runtime vars and makes suggestions
Notes:
http:s//cloud.percona.com to sign up for beta
Percona Cloud Tools
Notes:
General Admin / Maintenance
pt-slave-restart - try to restart a slave skipping errors
if replication fails
pt-summary - gives a general summary of the MySQL instance
pt-upgrade - tests logged queries against a new MySQL version
pt-config-diff - show formatted diff of my.cnf files
pt-heartbeat - update table on master with heartbeat data from slaves
pt-kill - kill MySQL threads according to filters
pt-index-usage - report on index structure and usage
pt-variable-advisor - looks at runtime vars and makes suggestions
Notes:
http:s//cloud.percona.com to sign up for beta
Percona Cloud Tools
Notes:
Notes:
QUESTIONS?
Notes:
Notes:
QUESTIONS?
Notes:

More Related Content

What's hot

The why and how of moving to PHP 5.5/5.6
The why and how of moving to PHP 5.5/5.6The why and how of moving to PHP 5.5/5.6
The why and how of moving to PHP 5.5/5.6Wim Godden
 
Deploying Symfony | symfony.cat
Deploying Symfony | symfony.catDeploying Symfony | symfony.cat
Deploying Symfony | symfony.catPablo Godel
 
The why and how of moving to PHP 5.4/5.5
The why and how of moving to PHP 5.4/5.5The why and how of moving to PHP 5.4/5.5
The why and how of moving to PHP 5.4/5.5Wim Godden
 
The why and how of moving to php 5.4
The why and how of moving to php 5.4The why and how of moving to php 5.4
The why and how of moving to php 5.4Wim Godden
 
Static Typing in Vault
Static Typing in VaultStatic Typing in Vault
Static Typing in VaultGlynnForrest
 
What you need to remember when you upload to CPAN
What you need to remember when you upload to CPANWhat you need to remember when you upload to CPAN
What you need to remember when you upload to CPANcharsbar
 
"Swoole: double troubles in c", Alexandr Vronskiy
"Swoole: double troubles in c", Alexandr Vronskiy"Swoole: double troubles in c", Alexandr Vronskiy
"Swoole: double troubles in c", Alexandr VronskiyFwdays
 
[Community Open Camp] 給 PHP 開發者的 VS Code 指南
[Community Open Camp] 給 PHP 開發者的 VS Code 指南[Community Open Camp] 給 PHP 開發者的 VS Code 指南
[Community Open Camp] 給 PHP 開發者的 VS Code 指南Shengyou Fan
 
Beyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic AnalysisBeyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic AnalysisFastly
 
WP Weekend #2 - Corcel, aneb WordPress přes Laravel
WP Weekend #2 - Corcel, aneb WordPress přes LaravelWP Weekend #2 - Corcel, aneb WordPress přes Laravel
WP Weekend #2 - Corcel, aneb WordPress přes LaravelBrilo Team
 
Information security programming in ruby
Information security programming in rubyInformation security programming in ruby
Information security programming in rubyHiroshi Nakamura
 
PuppetConf 2017: Use Puppet to Tame the Dockerfile Monster- Bryan Belanger, A...
PuppetConf 2017: Use Puppet to Tame the Dockerfile Monster- Bryan Belanger, A...PuppetConf 2017: Use Puppet to Tame the Dockerfile Monster- Bryan Belanger, A...
PuppetConf 2017: Use Puppet to Tame the Dockerfile Monster- Bryan Belanger, A...Puppet
 

What's hot (20)

Unit Testing Lots of Perl
Unit Testing Lots of PerlUnit Testing Lots of Perl
Unit Testing Lots of Perl
 
The why and how of moving to PHP 5.5/5.6
The why and how of moving to PHP 5.5/5.6The why and how of moving to PHP 5.5/5.6
The why and how of moving to PHP 5.5/5.6
 
Deploying Symfony | symfony.cat
Deploying Symfony | symfony.catDeploying Symfony | symfony.cat
Deploying Symfony | symfony.cat
 
The why and how of moving to PHP 5.4/5.5
The why and how of moving to PHP 5.4/5.5The why and how of moving to PHP 5.4/5.5
The why and how of moving to PHP 5.4/5.5
 
Intro to PSGI and Plack
Intro to PSGI and PlackIntro to PSGI and Plack
Intro to PSGI and Plack
 
Laravel Day / Deploy
Laravel Day / DeployLaravel Day / Deploy
Laravel Day / Deploy
 
The why and how of moving to php 5.4
The why and how of moving to php 5.4The why and how of moving to php 5.4
The why and how of moving to php 5.4
 
Static Typing in Vault
Static Typing in VaultStatic Typing in Vault
Static Typing in Vault
 
Getting testy with Perl
Getting testy with PerlGetting testy with Perl
Getting testy with Perl
 
What you need to remember when you upload to CPAN
What you need to remember when you upload to CPANWhat you need to remember when you upload to CPAN
What you need to remember when you upload to CPAN
 
Ruby HTTP clients
Ruby HTTP clientsRuby HTTP clients
Ruby HTTP clients
 
"Swoole: double troubles in c", Alexandr Vronskiy
"Swoole: double troubles in c", Alexandr Vronskiy"Swoole: double troubles in c", Alexandr Vronskiy
"Swoole: double troubles in c", Alexandr Vronskiy
 
Perlbal Tutorial
Perlbal TutorialPerlbal Tutorial
Perlbal Tutorial
 
[Community Open Camp] 給 PHP 開發者的 VS Code 指南
[Community Open Camp] 給 PHP 開發者的 VS Code 指南[Community Open Camp] 給 PHP 開發者的 VS Code 指南
[Community Open Camp] 給 PHP 開發者的 VS Code 指南
 
Docker perl build
Docker perl buildDocker perl build
Docker perl build
 
Beyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic AnalysisBeyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic Analysis
 
Os Treat
Os TreatOs Treat
Os Treat
 
WP Weekend #2 - Corcel, aneb WordPress přes Laravel
WP Weekend #2 - Corcel, aneb WordPress přes LaravelWP Weekend #2 - Corcel, aneb WordPress přes Laravel
WP Weekend #2 - Corcel, aneb WordPress přes Laravel
 
Information security programming in ruby
Information security programming in rubyInformation security programming in ruby
Information security programming in ruby
 
PuppetConf 2017: Use Puppet to Tame the Dockerfile Monster- Bryan Belanger, A...
PuppetConf 2017: Use Puppet to Tame the Dockerfile Monster- Bryan Belanger, A...PuppetConf 2017: Use Puppet to Tame the Dockerfile Monster- Bryan Belanger, A...
PuppetConf 2017: Use Puppet to Tame the Dockerfile Monster- Bryan Belanger, A...
 

Similar to SDPHP - Percona Toolkit (It's Basically Magic)

Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeWim Godden
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeWim Godden
 
MySQL Scaling Presentation
MySQL Scaling PresentationMySQL Scaling Presentation
MySQL Scaling PresentationTommy Falgout
 
Beyond PHP - it's not (just) about the code
Beyond PHP - it's not (just) about the codeBeyond PHP - it's not (just) about the code
Beyond PHP - it's not (just) about the codeWim Godden
 
fog or: How I Learned to Stop Worrying and Love the Cloud
fog or: How I Learned to Stop Worrying and Love the Cloudfog or: How I Learned to Stop Worrying and Love the Cloud
fog or: How I Learned to Stop Worrying and Love the CloudWesley Beary
 
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)Wesley Beary
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeWim Godden
 
How I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine Yard
How I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine YardHow I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine Yard
How I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine YardSV Ruby on Rails Meetup
 
Speed up R with parallel programming in the Cloud
Speed up R with parallel programming in the CloudSpeed up R with parallel programming in the Cloud
Speed up R with parallel programming in the CloudRevolution Analytics
 
Beyond PHP - It's not (just) about the code
Beyond PHP - It's not (just) about the codeBeyond PHP - It's not (just) about the code
Beyond PHP - It's not (just) about the codeWim Godden
 
Riak add presentation
Riak add presentationRiak add presentation
Riak add presentationIlya Bogunov
 
PostgreSQL Portland Performance Practice Project - Database Test 2 Howto
PostgreSQL Portland Performance Practice Project - Database Test 2 HowtoPostgreSQL Portland Performance Practice Project - Database Test 2 Howto
PostgreSQL Portland Performance Practice Project - Database Test 2 HowtoMark Wong
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalabilityWim Godden
 
PostgreSQL as seen by Rubyists (Kaigi on Rails 2022)
PostgreSQL as seen by Rubyists (Kaigi on Rails 2022)PostgreSQL as seen by Rubyists (Kaigi on Rails 2022)
PostgreSQL as seen by Rubyists (Kaigi on Rails 2022)Андрей Новиков
 
Confitura 2018 — Apache Beam — Promyk Nadziei Data Engineera
Confitura 2018 — Apache Beam — Promyk Nadziei Data EngineeraConfitura 2018 — Apache Beam — Promyk Nadziei Data Engineera
Confitura 2018 — Apache Beam — Promyk Nadziei Data EngineeraPiotr Wikiel
 
Design Summit - Rails 4 Migration - Aaron Patterson
Design Summit - Rails 4 Migration - Aaron PattersonDesign Summit - Rails 4 Migration - Aaron Patterson
Design Summit - Rails 4 Migration - Aaron PattersonManageIQ
 
Postgres Vienna DB Meetup 2014
Postgres Vienna DB Meetup 2014Postgres Vienna DB Meetup 2014
Postgres Vienna DB Meetup 2014Michael Renner
 

Similar to SDPHP - Percona Toolkit (It's Basically Magic) (20)

Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the code
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the code
 
MySQL Scaling Presentation
MySQL Scaling PresentationMySQL Scaling Presentation
MySQL Scaling Presentation
 
Percona toolkit
Percona toolkitPercona toolkit
Percona toolkit
 
Beyond PHP - it's not (just) about the code
Beyond PHP - it's not (just) about the codeBeyond PHP - it's not (just) about the code
Beyond PHP - it's not (just) about the code
 
Osol Pgsql
Osol PgsqlOsol Pgsql
Osol Pgsql
 
MariaDB workshop
MariaDB workshopMariaDB workshop
MariaDB workshop
 
fog or: How I Learned to Stop Worrying and Love the Cloud
fog or: How I Learned to Stop Worrying and Love the Cloudfog or: How I Learned to Stop Worrying and Love the Cloud
fog or: How I Learned to Stop Worrying and Love the Cloud
 
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the code
 
How I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine Yard
How I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine YardHow I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine Yard
How I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine Yard
 
Speed up R with parallel programming in the Cloud
Speed up R with parallel programming in the CloudSpeed up R with parallel programming in the Cloud
Speed up R with parallel programming in the Cloud
 
Beyond PHP - It's not (just) about the code
Beyond PHP - It's not (just) about the codeBeyond PHP - It's not (just) about the code
Beyond PHP - It's not (just) about the code
 
Riak add presentation
Riak add presentationRiak add presentation
Riak add presentation
 
PostgreSQL Portland Performance Practice Project - Database Test 2 Howto
PostgreSQL Portland Performance Practice Project - Database Test 2 HowtoPostgreSQL Portland Performance Practice Project - Database Test 2 Howto
PostgreSQL Portland Performance Practice Project - Database Test 2 Howto
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalability
 
PostgreSQL as seen by Rubyists (Kaigi on Rails 2022)
PostgreSQL as seen by Rubyists (Kaigi on Rails 2022)PostgreSQL as seen by Rubyists (Kaigi on Rails 2022)
PostgreSQL as seen by Rubyists (Kaigi on Rails 2022)
 
Confitura 2018 — Apache Beam — Promyk Nadziei Data Engineera
Confitura 2018 — Apache Beam — Promyk Nadziei Data EngineeraConfitura 2018 — Apache Beam — Promyk Nadziei Data Engineera
Confitura 2018 — Apache Beam — Promyk Nadziei Data Engineera
 
Design Summit - Rails 4 Migration - Aaron Patterson
Design Summit - Rails 4 Migration - Aaron PattersonDesign Summit - Rails 4 Migration - Aaron Patterson
Design Summit - Rails 4 Migration - Aaron Patterson
 
Postgres Vienna DB Meetup 2014
Postgres Vienna DB Meetup 2014Postgres Vienna DB Meetup 2014
Postgres Vienna DB Meetup 2014
 

Recently uploaded

DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationBhangaleSonal
 
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLEGEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLEselvakumar948
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Call Girls Mumbai
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...drmkjayanthikannan
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptDineshKumar4165
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VDineshKumar4165
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwaitjaanualu31
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARKOUSTAV SARKAR
 
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxmaisarahman1
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxJuliansyahHarahap1
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"mphochane1998
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXssuser89054b
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdfKamal Acharya
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdfKamal Acharya
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadhamedmustafa094
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startQuintin Balsdon
 

Recently uploaded (20)

DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLEGEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal load
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 

SDPHP - Percona Toolkit (It's Basically Magic)

  • 1. Percona Toolkit (It's Basically Magic) SDPHP | Business.com | 05-28-14 Notes: Who Am I? https://twitter.com/robertswisher https://plus.google.com/+RobertSwisher https://www.linkedin.com/in/robertswisher robert@business.com Notes:
  • 2. Percona Toolkit (It's Basically Magic) SDPHP | Business.com | 05-28-14 Notes: Who Am I? https://twitter.com/robertswisher https://plus.google.com/+RobertSwisher https://www.linkedin.com/in/robertswisher robert@business.com Notes:
  • 3. Percona? Who the hell are they?! Notes: Formerly known as Maatkit & Aspersa Baron Shwartz literally wrote the book on MySQL Open-source collection of scripts to help common tasks that every DBA and developer has to do. - Development - Profiling - Configuration - Monitoring - Replication - Same code, same developers, new branding - Source now on LaunchPad (like Percona Server) (https://launchpad.net/percona-toolkit) What is Percona Toolkit? (You should use Percona Server too!) Notes:
  • 4. Percona? Who the hell are they?! Notes: Formerly known as Maatkit & Aspersa Baron Shwartz literally wrote the book on MySQL Open-source collection of scripts to help common tasks that every DBA and developer has to do. - Development - Profiling - Configuration - Monitoring - Replication - Same code, same developers, new branding - Source now on LaunchPad (like Percona Server) (https://launchpad.net/percona-toolkit) What is Percona Toolkit? (You should use Percona Server too!) Notes:
  • 5. Basically anyone using running MySQL who has lots of data Who Uses It? (Or anyone smart and lazy like all of us) Notes: InstallationAs of writing current version is 2.2.7 Yum Apt or source Notes:
  • 6. Basically anyone using running MySQL who has lots of data Who Uses It? (Or anyone smart and lazy like all of us) Notes: InstallationAs of writing current version is 2.2.7 Yum Apt or source Notes:
  • 7. Tools Notes: What Do You Use It For? - Schema changes - Data archival - Query optimization - Data consistency - Performance debugging - General maintenance Notes:
  • 8. Tools Notes: What Do You Use It For? - Schema changes - Data archival - Query optimization - Data consistency - Performance debugging - General maintenance Notes:
  • 9. Schema Changes - Always creates a copy of table before 5.6 (except fast index creation in 5.5 or 5.1 with innodb plugin) - Table is locked during the change - BIG tables = BIG TROUBLE (millions of rows take hours or more) - Used to require trickery like ALTER on slave, promote to master, ALTER on old master, promote to master again (Gets really ugly with master-master or tiered replication) Notes: pt-online-schema-change Triggers are trouble, but can be handled (dropped by default) Foreign keys are trouble, but can be handled (dropped and rebuilt) Takes longer than ALTER TABLE (up to 4x) ALWAYS backup first Notes:
  • 10. Schema Changes - Always creates a copy of table before 5.6 (except fast index creation in 5.5 or 5.1 with innodb plugin) - Table is locked during the change - BIG tables = BIG TROUBLE (millions of rows take hours or more) - Used to require trickery like ALTER on slave, promote to master, ALTER on old master, promote to master again (Gets really ugly with master-master or tiered replication) Notes: pt-online-schema-change Triggers are trouble, but can be handled (dropped by default) Foreign keys are trouble, but can be handled (dropped and rebuilt) Takes longer than ALTER TABLE (up to 4x) ALWAYS backup first Notes:
  • 11. pt-online-schema-change -- dry-run and --execute mutually exclusive Use nohup with -- password `cat /tmp/pass` Tune --max-lag and --max load for busy systems Example: nohup pt-online-schema-change --dry-run --alter 'CHANGE `foo` `foo` varchar(24) COLLATE 'latin1_bin' NULL AFTER `bar`' --password `cat /tmp/pass` --print --nocheck-replication-filters --max-load "Threads_connected:60,Threads_running:20" D=your_db,t=really_big_table & Notes: Notes:
  • 12. pt-online-schema-change -- dry-run and --execute mutually exclusive Use nohup with -- password `cat /tmp/pass` Tune --max-lag and --max load for busy systems Example: nohup pt-online-schema-change --dry-run --alter 'CHANGE `foo` `foo` varchar(24) COLLATE 'latin1_bin' NULL AFTER `bar`' --password `cat /tmp/pass` --print --nocheck-replication-filters --max-load "Threads_connected:60,Threads_running:20" D=your_db,t=really_big_table & Notes: Notes:
  • 13. Notes: Data Archival - LOTS of writing to BIG tables = BAD - Pruning BIG tables to only frequently accessed data = GOOD - BIG tables more prone to corruption - Deleting from BIG tables = SLOOOOOOW - Long running transactions = REALLY SLOOOOOOOOOW - DELETE locks MyISAM Notes:
  • 14. Notes: Data Archival - LOTS of writing to BIG tables = BAD - Pruning BIG tables to only frequently accessed data = GOOD - BIG tables more prone to corruption - Deleting from BIG tables = SLOOOOOOW - Long running transactions = REALLY SLOOOOOOOOOW - DELETE locks MyISAM Notes:
  • 15. pt-archiver Create destination table first --dry-run exists, but --execute doesn't If you use an auto-increment column, edit the schema --limit is good for sequential data, but be careful if bouncing around Use --progress to track May want to archive from slave, then purge from master ALWAYS backup first Notes: Notes:
  • 16. pt-archiver Create destination table first --dry-run exists, but --execute doesn't If you use an auto-increment column, edit the schema --limit is good for sequential data, but be careful if bouncing around Use --progress to track May want to archive from slave, then purge from master ALWAYS backup first Notes: Notes:
  • 17. pt-archiver Slave: pt-archiver --dry-run --ask-pass --progress 5000 --statistics --bulk-insert --no-delete --limit 5000 --source D=your_db,t=big_table --dest D=your_db,t=big_table_archive --where "timestamp < '2013-01-01'" Master: pt-archiver --dry-run --ask-pass --progress 5000 --statistics --bulk-delete --purge --limit 5000 --source D=your_db,t=big_table --where "timestamp < '2013-01-01'" Notes: Notes:
  • 18. pt-archiver Slave: pt-archiver --dry-run --ask-pass --progress 5000 --statistics --bulk-insert --no-delete --limit 5000 --source D=your_db,t=big_table --dest D=your_db,t=big_table_archive --where "timestamp < '2013-01-01'" Master: pt-archiver --dry-run --ask-pass --progress 5000 --statistics --bulk-delete --purge --limit 5000 --source D=your_db,t=big_table --where "timestamp < '2013-01-01'" Notes: Notes:
  • 19. Query Optimization Notes: Query Optimization --filter perl code that must return true for query to appear --limit shows only the top % of worst queries Notes:
  • 20. Query Optimization Notes: Query Optimization --filter perl code that must return true for query to appear --limit shows only the top % of worst queries Notes:
  • 21. # Query 1: 0.00 QPS, 0.01x concurrency, ID 0x76F9EC92751F314A at byte 80096643 # This item is included in the report because it matches --limit. # Scores: V/M = 188.68 # Time range: 2012-02-01 09:20:24 to 2013-10-04 10:47:56 # Attribute pct total min max avg 95% stddev median # ============ === ======= ======= ======= ======= ======= ======= ======= # Count 1 490 # Exec time 14 384617s 9s 4869s 785s 1292s 385s 833s # Lock time 2 11s 169us 6s 22ms 6ms 290ms 316us # Rows sent 0 711.60k 0 4.82k 1.45k 4.27k 1.44k 685.39 # Rows examine 10 30.01G 0 123.80M 62.71M 117.57M 44.73M 75.78M # Rows affecte 0 0 0 0 0 0 0 0 # Rows read 0 711.60k 0 4.82k 1.45k 4.27k 1.44k 685.39 # Bytes sent 0 21.90M 0 167.52k 45.77k 143.37k 52.07k 8.46k # Tmp tables 8 1.91k 2 4 3.99 3.89 0.16 3.89 # Tmp disk tbl 0 0 0 0 0 0 0 0 # Tmp tbl size 3 3.36G 0 7.98M 7.02M 7.65M 1.26M 7.65M # Query size 0 471.35k 982 986 985.03 964.41 0 964.41 # String: # Databases bdc_ccm # Hosts # InnoDB trxID 13E9F1B2 (1/0%), 1402493D (1/0%)... 488 more # Last errno 0 # Users semuser (488/99%), jackie.lam (1/0%)... 1 more # Query_time distribution # 1us # 10us # 100us # 1ms # 10ms # 100ms # 1s # # 10s+ ################################################################ # Tables # SHOW TABLE STATUS FROM `bdc_ccm` LIKE 'click_log_inbound'G # SHOW CREATE TABLE `bdc_ccm`.`click_log_inbound`G # SHOW TABLE STATUS FROM `bdc_ccm` LIKE 'click_log_outbound_tp'G # SHOW CREATE TABLE `bdc_ccm`.`click_log_outbound_tp`G # SHOW TABLE STATUS FROM `bdc_ccm` LIKE 'click_log_outbound'G # SHOW CREATE TABLE `bdc_ccm`.`click_log_outbound`G # EXPLAIN /*!50100 PARTITIONS*/ selectdate(a.timestamp), a.referrer, count(b.inbound_id), sum(b.cpc), 'AS' astag from click_log_inbound a, click_log_outbound_tp b wherea.id = b.inbound_id and a.timestamp between '2012-02-08 00:00:00' and '2012-02-09 23:59:59' and b.partner like'adsense' and b.flag = 0 group by date(a.timestamp), a.referrer union all selectdate(a.timestamp), a.referrer, count(b.inbound_id), sum(b.cpc) , 'FL' astag from click_log_inbound a, click_log_outbound b wherea.id = b.inbound_id and a.timestamp between '2012-02-08 00:00:00' and '2012-02-09 23:59:59' and flag = 0 group by date(a.timestamp), a.referrer union all selectdate(a.timestamp), a.referrer, count(b.inbound_id), sum(b.cpc), 'TP' astag from click_log_inbound a, click_log_outbound_tp b wherea.id = b.inbound_id and a.timestamp between '2012-02-08 00:00:00' and '2012-02-09 23:59:59' and b.partner in ('capterra', 'bdc_network') and b.flag = 0 group by date(a.timestamp), a.referrerG Notes: Data Consistency - Replication isn't perfect - Replication filters - master-master replication - 1062 “DUPLICATE KEY ERROR” - Server crashes - Non-deterministic (aka not idempotent) writes Notes:
  • 22. # Query 1: 0.00 QPS, 0.01x concurrency, ID 0x76F9EC92751F314A at byte 80096643 # This item is included in the report because it matches --limit. # Scores: V/M = 188.68 # Time range: 2012-02-01 09:20:24 to 2013-10-04 10:47:56 # Attribute pct total min max avg 95% stddev median # ============ === ======= ======= ======= ======= ======= ======= ======= # Count 1 490 # Exec time 14 384617s 9s 4869s 785s 1292s 385s 833s # Lock time 2 11s 169us 6s 22ms 6ms 290ms 316us # Rows sent 0 711.60k 0 4.82k 1.45k 4.27k 1.44k 685.39 # Rows examine 10 30.01G 0 123.80M 62.71M 117.57M 44.73M 75.78M # Rows affecte 0 0 0 0 0 0 0 0 # Rows read 0 711.60k 0 4.82k 1.45k 4.27k 1.44k 685.39 # Bytes sent 0 21.90M 0 167.52k 45.77k 143.37k 52.07k 8.46k # Tmp tables 8 1.91k 2 4 3.99 3.89 0.16 3.89 # Tmp disk tbl 0 0 0 0 0 0 0 0 # Tmp tbl size 3 3.36G 0 7.98M 7.02M 7.65M 1.26M 7.65M # Query size 0 471.35k 982 986 985.03 964.41 0 964.41 # String: # Databases bdc_ccm # Hosts # InnoDB trxID 13E9F1B2 (1/0%), 1402493D (1/0%)... 488 more # Last errno 0 # Users semuser (488/99%), jackie.lam (1/0%)... 1 more # Query_time distribution # 1us # 10us # 100us # 1ms # 10ms # 100ms # 1s # # 10s+ ################################################################ # Tables # SHOW TABLE STATUS FROM `bdc_ccm` LIKE 'click_log_inbound'G # SHOW CREATE TABLE `bdc_ccm`.`click_log_inbound`G # SHOW TABLE STATUS FROM `bdc_ccm` LIKE 'click_log_outbound_tp'G # SHOW CREATE TABLE `bdc_ccm`.`click_log_outbound_tp`G # SHOW TABLE STATUS FROM `bdc_ccm` LIKE 'click_log_outbound'G # SHOW CREATE TABLE `bdc_ccm`.`click_log_outbound`G # EXPLAIN /*!50100 PARTITIONS*/ selectdate(a.timestamp), a.referrer, count(b.inbound_id), sum(b.cpc), 'AS' astag from click_log_inbound a, click_log_outbound_tp b wherea.id = b.inbound_id and a.timestamp between '2012-02-08 00:00:00' and '2012-02-09 23:59:59' and b.partner like'adsense' and b.flag = 0 group by date(a.timestamp), a.referrer union all selectdate(a.timestamp), a.referrer, count(b.inbound_id), sum(b.cpc) , 'FL' astag from click_log_inbound a, click_log_outbound b wherea.id = b.inbound_id and a.timestamp between '2012-02-08 00:00:00' and '2012-02-09 23:59:59' and flag = 0 group by date(a.timestamp), a.referrer union all selectdate(a.timestamp), a.referrer, count(b.inbound_id), sum(b.cpc), 'TP' astag from click_log_inbound a, click_log_outbound_tp b wherea.id = b.inbound_id and a.timestamp between '2012-02-08 00:00:00' and '2012-02-09 23:59:59' and b.partner in ('capterra', 'bdc_network') and b.flag = 0 group by date(a.timestamp), a.referrerG Notes: Data Consistency - Replication isn't perfect - Replication filters - master-master replication - 1062 “DUPLICATE KEY ERROR” - Server crashes - Non-deterministic (aka not idempotent) writes Notes:
  • 23. pt-table-checksum Requires STATEMENT based replication for tiered replication Replication filters are dangerous because a failed query can break replication May want to use nohup since it can be slow Notes: Notes:
  • 24. pt-table-checksum Requires STATEMENT based replication for tiered replication Replication filters are dangerous because a failed query can break replication May want to use nohup since it can be slow Notes: Notes:
  • 25. pt-table-sync Notes: pt-table-sync --dry-run and --execute mutually exclusive ALWAYS backup first In a tiered replication setup or master-master take extra care to think through what will be done Run on master to sync all slaves pt-table-sync --execute --replicate test.checksum master1 Run on master for slaves individually to sync to master pt-table-sync --execute --sync-to-master slave1 Notes:
  • 26. pt-table-sync Notes: pt-table-sync --dry-run and --execute mutually exclusive ALWAYS backup first In a tiered replication setup or master-master take extra care to think through what will be done Run on master to sync all slaves pt-table-sync --execute --replicate test.checksum master1 Run on master for slaves individually to sync to master pt-table-sync --execute --sync-to-master slave1 Notes:
  • 29. Performance Debugging - Problems can be random - Problems only last for a few seconds, you can't connect and observe fast enough - Problems like to happen at odd hours; ETL, rollups, reporting, etc - You can't ALWAYS log on Notes: pt-stalk - Creates a lot of files - Output inspected with pt-sift Notes:
  • 30. Performance Debugging - Problems can be random - Problems only last for a few seconds, you can't connect and observe fast enough - Problems like to happen at odd hours; ETL, rollups, reporting, etc - You can't ALWAYS log on Notes: pt-stalk - Creates a lot of files - Output inspected with pt-sift Notes:
  • 31. pt-stalk Run as root --daemonize fork and run in the background -- sleep length to sleep between collects -- cycles the number of cycles the var must be true to collect --variable Threads_running and Execution_time are good ones --disk-bytes-free don't collect if this threshold is hit (best practice would be to set --log and --dest to a different disk than your data lives on the same as other mysql logs) Notes: Notes:
  • 32. pt-stalk Run as root --daemonize fork and run in the background -- sleep length to sleep between collects -- cycles the number of cycles the var must be true to collect --variable Threads_running and Execution_time are good ones --disk-bytes-free don't collect if this threshold is hit (best practice would be to set --log and --dest to a different disk than your data lives on the same as other mysql logs) Notes: Notes:
  • 33. pt-sift Pass it the path to the dir used with --data (default /var/lib/pt-stalk) Interactive program Lots of data points collected from the time of the incident Notes: Notes:
  • 34. pt-sift Pass it the path to the dir used with --data (default /var/lib/pt-stalk) Interactive program Lots of data points collected from the time of the incident Notes: Notes:
  • 35. General Admin / Maintenance pt-slave-restart - try to restart a slave skipping errors if replication fails pt-summary - gives a general summary of the MySQL instance pt-upgrade - tests logged queries against a new MySQL version pt-config-diff - show formatted diff of my.cnf files pt-heartbeat - update table on master with heartbeat data from slaves pt-kill - kill MySQL threads according to filters pt-index-usage - report on index structure and usage pt-variable-advisor - looks at runtime vars and makes suggestions Notes: http:s//cloud.percona.com to sign up for beta Percona Cloud Tools Notes:
  • 36. General Admin / Maintenance pt-slave-restart - try to restart a slave skipping errors if replication fails pt-summary - gives a general summary of the MySQL instance pt-upgrade - tests logged queries against a new MySQL version pt-config-diff - show formatted diff of my.cnf files pt-heartbeat - update table on master with heartbeat data from slaves pt-kill - kill MySQL threads according to filters pt-index-usage - report on index structure and usage pt-variable-advisor - looks at runtime vars and makes suggestions Notes: http:s//cloud.percona.com to sign up for beta Percona Cloud Tools Notes: