Successfully reported this slideshow.
Your SlideShare is downloading. ×

N:1 Replication meets MHA

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Loading in …3
×

Check these out next

1 of 29 Ad

More Related Content

Slideshows for you (20)

Advertisement

Similar to N:1 Replication meets MHA (20)

More from do_aki (20)

Advertisement

Recently uploaded (20)

N:1 Replication meets MHA

  1. 1. N:1 Replication meets MHA 2014/07/11 MySQL Casual Talks vol6 do_aki
  2. 2. @do_aki @do_aki http://do-aki.net/
  3. 3. About N:1 Replication • Multi Master to Single Slave Replication • a.k.a Multi-source Replication – MariaDB 10 (https://mariadb.com/kb/en/mariadb/mariadb- documentation/replication-cluster-multi-master/replication/multi- source-replication/) – MySQL 5.7 (labs) (http://www.mysqlperformanceblog.com/2013/10/02/mysql-5-7-multi- source-replication/) • N:1 Replication work on MySQL5.0!
  4. 4. Master A Slave A+B Master B N:1 Replication
  5. 5. Master A Slave A+B Master B CHANGE MATER TO ‘Master A’ repeat for ever per 2seconds
  6. 6. Master A Slave A+B Master B CHANGE MATER TO ‘Master B’ repeat for ever per 2seconds
  7. 7. Master A Slave A1 Slave A2 Slave B1 Master B Slave B2 table foo bar … table hoge piyo … Application before (weak) relation
  8. 8. Master A Slave A1 Slave A2 Slave B1 Master B Slave B2 table foo bar … table hoge piyo … Application problem weak relation
  9. 9. Master A Slave A1 Slave A2 Slave B1 Master B Slave B2 Slave A+B SELECT with JOIN Application objective
  10. 10. Flowchart of N:1 Replication wait for Seconds_Behind_Master = 0 START SLAVE STOP SLAVE IO_THREAD MASTER_POS_WAIT(Master_Log_F ile,Read_Master_Log_Pos) Timeout? START SLAVE IO_THREAD STOP SLAVE CHANGE MASTER TO ‘next master’ Yes No
  11. 11. I talked about above at 3 years ago
  12. 12. Current N:1 Replication • Work in my production for 3 years • I almost never use time to maintenance • can’t keep pace in some case – pt-online-schema-change – master server changed – need restart (relatively trouble) 
  13. 13. https://github.com/do-aki/n1repl
  14. 14. temporary rotation stop • n1repl_command.pl stop – stop rotate replication connection – single replication is alive • n1repl_command.pl start – start rotate replication connection
  15. 15. support changed master server n1repl_command.pl switch --orig_master_host = masterA --orig_master_port = 3306 --orig_master_log_file = bin.00x --orig_master_log_pos = 893 --new_master_host = masterB --new_master_pos = 3306 --new_master_log_file = bin.00x --new_master_log_pos = 1129
  16. 16. A’ n1repl switch (before) A A+B B
  17. 17. A’ n1repl swith (after) A A+B B
  18. 18. support MHA for MySQL?
  19. 19. MHA for MySQL • Master High Availability Manager and tools for MySQL (https://code.google.com/p/mysql-master-ha/) • Automating master failover – slave promotes to master when master goes down – include “Graceful master switch” function (masterha_master_switch --master_state=alive) http://www.slideshare.net/matsunobu/automated-master-failover/44
  20. 20. MHA (master switch) 1 current master (orig_master) other slaves candidate of master (new_master) write
  21. 21. MHA (master switch) 2 write record binlog filename and position (orig_master_log_file, orig_master_log_pos)
  22. 22. MHA (master switch) 3 MASTER_POS_WAIT( orig_master_log_file, orig_master_log_pos) record binlog (new_master_log_file, new_master_log_pos) write
  23. 23. MHA (master switch) 4 other slaves: MASTER_POS_WAIT( orig_master_log_file, orig_master_log_pos) CHANGE MASTER TO ‘new_master’ (new_master_log_file, new_master_log_pos) write write
  24. 24. MHA (master switch) 5 write complete!
  25. 25. similar mechanism • wait replication delay is zero • change connection • specify same (orig->new) position • it’s looked N:1 Replication code
  26. 26. support changed master server n1repl_command.pl switch --orig_master_host = masterA --orig_master_port = 3306 --orig_master_log_file = bin.00x --orig_master_log_pos = 893 --new_master_host = masterB --new_master_pos = 3306 --new_master_log_file = bin.00x --new_master_log_pos = 1129
  27. 27. But but but... • Don’t work when master is dead  • MHA has hook functions call specified script *without* binlog file and position!
  28. 28. Conclusion • N:1 Replication not support MHA… • please expect “JIKAISAKU”
  29. 29. Any question?

×