SlideShare a Scribd company logo
Geert Vanderkelen
MySQL Senior Support Engineer
Sun Microsystems
Monitoring MySQL
Copyright © 2008 Sun Microsystems, Inc.
Agenda
• Short intro into MySQL, the company
• Monitoring MySQL: some examples
• Nagios plugins for MySQL
• MySQL Enterprise Monitor
Copyright © 2008 Sun Microsystems, Inc.
From MySQL
to Sun
Whoohoo!
Copyright © 2008 Sun Microsystems, Inc.
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!
Copyright © 2008 Sun Microsystems, Inc.
Monitoring MySQL
Basics and Some examples..
Copyright © 2008 Sun Microsystems, Inc.
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
Copyright © 2008 Sun Microsystems, Inc.
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
Copyright © 2008 Sun Microsystems, Inc.
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
Copyright © 2008 Sun Microsystems, Inc.
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';
Copyright © 2008 Sun Microsystems, Inc.
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 |
+---------------------+--------+
Copyright © 2008 Sun Microsystems, Inc.
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 |
+-------------------+
Copyright © 2008 Sun Microsystems, Inc.
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%
Copyright © 2008 Sun Microsystems, Inc.
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)
Copyright © 2008 Sun Microsystems, Inc.
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
Copyright © 2008 Sun Microsystems, Inc.
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.
Copyright © 2008 Sun Microsystems, Inc.
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)
Copyright © 2008 Sun Microsystems, Inc.
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 |
+------------------+-----------+
Copyright © 2008 Sun Microsystems, Inc.
Slave status
mysql> SHOW SLAVE STATUSG
..
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:
Copyright © 2008 Sun Microsystems, Inc.
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
Copyright © 2008 Sun Microsystems, Inc.
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)
Copyright © 2008 Sun Microsystems, Inc.
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/
Copyright © 2008 Sun Microsystems, Inc.
Nagios + MySQL
Monitoring MySQL with Nagios
Copyright © 2008 Sun Microsystems, Inc.
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
}
Copyright © 2008 Sun Microsystems, Inc.
Configuration tips (2)
• Secure your setup: SSL or SSH
• Don’t use MySQL root user for checks
• Could use NRPE (Nagios add-on)
Copyright © 2008 Sun Microsystems, Inc.
Some plugins..
• Oli Sennhauser
> http://www.shinguz.ch/MySQL/mysql_monitoring.html
Copyright © 2008 Sun Microsystems, Inc.
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..
Copyright © 2008 Sun Microsystems, Inc.
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!
Copyright © 2008 Sun Microsystems, Inc.
Write Your Own with Python
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)
• Email geert@mysql.com for the full version
Copyright © 2008 Sun Microsystems, Inc.
MySQL Enterprise Monitor
What is it, and how combining it with Nagios?
Copyright © 2008 Sun Microsystems, Inc.
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
Copyright © 2008 Sun Microsystems, Inc.
Copyright © 2008 Sun Microsystems, Inc.
Advisors/Rules
• Comparable with Nagios plugins
• Possible using Nagios plugins making custom
Advisors for MEM
• Can use SNMP Traps
Copyright © 2008 Sun Microsystems, Inc.
MEM, Nagios and SNMP
• Using Passive Service Checks
• Handle SNMP traps
> Using traphandle in snmptrapd configuration
• Nagios and MEM host names must match
MEMView
NagiosView
Copyright © 2008 Sun Microsystems, Inc.
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
}
Copyright © 2008 Sun Microsystems, Inc.
SNMP Handler Script (part 1)
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
• Reading SNMP trap information
Copyright © 2008 Sun Microsystems, Inc.
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
Copyright © 2008 Sun Microsystems, Inc.
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
Ad

More Related Content

What's hot (20)

Using Apache Spark and MySQL for Data Analysis
Using Apache Spark and MySQL for Data AnalysisUsing Apache Spark and MySQL for Data Analysis
Using Apache Spark and MySQL for Data Analysis
Sveta Smirnova
 
Introducing new SQL syntax and improving performance with preparse Query Rewr...
Introducing new SQL syntax and improving performance with preparse Query Rewr...Introducing new SQL syntax and improving performance with preparse Query Rewr...
Introducing new SQL syntax and improving performance with preparse Query Rewr...
Sveta Smirnova
 
Lab 1 my sql tutorial
Lab 1 my sql tutorial Lab 1 my sql tutorial
Lab 1 my sql tutorial
Manuel Contreras
 
Memcached Functions For My Sql Seemless Caching In My Sql
Memcached Functions For My Sql Seemless Caching In My SqlMemcached Functions For My Sql Seemless Caching In My Sql
Memcached Functions For My Sql Seemless Caching In My Sql
MySQLConference
 
Managing MariaDB Server operations with Percona Toolkit
Managing MariaDB Server operations with Percona ToolkitManaging MariaDB Server operations with Percona Toolkit
Managing MariaDB Server operations with Percona Toolkit
Sveta Smirnova
 
제 6회 엑셈 수요 세미나 자료 연구컨텐츠팀
제 6회 엑셈 수요 세미나 자료 연구컨텐츠팀제 6회 엑셈 수요 세미나 자료 연구컨텐츠팀
제 6회 엑셈 수요 세미나 자료 연구컨텐츠팀
EXEM
 
Performance schema 설정
Performance schema 설정Performance schema 설정
Performance schema 설정
EXEM
 
New features in Performance Schema 5.7 in action
New features in Performance Schema 5.7 in actionNew features in Performance Schema 5.7 in action
New features in Performance Schema 5.7 in action
Sveta Smirnova
 
Basic MySQL Troubleshooting for Oracle Database Administrators
Basic MySQL Troubleshooting for Oracle Database AdministratorsBasic MySQL Troubleshooting for Oracle Database Administrators
Basic MySQL Troubleshooting for Oracle Database Administrators
Sveta Smirnova
 
MySQLinsanity
MySQLinsanityMySQLinsanity
MySQLinsanity
Stanley Huang
 
Why Use EXPLAIN FORMAT=JSON?
 Why Use EXPLAIN FORMAT=JSON?  Why Use EXPLAIN FORMAT=JSON?
Why Use EXPLAIN FORMAT=JSON?
Sveta Smirnova
 
Introduction into MySQL Query Tuning
Introduction into MySQL Query TuningIntroduction into MySQL Query Tuning
Introduction into MySQL Query Tuning
Sveta Smirnova
 
Second Step to the NoSQL Side: MySQL JSON Functions
Second Step to the NoSQL Side: MySQL JSON FunctionsSecond Step to the NoSQL Side: MySQL JSON Functions
Second Step to the NoSQL Side: MySQL JSON Functions
Sveta Smirnova
 
My sql failover test using orchestrator
My sql failover test  using orchestratorMy sql failover test  using orchestrator
My sql failover test using orchestrator
YoungHeon (Roy) Kim
 
Performance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingPerformance Schema for MySQL Troubleshooting
Performance Schema for MySQL Troubleshooting
Sveta Smirnova
 
Troubleshooting MySQL Performance
Troubleshooting MySQL PerformanceTroubleshooting MySQL Performance
Troubleshooting MySQL Performance
Sveta Smirnova
 
Amazon aurora 1
Amazon aurora 1Amazon aurora 1
Amazon aurora 1
EXEM
 
Performance Schema for MySQL Troubleshooting
 Performance Schema for MySQL Troubleshooting Performance Schema for MySQL Troubleshooting
Performance Schema for MySQL Troubleshooting
Sveta Smirnova
 
Curso de MySQL 5.7
Curso de MySQL 5.7Curso de MySQL 5.7
Curso de MySQL 5.7
Eduardo Legatti
 
Introduction to MySQL InnoDB Cluster
Introduction to MySQL InnoDB ClusterIntroduction to MySQL InnoDB Cluster
Introduction to MySQL InnoDB Cluster
I Goo Lee
 
Using Apache Spark and MySQL for Data Analysis
Using Apache Spark and MySQL for Data AnalysisUsing Apache Spark and MySQL for Data Analysis
Using Apache Spark and MySQL for Data Analysis
Sveta Smirnova
 
Introducing new SQL syntax and improving performance with preparse Query Rewr...
Introducing new SQL syntax and improving performance with preparse Query Rewr...Introducing new SQL syntax and improving performance with preparse Query Rewr...
Introducing new SQL syntax and improving performance with preparse Query Rewr...
Sveta Smirnova
 
Memcached Functions For My Sql Seemless Caching In My Sql
Memcached Functions For My Sql Seemless Caching In My SqlMemcached Functions For My Sql Seemless Caching In My Sql
Memcached Functions For My Sql Seemless Caching In My Sql
MySQLConference
 
Managing MariaDB Server operations with Percona Toolkit
Managing MariaDB Server operations with Percona ToolkitManaging MariaDB Server operations with Percona Toolkit
Managing MariaDB Server operations with Percona Toolkit
Sveta Smirnova
 
제 6회 엑셈 수요 세미나 자료 연구컨텐츠팀
제 6회 엑셈 수요 세미나 자료 연구컨텐츠팀제 6회 엑셈 수요 세미나 자료 연구컨텐츠팀
제 6회 엑셈 수요 세미나 자료 연구컨텐츠팀
EXEM
 
Performance schema 설정
Performance schema 설정Performance schema 설정
Performance schema 설정
EXEM
 
New features in Performance Schema 5.7 in action
New features in Performance Schema 5.7 in actionNew features in Performance Schema 5.7 in action
New features in Performance Schema 5.7 in action
Sveta Smirnova
 
Basic MySQL Troubleshooting for Oracle Database Administrators
Basic MySQL Troubleshooting for Oracle Database AdministratorsBasic MySQL Troubleshooting for Oracle Database Administrators
Basic MySQL Troubleshooting for Oracle Database Administrators
Sveta Smirnova
 
Why Use EXPLAIN FORMAT=JSON?
 Why Use EXPLAIN FORMAT=JSON?  Why Use EXPLAIN FORMAT=JSON?
Why Use EXPLAIN FORMAT=JSON?
Sveta Smirnova
 
Introduction into MySQL Query Tuning
Introduction into MySQL Query TuningIntroduction into MySQL Query Tuning
Introduction into MySQL Query Tuning
Sveta Smirnova
 
Second Step to the NoSQL Side: MySQL JSON Functions
Second Step to the NoSQL Side: MySQL JSON FunctionsSecond Step to the NoSQL Side: MySQL JSON Functions
Second Step to the NoSQL Side: MySQL JSON Functions
Sveta Smirnova
 
My sql failover test using orchestrator
My sql failover test  using orchestratorMy sql failover test  using orchestrator
My sql failover test using orchestrator
YoungHeon (Roy) Kim
 
Performance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingPerformance Schema for MySQL Troubleshooting
Performance Schema for MySQL Troubleshooting
Sveta Smirnova
 
Troubleshooting MySQL Performance
Troubleshooting MySQL PerformanceTroubleshooting MySQL Performance
Troubleshooting MySQL Performance
Sveta Smirnova
 
Amazon aurora 1
Amazon aurora 1Amazon aurora 1
Amazon aurora 1
EXEM
 
Performance Schema for MySQL Troubleshooting
 Performance Schema for MySQL Troubleshooting Performance Schema for MySQL Troubleshooting
Performance Schema for MySQL Troubleshooting
Sveta Smirnova
 
Introduction to MySQL InnoDB Cluster
Introduction to MySQL InnoDB ClusterIntroduction to MySQL InnoDB Cluster
Introduction to MySQL InnoDB Cluster
I Goo Lee
 

Similar to OSMC 2008 | Monitoring MySQL by Geert Vanderkelen (20)

Instalar MySQL CentOS
Instalar MySQL CentOSInstalar MySQL CentOS
Instalar MySQL CentOS
Moisés Elías Araya
 
Percona Live 2019 - MySQL Security
Percona Live 2019 - MySQL SecurityPercona Live 2019 - MySQL Security
Percona Live 2019 - MySQL Security
Vinicius M Grippa
 
MySQL Performance Schema in 20 Minutes
 MySQL Performance Schema in 20 Minutes MySQL Performance Schema in 20 Minutes
MySQL Performance Schema in 20 Minutes
Sveta Smirnova
 
Fluentd 20150918 no_demo_public
Fluentd 20150918 no_demo_publicFluentd 20150918 no_demo_public
Fluentd 20150918 no_demo_public
Saewoong Lee
 
Confoo 2021 -- MySQL New Features
Confoo 2021 -- MySQL New FeaturesConfoo 2021 -- MySQL New Features
Confoo 2021 -- MySQL New Features
Dave Stokes
 
MySQL Best Practices - OTN
MySQL Best Practices - OTNMySQL Best Practices - OTN
MySQL Best Practices - OTN
Ronald Bradford
 
Drizzle to MySQL, Stress Free Migration
Drizzle to MySQL, Stress Free MigrationDrizzle to MySQL, Stress Free Migration
Drizzle to MySQL, Stress Free Migration
Andrew Hutchings
 
My sql 5.7-upcoming-changes-v2
My sql 5.7-upcoming-changes-v2My sql 5.7-upcoming-changes-v2
My sql 5.7-upcoming-changes-v2
Morgan Tocker
 
Advanced Query Optimizer Tuning and Analysis
Advanced Query Optimizer Tuning and AnalysisAdvanced Query Optimizer Tuning and Analysis
Advanced Query Optimizer Tuning and Analysis
MYXPLAIN
 
Perf Tuning Short
Perf Tuning ShortPerf Tuning Short
Perf Tuning Short
Ligaya Turmelle
 
Performance schema and sys schema
Performance schema and sys schemaPerformance schema and sys schema
Performance schema and sys schema
Mark Leith
 
Mysql tracing
Mysql tracingMysql tracing
Mysql tracing
Anis Berejeb
 
Mysql tracing
Mysql tracingMysql tracing
Mysql tracing
Anis Berejeb
 
ProxySQL & PXC(Query routing and Failover Test)
ProxySQL & PXC(Query routing and Failover Test)ProxySQL & PXC(Query routing and Failover Test)
ProxySQL & PXC(Query routing and Failover Test)
YoungHeon (Roy) Kim
 
2012 09 MariaDB Boston Meetup - MariaDB 是 Mysql 的替代者吗
2012 09 MariaDB Boston Meetup - MariaDB 是 Mysql 的替代者吗2012 09 MariaDB Boston Meetup - MariaDB 是 Mysql 的替代者吗
2012 09 MariaDB Boston Meetup - MariaDB 是 Mysql 的替代者吗
YUCHENG HU
 
Build your own private openstack cloud
Build your own private openstack cloudBuild your own private openstack cloud
Build your own private openstack cloud
NUTC, imac
 
Query Optimization with MySQL 5.7 and MariaDB 10: Even newer tricks
Query Optimization with MySQL 5.7 and MariaDB 10: Even newer tricksQuery Optimization with MySQL 5.7 and MariaDB 10: Even newer tricks
Query Optimization with MySQL 5.7 and MariaDB 10: Even newer tricks
Jaime Crespo
 
MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)
MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)
MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)
Valeriy Kravchuk
 
MySQL Idiosyncrasies That Bite SF
MySQL Idiosyncrasies That Bite SFMySQL Idiosyncrasies That Bite SF
MySQL Idiosyncrasies That Bite SF
Ronald Bradford
 
How to Avoid Pitfalls in Schema Upgrade with Galera
How to Avoid Pitfalls in Schema Upgrade with GaleraHow to Avoid Pitfalls in Schema Upgrade with Galera
How to Avoid Pitfalls in Schema Upgrade with Galera
Sveta Smirnova
 
Percona Live 2019 - MySQL Security
Percona Live 2019 - MySQL SecurityPercona Live 2019 - MySQL Security
Percona Live 2019 - MySQL Security
Vinicius M Grippa
 
MySQL Performance Schema in 20 Minutes
 MySQL Performance Schema in 20 Minutes MySQL Performance Schema in 20 Minutes
MySQL Performance Schema in 20 Minutes
Sveta Smirnova
 
Fluentd 20150918 no_demo_public
Fluentd 20150918 no_demo_publicFluentd 20150918 no_demo_public
Fluentd 20150918 no_demo_public
Saewoong Lee
 
Confoo 2021 -- MySQL New Features
Confoo 2021 -- MySQL New FeaturesConfoo 2021 -- MySQL New Features
Confoo 2021 -- MySQL New Features
Dave Stokes
 
MySQL Best Practices - OTN
MySQL Best Practices - OTNMySQL Best Practices - OTN
MySQL Best Practices - OTN
Ronald Bradford
 
Drizzle to MySQL, Stress Free Migration
Drizzle to MySQL, Stress Free MigrationDrizzle to MySQL, Stress Free Migration
Drizzle to MySQL, Stress Free Migration
Andrew Hutchings
 
My sql 5.7-upcoming-changes-v2
My sql 5.7-upcoming-changes-v2My sql 5.7-upcoming-changes-v2
My sql 5.7-upcoming-changes-v2
Morgan Tocker
 
Advanced Query Optimizer Tuning and Analysis
Advanced Query Optimizer Tuning and AnalysisAdvanced Query Optimizer Tuning and Analysis
Advanced Query Optimizer Tuning and Analysis
MYXPLAIN
 
Performance schema and sys schema
Performance schema and sys schemaPerformance schema and sys schema
Performance schema and sys schema
Mark Leith
 
ProxySQL & PXC(Query routing and Failover Test)
ProxySQL & PXC(Query routing and Failover Test)ProxySQL & PXC(Query routing and Failover Test)
ProxySQL & PXC(Query routing and Failover Test)
YoungHeon (Roy) Kim
 
2012 09 MariaDB Boston Meetup - MariaDB 是 Mysql 的替代者吗
2012 09 MariaDB Boston Meetup - MariaDB 是 Mysql 的替代者吗2012 09 MariaDB Boston Meetup - MariaDB 是 Mysql 的替代者吗
2012 09 MariaDB Boston Meetup - MariaDB 是 Mysql 的替代者吗
YUCHENG HU
 
Build your own private openstack cloud
Build your own private openstack cloudBuild your own private openstack cloud
Build your own private openstack cloud
NUTC, imac
 
Query Optimization with MySQL 5.7 and MariaDB 10: Even newer tricks
Query Optimization with MySQL 5.7 and MariaDB 10: Even newer tricksQuery Optimization with MySQL 5.7 and MariaDB 10: Even newer tricks
Query Optimization with MySQL 5.7 and MariaDB 10: Even newer tricks
Jaime Crespo
 
MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)
MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)
MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)
Valeriy Kravchuk
 
MySQL Idiosyncrasies That Bite SF
MySQL Idiosyncrasies That Bite SFMySQL Idiosyncrasies That Bite SF
MySQL Idiosyncrasies That Bite SF
Ronald Bradford
 
How to Avoid Pitfalls in Schema Upgrade with Galera
How to Avoid Pitfalls in Schema Upgrade with GaleraHow to Avoid Pitfalls in Schema Upgrade with Galera
How to Avoid Pitfalls in Schema Upgrade with Galera
Sveta Smirnova
 
Ad

Recently uploaded (20)

Landscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature ReviewLandscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature Review
Hironori Washizaki
 
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
steaveroggers
 
Expand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchangeExpand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchange
Fexle Services Pvt. Ltd.
 
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and CollaborateMeet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Maxim Salnikov
 
Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)
Allon Mureinik
 
How can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptxHow can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptx
laravinson24
 
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
ssuserb14185
 
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Ranjan Baisak
 
Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]
saniaaftab72555
 
WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)
sh607827
 
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Lionel Briand
 
Adobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest VersionAdobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest Version
kashifyounis067
 
Top 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docxTop 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docx
Portli
 
Revolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptxRevolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptx
nidhisingh691197
 
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
University of Hawai‘i at Mānoa
 
The Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdfThe Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdf
drewplanas10
 
EASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License CodeEASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License Code
aneelaramzan63
 
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& ConsiderationsDesigning AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Dinusha Kumarasiri
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025
kashifyounis067
 
Landscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature ReviewLandscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature Review
Hironori Washizaki
 
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
steaveroggers
 
Expand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchangeExpand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchange
Fexle Services Pvt. Ltd.
 
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and CollaborateMeet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Maxim Salnikov
 
Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)
Allon Mureinik
 
How can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptxHow can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptx
laravinson24
 
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
ssuserb14185
 
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Ranjan Baisak
 
Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]
saniaaftab72555
 
WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)
sh607827
 
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Lionel Briand
 
Adobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest VersionAdobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest Version
kashifyounis067
 
Top 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docxTop 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docx
Portli
 
Revolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptxRevolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptx
nidhisingh691197
 
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
University of Hawai‘i at Mānoa
 
The Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdfThe Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdf
drewplanas10
 
EASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License CodeEASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License Code
aneelaramzan63
 
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& ConsiderationsDesigning AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Dinusha Kumarasiri
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025
kashifyounis067
 
Ad

OSMC 2008 | Monitoring MySQL by Geert Vanderkelen

  • 1. Geert Vanderkelen MySQL Senior Support Engineer Sun Microsystems Monitoring MySQL
  • 2. Copyright © 2008 Sun Microsystems, Inc. Agenda • Short intro into MySQL, the company • Monitoring MySQL: some examples • Nagios plugins for MySQL • MySQL Enterprise Monitor
  • 3. Copyright © 2008 Sun Microsystems, Inc. From MySQL to Sun Whoohoo!
  • 4. Copyright © 2008 Sun Microsystems, Inc. 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!
  • 5. Copyright © 2008 Sun Microsystems, Inc. Monitoring MySQL Basics and Some examples..
  • 6. Copyright © 2008 Sun Microsystems, Inc. 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
  • 7. Copyright © 2008 Sun Microsystems, Inc. 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
  • 8. Copyright © 2008 Sun Microsystems, Inc. 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
  • 9. Copyright © 2008 Sun Microsystems, Inc. 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';
  • 10. Copyright © 2008 Sun Microsystems, Inc. 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 | +---------------------+--------+
  • 11. Copyright © 2008 Sun Microsystems, Inc. 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 | +-------------------+
  • 12. Copyright © 2008 Sun Microsystems, Inc. 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%
  • 13. Copyright © 2008 Sun Microsystems, Inc. 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)
  • 14. Copyright © 2008 Sun Microsystems, Inc. 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
  • 15. Copyright © 2008 Sun Microsystems, Inc. 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.
  • 16. Copyright © 2008 Sun Microsystems, Inc. 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)
  • 17. Copyright © 2008 Sun Microsystems, Inc. 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 | +------------------+-----------+
  • 18. Copyright © 2008 Sun Microsystems, Inc. Slave status mysql> SHOW SLAVE STATUSG .. 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:
  • 19. Copyright © 2008 Sun Microsystems, Inc. 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
  • 20. Copyright © 2008 Sun Microsystems, Inc. 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)
  • 21. Copyright © 2008 Sun Microsystems, Inc. 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/
  • 22. Copyright © 2008 Sun Microsystems, Inc. Nagios + MySQL Monitoring MySQL with Nagios
  • 23. Copyright © 2008 Sun Microsystems, Inc. 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 }
  • 24. Copyright © 2008 Sun Microsystems, Inc. Configuration tips (2) • Secure your setup: SSL or SSH • Don’t use MySQL root user for checks • Could use NRPE (Nagios add-on)
  • 25. Copyright © 2008 Sun Microsystems, Inc. Some plugins.. • Oli Sennhauser > http://www.shinguz.ch/MySQL/mysql_monitoring.html
  • 26. Copyright © 2008 Sun Microsystems, Inc. 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..
  • 27. Copyright © 2008 Sun Microsystems, Inc. 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!
  • 28. Copyright © 2008 Sun Microsystems, Inc. Write Your Own with Python 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) • Email [email protected] for the full version
  • 29. Copyright © 2008 Sun Microsystems, Inc. MySQL Enterprise Monitor What is it, and how combining it with Nagios?
  • 30. Copyright © 2008 Sun Microsystems, Inc. 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
  • 31. Copyright © 2008 Sun Microsystems, Inc.
  • 32. Copyright © 2008 Sun Microsystems, Inc. Advisors/Rules • Comparable with Nagios plugins • Possible using Nagios plugins making custom Advisors for MEM • Can use SNMP Traps
  • 33. Copyright © 2008 Sun Microsystems, Inc. MEM, Nagios and SNMP • Using Passive Service Checks • Handle SNMP traps > Using traphandle in snmptrapd configuration • Nagios and MEM host names must match MEMView NagiosView
  • 34. Copyright © 2008 Sun Microsystems, Inc. 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 }
  • 35. Copyright © 2008 Sun Microsystems, Inc. SNMP Handler Script (part 1) 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 • Reading SNMP trap information
  • 36. Copyright © 2008 Sun Microsystems, Inc. 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
  • 37. Copyright © 2008 Sun Microsystems, Inc. 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