High Availability with MariaDB Enterprise

21
© SkySQL Corpora-on Ab. Company Confiden-al. 24/06/2014 1

description

High Availability with MariaDB Enterprise by Anders Karlsson. Presented 10.6.2014 at the MariaDB Roadshow in Helsinki, Finland.

Transcript of High Availability with MariaDB Enterprise

Page 1: High Availability with MariaDB Enterprise

©  SkySQL  Corpora-on  Ab.  Company  Confiden-al.  24/06/2014 1

Page 2: High Availability with MariaDB Enterprise

©  SkySQL  Corpora-on  Ab.  Company  Confiden-al.  

High  Availability  with  MariaDB  Enterprise  

Anders  Karlsson  Sales  Engineer,  SkySQL  

*   *  24/06/2014 2

Page 3: High Availability with MariaDB Enterprise

©  SkySQL  Corpora-on  Ab.  Company  Confiden-al.  

Agenda  

• Introduc-on  to  High  Availability  • Different  services  that  need  HA  • Different  components  of  High  Availability  • Different  MariaDB  HA  Solu-ons  

•  HA  using  MariaDB  Replica-on  •  HA  using  MariaDB  Galera  Cluster  

24/06/2014 3

Page 4: High Availability with MariaDB Enterprise

©  SkySQL  Corpora-on  Ab.  Company  Confiden-al.  

Introduc-on  to  High  Availability  

High availability is a system design protocol and associated

implementation that ensures a certain degree of operational continuity during

a given measurement period

24/06/2014 4

Page 5: High Availability with MariaDB Enterprise

©  SkySQL  Corpora-on  Ab.  Company  Confiden-al.  

Introduc-on  to  High  Availability  

24/06/2014 5

• High  Availability  isn’t  always  the  same  as  Long  Up(me  

•  A  system  that  is  “up”  might  s-ll  not  be  accessible  •  A  system  that  is  “down”  just  once,  but  for  a  long  -me,  isn’t  highly  available  

• High  Availability  rather  means  •  Long  Mean  Time  Between  Failures  (MTBF)  •  Short  Mean  Time  To  Recover  (MTTR)  

Page 6: High Availability with MariaDB Enterprise

©  SkySQL  Corpora-on  Ab.  Company  Confiden-al.  

Introduc-on  to  High  Availability  

• The  level  of  availability  is  measured  as  the  ra-o  of  -me  the  system  is  available  over  a  year,  expressed  as  a  percentage  

•  99.9%  availability  means  that  the  system  is  available  at  least  8.751  of  8.760  hours  in  a  year,  or  that  it  is  unavailable  at  the  most  9  hours  per  year  •  99.999%  availability  means  that  the  system  is  available  at  least  525.595  or  525.600  minutes  in  a  year,  or  that  it  is  unavailable  at  the  most  5  minutes  per  year  

24/06/2014 6

Page 7: High Availability with MariaDB Enterprise

©  SkySQL  Corpora-on  Ab.  Company  Confiden-al.  

Maintaining  High  Availability  

• There  are  two  common  situa-ons  that  we  try  to  protect  ourselves  from  using  an  HA  solu-on  

•  Datacenter  failure  –  A  whole  datacenter  becomes  unavailable  for  some  reason,  like  power  failure,  network  failure,  a  virus  or  similar  situa-ons  •  Server  failure  –  An  individual  server  fails  because  of  a  hardware  failure  or  something  similar  

24/06/2014 7

Page 8: High Availability with MariaDB Enterprise

©  SkySQL  Corpora-on  Ab.  Company  Confiden-al.  

Services  in  an  HA  Solu-on  

• All  services  that  make  up  the  applica-on  stack  needs  HA  for  the  system  to  achieve  HA  

•  Web  servers  •  Applica-on  servers  •  Applica-ons  •  Database  servers  •  Storage  •  Network  

24/06/2014 8

Page 9: High Availability with MariaDB Enterprise

©  SkySQL  Corpora-on  Ab.  Company  Confiden-al.  

Services  in  an  HA  Solu-on  

• Of  the  different  types  of  services,  there  are  two  types  

•  Stateless  services  These  servers  has  no  state  beyond  the  current  opera-on.  If  such  a  server  fails,  another  server  of  the  same  type  can  replace  it  without  having  to  transfer  any  set  of  data.  Webservers  and  applica-on  servers  are  typical  stateless  services  

•  Stateful  services  These  services  maintains  a  state,  and  that  state  needs  to  be  preserved  if  a  server  fails,  and  has  to  be  made  available  to  any  other  server  that  takes  it  place.  A  database  service  such  as  a  MariaDB  server  is  a  typical  stateful  service  

24/06/2014 9

Page 10: High Availability with MariaDB Enterprise

©  SkySQL  Corpora-on  Ab.  Company  Confiden-al.  

Components  of  High  Availability  

• Monitoring  and  Management  •  Availability  of  the  services  needs  to  be  monitored,  to  be  able  to  take  ac-on  when  there  is  a  failure.  A  failover  can  be  manual  or  automa-c,  but  it  has  to  be  managed  

• Failover  /  Load  Balancing  mechanism  •  Some  mechanism  to  redirect  traffic  from  the  failed  server  or  Datacenter  and  to  a  working  one  

• Data  redundancy  •  For  stateful  services,  we  need  to  make  sure  that  data  is  somehow  made  redundant  

24/06/2014 10

Page 11: High Availability with MariaDB Enterprise

©  SkySQL  Corpora-on  Ab.  Company  Confiden-al.  

Monitoring  and  Management  

• There  are  many  different  solu-ons  here,  some  focused  on  specific  services  (in  par-cular  database),  some  as  part  of  a  Load  Balancing  soeware  solu-on  of  an  Appliance  or  a  pure  soeware  based  solu-on  such  as  LinuxHA  

24/06/2014 11

Page 12: High Availability with MariaDB Enterprise

©  SkySQL  Corpora-on  Ab.  Company  Confiden-al.  

Failover  mechanism  

• There  is  a  wide  range  of  op-ons  here  too,  in  par-cular  when  it  comes  to  Datacenter  failover,  which  can  be  more  complicated  

• Common  mechanisms  range  from  applica-on  based  failover  and  DNS  failover  to  Load  Balancing  and  Network  Failover    

24/06/2014 12

Page 13: High Availability with MariaDB Enterprise

©  SkySQL  Corpora-on  Ab.  Company  Confiden-al.  

Data  Redundancy  

• Providing  Data  Redundancy  is  complex,  error  prone  and  takes  a  toll  on  performance  

• It  also  has  to  be  men-oned  that  a  SAN  does  not  provide  redundancy  just  because  a  disk  set  can  be  failed  over  from  one  server  to  another.  A  SAN  might  be  a  SPOF,  but  in  some  cases  that  is  a  risk  that  some  customers  is  willing  to  take  

24/06/2014 13

Page 14: High Availability with MariaDB Enterprise

©  SkySQL  Corpora-on  Ab.  Company  Confiden-al.  

Data  Redundancy  with  MariaDB  

• For  MariaDB,  there  are  a  number  of  op-ons  for  Data  Redundancy  

•  MariaDB  Classic  Replica-on  •  MariaDB  Galera  Cluster  •  Storage  based  redundancy  (Ac-ve  /  Passive  setups)  

•  DRBD  (Distributed  Replicated  Block  Device)  •  SAN  (Storage  Area  Network)  

24/06/2014 14

Page 15: High Availability with MariaDB Enterprise

©  SkySQL  Corpora-on  Ab.  Company  Confiden-al.  

HA  using  MariaDB  Replica-on  

• This  is  in  many  cases  a  good  enough  solu-on,  but  it  has  some  issues  

•  The  cluster  is  very  loosely  coupled,  not  all  nodes  are  aware  of  all  the  other  nodes  for  example  •  Replica-on  is  asynchronous,  so  failing  over  is  more  difficult  than  usually  (but  MHA  solves  this)  •  Adding  a  slave  is  difficult  

• But  there  are  also  many  advantages  •  Low  performance  penalty  •  Well  known  and  easy  to  use  technology  

24/06/2014 15

Page 16: High Availability with MariaDB Enterprise

©  SkySQL  Corpora-on  Ab.  Company  Confiden-al.  

HA  using  MariaDB  Galera  Cluster    

• This  a  soeware-­‐only  solu-on  with  many  advantages  

•  Scales  writes  and  well  as  reads  •  “Proper”  Cluster  with  built-­‐in  failover,  locking  and  split-­‐brain  protec-on  •  Synchronous  replica(on  with  low  overhead  due  to  op-mis-c  locking  

• There  are  some  disadvantages  •  More  overhead  than  using  Asynchronous  Replica-on  •  Only  works  with  InnoDB  •  For  distributed  writes,  some  restric-ons  apply  

24/06/2014 16

Page 17: High Availability with MariaDB Enterprise

©  SkySQL  Corpora-on  Ab.  Company  Confiden-al.  

MariaDB  Galera  Cluster  setup  

24/06/2014 17

MariaDB Server MariaDB Server MariaDB Server

Galera wsrep Library Galera wsrep Library Galera wsrep Library

Synchronous Replication

Load Balancer / Failover

Application / Application server

Page 18: High Availability with MariaDB Enterprise

©  SkySQL  Corpora-on  Ab.  Company  Confiden-al.  

Sehng  up  MariaDB  Galera  Cluster  

• MariaDB  Galera  Cluster  consists  of  the  MariaDB  binary  that  in  turns  talks  to  the  Galera  wsrep  library  

• Once  set  up,  Galera  is  configured  using  the  usual  my.cnf  file,  and  is  monitored  using  the  SHOW  GLOBAL  STATUS  command  

24/06/2014 18

Page 19: High Availability with MariaDB Enterprise

©  SkySQL  Corpora-on  Ab.  Company  Confiden-al.  

MariaDB  Galera  Cluster  failover  

• MariaDB  Galera  Cluster  handles  failed  servers  internally  

• MariaDB  Galera  Cluster  also  handles  split-­‐brain  protec(on  and  this  requires  at  least  3  servers  

• MariaDB  Galera  Cluster  can  also  be  configured  without  split-­‐brain  protec-on,  for  example  when  failover  is  manual  or  is  handled  in  some  other  way  

24/06/2014 19

Page 20: High Availability with MariaDB Enterprise

©  SkySQL  Corpora-on  Ab.  Company  Confiden-al.  

MariaDB  Galera  Cluster  setup  

• If  necessary  to  allow  for  protec-on  against  split-­‐brain  scenarios,  but  only  using  2  database  servers,  a  third  server  can  be  set  up  with  a  Galera  specific  arbitra(on  agent  

• Galera  also  can  be  used  with  it’s  own  simple  Load  Balancer,  although  it  is  much  more  common  that  other  technologies  are  used,  such  as  HA  aware  Connectors  or  a  Load  Balancer  

24/06/2014 20

Page 21: High Availability with MariaDB Enterprise

©  SkySQL  Corpora-on  Ab.  Company  Confiden-al.  

Ques(ons?  

24/06/2014 21