PostgreSQLとPacemakerを使用したフェイルオーバークラスターモデリング

前書き



しばらく前、私はPostgreSQLのフェイルオーバークラスターの開発を任され、同じ都市内の光ファイバーで接続された複数のデータセンターで動作し、1つのデータセンターの障害(たとえば、停電)に耐えることができました。これは、フェイルオーバークラスターを作成するためのRedHatの公式ソリューションであるため、フォールトトレランスを担当するソフトウェアとしてPacemakerを選択しました。幸いなことに、RedHatはそれをサポートしており、このソリューションはユニバーサル(モジュラー)です。その助けを借りて、PostgreSQLだけでなく、標準モジュールを使用するか、特定のニーズに合わせてそれらを作成する他のサービスにも障害耐性を提供することが可能になります。



この決定に対して合理的な疑問が生じました。フェイルオーバークラスターはどの程度フォールトトレラントになるのでしょうか。これを調査するために、クラスターノードでのさまざまな障害をシミュレートし、回復を待機し、障害が発生したノードを再構築し、ループでテストを続行するテストベンチを開発しました。当初、このプロジェクトはhapgsqlと呼ばれていましたが、時間が経つにつれて、母音が1つしかない名前に飽きてきました。したがって、私はフォールトトレラントデータベース(およびそれらを指すフロートIP)をkrogan(すべての重要な器官が複製されるコンピューターゲームのキャラクター)、ノード、クラスター、およびプロジェクト自体tuchanka(クロガンが住む惑星))と呼び始めました。



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



トゥチャンカのクロガン



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 ( )





トゥチャンカ1



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



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



, .



witness



失敗の目撃者



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



Tuchanka1



失敗Tuchanka1



- Tuchanka1. witness -. , float IP.



Tuchanka2 ()





トゥチャンカ2



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



, .



Tuchanka2



失敗Tuchanka2



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



Tuchanka4 ( )





トゥチャンカ4



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



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



Tuchanka4



失敗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 -)





トゥチャンカ3



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



Tuchanka3



失敗Tuchanka3



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



. , README. .





. test/failure. , . , :



test/failure 2 3


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



「テスト/失敗」のスクリーンショット



, ( ) . 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 :



ヌースボーンの許可




All Articles