MySQL Administration and Monitoring

download MySQL Administration and Monitoring

If you can't read please download the document

Transcript of MySQL Administration and Monitoring

MySQL Administration and
Monitoring

Mark Leith
Senior Software Development Manager @ Oracle

Program Agenda

Basic Command Line Tools

Internal Schemas

Backup / Recovery

GUI Tools

Monitoring

Basic Command Line Tools

Standard MySQL Client Programs

mysqlMySQL command line/shell for SQL statements

mysqladminPerforming administrative operations. You can use it to check the server's configuration and current status, to create and drop databases, and more

mysqlcheckPerforms table maintenance: It checks, repairs, optimizes, or analyzes tables

mysqldumpUsed to export a database(s) for backup or transfer to another server. The dump contains SQL statements to create tables, populate it with data, or both. Can also generate files in CSV, delimited text, or XML format.

mysqlbinlogReplays Binary Logs for Point In Time recovery

mysqlimportCommand-line interface to the LOAD DATA INFILE SQL statement.

http://dev.mysql.com/doc/refman/5.5/en/programs-client.html

Standard MySQL Client Programs Options

--host / -hThe host where the MySQL Instance is running.

--port / -PThe Port that the MySQL Instance is listening on.

--user / -uThe User to connect as.

--password / -pThe Password for the user.

--defaults-fileThe my.cnf/my.ini to use to read options from

http://dev.mysql.com/doc/refman/5.5/en/command-line-options.html

MySQL Startup Programs

mysqldThe MySQL daemon can be used to start directly (but has no keep alive in this mode

mysqld_safeRecommended way to start on Unix. Starts angel process for mysqld daemon.

mysql.serverUsed on systems (Linux and Solaris) that use System V-style run directories to start and stop system services. Also used by Mac OS X

mysqld_multiManage Multiple MySQL Servers running on different ports or sockets, with different data directories

http://dev.mysql.com/doc/refman/5.6/en/programs-server.html

Internal Schemas

mysql

The main system schema (a kind of Data Dictionary)

All user and privilege configuration

Stored programs (Procedures, Functions, Events)

Time Zone information

Also in 5.6InnoDB Table Index Statistics

Replication State

http://dev.mysql.com/doc/refman/5.6/en/grant-table-structure.html

INFORMATION_SCHEMA

ANSI SQL (SQL:2003) general access to database metadata

Tables, indexes, constraints, views, triggers, routines, privileges etc.

Also contains various extensions within MySQLMany of these are runtime metadata

Processlist, system / status variables, InnoDB runtime data

System Views (not real views, not real tables, generated on the fly)

http://dev.mysql.com/doc/refman/5.6/en/information-schema.html

Performance Schema

MySQL's Wait Interface

Instruments various wait eventsFile IO / Table IO / Network IO

Mutexes (Semaphores) / R/W Locks / Conditions

Table Locks

Statements and Stages (connection states of execution)

http://dev.mysql.com/doc/refman/5.6/en/performance-schema.html

Performance Schema Raw Wait Event

mysql> select * from performance_schema.events_waits_history limit 1\G*************************** 1. row *************************** THREAD_ID: 3 EVENT_ID:11 END_EVENT_ID:11 EVENT_NAME: wait/io/file/innodb/innodb_log_file SOURCE: os0file.cc:5542 TIMER_START: 2543370511043700 TIMER_END: 2543370535624100 TIMER_WAIT: 24580400 SPINS: NULL...

Performance Schema Raw Wait Event Cont..

mysql> select * from performance_schema.events_waits_history limit 1\G*************************** 1. row ***************************... OBJECT_SCHEMA: NULL OBJECT_NAME:/Users/mark/sb/msb_5_7_2/data/ib_logfile0 INDEX_NAME: NULL OBJECT_TYPE: FILEOBJECT_INSTANCE_BEGIN: 4771328832 NESTING_EVENT_ID: NULL NESTING_EVENT_TYPE: NULL OPERATION: write NUMBER_OF_BYTES: 512 FLAGS: NULL

Performance Schema Raw Stage Event

mysql> select * from performance_schema.events_stages_history_long limit 1\G*************************** 1. row *************************** THREAD_ID: 25 EVENT_ID: 5199518 END_EVENT_ID: 5199536 EVENT_NAME: stage/sql/System lock SOURCE: lock.cc:304 TIMER_START: 280557566125986000 TIMER_END: 280557566190403000 TIMER_WAIT: 64417000 NESTING_EVENT_ID: 5199509 NESTING_EVENT_TYPE: STATEMENT

Performance Schema Raw Statement Event

mysql> select * from performance_schema.events_statements_history_long limit 1\G*************************** 1. row *************************** THREAD_ID: 24 EVENT_ID: 3923 END_EVENT_ID: 4044 EVENT_NAME: statement/sql/insert_select SOURCE: mysqld.cc:931 TIMER_START: 251016737474892000 TIMER_END: 251016738730372000 TIMER_WAIT: 1255480000 LOCK_TIME: 573000000...

Performance Schema Raw Statement Event

mysql> select * from performance_schema.events_statements_history_long limit 1\G*************************** 1. row ***************************... SQL_TEXT: insert into t2 select * from t1 DIGEST: e6f8db8a3f557ffbb2bf6a7b237cd897 DIGEST_TEXT: INSERT INTO `t2` SELECT * FROM `t1` CURRENT_SCHEMA: test OBJECT_TYPE: NULL OBJECT_SCHEMA: NULL OBJECT_NAME: NULLOBJECT_INSTANCE_BEGIN: NULL...

Performance Schema Raw Statement Event

mysql> select * from performance_schema.events_statements_history_long limit 1\G*************************** 1. row ***************************... MYSQL_ERRNO: 0 RETURNED_SQLSTATE: 00000 MESSAGE_TEXT: Records: 5 Duplicates: 0 Warnings: 0 ERRORS: 0 WARNINGS: 0 ROWS_AFFECTED: 5 ROWS_SENT: 0 ROWS_EXAMINED: 5...

Performance Schema Raw Statement Event

mysql> select * from performance_schema.events_statements_history_long limit 1\G*************************** 1. row ***************************...CREATED_TMP_DISK_TABLES: 0 CREATED_TMP_TABLES: 0 SELECT_FULL_JOIN: 0 SELECT_FULL_RANGE_JOIN: 0 SELECT_RANGE: 0 SELECT_RANGE_CHECK: 0 SELECT_SCAN: 1...

Performance Schema Raw Statement Event

mysql> select * from performance_schema.events_statements_history_long limit 1\G*************************** 1. row ***************************... SORT_MERGE_PASSES: 0 SORT_RANGE: 0 SORT_ROWS: 0 SORT_SCAN: 0 NO_INDEX_USED: 1 NO_GOOD_INDEX_USED: 0 NESTING_EVENT_ID: NULL NESTING_EVENT_TYPE: NULL

Backup / Recovery

MySQL Backup Tools

Cold Backup (Offline, Physical)Simple file copy when instance down

Warm Backup (Locking, Logical)

mysqldump

Standby Copy (Hot swappable)

MySQL Replication

Hot Backup (Online, Physical)

MySQL Enterprise Backup, mysqlbackup

MySQL Backup Tools Cold Backup

Who wants to do this anyway..?

Moving on....

MySQL Backup Tools Warm Backup

Advantages for mysqldumpGood for small databases / tables

Logical, so more flexible and portable

Disadvantages for mysqldumpSingle thread for dump and restore, slow for larger instances

Not online, requires a transaction (for InnoDB) or global lock (for all other non-transactional tables)

Not incremental (needs binary logs as well, complex recovery)

MySQL Backup Tools Hot Standby

Advantages for MySQL ReplicationRolling snapshot

Very quick failover

Standby can be used for other backup types

Disadvantages for MySQL ReplicationOnly latest point in time (can use delayed replication with 5.6)

Not incremental (needs binary logs as well, complex recovery)

Can't archive (offsite, though can have an offsite standby)

MySQL Backup Tools Hot Backup

Advantages for MySQL Enterprise BackupPhysical Backup, so very quick (especially restore)

Ties in natively with Oracle Secure Backup to Tape (SBT)

Multi-Thread for Performance

Incremental Backups available

Compression Built-In

Disadvantages for MySQL Enterprise BackupNo logical option (good to have a periodic mysqldump too)

GUI Tools

MySQL Workbench

General purpose DBA / Developer ToolMySQL Instance Administration

SQL Development

Data Modeling

Commercial ExtensionsAudit Log Inspection

Hot Backup

MySQL Workbench Instance Overview

MySQL Workbench Current Connections

MySQL Workbench User Management

MySQL Workbench Config Management

MySQL Workbench Modeling

MySQL Workbench Online Backup

Monitoring

MySQL Enterprise Monitor

Distributed Monitoring for MySQL Environments

Intelligent analysis of key metrics / configuration

Historical reporting

Query Analysis

MEM Overview Dashboard

MEM - Advisors

MEM - Advisors

MEM - Events

MEM Event Details

MEM Timeseries Graphs

MEM Query Analysis Overview

MEM Query Analysis Query Details

Questions?

Copyright 2013, Oracle and/or its affiliates. All rights reserved.

Insert Information Protection Policy Classification from Slide 12 of the corporate presentation template

Copyright 2013, Oracle and/or its affiliates. All rights reserved.

Insert Information Protection Policy Classification from Slide 12 of the corporate presentation template

Insert Picture Here

Click to edit the title text formatClick to edit title

Click to edit the outline text formatSecond Outline LevelThird Outline LevelFourth Outline LevelFifth Outline LevelSixth Outline LevelSeventh Outline LevelEighth Outline Level

Ninth Outline LevelClick to edit Master text styles

Copyright 2013, Oracle and/or its affiliates. All rights reserved.

Insert Information Protection Policy Classification from Slide 12 of the corporate presentation template

Click to edit the title text formatClick to edit Master title style

Click to edit the outline text formatSecond Outline LevelThird Outline LevelFourth Outline LevelFifth Outline LevelSixth Outline LevelSeventh Outline LevelEighth Outline Level

Ninth Outline LevelClick to edit Master text styles

Copyright 2013, Oracle and/or its affiliates. All rights reserved.

Insert Information Protection Policy Classification from Slide 12 of the corporate presentation template

Click to edit the title text formatClick to edit Master title style

Click to edit the outline text formatSecond Outline LevelThird Outline LevelFourth Outline LevelFifth Outline LevelSixth Outline LevelSeventh Outline LevelEighth Outline Level

Ninth Outline LevelClick to edit Master text styles

Second level

Third level

Fourth level

Click to edit the outline text formatSecond Outline LevelThird Outline LevelFourth Outline LevelFifth Outline LevelSixth Outline LevelSeventh Outline LevelEighth Outline Level

Ninth Outline LevelClick to edit Master text styles

Copyright 2013, Oracle and/or its affiliates. All rights reserved.

Insert Information Protection Policy Classification from Slide 12 of the corporate presentation template

Click to edit the title text formatClick to edit Master title style

Click to edit the outline text formatSecond Outline LevelThird Outline LevelFourth Outline LevelFifth Outline LevelSixth Outline LevelSeventh Outline LevelEighth Outline Level

Ninth Outline LevelClick to edit Master text styles

Second level

Third level

Fourth level

Click to edit the outline text formatSecond Outline LevelThird Outline LevelFourth Outline LevelFifth Outline LevelSixth Outline LevelSeventh Outline LevelEighth Outline Level

Ninth Outline LevelClick to edit Master text styles

Copyright 2013, Oracle and/or its affiliates. All rights reserved.

Insert Information Protection Policy Classification from Slide 12 of the corporate presentation template

Click to edit the title text formatClick to edit text

Copyright 2013, Oracle and/or its affiliates. All rights reserved.

Insert Information Protection Policy Classification from Slide 12 of the corporate presentation template

Click to edit the title text formatClick to edit text

Insert Picture Here

Copyright 2013, Oracle and/or its affiliates. All rights reserved.

Insert Information Protection Policy Classification from Slide 12 of the corporate presentation template

Click to edit the outline text formatSecond Outline LevelThird Outline LevelFourth Outline LevelFifth Outline LevelSixth Outline LevelSeventh Outline LevelEighth Outline Level

Ninth Outline LevelCLICK TO EDIT
MASTER TEXT

Insert Picture Here

Copyright 2013, Oracle and/or its affiliates. All rights reserved.

Insert Information Protection Policy Classification from Slide 12 of the corporate presentation template

Click to edit the outline text formatSecond Outline LevelThird Outline LevelFourth Outline LevelFifth Outline LevelSixth Outline LevelSeventh Outline LevelEighth Outline Level

Ninth Outline LevelClick to edit Master text styles

Click to edit the title text formatClick to edit Master title style

Insert Picture Here

Copyright 2013, Oracle and/or its affiliates. All rights reserved.

Insert Information Protection Policy Classification from Slide 12 of the corporate presentation template

Insert Picture HereClick to edit the outline text formatSecond Outline LevelThird Outline LevelFourth Outline LevelFifth Outline LevelSixth Outline LevelSeventh Outline LevelEighth Outline Level

Ninth Outline LevelClick to edit Master text styles

Click to edit the outline text formatSecond Outline LevelThird Outline LevelFourth Outline LevelFifth Outline LevelSixth Outline LevelSeventh Outline LevelEighth Outline Level

Ninth Outline LevelMaster Text

Click to edit the title text formatClick to edit Master title style

Copyright 2013, Oracle and/or its affiliates. All rights reserved.

Insert Information Protection Policy Classification from Slide 12 of the corporate presentation template

Click to edit the outline text formatSecond Outline LevelThird Outline LevelFourth Outline LevelFifth Outline LevelSixth Outline LevelSeventh Outline LevelEighth Outline Level

Ninth Outline LevelClick to edit Master text styles

Click to edit the outline text formatSecond Outline LevelThird Outline LevelFourth Outline LevelFifth Outline LevelSixth Outline LevelSeventh Outline LevelEighth Outline Level

Ninth Outline LevelClick to edit name

Click to edit the outline text formatSecond Outline LevelThird Outline LevelFourth Outline LevelFifth Outline LevelSixth Outline LevelSeventh Outline LevelEighth Outline Level

Ninth Outline LevelClick to edit title

Copyright 2013, Oracle and/or its affiliates. All rights reserved.

Insert Information Protection Policy Classification from Slide 12 of the corporate presentation template

Click to edit the outline text formatSecond Outline LevelThird Outline LevelFourth Outline LevelFifth Outline LevelSixth Outline LevelSeventh Outline LevelEighth Outline Level

Ninth Outline LevelClick to edit Master text stylesSecond level

Insert Chart HereClick to edit the title text formatClick to edit Master title style

Copyright 2013, Oracle and/or its affiliates. All rights reserved.

Insert Information Protection Policy Classification from Slide 12 of the corporate presentation template