Upgrade to Pro — share decks privately, control downloads, hide ads and more …

MySQL Failover with Consul vol.2

MySQL Failover with Consul vol.2

MySQL Casual Talks vol 7. #mysqlcasual

C21584e232717e771226626c0bc2f30c?s=128

Michael H. Oshita

December 12, 2014
Tweet

Transcript

  1. MYSQL FAILOVER WITH CONSUL VOL. 2 12/12/2014 @ijin MySQL Casual

    Talks vol.7
  2. ABOUT ME (@IJIN) • Michael H. Oshita • Japanese American

    • 10+ Years in Japan • Software/Infra/Cloud Engineer • http://ijin.github.io
  3. ABOUT ME (@IJIN) τϥϒϧˑ͠Ύʔͨʔͣ

  4. https://walti.io WALTI

  5. BLOG https://ijin.github.io

  6. MYSQL FAILOVER • MySQL • MHA (MySQL Master HA) •

    Consul INGREDIENTES:
  7. None
  8. CONSUL

  9. CONSUL HTTP APIͱDNSͰૢ࡞͕Ͱ͖ΔKV಺ଂͳ෼ࢄܕΫϥελ

  10. CONSUL AGENT HTTP API /v1/kv/<key> key/value endpoint: RESTful: GET, PUT,

    DELETE
  11. CONSUL AGENT HTTP API key/value: base64 raw

  12. CONSUL AGENT DNS Interface <node>.node.<datacenter>.<domain> Node Lookup:

  13. CONSUL AGENT DNS Interface

  14. CONSISTENCY

  15. consensus protocol using raft server server (leader) server CONSISTENCY server

    server
  16. consensus protocol using raft server server (leader) server write CONSISTENCY

    server server
  17. consensus protocol using raft server server (leader) server write CONSISTENCY

    server server write
  18. consensus protocol using raft server server (leader) server write CONSISTENCY

    server server write write
  19. consensus protocol using raft server server (leader) server write CONSISTENCY

    server server write write quorum[(n/2)+1] reached, commited!
  20. CONSISTENCY writes: ! "?state" or "?consistent" parameter ɾdefault ɾstrongly consistent

    ɾstale ! consensus protocol using raft reads: ! Always Strongly Consistent
  21. MHA Master Slave Slave Manager MasterͰো֐ൃੜ

  22. Master Master Slave Manager ֤slaveʹ࠷৽binlogΛద༻͠ɺMasterঢ֨ binlog binlog binlog MHA

  23. MHA master_ip_failover

  24. Slave masterdb.node.consul Slave MHA

  25. Master Slave masterdb.node.consul MHA

  26. "Starting master failover."! "* Phase 1: Configuration Check Phase..\n"! "*

    Phase 2: Dead Master Shutdown Phase..\n"! ==> ͜͜ͰچMaster৘ใ࡟আ (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"! ==> ͜͜Ͱ৽Master৘ใొ࿥ (master_ip_failover)! "* Phase 4: Slaves Recovery Phase..\n" FAILOVERγʔέϯε MHA
  27. MHA & CONSUL master_ip_failover چmaster IPΛແޮԽ ৽master IPΛొ࿥

  28. IN ACTION https://www.youtube.com/watch?v=rA4hyJ-pccU

  29. ALTERNATIVES ɾconsul event & consul watch ! ɾconsul-template

  30. events propagated over gossip protocol event CONSUL EVENT watch watch

  31. CONSUL EVENT

  32. CONSUL-TEMPLATE haproxy.cfg

  33. CONSUL-TEMPLATE

  34. IN CLOSING • Use consul DNS catalog for MHA failover

    • Consul-Template over consul event