You are on page 1of 49

Introduction to Percona Server, XtraDB and Xtrabackup

Morgan Tocker morgan@percona.com

Who is Percona?

CONSULTING

SUPPORT

TRAINING

MAINTENANCE

.. for MySQL.

Who is Percona?

CONSULTING

SUPPORT

TRAINING

MAINTENANCE

.. for MySQL.

Who is Percona?

CONSULTING

SUPPORT

TRAINING

MAINTENANCE

.. for MySQL.

Who is Percona?

CONSULTING

SUPPORT

TRAINING

MAINTENANCE

.. for MySQL.

Who is Percona?

CONSULTING

SUPPORT

TRAINING

MAINTENANCE

.. for MySQL.

Todays Agenda

Percona products at 10 000 feet. A closer look at Percona Server with XtraDB. A closer look at XtraBackup. A quick look into the future. Finding more information.

Percona Server?
Official Oracle Product MySQL Server The InnoDB Storage Engine (Plugin edition) InnoDB Hot Backup License GPL/Commercial GPL/Commercial Commercial

Official Percona Product Percona Server The XtraDB Storage Engine XtraBackup

License GPL GPL GPL

Percona Server is...

A Percona sponsored distribution of the MySQL Server.


Current releases are based on MySQL 5.1. Earlier releases based on MySQL 5.0 are available.

Contains all of the great work of the MySQL engineering team + additional enhancements on top.

XtraDB is..

An enhanced version of the InnoDB storage engine.


We ship Percona Server 5.1 with XtraDB included. You dont have to download it separately, or do anything special to enable it.

XtraDB is based on the InnoDB plugin.

XtraBackup is...

An re-implementation of InnoDBs hot backup utility. XtraBackup can backup MyISAM, Archive and InnoDB tables. It can backup MySQL, Percona and MariaDB servers.

A fork or a spoon?

Percona Server and XtraDB are forks by denition.

We change the name to help users identify our distinctively different set of features. ~30K lines changed out of millions. We rebase off newer ofcial MySQL releases. License remains as GPL (Open Source). Compatibility is maintained.

Dont let the word fork scare you.


A word on compatibility:

The le format between MySQL with InnoDB to Percona Server with XtraDB does not change.* XtraDB identies itself as InnoDB:

ALTER TABLE my_table ENGINE=INNODB; or CREATE TABLE my_table (a INT) ENGINE=INNODB; still works!

If you want to revert back, just remove the Percona Packages and install MySQL packages.

Both Debian/Red Hat packages dont remove the data directory when you remove the programs.

* By default. You must explicitly enable features for incompatibility.

Compatibility (cont.)

When you connect from your PHP/Python/Perl/C/C++/ Ruby/.NET/<insert other language> application to Percona Server, you do not need to make any special changes. Your application just sees MySQL on port 3306. Really, nothing here changes.

10

Todays Agenda

Percona products at 10 000 feet. A closer look at Percona Server with XtraDB. A closer look at XtraBackup. A quick look into the future. Finding more information.

11

Release Model

Safe high value changes, made to market fast.


Short release cycle. Changes are mostly incremental enhancements. i.e. Version number should be reads as:
Percona-Server-server-51-5.1.52-rel11.6.140.rhel5.x86_64.rpm

Rebases against new MySQL releases.

Major MySQL Version (MySQL 5.1) Minor MySQL Version (MySQL 5.1.52)

XtraDB Release Version (Release 11.6)

12

Releases History

Historical average of a new release every 2 months:


Release-1 Release-2 Release-3 Release-4 Release-5 Release-6 Release-7 Release-8 Release-9 Release-9.1 Release-10 Dec 2008 Dec 2008 Feb 2009 April 2009 April 2009 July 2009 August 2009 Oct 2009 Jan 2010 March 2010 April 2010 Release-10.1 Release-11.0* Release-11.1 Release-11.2 Release-11.3 Release-12.0 Release-11.4 Release-12.1 Release-11.5 Release-11.6 May 2010 June 2010 June 2010 July 2010 September 2010 September 2010 October 2010 October 2010 October 2010 November 2010

13 * Recalled Release. The 12.1 branch is now Release Candidate.

So what changes?

Most of the enhancements fall into two categories:


Performance Improvements Operational / Usability Features

14

Performance Improvements
Improved Buffer Pool Scalability Separate location of double write buffer* Improved IO Path + adaptive checkpointing Transaction logs larger than 4G supported.

Faster Crash Recovery Insert buffer controls Separate purge thread Completely disable the query cache. Faster page checksums* Strip comments before using query cache

Remove excess fcntl calls Improved Rollback Segment Scalability*

Data dictionary memory consumption controls Support for different page sizes*

Increased number of undo slots* Per session configuration of innodb_flush_log_at_trx_commit

15

* Changes on disk format. Must use mysqldump to revert to regular MySQL releases.

Its not all raw performance

Many people get carried away with performance.

Consistency of timing is also more important than raw throughput. Without diagnostics, you wont get what you are entitled to.

An earlier benchmark showing Performance of XtraDB 9.x versus regular MySQL releases. Higher is better. Newer benchmarks are available at http://www.percona.com/ software/benchmarks/

16

Stability of results

Benchmarks is available at http://www.percona.com/software/benchmarks/

A lot of engineering work has been done to minimize variance. Sharp drops in MySQL releases are caused by checkpointing activities.

17

Usability Enhancements
Show data dictionary Show contents of the buffer pool Save index statistics between restarts Import / export of buffer pool contents Bug fixes - ahead User / Index / Table statistics of time Disable automatic statistics regeneration Transactional Replication Advise in processlist when waiting on Query cache mutex. Improved slow query log Log connection errors Import / export of innodb_file_per_table tables Deadlock counter Retain query response time distribution.

Store buffer pool in shared memory segment

Better handling of corrupted tables

Show Temporary Tables

18

The slow query log


$ tail /var/log/mysql.slow .. MySQL Server # Time: 100924 13:58:47 # User@Host: root[root] @ localhost [] # Query_time: 399.563977 Lock_time: 0.000110 Rows_sent: 1 Rows_examined: 46313608 SET timestamp=1285336727; select STRAIGHT_JOIN count(*) as c, person_id FROM cast_info FORCE INDEX(person_id) INNER JOIN title ON (cast_info.movie_id=title.id) WHERE title.kind_id = 1 GROUP BY cast_info.person_id ORDER by c DESC LIMIT 1;

$ mysql -e SET GLOBAL log_slow_verbosity = full; Percona Server $ tail /var/log/mysql.slow .. # Time: 100924 13:58:47 # User@Host: root[root] @ localhost [] # Thread_id: 10 Schema: imdb Last_errno: 0 Killed: 0 # Query_time: 399.563977 Lock_time: 0.000110 Rows_sent: 1 Rows_examined: 46313608 Rows_affected: 0 Rows_read: 1 # Bytes_sent: 131 Tmp_tables: 1 Tmp_disk_tables: 1 Tmp_table_sizes: 25194923 # InnoDB_trx_id: 1403 # QC_Hit: No Full_scan: Yes Full_join: No Tmp_table: Yes Tmp_table_on_disk: Yes # Filesort: Yes Filesort_on_disk: Yes Merge_passes: 5 # InnoDB_IO_r_ops: 1064749 InnoDB_IO_r_bytes: 17444847616 InnoDB_IO_r_wait: 26.935662 # InnoDB_rec_lock_wait: 0.000000 InnoDB_queue_wait: 0.000000 # InnoDB_pages_distinct: 65329 SET timestamp=1285336727; select STRAIGHT_JOIN count(*) as c, person_id FROM cast_info FORCE INDEX(person_id) INNER JOIN title ON (cast_info.movie_id=title.id) WHERE title.kind_id = 1 GROUP BY cast_info.person_id ORDER by c DESC LIMIT 1;

19

Slow log (cont.)

In XtraDB 12.1, this is even further enhanced:

$ mysql -e SET GLOBAL profiling_server = 1; $ tail /var/log/mysql.slow .. # Query_time: 4.555235 Lock_time: 0.000000 Rows_sent: 1 Rows_examined: 0 Rows_affected: 0 Rows_read: 1 # Profile_starting: 4.554799 Profile_starting_cpu: 0.000000 Profile_checking_permissions: 0.000095 Profile_checking_permissions_cpu: 0.000000 Profile_Opening_tables: 0.000088 Profile_Opening_tables_cpu: 0.000000 Profile_init: 0.000056 Profile_init_cpu: 0.000000 Profile_optimizing: 0.000046 Profile_optimizing_cpu: 0.000000 Profile_executing: 0.000098 Profile_executing_cpu: 0.000000 Profile_end: 0.000049 Profile_end_cpu: 0.000000 Profile_query_end: 0.000045 Profile_query_end_cpu: 0.000000 Profile_freeing_items: 0.000084 Profile_freeing_items_cpu: 0.000000 Profile_logging_slow_query: 0.000045 Profile_logging_slow_query_cpu: 0.000000 # Profile_total: 4.555405 Profile_total_cpu: 0.000000 insert into teee4 select * from teee4 limit 10000000;

20

Find indexes not being used


( Not Possible )
MySQL Server

mysql> SET GLOBAL userstat_running = 1; Percona mysql> SELECT DISTINCT s.TABLE_SCHEMA, s.TABLE_NAME, s.INDEX_NAME FROM information_schema.statistics `s` LEFT JOIN information_schema.index_statistics IS ON (s.TABLE_SCHEMA = IS.TABLE_SCHEMA AND s.TABLE_NAME=IS.TABLE_NAME AND s.INDEX_NAME=IS.INDEX_NAME) WHERE IS.TABLE_SCHEMA IS NULL; +--------------+---------------------------+-----------------+ | TABLE_SCHEMA | TABLE_NAME | INDEX_NAME | +--------------+---------------------------+-----------------+ | art100 | article100 | ext_key | | art100 | article100 | site_id | | art100 | article100 | hash | | art100 | article100 | forum_id_2 | | art100 | article100 | published | | art100 | article100 | inserted | | art100 | article100 | site_id_2 | | art100 | author100 | PRIMARY | | art100 | author100 | site_id | ... +--------------+---------------------------+-----------------+ 1150 rows IN SET (1 min 44.23 sec)

Server

21

Usability (cont.)

Internal locking on the query cache is a major problem on multi-core servers. Wonder if youre waiting on the Query Cache?

We have a new SHOW PROCESSLIST state.

22

Show Buffer Pool Contents


mysql> SELECT d.*,round(100*cnt*16384/(data_length+index_length),2) fit FROM (SELECT schema_name,table_name,count(*) cnt,sum(dirty),sum(hashed) FROM INNODB_BUFFER_POOL_PAGES_INDEX GROUP BY schema_name,table_name ORDER BY cnt DESC LIMIT 20) d JOIN TABLES ON (TABLES.table_schema=d.schema_name AND TABLES.table_name=d.table_name); +-------------+---------------------+---------+------------+-------------+--------+ | schema_name | table_name | cnt | sum(dirty) | sum(hashed) | fit | +-------------+---------------------+---------+------------+-------------+--------+ | db | table1 | 1699133 | 13296 | 385841 | 87.49 | | db | table2 | 1173272 | 17399 | 11099 | 98.42 | | db | table3 | 916641 | 7849 | 15316 | 94.77 | | db | table4 | 86999 | 1555 | 75554 | 87.42 | | db | table5 | 32701 | 7997 | 30082 | 91.61 | | db | table6 | 31990 | 4495 | 25681 | 102.97 | | db | table7 | 1 | 0 | 0 | 100.00 | +-------------+---------------------+---------+------------+-------------+--------+ 7 rows in set (26.45 sec)

23

Source: http://www.mysqlperformanceblog.com/ 2010/03/26/tables-fit-buffer-poo/

Save Buffer Pool Contents

Export the contents of the buffer pool to a le called ib_lru_dump in the data directory:

SELECT * FROM information_schema.XTRADB_ADMIN_COMMAND /*! XTRA_LRU_DUMP*/; SELECT * FROM information_schema.XTRADB_ADMIN_COMMAND /*! XTRA_LRU_RESTORE*/;

Restored ib_lru_dump:

24

Note: Not the actual contents - it takes 8 bytes to remember the address of a 16K page.

To summarize

Many MySQL users are not getting the performance they are entitled to.

They lack visibility into internal operations of MySQL. Giving a 50% improvement through new features sounds nice. What they dont realize is theyre losing 100% by not being aware.

25

Todays Agenda

Percona products at 10 000 feet. A closer look at Percona Server with XtraDB. A closer look at XtraBackup. A quick look into the future. Finding more information.

26

Backup Overview in MySQL


Popular for small databases. Popular for databases with MyISAM Best choice when all InnoDB

mysqldump

mysqldump

Filesystem Snapshot (LVM) ALL MOSTLY HOT SYSTEM SYSTEM SLOW-MED BEST HIGH YES

XtraBackup /InnoDB Hot Backup INNODB HOT TABLE TABLE FAST BEST LOW YES

XtraBackup /InnoDB Hot Backup ALL WARM TABLE TABLE FAST BEST LOW YES

MySQLHotc opy MyISAM WARM TABLE TABLE FAST BEST MED YES

Cold Backup ALL COLD SYSTEM SYSTEM BEST BEST N/A YES

Engines Warmth Flexibility of Backup Flexibility of Restore Backup Time Restore Time Impact of Backup Binary log Coordination

InnoDB HOT ROW MOST MED WORST HIGH YES

ALL WARM ROW MOST MED WORST HIGH YES

27

Whats the difference between..?


Filesystem Snapshot (LVM) Engines Warmth Flexibility of Backup Flexibility of Restore Backup Time Restore Time Impact of Backup Binary log Coordination ALL MOSTLY HOT SYSTEM SYSTEM SLOW-MED BEST HIGH YES XtraBackup/ InnoDB Hot Backup INNODB HOT TABLE TABLE FAST BEST LOW YES

Performance when in snapshot mode with LVM on Linux is much worse.

If your off-peak load is not six times less than your peak load, this may result in a need to over-provision.

28

See: http://www.mysqlperformanceblog.com/2009/02/05/ disaster-lvm-performance-in-snapshot-mode/

But you said...


mysqldump XtraBackup /InnoDB Hot Backup INNODB HOT TABLE TABLE FAST BEST LOW YES

Engines Warmth Flexibility of Backup Flexibility of Restore Backup Time Restore Time Impact of Backup Binary log Coordination

InnoDB HOT ROW MOST MED WORST HIGH YES

Mysqldump may be faster in a few cases. Concern yourself more with recovery time and impact.

29

http://www.mysqlperformanceblog.com/2010/11/08/anargument-for-not-using-mysqldump-in-production/

XtraBackup is...

The best option when you have a considerable amount of data:

Restore is as simple as moving the backup to your datadir. It causes the least impact while creating the backup - and is only blocking while backing up MyISAM tables.

30

InnoDB Hot Backup (1)


Feature License Price Open source Non-blocking InnoDB backups MyISAM backups Compressed backups Partial backups Throttling Point-in-time recovery support Incremental backups Percona XtraBackup GPL Free YES YES YES YES YES YES YES YES YES MySQL Enterprise Backup (InnoDB Hot Backup) Proprietary $5000 per server NO YES YES YES YES YES YES YES YES

31

More Information: http://www.percona.com/software/percona-xtrabackup/

InnoDB Hot Backup (2)


Feature Streaming backups OS buffer optimizations Export individual tables Restore tables to a different server Analyze data & index files Familiar command-line behavior Percona XtraBackup YES YES YES YES YES YES MySQL Enterprise Backup (InnoDB Hot Backup) NO NO NO NO NO NO

32

More Information: http://www.percona.com/software/percona-xtrabackup/

Advanced Features

XtraBackup supports some advanced backup options:

Backup to a stream (can be copied straight across the network, or fed through a compression program). Throttle to only a limited number of IOPS. Incremental backup.*

33

* Some special restrictions apply. Data Definition must not have changed since last backup.

Advanced Features (cont.)

Report on fragmentation of indexes:


$ xtrabackup --stats --tables=art.link* -datadir=/mnt/data/mysql/ ... table: art/link_out104, index: PRIMARY, space id: 12, root page 3 leaf pages: recs=25958413, pages=497839, data=7492026403 bytes, data/pages=91% ...

34

http://www.mysqlperformanceblog.com/2009/09/14/statisticsof-innodb-tables-and-indexes-available-in-xtrabackup/

Todays Agenda

Percona products at 10 000 feet. A closer look at Percona Server with XtraDB. A closer look at XtraBackup. A quick look into the future. Finding more information.

35

MySQL 5.5

In Release Candidate now. An awesome release!


A greatly improved focus on performance. Some additional diagnostic/usability features. Work has already began porting features. We will continue to maintain our 5.1 series.

Percona Server will rebase against 5.5.


36

Percona Server Plans

Our Blueprints are publicly available through LaunchPad: https://blueprints.launchpad.net/percona-server Percona Server with XtraDB R12.1 is now a release candidate.

It will include the ability to store the buffer pool in shared memory and built-in response time distribution stats. It will also feature HandlerSocket.

37

XtraBackup Plans

XtraBackup 1.5 will support parallel backup:

http://www.percona.com/docs/wiki/perconaxtrabackup:xtrabackup:option-and-variablereference#parallel

This is very helpful for RAID controllers and some SSDs, which require multiple threads to exploit their capacity.

38

Support & Maintenance


Feature development is customer-driven. Commercial Support and Maintenance for Percona Server, XtraDB and XtraBackup are available.

http://www.percona.com/support/mysql-supportmaintenance/

39

Support & Maintenance (cont.)

Seeking sponsorship of parallel replication: http://www.mysqlperformanceblog.com/2010/11/08/ implementing-parallel-replication-in-mysql/ We need to get more customers involved, to share the cost of this large and ambitious project.

40

Support & Maintenance (cont.)

Provides you with:


Expert technical advice. Insurance against bugs in MySQL. Customized server binaries.

41

Todays Agenda

Percona products at 10 000 feet. A closer look at Percona Server with XtraDB. A closer look at XtraBackup. A quick look into the future. Finding more information.

42

Getting Started

Percona Server with XtraDB and XtraBackup are free software released under the GPL license.

More information can be found at: http://www.percona.com/software/percona-server/ http://www.percona.com/software/percona-xtrabackup/ http://www.percona.com/docs/wiki/release:start

We provide YUM and APT repositories:

43

Training Classes

Chicago
Tuesday, 01 Feb 2011 to Friday, 04 Feb 2011

London
Monday, 21 Feb 2011 to Thursday, 24 Feb 2011

Frankfurt
Monday, 28 Feb 2011 to Thursday, 03 Mar 2011

See www.percona.com/training to register. Private training and combined onsite consulting/training is available.

44

Any Questions?
Slides and a recording will be made available after this presentation.

45

You might also like