pgpool2.git / summary / log / commit / refs

commit    57ccb9bf80cebfe206ea55dec76b3b560f147a9b
Author:   Tatsuo Ishii <ishii@postgresql.org>
Date:     Fri Nov 18 02:46:48 2016 +0000

    Translate AWS watchdog example.


doc.ja/src/sgml/examples.sgml | 387 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 384 insertions(+), 3 deletions(-) diff --git a/doc.ja/src/sgml/examples.sgml b/doc.ja/src/sgml/examples.sgml index c81d87d19..6cf41d57c 100644 --- a/doc.ja/src/sgml/examples.sgml +++ b/doc.ja/src/sgml/examples.sgml @@ -1042,13 +1042,394 @@ arping_cmd = 'arping -U $_IP_$ -w 1' --> <title>AWS設定の例</title> + <para> +<!-- + This tutrial explains the simple way to try "Watchdog" + on <ulink url="https://aws.amazon.com/">AWS</ulink> and using + the <ulink url="http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html"> + Elastic IP Address</ulink> as the Virtual IP for the high availability solution. + <note> + <para> + You can use watchdog with <productname> + Pgpool-II</productname> in any mode: replication mode, + master/slave mode and raw mode. + </para> + </note> +--> +このチュートリアルでは、<ulink url="https://aws.amazon.com/">AWS</ulink>上で"Watchdog"を使う簡単な例を示します。 +この例では、高可用性のために<ulink url="http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html">Elastic IP Address</ulink>を仮想IPとして使います。 + <note> + <para> + watchdogは、<productname>Pgpool-II</productname>のすべてのモード、すなわちレプリケーションモード、マスタ/スレーブモード、ローモードのいずれでも使えます。 + </para> + </note> + </para> + + <sect2 id="example-AWS-setup"> +<!-- + <title>AWS Setup</title> +--> + <title>AWSのセットアップ</title> <para> <!-- - AWS watchdog configuration. + For this example, we will use two node <productname> + Pgpool-II</productname> watchdog cluster. So we will set up two + Linux Amazon EC2 instances and one Elastic IP address. + So for this example, do the following steps: --> -AWS watchdogの設定 +この例では、2ノードの<productname>Pgpool-II</productname> watchdogクラスタを使います。 +そこで、2つのAmazon Linux EC2インスタンスを設定し、ひとつのElastic IPアドレスを使用します。 +以下のステップを実施してください。 </para> - </sect1> + <itemizedlist> + + <listitem> + <para> +<!-- + Launch two Linux Amazon EC2 instances. For this example, we name these + instances as "instance-1" and "instance-2" +--> +Amazon Linux EC2インスタンスを2つ起動します。 +この例では、それぞれ"instance-1"と"instance-2"という名前を付けます。 + </para> + </listitem> + + <listitem> + <para> +<!-- + Configure the security group for the instances and allow inbound traffic + on ports used by pgpool-II and watchdog. +--> +これらのインスタンスのセキュリティグループを設定し、Pgpool-IIとwatchdogが使用するポートへのインバウンドトラフィックを許可します。 + </para> + </listitem> + + <listitem> + <para> +<!-- + Install the <productname>Pgpool-II</productname> on both instances. +--> +<productname>Pgpool-II</productname>を両方のインスタンスにインストールします。 + </para> + </listitem> + + <listitem> + <para> +<!-- + Allocate an Elastic IP address. + For this example, we will use "35.163.178.3" as an Elastic IP address" +--> +Elastic IPアドレスを確保します。 +この例では、Elastic IPアドレスに"35.163.178.3"を設定します。 + </para> + </listitem> + + </itemizedlist> + + </sect2> + + <sect2 id="example-AWS-pgpool-config"> +<!-- + <title><productname>Pgpool-II</productname> configurations</title> +--> + <title><productname>Pgpool-II</productname>の設定</title> + <para> +<!-- + Mostly the <productname>Pgpool-II</productname> configurations for this + example will be same as in the <xref linkend="example-watchdog">, except the + <xref linkend="guc-delegate-ip"> which we will not set in this example instead + we will use <xref linkend="guc-wd-escalation-command"> and + <xref linkend="guc-wd-de-escalation-command"> to switch the + Elastic IP address to the maste/Active <productname>Pgpool-II</productname> node. +--> +この例の設定は<xref linkend="example-watchdog">とほとんど同じになりますが、<xref linkend="guc-delegate-ip">を設定せず、代わりに<xref linkend="guc-wd-escalation-command">と<xref linkend="guc-wd-de-escalation-command">を使ってmaste/Active <productname>Pgpool-II</productname>ノードのElastic IPアドレスを切り替えるのが異なります。 + </para> + + <sect3 id="example-AWS-pgpool-config-instance-1"> +<!-- + <title><productname>Pgpool-II</productname> configurations on Instance-1</title> +--> + <title>Instance-1における<productname>Pgpool-II</productname>の設定</title> + <para> + + <programlisting> +use_watchdog = on +wd_hostname = 'instance-1-private-ip' +other_pgpool_hostname0 = 'instance-2-private-ip' +other_pgpool_port0 = 9999 +other_wd_port0 = 9000 +wd_escalation_command = '$path_to_script/aws-escalation.sh' +wd_de_escalation_command = '$path_to_script/aws-de-escalation.sh' + </programlisting> + + </para> + </sect3> + + <sect3 id="example-AWS-pgpool-config-instance-2"> +<!-- + <title><productname>Pgpool-II</productname> configurations on Instance-2</title> +--> + <title>Instance-2における<productname>Pgpool-II</productname>の設定</title> + <para> + + <programlisting> +use_watchdog = on +wd_hostname = 'instance-2-private-ip' +other_pgpool_hostname0 = 'instance-1-private-ip' +other_pgpool_port0 = 9999 +other_wd_port0 = 9000 +wd_escalation_command = '$path_to_script/aws-escalation.sh' +wd_de_escalation_command = '$path_to_script/aws-de-escalation.sh' + </programlisting> + + </para> + </sect3> + </sect2> + + <sect2 id="example-AWS-pgpool-aws-escalation-instance"> +<!-- + <title>escalation and de-escalation Scripts</title> +--> + <title>エスカレーションおよびディエスカレーション用のスクリプト</title> + <para> +<!-- + Create the aws-escalation.sh and aws-de-escalation.sh scripts on both + instances and point the <xref linkend="guc-wd-escalation-command"> and + <xref linkend="guc-wd-de-escalation-command"> to the respective scripts. +--> +aws-escalation.shとaws-de-escalation.shスクリプトを2つのインスタンス上に作成し、<xref linkend="guc-wd-escalation-command">と<xref linkend="guc-wd-de-escalation-command">がそれぞれそれらを指すようにしてください。 + </para> + + <note> + <para> +<!-- + You may need to configure the AWS CLI first on all AWS instances + to enable the execution of commands used by wd-escalation.sh and wd-de-escalation.sh. + See <ulink url="http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html">configure AWS CLI</ulink> +--> +AWSインスタンス上でwd-escalation.shとwd-de-escalation.shで使用するコマンドが実行できるようにするために、AWS CLIの設定が必要になるかもしれません。 +<ulink url="http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html">configure AWS CLI</ulink>を参照してください。 + </para> + </note> + + <sect3 id="example-AWS-pgpool-aws-escalation-script"> +<!-- + <title>escalation script</title> +--> + <title>エスカレーションスクリプト</title> + + <para> +<!-- + This script will be executed by the watchdog + to assign the Elastic IP on the instance when the watchdog becomes the active/master node. + Change the INSTANCE_ID and ELASTIC_IP values as per your AWS setup values. +--> +このスクリプトは、watchdogがactive/masterノードになったときに、Elastic IPをアサインするためにwatchdogが実行します。 + </para> + <para> + <emphasis>aws-escalation.sh:</emphasis> + <programlisting> +#! /bin/sh + +ELASTIC_IP=35.163.178.3 + # replace it with the Elastic IP address you + # allocated from the aws console +INSTANCE_ID=i-0a9b64e449b17ed4b + # replace it with the instance id of the Instance + # this script is installed on + +echo "Assigning Elastic IP $ELASTIC_IP to the instance $INSTANCE_ID" +# bring up the Elastic IP +aws ec2 associate-address --instance-id $INSTANCE_ID --public-ip $ELASTIC_IP + +exit 0 + </programlisting> + + </para> + + </sect3> + <sect3 id="example-AWS-pgpool-aws-de-escalation-script"> +<!-- + <title>de-escalation script</title> +--> + <title>ディエスカレーションスクリプト</title> + <para> +<!-- + This script will be executed by watchdog + to remove the Elastic IP from the instance when the watchdog resign from the active/master node. +--> +このスクリプトは、watchdogがactive/masterノードを退任するときに、Elastic IPのアサインを解除するためにwatchdogが実行します。 + </para> + <para> + <emphasis>aws-de-escalation.sh:</emphasis> + <programlisting> +#! /bin/sh + +ELASTIC_IP=35.163.178.3 + # replace it with the Elastic IP address you + # allocated from the aws console + +echo "disassociating the Elastic IP $ELASTIC_IP from the instance" +# bring down the Elastic IP +aws ec2 disassociate-address --public-ip $ELASTIC_IP +exit 0 + </programlisting> + </para> + </sect3> + + <bibliography> +<!-- + <title>AWS Command References</title> +--> + <title>AWSコマンドリファレンス</title> + + <biblioentry> + <biblioset relation="article"> + <title><ulink url="http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html">Configure AWS CLI</ulink></title> + </biblioset> + <biblioset relation="book"> + <title>AWS Documentation: Configuring the AWS Command Line Interface</title> + </biblioset> + </biblioentry> + + <biblioentry> + <biblioset relation="article"> + <title><ulink url="http://docs.aws.amazon.com/cli/latest/reference/ec2/associate-address.html">associate-address</ulink></title> + </biblioset> + <biblioset relation="book"> + <title>AWS Documentation: associate-address reference</title> + </biblioset> + </biblioentry> + + <biblioentry> + <biblioset relation="article"> + <title><ulink url="http://docs.aws.amazon.com/cli/latest/reference/ec2/disassociate-address.html">disassociate-address</ulink></title> + </biblioset> + <biblioset relation="book"> + <title>AWS Documentation: disassociate-address reference</title> + </biblioset> + </biblioentry> + + </bibliography> + </sect2> + + <sect2 id="example-AWS-try"> +<!-- + <title>Try it out</title> +--> + <title>実行してみる</title> + <para> +<!-- + Start <productname>Pgpool-II</productname> on each server with "-n" switch + and redirect log messages to the pgpool.log file. + The log message of master/active <productname>Pgpool-II</productname> node + will show the message of Elastic IP assignment. +--> +それぞれのサーバ上で<productname>Pgpool-II</productname>を"-n"スイッチ付きで起動し、pgpool.logにログメッセージをリダイレクトします。 +master/active <productname>Pgpool-II</productname>ノードは、Elastic IPのアサインメッセージを表示します。 + <programlisting> +LOG: I am the cluster leader node. Starting escalation process +LOG: escalation process started with PID:23543 +LOG: watchdog: escalation started +<emphasis> +Assigning Elastic IP 35.163.178.3 to the instance i-0a9b64e449b17ed4b +{ + "AssociationId": "eipassoc-39853c42" +} +</emphasis> +LOG: watchdog escalation successful +LOG: watchdog escalation process with pid: 23543 exit with SUCCESS. + </programlisting> + </para> + + <para> +<!-- + Confirm to ping to the Elastic IP address. +--> +Elastic IPアドレスにpingが通ることを確かめます。 + <programlisting> +[user@someserver]$ ping 35.163.178.3 +PING 35.163.178.3 (35.163.178.3) 56(84) bytes of data. +64 bytes from 35.163.178.3: icmp_seq=1 ttl=64 time=0.328 ms +64 bytes from 35.163.178.3: icmp_seq=2 ttl=64 time=0.264 ms +64 bytes from 35.163.178.3: icmp_seq=3 ttl=64 time=0.412 ms + </programlisting> + </para> + + <para> +<!-- + Try to connect <productname>PostgreSQL</> by "psql -h ELASTIC_IP -p port". +--> +"psql -h ELASTIC_IP -p port"で<productname>PostgreSQL</>に接続してみます。 + <programlisting> +[user@someserver]$ psql -h 35.163.178.3 -p 9999 -l + </programlisting> + </para> + </sect2> + + <sect2 id="example-AWS-vip-switch"> +<!-- + <title>Switching Elastic IP</title> +--> + <title>Elastic IPの切換</title> + <para> +<!-- + To confirm if the Standby server acquires the Elastic IP when the + Active server becomes unavailable, Stop the <productname>Pgpool-II</productname> + on the Active server. Then, the Standby server should start using the Elastic IP address, + And the <productname>Pgpool-II</productname> log will show the below messages. +--> +アクティブなサーバが使用できなくなった時にスタンバイサーバがElastic IPを獲得できることを確認するために、アクティブサーバ上の<productname>Pgpool-II</productname>を停止します。 +すると、スタンバイサーバはElastic IPアドレスを使い始めるはずです。 +<productname>Pgpool-II</productname>のログには以下のようなメッセージが表示されます。 + <programlisting> +<emphasis> +LOG: remote node "172.31.2.94:9999 [Linux ip-172-31-2-94]" is shutting down +LOG: watchdog cluster has lost the coordinator node +</emphasis> +LOG: watchdog node state changed from [STANDBY] to [JOINING] +LOG: watchdog node state changed from [JOINING] to [INITIALIZING] +LOG: I am the only alive node in the watchdog cluster +HINT: skiping stand for coordinator state +LOG: watchdog node state changed from [INITIALIZING] to [MASTER] +LOG: I am announcing my self as master/coordinator watchdog node +LOG: I am the cluster leader node +DETAIL: our declare coordinator message is accepted by all nodes +LOG: I am the cluster leader node. Starting escalation process +LOG: escalation process started with PID:23543 +LOG: watchdog: escalation started +<emphasis> +Assigning Elastic IP 35.163.178.3 to the instance i-0dd3e60734a6ebe14 +{ + "AssociationId": "eipassoc-39853c42" +} +</emphasis> +LOG: watchdog escalation successful +LOG: watchdog escalation process with pid: 61581 exit with SUCCESS. + </programlisting> +<!-- + Confirm to ping to the Elastic IP address again. +--> +Elastic IPアドレスにpingが通ることを再度確かめます。 + <programlisting> +[user@someserver]$ ping 35.163.178.3 +PING 35.163.178.3 (35.163.178.3) 56(84) bytes of data. +64 bytes from 35.163.178.3: icmp_seq=1 ttl=64 time=0.328 ms +64 bytes from 35.163.178.3: icmp_seq=2 ttl=64 time=0.264 ms +64 bytes from 35.163.178.3: icmp_seq=3 ttl=64 time=0.412 ms + </programlisting> + </para> + <para> +<!-- + Try to connect <productname>PostgreSQL</> by "psql -h ELASTIC_IP -p port". +--> +"psql -h ELASTIC_IP -p port"で<productname>PostgreSQL</>に接続してみます。 + <programlisting> +[user@someserver]$ psql -h 35.163.178.3 -p 9999 -l + </programlisting> + </para> + </sect2> + </sect1> </chapter> </part> [parent: e840649f1846]