Monitoring MySQL Performance with Percona Monitoring and - - PowerPoint PPT Presentation

monitoring mysql performance with percona monitoring and
SMART_READER_LITE
LIVE PREVIEW

Monitoring MySQL Performance with Percona Monitoring and - - PowerPoint PPT Presentation

Monitoring MySQL Performance with Percona Monitoring and Management Santa Clara, California | April 23th 25th, 2018 MIchael Coburn, Product Manager Your Presenter Product Manager for PMM (also Percona Toolkit and Percona XtraBackup)


slide-1
SLIDE 1

Santa Clara, California | April 23th – 25th, 2018 MIchael Coburn, Product Manager

Monitoring MySQL Performance with Percona Monitoring and Management

slide-2
SLIDE 2

2

Your Presenter

  • Product Manager for PMM (also Percona Toolkit and Percona

XtraBackup)

  • With Percona for 6 years through 6 different roles
  • Consultant, Managing Consultant, Principal Architect, Technical Account

Manager, Principal Support Engineer

  • http://bit.ly/JoinPerconaLiveSlack

#monitoring-mysql-perf Percona Live App

slide-3
SLIDE 3

3

Agenda

  • Introductions - 1:30pm
  • Part 1 - Installation and Configuration - 1:45pm
  • Break ~3:00pm
  • Part 2 - Query Analytics - 3:15pm
  • Part 3 - Metrics Monitor - 3:45pm
  • Questions - 4:15pm
slide-4
SLIDE 4

4

Goals of Today's Tutorial

  • 1. Understand the components of PMM

○ pmm-client - Client tools & agents you install on each server ○ PMM Server

i. Prometheus, Grafana, Consul, QAN

  • 2. Able to install PMM Server at your site

○ OVF - Open Virtualization Format (VMware, Microsoft Systems Center, Virtualbox) ○ docker ○ AWS Marketplace

  • 3. Review MySQL queries using Query Analytics
  • 4. Analyze MySQL performance using Metrics Monitor
slide-5
SLIDE 5

5

What is PMM

  • Free, Open Source database troubleshooting and performance
  • ptimization platform for MySQL and MongoDB

○ We also support:

■ ProxySQL ■ Amazon RDS MySQL ■ Amazon Aurora MySQL

  • Runs in your secure environment (this is not a SaaS product!), on your

equipment

  • Secured with SSL between client and server
slide-6
SLIDE 6

6

PMM Distribution Methods

  • docker

○ docker pull percona/pmm-server:latest

  • Virtual Appliance

○ Supports VMware, RedHat Virtualization, Microsoft Systems Center ○ … and VirtualBox!

  • AWS Marketplace

○ Production-ready AMI running in EC2 ○ Available since November 2017

slide-7
SLIDE 7

7

AWS Marketplace

  • Deploy directly to EC2
  • Running CentOS 7

Search for "pmm" or "Percona Monitoring and Management" https://aws.amazon.com/marketplace/pp/B077J7FYGX

slide-8
SLIDE 8

8

PMM Architecture

  • pmm-client

○ mysqld_exporter ○ node_exporter ○ qan-agent

  • PMM Server

○ Query Analytics

■ QAN API ■ QAN App

○ Metrics Monitor

■ Prometheus ■ Grafana ■ Consul

slide-9
SLIDE 9

9

PMM Server Components

  • Metrics Monitor

○ Prometheus

■ Timeseries database ■ Powerful PromQL query language

○ Grafana

■ Visualization platform

○ Consul

■ Tracks which services are available to be scraped by Prometheus

  • Query Analytics

○ View query performance in real-time ○ Aggregated for queries consuming most amount of time in MySQL ○ Query drill-down for individual query performance

■ Rows read, Rows scanned, Query time, Query count ■ InnoDB statistics (Percona Server for MySQL only

slide-10
SLIDE 10

10

pmm-client Components

  • pmm-admin

○ Command-line tool for client management

  • node_exporter

○ Agent that exports Linux metrics

  • mysqld_exporter

○ Agent that exports MySQL server metrics

  • qan-agent

○ Agent that collects query metrics from MySQL Slow Log or PERFORMANCE_SCHEMA

slide-11
SLIDE 11

11

Prometheus Data Collection

  • Prometheus server asks Consul for which services & instances to query

○ by IP address and port ○ Example: curl https://192.168.56.3:42000/metrics

  • Prometheus exporter performs data collection upon curl request
  • Exporter generates text exposed via web server at :42002/metrics

[root@ps57r ~]# curl -s -k https://10.91.136.33:42002/metrics-hr |grep mysql | head -8 # HELP mysql_exporter_collector_duration_seconds Collector time duration. # TYPE mysql_exporter_collector_duration_seconds gauge mysql_exporter_collector_duration_seconds{collector="collect.global_status"} 0.019977679 mysql_exporter_collector_duration_seconds{collector="collect.info_schema.innodb_metric s"} 0.006224816 mysql_exporter_collector_duration_seconds{collector="connection"} 2.1584e-05 # HELP mysql_exporter_hr_last_scrape_error Whether the last scrape of metrics from MySQL resulted in an error (1 for error, 0 for success). # TYPE mysql_exporter_hr_last_scrape_error gauge mysql_exporter_hr_last_scrape_error 0

slide-12
SLIDE 12

Part 1

Installation and configuration

slide-13
SLIDE 13

13

Environment Notes

  • Authentication:

○ percona / percona

  • client 192.168.56.3

○ ssh percona@192.168.56.3

  • server 192.168.56.2

○ ssh admin@192.168.56.2

~/.ssh/config Host client User percona HostName 192.168.56.3 IdentityFile ~/.ssh/pmm

slide-14
SLIDE 14

14

PMM Installation Steps

  • High level steps:

○ Import Appliance into VirtualBox ○ Configure VirtualBox Host-Only Networking ○ Validate client and server can communicate ○ Start up sysbench test (optional) ○ Configure pmm-admin to start:

■ linux:metrics ■ mysql:metrics ■ mysql:queries

slide-15
SLIDE 15

15

Configuring VirtualBox

  • Import Appliance

○ File > Import Appliance…

  • Configure Network

○ VirtualBox > Preferences > Network > Host-only Networks

■ Create new host-only network via button on right

○ Adapter

■ Configure IPv4 Address: 192.168.56.1

  • DHCP Server

○ Enable Server

■ Configure Server Address: 192.168.56.1 ■ Configure Lower Address Bound: 192.168.56.2 ■ Configure Upper Address Bound: 192.168.56.10

  • Consider setting Execution Cap

at 50%, 2 cores

○ Per instance

slide-16
SLIDE 16

16

VirtualBox Host Only Network < v5 - OSX

slide-17
SLIDE 17

17

VirtualBox > v5 - Windows

slide-18
SLIDE 18

18

VirtualBox Network Interfaces - OSX

slide-19
SLIDE 19

19

VirtualBox Network Interfaces - Windows

slide-20
SLIDE 20

20

VirtualBox Network Interfaces - Windows

  • Start the two instances via VirtualBox

console

  • Connect using ssh

○ Optional:

■ ssh-agent bash ■ ssh-add ~/.ssh/pmm

○ ssh -l percona 192.168.56.3 ○ [client $] ssh admin@192.168.56.2

  • Ensure the nodes can see each other

○ [percona@client ~]$ ping pmm-server ○ [admin@pmm-server ~]$ ping client

  • Configure pmm-server for correct time

○ [pmm-server $] date --set='TimeFromClient'

~/.ssh/config Host client User percona HostName 192.168.56.3 IdentityFile ~/.ssh/pmm

slide-21
SLIDE 21

21

Starting Sysbench (optional)

  • We use sysbench to generate load in MySQL
  • Start the script:

○ client$ ./sysbench.sh

  • Configuration is for 1 trx/sec of 20 events on a 10k row InnoDB table
slide-22
SLIDE 22

22

Configuring PMM

  • FINALLY!
  • Connect client to pmm-server

○ sudo pmm-admin config --server 192.168.56.2 --server-user percona --server-password percona

  • Start data collection

○ sudo pmm-admin add mysql --create-user --socket /var/lib/mysql/mysql.sock --user percona --password percona ○ Generates a MySQL user account with bare minimum privileges

  • Creates three services

○ pmm-linux-metrics ○ pmm-mysql-metrics ○ pmm-mysql-queries

slide-23
SLIDE 23

23

Confirming it all Works

  • PMM Server: http://192.168.56.2/
  • Prometheus

http://192.168.56.2/prometheus

  • Do they work?
  • Great - take a break!
  • No? Let's Troubleshoot (next slide…)
slide-24
SLIDE 24

24

Troubleshooting PMM

  • Check for any red fields:

○ sudo pmm-admin list ○ sudo pmm-admin check-network

■ Time drift ?

  • pmm-server$ sudo date --set='<TimeFromClient>'
  • Restarting one or all components

○ sudo pmm-admin restart linux:metrics pmm-client ○ sudo pmm-admin restart --all

  • Logs are in /var/log/pmm-*.log
  • Check targets status in Prometheus

○ http://192.168.56.2/prometheus/targets

slide-25
SLIDE 25

25

Confirming IP address of PMM Server

  • Confirm the IP address

the server obtained from DHCP

slide-26
SLIDE 26

26

If all else fails...

  • I have a few PMM Server instances available in EC2:

○ http://13.58.238.204 ○ http://52.14.41.0 ○ http://18.221.240.156 ○ http://18.221.171.225 ○ http://13.58.244.142

  • To obtain a shell:

○ ssh -i ~/.ssh/pmm ec2-user@<IP>

slide-27
SLIDE 27

Break!

We'll resume in 15 minutes

slide-28
SLIDE 28

Using Query Analytics (QAN)

Examining queries in depth

slide-29
SLIDE 29

29

Query Analytics Dashboard

slide-30
SLIDE 30

30

Query Analytics Overview

  • Query Abstract

○ Query pattern with placeholders

  • ID

○ Unique fingerprint, used for query group by

  • Load

○ Grand Total Time - percentage of time that MySQL server spent executing the query

  • Count

○ QPS, total count during window, % of total

  • Latency

○ Min, Med, Avg, P95, Max

slide-31
SLIDE 31

31

PERFORMANCE_SCHEMA

slide-32
SLIDE 32

32

Slow Log - Percona Server Enhanced

slide-33
SLIDE 33

33

EXPLAIN - Table and JSON

slide-34
SLIDE 34

34

CREATE TABLE, TABLE STATUS, and INDEXES

slide-35
SLIDE 35

35

Server Summary Information

  • Collects and displays per Server:

○ pt-summary ○ pt-mysql-summary

  • _PMM System Summary
  • Summary can be downloaded from the UI
slide-36
SLIDE 36

Part 3 - Using Metrics Monitor

Eye candy

slide-37
SLIDE 37

37

Grafana in a Nutshell

  • Open Source data visualisation tool
  • Popular datasources

○ Prometheus ○ CloudWatch ○ Graphite ○ Elasticsearch

  • Templated Variables

○ Define your graph metrics, and let the hosts get filled in automatically ○ GREAT for large, dynamic environments where hosts are considered ephemeral

slide-38
SLIDE 38

38

Prometheus revisited

  • Timeseries database - metric name + key/value pairs

○ mysql_global_variables_innodb_buffer_pool_instances{instance= "ps57",job="mysql"} = 8 ○ mysql_slave_status_slave_io_running{instance="ps57r",job="mys ql",master_host="10.91.136.32",master_uuid="9809315d-4d97-11e 6-b85e-0007cb03dc86"} = 1

  • Flexible query language - PromQL
  • Collection of metrics based on HTTP pull
  • Targets identified via service discovery or static configuration files

○ We're using consul in PMM for service discovery

slide-39
SLIDE 39

39

How can I...

  • Compare servers to each other

○ Cross Server graphs

  • Show behaviour now() compared to past period

○ Trends Overview dashboard

  • At a glance MySQL + indepth

○ MySQL Overview, InnoDB, InnoDB Advanced

  • Table statistics*

○ Largest tables by rows and size, total DB size, tables by rows read and changed, auto_increment usage (about to hit the limit?)

  • User statistics*

○ Top users by connection count, network usage, rows read/changed

slide-40
SLIDE 40

40

Annotations

  • Visualize Application Events in PMM

○ pmm-admin annotate "Application deployment v1.3"

slide-41
SLIDE 41

41

Alerting

  • Alerting

○ Cannot use Templated Variables ○ Instead, replace with string constants for instance name

slide-42
SLIDE 42

Almost the end Parting thoughts

slide-43
SLIDE 43

43

Advice

  • PMM Metrics retention is 30 days

○ We are looking at options to present a longer history

  • mysql:metrics are polled at 1s, 5s, and 60s resolutions, and linux:metrics

is every 1s

○ On high-latency links you might need to tune scrape_interval up

  • Don't skimp on resources

○ Prometheus in particular needs a lot of CPU cores and fast disks, in order to sequence scrape data before writing chunks to disk

  • Consider disabling some mysqld_exporter features to minimise

performance impact

  • -disable-tablestats, --disable-processlist
  • Keep queries in the database (security)

  • -disable-queryexamples
slide-44
SLIDE 44

44

PMM Roadmap

  • Prometheus 2.x - faster, more instances per PMM Server
  • PostgreSQL Support
  • MySQL -> ClickHouse for QAN datastore

○ faster, aggregation across all servers, new filtering and sorting options

  • Long term metrics storage (past 30 days)
  • One-click ticket submission*
  • Standardised data collection for tickets*
  • Any feedback of what you'd like to see in PMM?

* for Percona Subscribers (Customers) only

slide-45
SLIDE 45

45

Thank You Sponsors!!

slide-46
SLIDE 46

46

Questions?

  • Michael Coburn michael.coburn@percona.com
  • Percona is looking for MongoDB and MySQL rockstars! Be sure to stop

by Percona’s booth.

  • Do you have any areas or benchmarks you want Percona to talk about in

blogs together? Any features or tools you think we should focus on to meet the community's needs?

slide-47
SLIDE 47

47

Rate My Session

slide-48
SLIDE 48

Thank You!