Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
RDS for MySQLからAuroraに移行した話 / RDS for MySQL to ...
Search
FUJIWARA Shunichiro
November 02, 2016
Technology
9
5.3k
RDS for MySQLからAuroraに移行した話 / RDS for MySQL to Aurora
2016.11.02 JAWS-UG横浜 - Reboot!!
http://jawsug-yokohama.connpass.com/event/40497/
FUJIWARA Shunichiro
November 02, 2016
Tweet
Share
More Decks by FUJIWARA Shunichiro
See All by FUJIWARA Shunichiro
alecthomas/kong はいいぞ
fujiwara3
6
1.6k
ecspressoの設計思想に至る道 / sekkeinight2025
fujiwara3
12
2.7k
さくらのIaaS基盤のモニタリングとOpenTelemetry/OSC Hokkaido 2025
fujiwara3
3
1.1k
監視のこれまでとこれから/sakura monitoring seminar 2025
fujiwara3
11
5.1k
k6による負荷試験 入門から日常的な実践まで/Re:TechTalk #01
fujiwara3
2
120
困難を「一般解」で解く
fujiwara3
10
3.8k
「隙間家具OSS」に至る道/Fujiwara Tech Conference 2025
fujiwara3
7
13k
alecthomas/kong はいいぞ / kamakura.go#7
fujiwara3
1
1.1k
ISUCONに強くなるかもしれない日々の過ごしかた/Findy ISUCON 2024-11-14
fujiwara3
11
1.4k
Other Decks in Technology
See All in Technology
トヨタ生産方式(TPS)入門
recruitengineers
PRO
2
220
Browser
recruitengineers
PRO
3
300
攻撃と防御で実践するプロダクトセキュリティ演習~導入パート~
recruitengineers
PRO
1
170
Android Studio の 新しいAI機能を試してみよう / Try out the new AI features in Android Studio
yanzm
0
270
Preferred Networks (PFN) とLLM Post-Training チームの紹介 / 第4回 関東Kaggler会 スポンサーセッション
pfn
PRO
1
180
LLMエージェント時代に適応した開発フロー
hiragram
1
410
そのコンポーネント、サーバー?クライアント?App Router開発のモヤモヤを可視化する補助輪
makotot
4
440
Devinを使ったモバイルアプリ開発 / Mobile app development with Devin
yanzm
0
190
ソフトウェア エンジニアとしての 姿勢と心構え
recruitengineers
PRO
2
700
新卒(ほぼ)専業Kagglerという選択肢
nocchi1
1
2.2k
Webアクセシビリティ入門
recruitengineers
PRO
1
240
7月のガバクラ利用料が高かったので調べてみた
techniczna
3
360
Featured
See All Featured
Measuring & Analyzing Core Web Vitals
bluesmoon
9
570
Typedesign – Prime Four
hannesfritz
42
2.8k
The World Runs on Bad Software
bkeepers
PRO
70
11k
How to Ace a Technical Interview
jacobian
279
23k
Unsuck your backbone
ammeep
671
58k
Statistics for Hackers
jakevdp
799
220k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
161
15k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4k
A better future with KSS
kneath
239
17k
Making Projects Easy
brettharned
117
6.3k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
Transcript
RDS for MySQL ͔Β Aurora ʹҠߦͨ͠ 2016.11.02 JAWS-UGԣ - Reboot!!
@fujiwara
౻ݪ ढ़Ұ @fujiwara github.com/fujiwara sfujiwara.hatenablog.com ٕज़෦
20149݄ϦϦʔε શ໘తʹAWSΛར༻ • ELB + EC2 • RDS for MySQL
• ElastiCache Redis • CloudFront • S3 • Redshift
ετϨʔδ MySQL ήʔϜͷಛੑ • 9ਓ x 2 νʔϜ͕ಉ࣌ʹҰͭͷࢼ߹Λૢ࡞͢Δ • ͦΕͱผʹࢼ߹ਐߦͰόονॲཧ͕Δ
• → τϥϯβΫγϣϯ͕ඞਢ
MySQL → Aurora
MySQL → Aurora ͳͥҠߦ͔͔ͨͬͨ͠ (1) ࣌ʑى͖ΔEBS٧·Γ͕ͭΒ͍ • ผAZͷॻ͖ࠐΈ͕ඵʙेඵ͞Δݱ • Aurora
3 AZ த 2 AZ ͷॻ͖ࠐΈྃͰฦͬͯ͘ΔͷͰ (ݪཧతʹ) ൃੜ͠ʹ͍ͣ͘
MySQL → Aurora ͳͥҠߦ͔͔ͨͬͨ͠ (2) ϦʔυϨϓϦΧͷஆؾ͕ͭΒ͍ • ϦʔυϨϓϦΧEBS snapshot͔Β෮ݩ͞ΕΔ •
EBSͷ First Touch Penalty • EC2ͳΒ dd ίϚϯυͰͰ͖Δ͕RDS… • primary key + secondary indexͯ͢ᢞΊΔඞཁ • ΠϕϯτલʹΠϯελϯεαΠζมߋ͕ΓͮΒ͍
MySQL → Aurora • 2016-08 ৽ϫʔϧυ্ཱͪ͛࠷ॳ͔ΒAuroraͰ • 2016-10 چϫʔϧυ MySQL
→ AuroraҠߦ
ࣄલͷݕূ • ։ൃαʔόΛAuroraʹͯ͠ςετΛճ͢ • ΞϓϦέʔγϣϯϨϕϧͷޓੑͳ͠ • ΞϓϦέʔγϣϯܦ༝ͰͷϕϯνϚʔΫ • ಛʹੑೳɺݶք্͕͕ΔΘ͚Ͱͳ͔ͬͨ !
Amazon AuroraΛਅʹཧղ͢ΔͨΊͷੑೳݕূ blog.father.gedow.net/2015/11/05/amazon-aurora- benchmark/
Ҡߦ࡞ۀ
Ҡߦ࡞ۀ ॳظঢ়ଶ
Ҡߦ࡞ۀ 1. MySQLͷϦʔυϨϓϦΧΛ࡞ͬͯϨϓϦΛࢭΊΔ
Ҡߦ࡞ۀ 2. ࢭΊͨMySQLϦʔυϨϓϦΧ͔ΒAuroraΛͭ͘Δ
Ҡߦ࡞ۀ 3. AuroraΛMySQL masterͱϨϓϦ͢Δ
Ҡߦ࡞ۀ 4. Ҡߦ༻ͷMySQLϦʔυϨϓϦΧআ
Ҡߦ࡞ۀ 5. AuroraͷϦʔυϨϓϦΧΛ࡞Δ
Ҡߦ࡞ۀ 6. AuroraΛঢ֨ɺΞϓϦέʔγϣϯͷଓઌมߋ
Ҡߦ࡞ۀ 7. Ҡߦྃ!
MySQL࣌ͱͷมߋ
MySQL࣌ͱͷมߋ HAProxyΛࢀরࢄʹ͍ͬͯΔ (֤ϗετͰىಈͯ͠localhost:3307ʹଓ)
MySQL࣌ͱͷมߋ Before: HAProxyΈࠐΈͷmysqlϔϧενΣοΫ • Πϯελϯε࡞Γ͠ͰͷIPΞυϨεมߋʹैͰ͖ͳ͍ • master͔slave͔͕͔Βͳ͍ ↓ After: HAProxy1.6ͷಈత໊લղܾ
+ ֎෦scriptʹ
MySQL࣌ͱͷมߋ tkuchiki.hatenablog.com/entry/2016/07/14/180046 HAProxy1.6ͷಈత໊લղܾ + ֎෦script listen mysql-slave bind 127.0.0.1:3307 mode
tcp option external-check external-check path "/usr/bin:/bin:/usr/local/bin" external-check command /usr/local/bin/check_aurora_slave.sh balance roundrobin server master db01.xxx.rds.amazonaws.com:3306 check backup resolvers mydns server slave1 db02.xxx.rds.amazonaws.com:3306 check resolvers mydns server slave2 db03.xxx.rds.amazonaws.com:3306 check resolvers mydns
MySQL࣌ͱͷมߋ HAProxyͷ֎෦script innodb_read_only͕ON → ReadReplica #!/bin/bash READ_ONLY=$(mysql -u haproxy -h
${HAPROXY_SERVER_ADDR} \ -P ${HAPROXY_SERVER_PORT} -BN\ -e "SHOW GLOBAL VARIABLES LIKE 'innodb_read_only';"\ --connect-timeout=5 | awk '{print $2}') [ "${READ_ONLY}" = "ON" ]
MySQL࣌ͱͷมߋ ReadReplicaͰ show engine innodb status ͕ݟ͑ͳ͍?? ༷ͱͷ͜ͱ (by αϙʔτ)
ࢹͰ ROW OPERATIONS Λूܭ͍ͯͨ͠ͷͰࠔΔ
MySQL࣌ͱͷมߋ show status like '%Innodb_rows%' ʹมߋ +----------------------+----------+ | Variable_name |
Value | +----------------------+----------+ | Innodb_rows_deleted | 1 | | Innodb_rows_inserted | 111002 | | Innodb_rows_read | 15682572 | | Innodb_rows_updated | 1020 | +----------------------+----------+
MySQL࣌ͱͷมߋ ΫΤϦͷϨΠςϯγ͕औΕΔΑ͏ʹͳͬͨ
Ҡߦͯ͠Έͯ
Ҡߦͯ͠Έͯ ࣌ʑى͖ΔEBS٧·Γ͕ͭΒ͍ → 2ʙ3िִؒͰൃੜ͍ͯͨ͠ͷ͕0ʹ ! Α͘ΕΔ
Ҡߦͯ͠Έͯ ϦʔυϨϓϦΧͷஆؾ͕ͭΒ͍ → ෆཁʹͳͬͨͷͰ৺ཧతʹָ ! (·ཱͩͯͯͳ͍͚Ͳ)
Ҡߦͯ͠Έͯ ! snapshotͷෛՙΛؾʹ͠ͳͯ͘Α͘ͳͬͨ • (ΞϓϦͷ)োରԠͷͨΊʹ͜·ΊʹsnapshotΛऔ͍ͬͯΔ • EBS snapshotଟগͳΓͱੑೳʹӨڹ͢Δ • AuroraͰӨڹͳ͠ͱͷ͜ͱ
(by αϙʔτ)
Ҡߦͯ͠Έͯ ! ίετେࠩͳ͠(͔Լ͕ͬͨ) • Provisioned IOPS (ߴ͍) • GP2ͰੑೳͷͨΊʹ༰ྔΛ֬อ͍ͯͨ͠ͷ͕ෆཁʹ •
Πϯελϯεඅ༻ ↑ • ετϨʔδɺIOඅ༻ ↓
·ͱΊ MySQL ͔Β Aurora Ҡߦ͢ΔՁ͋Γ ಛʹIOͷ҆ఆੑ ⭕ ϨϓϦέʔγϣϯΛ͑࠷খݶͷμϯλΠϜͰՄೳ ίετݮΒͤΔ(͔Εͳ͍)