Modelado de clústeres de conmutación por error con PostgreSQL y Pacemaker

Introducción



Hace algún tiempo, me encargaron desarrollar un clúster de conmutación por error para PostgreSQL , que operaba en varios centros de datos conectados por fibra óptica dentro de la misma ciudad y era capaz de resistir una falla (por ejemplo, un corte de energía) de un centro de datos. Elegí Pacemaker como el software responsable de la tolerancia a fallas, porque esta es la solución oficial de RedHat para crear clústeres de conmutación por error. La buena noticia es que RedHat brinda soporte para él y que es una solución universal (modular). Con su ayuda, será posible proporcionar tolerancia a fallas no solo para PostgreSQL, sino también para otros servicios, ya sea utilizando módulos estándar o creándolos para necesidades específicas.



Surgió una pregunta razonable a esta decisión: ¿qué tan tolerante será un clúster de conmutación por error? Para investigar esto, desarrollé un banco de pruebas que simula varias fallas en los nodos del clúster, espera una recuperación, reconstruye el nodo fallado y continúa probando en un ciclo. Inicialmente, este proyecto se llamaba hapgsql, pero con el tiempo me aburrí con el nombre, que solo tiene una vocal. Por lo tanto, comencé a llamar a las bases de datos tolerantes a fallas (y a las IP flotantes que las apuntaban) krogan (un personaje de un juego de computadora, en el que se duplican todos los órganos importantes), y nodos, clústeres y el proyecto en sí: tuchanka (el planeta donde vive krogan).



open source- MIT. README ( , Pacemaker PostgreSQL), README () .



Krogan sobre tuchanka



VirtualBox. 12 ( 36GiB), 4 ( ). PostgreSQL, -, witness c quorum device ( -), 50%/50%, . -: , , quorum device. PostgreSQL, -: , , witness c quorum device. -. , , .



ntpd , ntpd (orphan mode). witness NTP-, , . witness , ( ). HTTP proxy witness, Yum-. , , , witness .





v0. CentOS 7 PostgreSQL 11 VirtualBox 6.1.





-, -. split-brain Pacemaker, STONITH (Shoot The Other Node In The Head) fencing. : , - , , «» , , IPMI UPS. , IPMI UPS . , ( ) -. stonith- (IPMI, UPS ..) .



. , , . «+1» . , , , .. split-brain. , , , watchdog, , IPMI.



( -), 50%/50% (-), . quorum device — , -. ( ), 50%/50%. , quorum device, witness ( repmgr, ).



, , , . , ( ?), IP (float IP). IP, Pacemaker ( ). () , , ( ).



Tuchanka1 ( )





Tuchanka1



, , slave- hot standby read only- ( ).



- . PostgreSQL ( PostgreSQL , ( ), Pacemaker). , ( float IP). -, . ̒ ( ) (), ( shared_buffers ..), , ( ) -. ( read only-) , .



, .



witness



testigo del fracaso



witness (quorum device) Tuchanka1, . witness , , . 2 3, . .



Tuchanka1



fracaso Tuchanka1



- Tuchanka1. witness -. , float IP.



Tuchanka2 ()





Tuchanka2



. , . ( read only), float IP: krogan2 — , krogan2s1 — . , .



, .



Tuchanka2



fracaso Tuchanka2



- witness . - , float IP: . , , ( connection ..) float IP. .



Tuchanka4 ( )





Tuchanka4



. , read-only ( ). Tuchanka4 — , , . . ( ) - , PostgreSQL.



, . , , , -, -, . float IP. , - sql proxy, , . sql proxy, , . , (connection pool), .. ( SQL proxy , ).



Tuchanka4



fracaso Tuchanka4



- (.. ) witness . - : , float IP ( read-write ); , float IP ( read only-).



, : float IP , . , sql proxy float IP; sql proxy , float IP URL . libpq IP, . , , , JDBC, sql proxy. , float IP , , .



: - . , - , , , ( ).



Tuchanka3 (3 -)





Tuchanka3



, -, . quorum device . - , — . , ANY (slave1, slave2), , , . float IP . Tuchanka4 float IP . read-only SQL- sql proxy ( ), float IP, — .



Tuchanka3



fracaso Tuchanka3



- . float IP , — float IP ( , float IP). . ( ) - ( ).



. , README. .





. test/failure. , . , :



test/failure 2 3


. , . , tmux. Tmux tmux , - default tmux, tmux. . setup.



captura de pantalla de `prueba / falla`



, ( ) . Tuchanka2. :



  1. . :

    • failure — ( ), .
    • reaction — , . , , , . , , ( (Tuchanka3 Tuchanka4)), , , .
    • deviation — () reaction « ».
    • count — .
  2. , . (), ̒ . (> 5 ) - .
  3. heart () — . float IP . .
  4. beat () — « », heart , float IP. . Tuchanka1 float IP ( , ), (), beat, heart .
  5. pcs mon. , .
  6. . — . CPU Load ( ), , System Load ( Load Average, 5, 10 15 ), .
  7. , . — — .


. , , . , . ( ) - (> 5 , ) , - .



:



  1. , .
  2. Ready? — ( ).
  3. (reaction).
  4. Fix — «». .


, :



  • ForkBomb: "Out of memory" -.
  • OutOfSpace: . , , , , , PostgreSQL .
  • Postgres-KILL: PostgreSQL killall -KILL postgres.
  • Postgres-STOP: PostgreSQL killall -STOP postgres.
  • PowerOff: «» VBoxManage controlvm "" poweroff.
  • Reset: VBoxManage controlvm "" reset.
  • SBD-STOP: SBD killall -STOP sbd.
  • ShutDown: SSH systemctl poweroff, .
  • UnLink: , VBoxManage controlvm "" setlinkstate1 off.


tmux "kill-window" Ctrl-b &, "detach-client" Ctrl-b d: , tmux , .





  • watchdog sbd , . , , , Corosync Pacemaker, sbd. Corosync PR#83 ( GitHub sbd), master. ( PR#83), Pacemaker - , , RedHat 8 . «» , , , killall -STOP corosync, .



  • Pacemaker CentOS 7 sync_timeout quorum device, , . sync_timeout quorum device ( setup/setup1). Pacemaker, ( ), .



  • , LC_MESSAGES ( ) , , ru_RU.UTF-8, postgres , locale UTF-8, , ( pacemaker+pgsqlms(paf) postgres), UTF-8 . PostgreSQL , . , LC_MESSAGES=en_US.UTF-8 () .



  • wal_receiver_timeout ( 60s), PostgreSQL-STOP tuchanka3 tuchanka4 . , , . wal_receiver_timeout=0 PostgreSQL.



  • PostgreSQL ForkBomb ( ). ForkBomb . tuchanka3 tuchanka4, - , , . , - ( ). , . , , .





Deviant Art c :



Permiso de Noosborn




All Articles