Monitoring MySQL. Geert Vanderkelen MySQL Senior Support Engineer Sun Microsystems



Similar documents
Maintaining Non-Stop Services with Multi Layer Monitoring

Monitoring MySQL. Kristian Köhntopp

High Availability Solutions for MySQL. Lenz Grimmer DrupalCon 2008, Szeged, Hungary

Monitoring Systems and Services. Alwin Brokmann DESY-IT March 24 28,2003 CHEP 2003 San Diego

Monitoring MySQL. Presented by, MySQL & O Reilly Media, Inc. A quick overview of available tools

DEPLOYMENT GUIDE Version 1.0. Deploying the BIG-IP LTM with the Nagios Open Source Network Monitoring System

DBA Tutorial Kai Voigt Senior MySQL Instructor Sun Microsystems Santa Clara, April 12, 2010

There are numerous ways to access monitors:

How to evaluate which MySQL High Availability solution best suits you

Architectures Haute-Dispo Joffrey MICHAÏE Consultant MySQL

MySQL Cluster New Features. Johan Andersson MySQL Cluster Consulting johan.andersson@sun.com

Evaluation of standard monitoring tools(including log analysis) for control systems at Cern

Nagios in High Availability Environments

Monitoring VoIP Systems. Sebastian Damm

Install and configure the Net- SNMP agent for Windows

Part 3. MySQL DBA I Exam

Document d'installation FAN 2.1

Dave Stokes MySQL Community Manager

MySQL High Availability Solutions. Lenz Grimmer OpenSQL Camp St. Augustin Germany

How To Monitor A Network With Nagios And Other Tools

Availability Management Nagios overview. TEIN2 training Bangkok September 2005

MySQL Enterprise Monitor

High Availability Solutions for the MariaDB and MySQL Database

High Availability and Scalability for Online Applications with MySQL

MySQL Fabric: High Availability Solution for Connector/Python

Products and Solutions

Setting Up A Nagios Monitoring System Warren Block, May 2005

NRPE Documentation CONTENTS. 1. Introduction... a) Purpose... b) Design Overview Example Uses... a) Direct Checks... b) Indirect Checks...

WhatsUp Gold v11 Features Overview

Using MySQL for Big Data Advantage Integrate for Insight Sastry Vedantam

How To Monitor Mysql With Zabbix

How to configure Microsoft System Center Operations Manager (SCOM) 2012 R2 as SNMP trap receiver for VMware vcenter on MS Windows?

Nagios. cooler than it looks. Wednesday, 31 October 2007

MySQL Storage Engines

5 Percona Toolkit tools that could save your day. Stéphane Combaudon FOSDEM February 3rd, 2013

Tushar Joshi Turtle Networks Ltd

<Insert Picture Here> Introduction to Using MySQL in Cloud Computing

Zero Downtime Deployments with Database Migrations. Bob Feldbauer

Monitoring Drupal with Sensu. John VanDyk Iowa State University DrupalCorn Iowa City August 10, 2013

HP LeftHand SAN Solutions

How to backup a remote MySQL server with ZRM over the Internet

A Quick Start Guide to MONyog Ultimate Enterprise Monitor

MONyog White Paper. Webyog

EVENT LOG MANAGEMENT...

Synchronous multi-master clusters with MySQL: an introduction to Galera

How To Manage Myroster Database With Hp And Myroberty

WhatsUp Gold v11 Features Overview

This section describes how to set up, find and delete community strings.

MySQL Security for Security Audits

IBM Redistribute Big SQL v4.x Storage Paths IBM. Redistribute Big SQL v4.x Storage Paths

Présentation de Nagios

wget

Bernd Ahlers Michael Friedrich. Log Monitoring Simplified Get the best out of Graylog2 & Icinga 2

Percona Server features for OpenStack and Trove Ops

SCALABLE DATA SERVICES

Asterisk Cluster with MySQL Replication. JR Richardson Engineering for the Masses

Parallel Replication for MySQL in 5 Minutes or Less

Database Administration with MySQL

Snapt Redundancy Manual

MyOra 3.0. User Guide. SQL Tool for Oracle. Jayam Systems, LLC

MySQL High-Availability and Scale-Out architectures

High Availability And Disaster Recovery

Configuring an Alternative Database for SAS Web Infrastructure Platform Services

Vital Security Web Appliances NG-1100/NG-5100/NG How to Use Simple Network Management Protocol (SNMP) Monitoring

Applications Manager Best Practices document

Informatica Corporation Proactive Monitoring for PowerCenter Operations Version 3.0 Release Notes May 2014

escan SBS 2008 Installation Guide

Monitoring HP OO 10. Overview. Available Tools. HP OO Community Guides

Monitor TemPageR 4E With PageR Enterprise

Robust & Reliable DNS Operations Logging & Monitoring

Availability Guide for Deploying SQL Server on VMware vsphere. August 2009

Using Cacti To Graph MySQL s Metrics

Aradial Installation Guide

COMMANDS 1 Overview... 1 Default Commands... 2 Creating a Script from a Command Document Revision History... 10

MySQL Administration and Management Essentials

Network Monitoring with SNMP

Managed File Transfer

Network Monitoring with SNMP

MySQL synchronous replication in practice with Galera

Configuring System Message Logging

New Features in MySQL 5.0, 5.1, and Beyond

SCF/FEF Evaluation of Nagios and Zabbix Monitoring Systems. Ed Simmonds and Jason Harrington 7/20/2009

Setting Up the Site Licenses

Who did what, when, where and how MySQL Audit Logging. Jeremy Glick & Andrew Moore 20/10/14

White Paper. Optimizing the Performance Of MySQL Cluster

The Nagios check_logfiles plugin helps you monitor your logfiles even if the logs rotate and change names.

Java DB Performance. Olav Sandstå Sun Microsystems, Trondheim, Norway Submission ID: 860

How to configure High Availability (HA) in AlienVault USM (for versions 4.14 and prior)

MySQL: Cloud vs Bare Metal, Performance and Reliability

MariaDB Cassandra interoperability

Effective MySQL Monitoring. Baron Schwartz March 2012

MySQL Reference Architectures for Massively Scalable Web Infrastructure

Centerity Monitor Standard V3.8.4 USER GUIDE VERSION 9.15

Monitoring Software Services registered with science.canarie.ca

Jason Hill HPC Operations Group ORNL Cray User s Group 2011, Fairbanks, AK

Supermicro Server Monitoring with SuperDoctor 5 and Nagios Using SNMP Protocol. Version 1.1b

Installing, Uninstalling, and Upgrading Service Monitor

vrealize Automation Load Balancing


Transcription:

Monitoring MySQL Geert Vanderkelen MySQL Senior Support Engineer Sun Microsystems

Agenda Short intro into MySQL, the company Monitoring MySQL: some examples Nagios plugins for MySQL MySQL Enterprise Monitor

From MySQL to Sun Whoohoo!

What Makes MySQL Special OpenSource! Commercial and Community Support Storage engines Simplicity Sun Microsystems MySQL 5.1 is coming! MySQL Cluster 6.2 is here!

Monitoring MySQL Basics and Some examples..

Getting Status Information SHOW GLOBAL STATUS > Global keyword is important! Snapshot regularly > mysqladmin -i 20 extended-status >> status.log Also available as information_schema.global_status For example: > Com_xxx counter variables > Questions for Queries/Sec

Index usage Find out if you do lots of table scans mysql> SHOW GLOBAL STATUS LIKE Handler\_read% ; Handler_read_first 83574685 Handler_read_key 11274900036 Handler_read_next 31376780526 Handler_read_prev 34482622 Handler_read_rnd 265239832 Handler_read_rnd_next 307182727076 ((Handler_read_rnd + Handler_read_rnd_next) / ( (Handler_read_%))*100 = 87.8

Temp. Tables Going To Disk? mysql> SHOW GLOBAL STATUS LIKE Created\_tmp% ; Created_tmp_disk_tables 5032520 Created_tmp_files 71 Created_tmp_tables 13117923 (Created_tmp_disk_tables / Created_tmp_tables) *100 = 38.3

Check # Of Processes To much long running process: mostly trouble SHOW PROCESSLIST or: mysql> USE information_schema; mysql> SELECT COUNT(*) FROM processlist WHERE user <> 'replication' AND id <> CONNECTION_ID() AND time > 60 AND command <> 'Sleep';

Check uptime MySQL might crash and restart quickly Other checks might miss it mysql> USE information_schema; mysql> SELECT DATE_SUB(NOW(), INTERVAL variable_value SECOND) AS started, variable_value AS uptime FROM global_status WHERE variable_name = 'UPTIME'; +---------------------+--------+ STARTED UPTIME +---------------------+--------+ 2008-09-08 10:58:24 36604 +---------------------+--------+

InnoDB Table Size Usually auto-extends innodb_data_file_path = ibdata1:200m Before MySQL 5.1 in table comments! mysql> USE information_schema; mysql> SELECT data_free*1024 AS 'InnoDB free space' FROM tables WHERE table_name = 'innotest'; +-------------------+ InnoDB free space +-------------------+ 201326592 +-------------------+

InnoDB Buffer Pool Hit Rate Is the buffer still big enough? mysql> SHOW GLOBAL STATUS LIKE 'InnoDB\_buffer\_pool\_read%'; +-----------------------------------+------------+ Variable_name Value +-----------------------------------+------------+.. Innodb_buffer_pool_read_requests 2226519108 Innodb_buffer_pool_reads 74845 +-----------------------------------+------------+ 100 * ( 1 - (Innodb_buffer_pool_reads / Innodb_buffer_pool_read_requests)) = 99.99%

Checking configuration SHOW GLOBAL VARIABLES > Also information_schema.global_variables What version is running? Default storage engine still InnoDB? Global character set is still UTF-8? Logs enabled? > slow and general query log (online as of 5.1)

Logging Enabled? General log > Log every statement, useful for debugging > SHOW GLOBAL VARIABLES LIKE 'general_log'; Slow query log > Show long running queries, or not using indexes > SHOW GLOBAL VARIABLES LIKE 'slow_query_log'; As of MySQL 5.1 > Can be toggled online, and logged to tables Should not be running all the time

Monitoring Replication On Master > Check number of binary logs > Limit number of slaves On Slave > Use SHOW SLAVE STATUS > Check seconds behind master > Check if still reading from Master > etc.

Master And Her Slaves Master can handle lots of slave > But it s good to set a limit SHOW SLAVE HOSTS > Does list registered hosts, not connected ones mysql> SHOW SLAVE HOSTS; +-----------+--------+------+...+-----------+ Server_id Host Port... Master_id +-----------+--------+------+...+-----------+ 2 cent02 3306... 1 +-----------+--------+------+...+-----------+ 1 row in set (0.00 sec)

Number Of Binary Logs Regularly causing disk space issues > Can use PURGE MASTER LOGS SHOW BINARY LOGS mysql> SHOW BINARY LOGS; +------------------+-----------+ Log_name File_size +------------------+-----------+ cent01bin.000001 125 cent01bin.000002 1021 cent01bin.000004 125 cent01bin.000005 462 +------------------+-----------+

Slave status mysql> SHOW SLAVE STATUS\G.. Master_Host: 192.168.14.100 Master_User: replication Master_Port: 3306.. Slave_IO_Running: Yes Slave_SQL_Running: Yes.. Seconds_Behind_Master: 0.. Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 0 Last_SQL_Error:

Seconds Behind Master Number of seconds elapsed since timestamp of last statement received from Master Only useful in fast networks > Slow I/O gives bad approximation Use a heartbeat table > INSERT INTO replication_ping VALUES (NOW()) > Check on slave when table is updated > Calculate time difference > Or use mk-heartbeat from Maatkit

Monitoring Cluster Still not easy to do Using NDB API Parse logs Using ndb_mgm shell> ndb_mgm -e "SHOW" Connected to Management Server at: localhost:1406 Cluster Configuration --------------------- [ndbd(ndb)] 2 node(s) id=3 @10.100.9.8 (mysql-5.1.27 ndb-6.3.17, Nodegroup: 0, Master) id=4 @10.100.9.9 (mysql-5.1.27 ndb-6.3.17, Nodegroup: 0) [ndb_mgmd(mgm)] 2 node(s) id=1 @10.100.9.6 (mysql-5.1.27 ndb-6.3.17) id=2 (not connected, accepting connect from ndbsup-priv-2) [mysqld(api)] 7 node(s) id=5 @10.100.9.6 (mysql-5.1.27 ndb-6.3.17) id=6 (not connected, accepting connect from any host)

Useful Tools MySQL client tools and SQL! MySQL Enterprise Monitor > http://www.mysql.com/products/enterprise/ innotop > http://innotop.sourceforge.net/ Maatkit > http://www.maatkit.org/

Nagios + MySQL Monitoring MySQL with Nagios

Configuration tips Using hostgroups > Useful for replication setups or Cluster define hostgroup { hostgroup_name mysql-masters } define hostgroup { hostgroup_name mysql-slaves } define host { use generic-virtualbox host_name cent02 alias cent02 (VMWare) address 192.168.14.101 hostgroups virtualboxes,vmware,mysql-slaves } define service { use generic-service hostgroup_name mysql-slaves service_description Slave SQL Thread check_command mysql_repl_sqlthread }

Configuration tips (2) Secure your setup: SSL or SSH Don t use MySQL root user for checks Could use NRPE (Nagios add-on)

Some plugins.. Oli Sennhauser > http://www.shinguz.ch/mysql/mysql_monitoring.html

Some plugins.. (2) check_mysql_perf > http://www.consol.com/opensource/nagios/check-mysql-perf/ Checks various buffers > hit rates for qcache, keycache InnoDB checks > bufferpool, etc.. Checks for slow queries and more..

Write your own! http://nagiosplug.sourceforge.net/developer-guidelines.html Quite easy: here a very simple plugin #!/bin/sh mysql -e "SELECT NOW()" -NB -h $1 -u$2 -p$3 2>/dev/null if [ $?!= 0 ]; then echo "Oops!" ; exit 2 # Criticial fi exit 0 # OK shell>./simple.sh cent02.kemuri.net agent cop 2008-09-08 13:37:09 shell>./simple.sh cent02.kemuri.net agent cap Oops!

Write Your Own with Python Email geert@mysql.com for the full version def get_uptime(): global OPTIONS db = MySQLdb.connection(host=OPTIONS['hostname'], user=options['user'],passwd=options['password']) db.query("show GLOBAL STATUS LIKE 'Uptime'") res = db.store_result() row = res.fetch_row(1) return int(row[0][1]) def check_uptime(uptime): global OPTIONS, ERRORS line = 'Uptime %ds' % uptime err = ERRORS['OK'] if uptime < OPTIONS['critical']: err = ERRORS['CRITICAL'] elif uptime < OPTIONS['warning']: err = ERRORS['WARNING'] print line sys.exit(err)

MySQL Enterprise Monitor What is it, and how combining it with Nagios?

MySQL Enterprise Monitor (MEM) Single, consolidated view Auto discovery of MySQL Servers, Replication Topologies Problem Query Detection, Analysis and Tuning New! Customizable rules-based monitoring and alerts Identifies problems before they occur Reduces risk of downtime Easier to scale-out without requiring more DBAs

Advisors/Rules Comparable with Nagios plugins Possible using Nagios plugins making custom Advisors for MEM Can use SNMP Traps

MEM, Nagios and SNMP Using Passive Service Checks Handle SNMP traps > Using traphandle in snmptrapd configuration Nagios and MEM host names must match MEM View Nagios View

MEM, Nagios and SNMP (cont.) Configure snmptrapd to handle MEM traps # Usually /etc/snmp/snmptrapd.conf traphandle default /path/to/handle_mysql_memtrap.sh Setup Nagios define service { use generic-service service_description MEM SNMP Trap hostgroup_name mysql-masters,mysql-slaves register 0 check_command check_no is_volatile 1 max_check_attempts 1 retry_check_interval 1 normal_check_interval 4 active_checks_enabled 0 passive_checks_enabled 1 }

SNMP Handler Script (part 1) Reading SNMP trap information read host read ip while read oid val do val=`expr "$val" : '"\(.*\)"'` vars="$vars;; $oid: $val" case "$oid" in MYSQLTRAP-MIB::advisor.0) hostname=$val ;; MYSQLTRAP-MIB::advisor.1) memstate=$val ;; MYSQLTRAP-MIB::advisor.4) message=$val ;; esac done

SNMP Handler Script (part 2) Translate and send it to Nagios. state=$state_ok case "$memstate" in critical) state=$state_critical ;; warning info success) state=$state_warning ;; esac datetime=`date +%s` cmd="[$datetime] PROCESS_SERVICE_CHECK_RESULT;$hostname; $service;$state;$message" echo $cmd >> $nagioscmdfile

Some Links.. MySQL Enterprise > http://www.mysql.com/products/enterprise/ Nagios documentation > http://nagios.sourceforge.net/docs/2_0/passivechecks.html > http://www.nagios.org/faqs/viewfaq.php?faq_id=29 Email Geert for the handler script

Monitoring MySQL Geert Vanderkelen geert.vanderkelen@sun.com