www.it-ebooks.info Instant InnoDB A quick reference guide to walk you through the setup of InnoDB, and help you start unlocking the engine's potential Matt Reid BIRMINGHAM - MUMBAI www.it-ebooks.info Instant InnoDB Copyright © 2013 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: January 2013 Production Reference: 2240113 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-84968-748-5 www.packtpub.com Cover image by Deborah Lattimore (deborah.lattimore@gmail.com) www.it-ebooks.info Credits Author Matt Reid Reviewers Marc Delisle Daniël van Eeden Shiv Iyer Acquisition Editor Robin de Jongh Commissioning Editor Meeta Rajani Technical Editors Harsha Bharwani Jalasha D'costa Project Coordinators Shraddha Bagadia Esha Thakker Proofreader Mario Cecere Indexer Rekha Nair Production Coordinators Aparna Bhagat Shantanu Zagade Cover Work Aparna Bhagat www.it-ebooks.info About the Author Matt Reid is a Systems Architect and Engineer who has focused his career on helping corporations solve large scale computing challenges. He is experienced in a wide range of Internet architectures ranging from global application load balancing to database clusters designed for serving millions of concurrent users. His career has included work with geographically-distributed application and database environments, enterprise analytics and monitoring, database performance tuning, disaster recovery architectures, enterprise application programming, as well as systems infrastructure automation. He has worked and consulted for a multitude of companies including Riot Games, Adobe Software, British Sky Broadcasting, AdMob, Business Objects/SAP, OpSource, Arc90, Mattel, and NTT Communications. Matt currently functions as the CTO and Engineering Architect for his consulting company MobileAxiom. His current projects include infrastructure automation engineering for the video game League of Legends, working on the global VPN architecture for startup Virtual Private Internet, and maintaining several open source projects for the MySQL community. I would like to thank the following people for having an extraordinary impact on my career. Opportunity is everything and without you I would not be where I am today: Jim Reid, Deborah Lattimore, James Lester Reid, Molly Reid, Ryan Morgan, Monte Sanford, Dawn Baker, Don Barlow, Bruce Soto, Steve Crusenberry, and Dima Polyak. I'd also like to thank the Open Source community on the whole for helping to keep knowledge and intellectual resources free and transparent for the world. www.it-ebooks.info About the Reviewers Marc Delisle was awarded "MySQL Community Member of the Year 2009" because of his involvement with phpMyAdmin, a web interface for MySQL. He started to contribute to the project in December 1998, when he made the multi-language version. He is involved with phpMyAdmin as a developer, translator and project administrator, and enjoys meeting phpMyAdmin users in person. Marc is a System Administrator at Cegep de Sherbrooke, Québec, Canada. In addition to the Mastering phpMyAdmin successive editions, Marc has written Creating your MySQL Database: Practical Design Tips and Techniques and phpMyAdmin Starter, all with Packt Publishing. Daniël van Eeden lives in the Netherlands. He works as a Database Consultant for Snow B.V. He blogs about databases at http://databaseblog.myname.nl. Besides working as a DBA, he has also worked as a System Administrator and Storage Administrator. Other areas of experience are High Availablity and Security. He is a member of the IOUG MySQL Council. www.it-ebooks.info Shiv Iyer has over 12 years of experience in architecturing very large volume/ transaction intensive database applications in Oracle, SQL Server, MySQL, and PostgreSQL. Shiv specializes in Database Architecture, Performance Engineering, Scalability, High Availability, Disaster Recovery, Database Migration, Benchmarking, and Fine-Tuning and Database Security. He is the founder and Principal Database Architect of Ask DB Experts, a boutique "Database Technologies" consulting company based out of Bangalore, India. Shiv has also worked on books such as Oracle Database 11g Release 2 Performance Tuning Tips and Techniques by Richard Niemiec, published by McGraw-Hill Osborne Media. My parents, wife, family,friends, and Richard Niemiec www.it-ebooks.info www.PacktPub.com Support les, eBooks, discount offers and more You might want to visit www.PacktPub.com for support les and downloads related to your book. Did you know that Packt offers eBook versions of every book published, with PDF and ePub les available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at service@packtpub.com for more details. At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks. TM http://PacktLib.PacktPub.com Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books. Why Subscribe? • Fully searchable across every book published by Packt • Copy and paste, print and bookmark content • On demand and accessible via web browser Free Access for Packt account holders If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access. Instant Updates on New Packt Books Get notied! Find out when new books are published by following @PacktEnterprise on Twitter, or the Packt Enterprise Facebook page. www.it-ebooks.info www.it-ebooks.info Table of Contents Preface 1 Chapter 1: Getting Started with InnoDB 5 Basic features of InnoDB 5 Referential integrity 6 Multiversion concurrency control 6 Transaction isolation 6 ACID compliance 7 Locking characteristics 7 System requirements and supported platforms 7 Downloading MySQL with InnoDB 8 Installing MySQL with InnoDB support 9 Verifying InnoDB support and transaction settings 9 Atomicity 10 Consistency 11 Isolation 11 Durability 11 Setting the transaction isolation level for InnoDB 11 Creating your rst InnoDB table 12 Summary 13 Chapter 2: Basic Conguration Parameters 15 MySQL memory allocation equations 16 InnoDB memory and data le conguration 17 Static variables 17 innodb_data_home_dir 17 innodb_data_le_path 18 innodb_log_group_home_dir 18 innodb_log_le_size 18 innodb_log_buffer_size 19 innodb_log_les_in_group 20 innodb_buffer_pool_size 20 www.it-ebooks.info [...]...Table of Contents innodb_ status_file transaction-isolation skip -innodb 21 21 21 Summary Chapter 3: Advanced Configuration Parameters InnoDB and input/output resources SysBench Fio Bonnie++ Disk speed: standard IOPS InnoDB variables Dynamic InnoDB variables 22 23 23 24 24 25 25 26 26 innodb_ table_locks 26 innodb_ flush_log_at_trx_commit 27 innodb_ io_capacity 28 innodb_ thread_concurrency 28 innodb_ commit_concurrency... 28 innodb_ thread_concurrency 28 innodb_ commit_concurrency 29 innodb_ support_xa 29 innodb_ fast_shutdown 30 Static InnoDB variables 30 innodb_ file_per_table 30 innodb_ additional_mem_pool_size 32 innodb_ buffer_pool_instances 32 innodb_ write_io_threads 33 innodb_ read_io_threads 33 skip -innodb- doublewrite 33 Summary 33 Chapter 4: Load Testing InnoDB for Performance 35 Open source system monitoring tools... 43 InnoDB Flush methods 43 InnoDB Flush method comparison chart 44 Thread concurrency testing 44 [ ii ] www.it-ebooks.info Table of Contents Advisory on transaction-isolation level 44 Summary 44 Chapter 5: Maintenance and Monitoring 45 Chapter 6: Troubleshooting InnoDB 53 Maintenance procedures Adding and resizing InnoDB log files Adding tablespaces to InnoDB Utilizing RAW tablespaces Monitoring InnoDB. .. variables Third-party resources for trending and visualization Equations for analyzing InnoDB statistics Summary Troubleshooting system issues InnoDB system crashes Using InnoDB crash recovery modes Enabling InnoDB recovery modes 45 45 46 47 48 48 48 50 50 51 52 53 53 54 55 Utilizing InnoDB status statistics 56 Troubleshooting InnoDB performance 57 I/O resources 58 Table-space and logging 58 Memory resources... Terminology 66 InnoDB tuning references 67 Index 69 [ iv ] www.it-ebooks.info Preface InnoDB is one of the most commonly used database engines in the world today Knowing how to effectively manage this technology can make or break a MySQL database environment Instant InnoDB addresses everything you need to know for the installation, configuration, load testing, analysis, and long term support of an InnoDB- based... performance tuning options for running the InnoDB database engine in production environments Instant InnoDB contains detailed discussions for a range of simple to advanced topics If you've ever wanted to learn more about InnoDB but didn't want to sit down with a dauntingly large or stale read then this reference guide is the answer to your queries You will learn about common InnoDB monitoring and reporting applications... installation of InnoDB Chapter 4, Load Testing InnoDB for Performance, explains all about general purpose InnoDB load testing as well as common methods for simulating production workloads www.it-ebooks.info Preface Chapter 5, Maintenance and Monitoring, covers the important sections of InnoDB to monitor, tools to use, and processes that adhere to industry best practices Chapter 6, Troubleshooting InnoDB, explains... the InnoDB Plugin is included in MySQL 5.1 releases, in addition to the built-in version of InnoDB that has been included in the previous releases MySQL 5.1.42 through 5.1.45 include InnoDB Plugin 1.0.6, which is considered of Release Candidate (RC) quality MySQL 5.1.46 and up include InnoDB Plugin 1.0.7 or higher, which is considered of General Availability (GA) quality Installing MySQL with InnoDB. .. desired and the InnoDB engine will simply create additional log files upon process restart If you decide to decrease this variable and use fewer log files you must follow the same process used for resizing the InnoDB log files, which is outlined in Chapter 5, Maintenance and Monitoring innodb_ buffer_pool_size InnoDB is all about speed, and the biggest performance impact you can give an InnoDB based database... Getting Started with InnoDB In the simplest terms, InnoDB is a transactional database information processing engine It is the most commonly used engine currently available for the MySQL database application and was the first transactional engine offered with the application Different versions of MySQL ship with varying levels of InnoDB support and corresponding default settings for the InnoDB engine Knowing . variables 17 innodb_ data_home_dir 17 innodb_ data_le_path 18 innodb_ log_group_home_dir 18 innodb_ log_le_size 18 innodb_ log_buffer_size 19 innodb_ log_les_in_group. 26 innodb_ table_locks 26 innodb_ ush_log_at_trx_commit 27 innodb_ io_capacity 28 innodb_ thread_concurrency 28 innodb_ commit_concurrency 29 innodb_ support_xa 29 innodb_ fast_shutdown