Slide 1

Slide 1 text

ʮorchestratorͱGTIDӡ༻Λࢧ͑Δ؂ࢹʯͷษڧ MySQL Casual Talks vol.13 kazeburo ٯʹͳΓ·ͨ͠

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

• After 3 months • Applied orchestrator to JP and US infrastructure • Introduced ALL DB shards (cluster) • Developed Fast (less than 1 sec) master SwitchOver(Graceful TakeOver) using VIP • Experienced successful FailOver caused by manual operation error (me)

Slide 5

Slide 5 text

• After 3 months • Upgraded majority of DB shards to MySQL 5.7.x and enabled GTID

Slide 6

Slide 6 text

• How to upgrade MySQL 1. mysqldump from MySQL 5.6 backup server 2. Restore on Newer MySQL 5.7 and replicate from 5.6 master 3. Query replay test using custom go-sniffer 4. Do Fast master SwitchOver at mid night • After complete upgrading, Enable GTID on each servers

Slide 7

Slide 7 text

• orchestrator ʹΑΔ FailOver, SwitchOverΛ࣮֬ʹߦ͏ͨΊͷ؂ࢹ • GTIDӡ༻ͷͨΊͷ؂ࢹ • ichirin2501ࢯɾtaka-hࢯʹΑͬͯߏங͞Εͨ͜ΕΒΛษڧ͢Δͷ͕ຊεϥΠυͷ໨త • αʔό؂ࢹ͸MackerelΛར༻͍ͯ͠·͢

Slide 8

Slide 8 text

• check-mysql-repli-timeout

Slide 9

Slide 9 text

• timeoutॏཁ • orchestrator͸masterͷμ΢ϯݕ஌ʹ֤slave͔Βͷૄ௨Λར༻

Slide 10

Slide 10 text

• check-mysql-repli-timeout • MASTER_CONNECT_RETRY, MASTER_RETRY_COUNT, slave_net_timeout ͷ֬ೝ • MASTER_HEARTBEAT_PERIOD ͕ slave_net_timeout ͷ൒෼ • slave_net_timeout͚ͩԼ͛Δͱɺheartbeatͷִ͕ؒtimeoutΑΓ௕͘ͳͬͯ͠·͏

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

• check read_only

Slide 13

Slide 13 text

• check read_only • ҙਤ͠ͳ͍ slave Ͱͷߋ৽ΫΤϦͷ࣮ߦʹΑΔෆ੔߹ͷൃੜΛ๷͙ • orchestrator ಋೖͰ read_only ͷӡ༻ʹมߋ • orchestratorͰͷmasterঢ֨࣌ʹ (super_)?read_only ͸ղআ͞ΕΔ • ҙਤ͠ͳ͍ master Ͱͷ read_only=on ͸ճආͰ͖Δ

Slide 14

Slide 14 text

• check read_only • slave ͸ read_only=on Ͱ͋Δ͜ͱΛ֬ೝ • master͸ read_only=off Ͱ͋Δ͜ͱΛ֬ೝ

Slide 15

Slide 15 text

$ /usr/bin/check-mysql readonly -h Usage: check-mysql readonly [OPTIONS] [ON|OFF] Application Options: -H, --host= Hostname (default: localhost) -p, --port= Port (default: 3306) -S, --socket= Path to unix socket -u, --user= Username (default: root) -P, --password= Password [$MYSQL_PASSWORD] Help Options: -h, --help Show this help message mackerel-plugin

Slide 16

Slide 16 text

/usr/bin/check-mysql readonly $(if /sbin/ip a | grep -qF $(dig +short {{ master }} | tail -n 1); then echo 'OFF'; else echo 'ON'; fi)

Slide 17

Slide 17 text

• check read_only • ىಈ࣌σϑΥϧτΛ read_only=on ΁มߋ • orchestrator͔Βͷҙਤ͠ͳ͍ Pseudo-GTID ͷૠೖΑΔ Errant GTID Λճආ

Slide 18

Slide 18 text

• check-mysql-gtid-state

Slide 19

Slide 19 text

• slave ʹ͔͠ͳ͍ transaction (Errant transaction) • read_only ӡ༻Ҏલ͸ slave Ͱߋ৽ΫΤϦ͕ҙਤ࣮ͤͣߦ͞Εͯ͠·͏Մೳੑ • Rolling Schema Upgrade • GTIDͰ͸ errant transaction (Errant GTID) ͕ଘࡏ͢Δ slave ͕ master ʹঢ֨ ͢Δ͜ͱͰෆ੔߹͕ൃੜ͢ΔϦεΫ

Slide 20

Slide 20 text

• check-mysql-gtid-state • slave Ͱ gtid_executed Λऔಘ • master Ͱ gtid_executed Λऔಘ • MSRͷ৔߹͸શͯͷmaster͔Βऔಘ • GTID_SUBSET(slave, master) Ͱൺֱ

Slide 21

Slide 21 text

• GTID_SUBSET(subset{slave},set{master}) • 2 ηοτͷάϩʔόϧτϥϯβΫγϣϯ ID subset ͱ set ͕ࢦఆ͞Εͨ৔߹ɺ subset ಺ͷ͢΂ͯͷ GTID ͕ set ʹ΋ଘࡏ͢Ε͹ true (1) Λฦ͠·͢ɻͦΕҎ֎ ͷ৔߹͸ɺfalse (0) Λฦ͠·͢ɻ

Slide 22

Slide 22 text

• How to fix Errant GTID • Insert Empty transaction • Remove from binlog

Slide 23

Slide 23 text

• How to fix Errant GTID (Remove from binlog) 1. [slave] STOP SLAVE ͠ɺ@@global. gtid_executed Λ֬ೝ 2. [master] SHOW MASTER STATUS ͠ɺslaveʹ͔͠ͳ͍GTIDηοτΛ֬ೝ 3. [slave] RESET SLAVE; RESET MASTERͯ͠ gtid_executed ΛΫϦΞ 4. [slave] SET GLOBAL gtid_purged = '1ͷGTIDηοτ͔Β2Ͱ֬ೝͨ͠ηοτΛ࡟আ' 5. [slave] CHANGE MASTER TO MASTER_AUTO_POSITION=1; START SLAVE

Slide 24

Slide 24 text

orchestrator (>= v3.0.14) https://www.percona.com/live/19/sites/default/files/slides/Errant%20GTIDs%20Breaking%20Replication_%20How%20to%20Detect%20and%20Avoid%20Them%20-%20FileId%20-%20187306.pdf

Slide 25

Slide 25 text

• check-gtid-auto-succeed

Slide 26

Slide 26 text

FailOver/SwitchOver ࣌ʹ master ͱͳΔαʔό͕ద੾ʹGTIDσʔληοτΛ౉ͤΔ͔ ʢը໘͸Πϝʔδ)

Slide 27

Slide 27 text

• check-gtid-auto-succeed • orchestrator ͷ DB ͔Β cluster ʹଐ͢Δ αʔόΛऔಘ • masterީิ*slaveީิ ͷ N * (N - 1) ύλʔϯΛ؂ࢹ

Slide 28

Slide 28 text

• GTID_SUBTRACT(masterީิͷgtid_purgedɺslaveީิͷgtid_executed) • slave ީิͷGTIDηοτΛ master ީิ͕͢΂͍ͯ࣋ͬͯΕ͹ empty => OK

Slide 29

Slide 29 text

• ·ͱΊ

Slide 30

Slide 30 text

• orchestrator εΰΠϕϯϦ • orchestrator ͱ GTID ͷ࣮֬ͳӡ༻ͷͨΊͷ؂ࢹΛண࣮ʹ࡞͍ͬͯΔ • ichirin2501 ͸͍͢͝ਓ

Slide 31

Slide 31 text

No content