Top Banner
Running MySQL on AWS Michael Coburn Wednesday, April 15th, 2015
23

Running MySQL on AWS - Percona€¦ · Running MySQL on AWS Michael Coburn ... you launch and instance of Linux and install MySQL as if it were a regular server

May 28, 2018

Download

Documents

buikhanh
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Running MySQL on AWS - Percona€¦ · Running MySQL on AWS Michael Coburn ... you launch and instance of Linux and install MySQL as if it were a regular server

Running MySQL on AWS

Michael Coburn Wednesday, April 15th, 2015

Page 2: Running MySQL on AWS - Percona€¦ · Running MySQL on AWS Michael Coburn ... you launch and instance of Linux and install MySQL as if it were a regular server

Who am I?

• Senior Architect with Percona • 3 years on Friday!

• Canadian but I now live in Costa Rica • I see 3-10 different customer

environments per week, about 50% are now AWS based

2

Page 3: Running MySQL on AWS - Percona€¦ · Running MySQL on AWS Michael Coburn ... you launch and instance of Linux and install MySQL as if it were a regular server

Introduction

• There is a lot of Alphabet Soup in this talk • Intention is to de-mystify running MySQL

in the “cloud” using AWS

3

Page 4: Running MySQL on AWS - Percona€¦ · Running MySQL on AWS Michael Coburn ... you launch and instance of Linux and install MySQL as if it were a regular server

What is AWS

• Acronym for Amazon Web Services • A division of amazon.com (the book retailer) • Operates as a set of connected services • EVERYTHING IS A SERVICE!

• Fun fact: AWS came to be first to support amazon.com until they realised this concept could be monetised

4

Page 5: Running MySQL on AWS - Percona€¦ · Running MySQL on AWS Michael Coburn ... you launch and instance of Linux and install MySQL as if it were a regular server

What is Virtualisation?

• To virtualise: the act of separating the guest OS from the physical server's hardware

• The guest OS can be Linux, Windows, Solaris, etc…

• Generally we see only Linux deployed in AWS for running MySQL

5

Page 6: Running MySQL on AWS - Percona€¦ · Running MySQL on AWS Michael Coburn ... you launch and instance of Linux and install MySQL as if it were a regular server

What is EC2?

• Acronym for Elastic Cloud Compute • The platform most commonly used to run MySQL • Traditional virtualisation: you launch and

instance of Linux and install MySQL as if it were a regular server

• Can be provisioned with a range or resources, such as RAM from 1GB to 244GB, and CPU cores from 1 to 32

6

Page 7: Running MySQL on AWS - Percona€¦ · Running MySQL on AWS Michael Coburn ... you launch and instance of Linux and install MySQL as if it were a regular server

What is EBS?

• Stands for Elastic Block Storage • Represents a model of virtualising the disk • Allows AWS to provision different sizes from

10GB to 1TB and IOPS from 500 to +80,000 • Can use multiple EBS volumes along with

LVM/mdadm for increasing mount point size and/or RAID redundancy and performance

7

Page 8: Running MySQL on AWS - Percona€¦ · Running MySQL on AWS Michael Coburn ... you launch and instance of Linux and install MySQL as if it were a regular server

What is RDS?

• Stands for Relational Database Service • Supports Community MySQL (not Percona Server), Oracle,

Microsoft SQL Server, PostgreSQL • Automates a lot of the traditional DBA tasks such as:

• Backups • Failover • Slave provisioning

• Allows you to treat your MySQL database as more of a "black box" with the tradeoff that you give up some control

8

Page 9: Running MySQL on AWS - Percona€¦ · Running MySQL on AWS Michael Coburn ... you launch and instance of Linux and install MySQL as if it were a regular server

What are IOPS?

• Stands for Input/Output Operations Per Second • Common measurement for disks to rate their

throughput • The higher the value, the more work your

database server can do • Work: number of SELECT, INSERT, UPDATE,

and DELETE operations is related to amount of IOPS your server has (normally…)

9

Page 10: Running MySQL on AWS - Percona€¦ · Running MySQL on AWS Michael Coburn ... you launch and instance of Linux and install MySQL as if it were a regular server

Use cases: EC2

• Control over all facets of MySQL • gdb, oprofile, strace, pt-stalk, disk/CPU/

network • Generally more mature application • Admins want more control or need to tune

something that is IsModifiable=false • Generally cheaper than RDS

10

Page 11: Running MySQL on AWS - Percona€¦ · Running MySQL on AWS Michael Coburn ... you launch and instance of Linux and install MySQL as if it were a regular server

Use cases: RDS

• Want to treat database like a “black box” • Automated tasks • backups, upgrades

• Easy read-replica setup • Easy Multi-AZ failover

11

Page 12: Running MySQL on AWS - Percona€¦ · Running MySQL on AWS Michael Coburn ... you launch and instance of Linux and install MySQL as if it were a regular server

Application benefits from AWS?

• Ease of spinning up new instances • On-demand computing resources

• Pay as you go pricing • Flexible pricing models • CLI/API access to deploying and

configuring resources

12

Page 13: Running MySQL on AWS - Percona€¦ · Running MySQL on AWS Michael Coburn ... you launch and instance of Linux and install MySQL as if it were a regular server

Virtualised vs non-virtualised

• In general there isn’t a lot different about running MySQL virtualised vs non-virtualised

• You should make specific accommodations for SSD vs magnetic

• You should pay attention to “noisy neighbour” conditions

13

Page 14: Running MySQL on AWS - Percona€¦ · Running MySQL on AWS Michael Coburn ... you launch and instance of Linux and install MySQL as if it were a regular server

What are the tradeoffs to AWS?

• Not easy to completely isolate your instance from “noisy neighbours”

• Higher latency to disk • Overhead from virtualisation layer

14

Page 15: Running MySQL on AWS - Percona€¦ · Running MySQL on AWS Michael Coburn ... you launch and instance of Linux and install MySQL as if it were a regular server

Taking backups of MySQL

• EC2: Percona XtraBackup, mysqldump, LVM or EBS snapshots

• RDS: mysqldump, RDS snapshots

15

Page 16: Running MySQL on AWS - Percona€¦ · Running MySQL on AWS Michael Coburn ... you launch and instance of Linux and install MySQL as if it were a regular server

Changing MySQL configuration

• EC2: my.cnf, mysql client • RDS: Parameter Group + refresh interval,

mysql client (more limited)

16

Page 17: Running MySQL on AWS - Percona€¦ · Running MySQL on AWS Michael Coburn ... you launch and instance of Linux and install MySQL as if it were a regular server

Upgrading MySQL

• EC2: yum or apt-get + mysql_upgrade • Manual

• RDS: Maintenance window • Automated

17

Page 18: Running MySQL on AWS - Percona€¦ · Running MySQL on AWS Michael Coburn ... you launch and instance of Linux and install MySQL as if it were a regular server

Spinning up slaves

• EC2: take copy of master, stand up slave, start replication • at least an hour to … hours of effort :)

• RDS: a few mouse clicks or API calls • so like a few seconds?

18

Page 19: Running MySQL on AWS - Percona€¦ · Running MySQL on AWS Michael Coburn ... you launch and instance of Linux and install MySQL as if it were a regular server

Failover of MySQL

• EC2: MHA/PRM, slave promoted to Master • RDS: Multi-AZ failover (old Primary goes

offline), Read Replicas

19

Page 20: Running MySQL on AWS - Percona€¦ · Running MySQL on AWS Michael Coburn ... you launch and instance of Linux and install MySQL as if it were a regular server

Schema changes

• EC2: pt-online-schema-change, ALTER TABLE

• RDS: pt-online-schema-change, ALTER TABLE

20

Page 21: Running MySQL on AWS - Percona€¦ · Running MySQL on AWS Michael Coburn ... you launch and instance of Linux and install MySQL as if it were a regular server

Monitoring the health of MySQL

• EC2: • Percona Cloud Tools • Cacti/Zabbix/etc • pt-stalk

• RDS: • Percona Cloud Tools (MySQL Metrics only) • Cacti/Zabbix/etc • pt-stalk (only somewhat) • CloudWatch

21

Page 22: Running MySQL on AWS - Percona€¦ · Running MySQL on AWS Michael Coburn ... you launch and instance of Linux and install MySQL as if it were a regular server

Recovering from failure in MySQL

• EC2: • error log • innodb_force_recovery • Data Recovery

• RDS: • error log • automated crash recovery of InnoDB

22

Page 23: Running MySQL on AWS - Percona€¦ · Running MySQL on AWS Michael Coburn ... you launch and instance of Linux and install MySQL as if it were a regular server

Things to watch for in AWS

• Don’t leave instances running idle • Be careful you don’t over-provision

instance sizes • Take advantage of EBS snapshots • Take advantage of multi-AZ

23