MySQL Server Variable Tuning

Published on March 2017 | Categories: Documents | Downloads: 48 | Comments: 0 | Views: 223
of 24
Download PDF   Embed   Report

Comments

Content

www.fromdual.com

MySQL Performance Tuning
DOAG 2013 Datenbank
14. Mai 2013, Düsseldorf
Oli Sennhauser
Senior MySQL Berater, FromDual GmbH

[email protected]

1 / 24

Über FromDual GmbH




www.fromdual.com

FromDual bietet neutral und unabhängig:


Beratung für MySQL



Support für MySQL und Galera Cluster



Remote-DBA Dienstleistungen für MySQL



MySQL Schulungen

Oracle Silver Partner (OPN)
www.fromdual.com

2 / 24

Inhalt

www.fromdual.com

HA Solutions
MySQL
Performance Tuning mit System-Variablen












Performance
Read
scale-out
Tuning Hebel
Replication
MySQL
System
set-up
Variablen
for HA
Active/passive
MySQL
Status Variablen
fail-over
MySQL Architektur
Cluster
Replication Cluster
Speicherbelegung
Storage-Engine-Replication
Session
Variablen
Globale Variablen
MyISAM Variablen
InnoDB Variablen
Monitoring
Informationen

3 / 24

Performance Tuning Hebel

www.fromdual.com

4 / 24

MySQL System Variablen


www.fromdual.com

Datenbank-Konfiguration
my.cnf
mysqld ­­help –verbose
/etc/my.cnf /etc/mysql/my.cnf 
/usr/local/mysql/etc/my.cnf 
$basedir/my.cnf ~/.my.cnf
SHOW GLOBAL VARIABLES;

5 / 24

MySQL Status Variablen


www.fromdual.com

Was wir damit anrichten sieht man mit:
SHOW /*!50001 GLOBAL */ STATUS;
SHOW ENGINE INNODB STATUS\G

6 / 24

MySQL Architektur

www.fromdual.com

Application / Client
Thread
Cache

Connection
Manager
User Authentication

Logging

Command
Dispatcher

Query
Cache

Query Cache
Module

mysqld

Parser

Optimizer
Access Control
Table Manager

Table Open
Cache (.frm, fh)
Table Definition
Cache (tbl def.)

Handler Interface

MyISAM

InnoDB

Memory

NDB

PBXT

Aria

XtraDB

Tokutek

...

7 / 24

Speicherbelegung
Client 1
read_buffer
sort_buffer

Client 2

Client N

read_buffer

read_buffer
sort_buffer
tmp_table

Local Memory Areas

MySQL Server (mysqld)

www.fromdual.com

Storage Engines
key_buffer_size
innodb_buffer_pool_size
innodb_log_buffer_size
etc...

table_open_cache
table_definition_cache
query_cache_size
etc...

Global Memory Area

8 / 24

Thread Cache




www.fromdual.com

Konifguration:
thread_cache_size
Status:
threads_created
+­­­­­­­­­­­­­­­­­­­­­­+­­­­­­­+
| Variable_name        | Value |
+­­­­­­­­­­­­­­­­­­­­­­+­­­­­­­+
| Threads_cached       | 8     |
| Threads_connected    | 242   |
| Threads_created      | 15355 |
| Threads_running      | 16    |
+­­­­­­­­­­­­­­­­­­­­­­+­­­­­­­+

9 / 24

Query Cache

www.fromdual.com



Konfiguration: query_cache_size



Status:
Com_select,
Qcache_hits



Hit ratio:

+­­­­­­­­­­­­­­­­­­­­­­­­­+­­­­­­­­­­+
| Variable_name           | Value    |
+­­­­­­­­­­­­­­­­­­­­­­­­­+­­­­­­­­­­+
| Com_select              | 25712    |
| Qcache_free_memory      | 19553200 |
| Qcache_hits             | 65137    |
| Qcache_inserts          | 172167   |
+­­­­­­­­­­­­­­­­­­­­­­­­­+­­­­­­­­­­+

Qache_hits/(Com_select + Qcache_hits)

10 / 24

Per Session Parameter

www.fromdual.com



Im „Executor“



Alloziert/Dealloziert „on Demand“



Per Session oder global einstellbar



Meisst Effekt gering oder gar kontraproduktiv!



Join Buffer




join_buffer_size

Read Buffer und Read Random Buffer


read_buffer_size, read_rnd_buffer_size

11 / 24

Sort Buffer, temporäre Tabellen

www.fromdual.com



Temporäre Tabellen
(MEMORY oder MyISAM)






Konfiguration: tmp_table_size,
(max_heap_table_size)
Status: created_tmp_tables,
created_tmp_disk_tables

Sort Buffer




Konfiguration:
sort_buffer_size
Status: sort_merge_passes

12 / 24

Table Definition Cache

www.fromdual.com



Ab v5.1



Enthält Info vom .frm File



Konfiguration: table_definition_cache



Status: open_table_definitions, 
opened_table_defintions
+­­­­­­­­­­­­­­­­­­­­­­­­­­+­­­­­­­+
| Variable_name            | Value |
+­­­­­­­­­­­­­­­­­­­­­­­­­­+­­­­­­­+
| Open_table_definitions   | 100   |
| Opened_table_definitions | 100   |
+­­­­­­­­­­­­­­­­­­­­­­­­­­+­­­­­­­+

13 / 24

Table (Open) Cache


www.fromdual.com

Ab v5.1


File-Descriptioren (1 pro Connection pro Table)



Früher table_cache



Konfiguration: table_open_cache



Status: open_tables, opened_tables

+­­­­­­­­­­­­­­­­­­­­­­­­­­+­­­­­­­+
| Variable_name            | Value |
+­­­­­­­­­­­­­­­­­­­­­­­­­­+­­­­­­­+
| Open_tables              | 64    |
| Opened_tables            | 11812 |
+­­­­­­­­­­­­­­­­­­­­­­­­­­+­­­­­­­+

14 / 24

MyISAM


Bis MySQL 5.1 default Storage Engine



Konfiguration: key_buffer_size



www.fromdual.com

Status: Key_blocks_used, 
Key_blocks_unused, Key_reads, 
Key_read_requests

15 / 24

InnoDB Buffer Pool

adaptive hash idx

OS file cache

async

trx log buffer

innodb_buffer_pool_size,
innodb_buffer_pool_instances,
innodb_io_capacity

index pages
undo records
lock info table

buffer pool

sync

Konfiguration:

data pages

secondary index buffer

ib_logfile1



InnoDB Buffer Pool

mysqld

system table space: ibdata1
undo
double write area

ib_logfile2



InnoDB seit 5.5 default Storage Engine

ib_logfilen



www.fromdual.com

dd

tables/indexes

table table space table table space table table space

16 / 24

InnoDB Buffer Pool


www.fromdual.com

Status:
innodb_buffer_pool_pages_%, 
Innodb_buffer_bytes_%,
Innodb_data_%

17 / 24

InnoDB Log File



Status: innodb%log%

index pages
adaptive hash idx
undo records
lock info table

trx log buffer

OS file cache

async

innodb_flush_log_at_trx
_commit

sync

innodb_log_file_size, 

data pages

secondary index buffer

buffer pool

ib_logfile1

Konfiguration:

mysqld

system table space: ibdata1
undo
double write area

ib_logfile2



REDO Log, Transaction
Log

ib_logfilen



www.fromdual.com

dd

tables/indexes

table table space table table space table table space

18 / 24

Binary Log
Application

www.fromdual.com

Application

mysqld

Application
binlog_cache_size
binlog_stmt_cache_size

sync_binlog

bin-log.n

+­­­­­­­­­­­­­­­­­­­­­­­­­­­­+­­­­­­­+
| Variable_name              | Value |
+­­­­­­­­­­­­­­­­­­­­­­­­­­­­+­­­­­­­+
| Binlog_cache_disk_use      | 3456  |
| Binlog_cache_use           | 12786 |
| Binlog_stmt_cache_disk_use | 0     |
| Binlog_stmt_cache_use      | 0     |
+­­­­­­­­­­­­­­­­­­­­­­­­­­­­+­­­­­­­+
19 / 24

Monitoring




www.fromdual.com

Von Hand:


SHOW GLOBAL STATUS;



SHOW ENGINE INNODB STATUS\G



Performance Schema (P_S, >= v5.5)

Irgend ein graphisches Monitoring Tool...

20 / 24

PERFORMANCE_SCHEMA


In Diskussion seit mindestens 2006



Eingeführt in MySQL 5.5 (2010)



www.fromdual.com

→ Einblick in die Datenbank
In v5.5 disabled, in v5.6 enabled per default
performance_schema = 1



Overhead 5% - 200%! → also Vorsicht!

21 / 24

Beispiel: Table I/O waits

www.fromdual.com

SELECT OBJECT_SCHEMA, OBJECT_NAME
     , ROUND(SUM_TIMER_WAIT/1000000000, 3) AS SUM_TIMER_WAIT
     , ROUND(SUM_TIMER_READ/1000000000, 3) AS SUM_TIMER_READ
     , ROUND(SUM_TIMER_WRITE/1000000000, 3) AS SUM_TIMER_WRITE
  FROM table_io_waits_summary_by_table
 ORDER BY SUM_TIMER_WAIT DESC
 LIMIT 10
;
+­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­+
| OBJECT_SCHEMA | OBJECT_NAME  | SUM_TIMER_WAIT | SUM_TIMER_READ | SUM_TIMER_WRITE |
+­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­+
| zabbix        | items        |    1182496.258 |     616630.696 |      565865.562 |
| zabbix        | history_uint |     889884.116 |     370528.991 |      519355.125 |
| zabbix        | history_str  |     460411.155 |     246159.458 |      214251.697 |
| zabbix        | history      |     389815.659 |      86285.980 |      303529.679 |
| zabbix        | trends_uint  |     133955.560 |     107365.626 |       26589.934 |
| zabbix        | functions    |     128657.654 |     128657.654 |           0.000 |
| zabbix        | trends       |      43683.159 |      36314.732 |        7368.428 |
| mpm           | mpm_agent    |      27837.056 |      27837.056 |           0.000 |
| zabbix        | hosts        |      23820.284 |      14044.672 |        9775.612 |
| zabbix        | triggers     |      21052.459 |      20970.604 |          81.855 |
+­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­+

22 / 24

Informationen


www.fromdual.com

MySQL System Variablen:
http://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html



MySQL Status Variablen:
http://dev.mysql.com/doc/refman/5.5/en/server-status-variables.html



MySQL DB Health Check:
http://www.fromdual.com/mysql-database-health-check



MySQL Performance Monitor:
http://www.fromdual.com/mysql-performance-monitor

23 / 24

Q&A

www.fromdual.com

Fragen ?
Diskussion?

Wir haben Zeit für ein Performance Audit...!


FromDual bietet neutral und unabhängig:


Beratung



Remote-DBA



Support für MySQL und Galera Cluster



Schulung

www.fromdual.com/presentations
24 / 24

Sponsor Documents

Or use your account on DocShare.tips

Hide

Forgot your password?

Or register your new account on DocShare.tips

Hide

Lost your password? Please enter your email address. You will receive a link to create a new password.

Back to log-in

Close