pgpool2.git / summary / log / commit / refs
commit b4bfd4ccd04d0e78f8ebb74a53d6845a92ef5312
Author: Takuma Hoshiai <hoshiai@sraoss.co.jp>
Date: Tue Oct 15 08:50:43 2019 +0000
Doc: add failover_command description
Add more exaplain about a case that failover_command execute when it
does not have a new master node. In this case, special characters in
failover_command are specified fixed values. And update failover.sh.sample too.
doc.ja/src/sgml/example-cluster.sgml | 6 ++++++
doc.ja/src/sgml/failover.sgml | 27 +++++++++++++++++++++++++++
doc/src/sgml/example-cluster.sgml | 6 ++++++
doc/src/sgml/failover.sgml | 3 ++-
src/sample/scripts/failover.sh.sample | 6 ++++++
5 files changed, 47 insertions(+), 1 deletion(-)
diff --git a/doc.ja/src/sgml/example-cluster.sgml b/doc.ja/src/sgml/example-cluster.sgml
index cdc70b557..cfd5bc4bc 100644
--- a/doc.ja/src/sgml/example-cluster.sgml
+++ b/doc.ja/src/sgml/example-cluster.sgml
@@ -525,6 +525,12 @@ PGHOME=/usr/pgsql-11
logger -i -p local1.info failover.sh: start: failed_node_id=$FAILED_NODE_ID old_primary_node_id=$OLD_PRIMARY_NODE_ID failed_host=$FAILED_NODE_HOST new_master_host=$NEW_MASTER_NODE_HOST
+## If there's no master node anymore, skip failover.
+if [ $NEW_MASTER_NODE_ID -lt 0 ]; then
+ logger -i -p local1.info failover.sh: All nodes are down. Skipping failover.
+ exit 0
+fi
+
## Test passwrodless SSH
ssh -T -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null postgres@${NEW_MASTER_NODE_HOST} -i ~/.ssh/id_rsa_pgpool ls /tmp > /dev/null
diff --git a/doc.ja/src/sgml/failover.sgml b/doc.ja/src/sgml/failover.sgml
index b2cc6037b..7b5041676 100644
--- a/doc.ja/src/sgml/failover.sgml
+++ b/doc.ja/src/sgml/failover.sgml
@@ -196,6 +196,33 @@
</tgroup>
</table>
+ <note>
+ <para>
+ <!--
+ The "master node" refers to a node which has the
+ "youngest (or the smallest) node id" among live the
+ database nodes. In <link linkend="running-mode">streaming
+ replication mode</link>, this may be different from
+ primary node. In <xref linkend="failover-command-table">,
+ %m is the new master node chosen
+ by <productname>Pgpool-II</productname>. It is the node
+ being assigned the youngest (smallest) node id which is
+ alive. For example if you have 3 nodes, namely node 0, 1,
+ 2. Suppose node 1 the primary and all of them are healthy
+ (no down node). If node 1 fails, failover_command is
+ called with %m = 0. And, if all standby nodes are down and primary node
+ failover happens, failover_command is called with %m = -1 and %H,%R,$r = "".
+ -->
+ マスターノードは、生きているデータベースノードの中から一番若い(小さい)ノードIDを持つノードを参照します。
+ <link linkend="running-mode">ストリーミングレプリケーションモード</link>では、このノードはプライマリノードとは異なる場合があります。
+ <xref linkend="failover-command-table">内では、 %mは<productname>Pgpool-II</productname>によって選出された新しいマスターノードとなります。
+ 新しいマスターノードには生きているノードで一番若い(小さい)ノードが割り当てられます。
+ 例えば、ノード0、1、2という3つのノードを持ち、ノード1がプライマリノード、全てのノードは正常である(ダウンしているノードがない)と仮定します。
+ ノード1がダウンした場合、failover_command は %m = 0 で呼び出されます。
+ また、全てのスタンバイノードがダウンした状態でプライマリノードのフェイルオーバが起きた場合、failover_commandは %m = -1、および%H,%R,%r = "" で呼び出されます。
+ </para>
+ </note>
+
<note>
<para>
<!--
diff --git a/doc/src/sgml/example-cluster.sgml b/doc/src/sgml/example-cluster.sgml
index 329c68ef8..e6f93331e 100644
--- a/doc/src/sgml/example-cluster.sgml
+++ b/doc/src/sgml/example-cluster.sgml
@@ -554,6 +554,12 @@ PGHOME=/usr/pgsql-11
logger -i -p local1.info failover.sh: start: failed_node_id=$FAILED_NODE_ID old_primary_node_id=$OLD_PRIMARY_NODE_ID failed_host=$FAILED_NODE_HOST new_master_host=$NEW_MASTER_NODE_HOST
+## If there's no master node anymore, skip failover.
+if [ $NEW_MASTER_NODE_ID -lt 0 ]; then
+ logger -i -p local1.info failover.sh: All nodes are down. Skipping failover.
+ exit 0
+fi
+
## Test passwrodless SSH
ssh -T -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null postgres@${NEW_MASTER_NODE_HOST} -i ~/.ssh/id_rsa_pgpool ls /tmp > /dev/null
diff --git a/doc/src/sgml/failover.sgml b/doc/src/sgml/failover.sgml
index 4a708ccfa..8b1e7734f 100644
--- a/doc/src/sgml/failover.sgml
+++ b/doc/src/sgml/failover.sgml
@@ -193,7 +193,8 @@
alive. For example if you have 3 nodes, namely node 0, 1,
2. Suppose node 1 the primary and all of them are healthy
(no down node). If node 1 fails, failover_command is
- called with %m = 0.
+ called with %m = 0. And, if all standby nodes are down and primary node
+ failover happens, failover_command is called with %m = -1 and %H,%R,$r = "".
</para>
</note>
diff --git a/src/sample/scripts/failover.sh.sample b/src/sample/scripts/failover.sh.sample
index 2032ba306..4317ce04c 100755
--- a/src/sample/scripts/failover.sh.sample
+++ b/src/sample/scripts/failover.sh.sample
@@ -37,6 +37,12 @@ PGHOME=/usr/pgsql-11
logger -i -p local1.info failover.sh: start: failed_node_id=$FAILED_NODE_ID old_primary_node_id=$OLD_PRIMARY_NODE_ID failed_host=$FAILED_NODE_HOST new_master_host=$NEW_MASTER_NODE_HOST
+## If there's no master node anymore, skip failover.
+if [ $NEW_MASTER_NODE_ID -lt 0 ]; then
+ logger -i -p local1.info failover.sh: All nodes are down. Skipping failover.
+ exit 0
+fi
+
## Test passwrodless SSH
ssh -T -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null postgres@${NEW_MASTER_NODE_HOST} -i ~/.ssh/id_rsa_pgpool ls /tmp > /dev/null
[parent: ef7ed8b6afcc]