Custom Non-RDS Multi-AZ Mysql Replication

16
CUSTOM NON-RDS MULTI-AZ MYSQL REPLICATION Cloudpack Night #6 5/17/2013

description

Lightning Talk slide for Cloudpack Night #6

Transcript of Custom Non-RDS Multi-AZ Mysql Replication

Page 1: Custom Non-RDS Multi-AZ Mysql Replication

CUSTOM NON-RDS MULTI-AZ MYSQL REPLICATION

Cloudpack Night #6

5/17/2013

Page 2: Custom Non-RDS Multi-AZ Mysql Replication

ABOUT ME (@IJIN)

• Michael H. Oshita

• Japanese American

• In Japan since 2002

• Software/Infra/Cloud Engineer

• http://ijin.github.io

Page 3: Custom Non-RDS Multi-AZ Mysql Replication

CERTIFIED TODAY!

Page 4: Custom Non-RDS Multi-AZ Mysql Replication

COMPONENTS

• AWS VPC (Routing-Based HA Pattern)

• MySQL Master-Slave Replication

• MHA (Master HA Manager for MySQL)

• no RDS!!

Page 5: Custom Non-RDS Multi-AZ Mysql Replication

MHA

Master

Slave

Slave

Manager

Manager detects failure on master

Page 6: Custom Non-RDS Multi-AZ Mysql Replication

Master

Master

Slave

Manager

MHASlave is promoted to master after binlogs are applied

binlogbinlog

binlog

Page 7: Custom Non-RDS Multi-AZ Mysql Replication

"Starting master failover.""* Phase 1: Configuration Check Phase..\n""* Phase 2: Dead Master Shutdown Phase..\n" ==> Delete routing table (master_ip_failover)"* Phase 3: Master Recovery Phase..\n" "* Phase 3.1: Getting Latest Slaves Phase..\n" "* Phase 3.2: Saving Dead Master's Binlog Phase..\n" "* Phase 3.3: Determining New Master Phase..\n" ==> Change routing table (master_ip_failover)"* Phase 4: Slaves Recovery Phase..\n"

MHAFAILOVER SEQUENCE

Page 8: Custom Non-RDS Multi-AZ Mysql Replication

“SHARE A PRIVATE IP ACROSS AVAILABILITY ZONES”

http://d.hatena.ne.jp/c9katayama/20111225/1324837509

#ヤマン ++

Page 9: Custom Non-RDS Multi-AZ Mysql Replication

• Storage engines & distributions

• Instance types

• Fast

• Efficient

WHY NOT RDS?→ FLEXIBILITY!!

Page 10: Custom Non-RDS Multi-AZ Mysql Replication

• Percona Server (XtraDB)

• MariaDB

• TokuDB

• Mroonga

STORAGE ENGINES & DISTRIBUTIONS

Page 11: Custom Non-RDS Multi-AZ Mysql Replication

• hi1.xlarge

• m3.xlarge

• c1.xlarge

• etc.

INSTANCE TYPES

Page 12: Custom Non-RDS Multi-AZ Mysql Replication

• Routing Table changes pretty quickly

• Total failover in roughly <20s (RDS takes 3-6m)

• Non-DNS based

• Apps can be configured with a single IP

• no need to worry about internal DNS problems

FAST FAILOVER

Page 13: Custom Non-RDS Multi-AZ Mysql Replication

• Minimum of 2 (web+db) servers

• Warm up (replication booster)

• Fine tuning

• Server Logs

EFFECIENT

Page 14: Custom Non-RDS Multi-AZ Mysql Replication

DEMO

Page 15: Custom Non-RDS Multi-AZ Mysql Replication

CONSIDERATIONS

• Backups → Xtrabackup, copy binlogs to s3

• Point in Time Recovery → Automate with Chef

• Provisioning Replicas → Automate with Chef

• Some learning curve

• API backplane a SPoF

Page 16: Custom Non-RDS Multi-AZ Mysql Replication

THANK YOU!