Viewing PGD topology
====================

PGDグループのリスト
-------------------

 :ref:`pgd-cli <../cli>` の使用
^^^^^^^^^^^^^^^^^^^

 :ref:`pgd-cli <../cli>`  ``show-groups``
コマンドを使用して、PGDクラスター内のすべてのグループをリストします。

.. code:: shell

   pgd show-groups

.. code:: console

     Group    Group ID   Type            Parent Group Location Raft  Routing Write Leader
     -----    --------   ----            ------------ -------- ----  ------- ------------
     bdrgroup 1360502012 global                                true  false
     group_a  3618712053 data            bdrgroup     a        true  true    bdr-a1
     group_b  402614658  data            bdrgroup     b        true  true    bdr-b1
     group_c  2808307099 data            bdrgroup     c        false false
     group_so 2123208041 subscriber-only bdrgroup     c        false false

SQLを使用する
^^^^^^^^^^^^^

次の単純なクエリーは、現在のノードがメンバーであるすべてのPGDノードグループをリストします。現在、
 :ref:`bdr.local_node_summary <bdr.local_node_summary>`  から1行のみを返します。

.. code:: sql

   SELECT node_group_name
   FROM bdr.local_node_summary;

より複雑なクエリーを使用して、各ノードグループの構成を表示できます。

.. code:: sql

   SELECT g.node_group_name
   , ns.pub_repsets
   , ns.sub_repsets
   , g.node_group_default_repset     AS default_repset
   , node_group_check_constraints    AS check_constraints
   FROM bdr.local_node_summary ns
   JOIN bdr.node_group g USING (node_group_name);

PGDグループ内のノードのリスト
-----------------------------

 :ref:`pgd-cli <../cli>` の使用
^^^^^^^^^^^^^^^^^^^

``show-nodes``
コマンドを使用して、PGDクラスター内のすべてのノードをリストします。

.. code:: shell

   pgd show-nodes

.. code:: console

     Node               Node ID    Group    Type            Current State Target State Status Seq ID
     ----               -------    -----    ----            ------------- ------------ ------ ------
     bdr-a1             3136956818 group_a  data            ACTIVE        ACTIVE       Up     6
     bdr-a2             2133699692 group_a  data            ACTIVE        ACTIVE       Up     3
     logical-standby-a1 1140256918 group_a  standby         STANDBY       STANDBY      Up     9
     witness-a          3889635963 group_a  witness         ACTIVE        ACTIVE       Up     7
     bdr-b1             2380210996 group_b  data            ACTIVE        ACTIVE       Up     1
     bdr-b2             2244996162 group_b  data            ACTIVE        ACTIVE       Up     2
     logical-standby-b1 3541792022 group_b  standby         STANDBY       STANDBY      Up     10
     witness-b          661050297  group_b  witness         ACTIVE        ACTIVE       Up     5
     witness-c          1954444188 group_c  witness         ACTIVE        ACTIVE       Up     4
     subscriber-only-c1 2448841809 group_so subscriber-only ACTIVE        ACTIVE       Up     8

グループ名で\ ``grep``
を使用して、リストを特定のグループにフィルタリングします。

.. code:: shell

   pgd show-nodes | grep group_b

.. code:: console

     bdr-b1             2380210996 group_b  data            ACTIVE        ACTIVE       Up     1
     bdr-b2             2244996162 group_b  data            ACTIVE        ACTIVE       Up     2
     logical-standby-b1 3541792022 group_b  standby         STANDBY       STANDBY      Up     10
     witness-b          661050297  group_b  witness         ACTIVE        ACTIVE       Up     5

.. _sqlを使用する-1:

SQLを使用する
^^^^^^^^^^^^^

 :ref:`bdr.node_summary <bdr.node_summary>`  ``ビューから、特定のノードグループ``
mygroup`などのすべてのノードのリストを抽出できます。例

.. code:: sql

   SELECT node_name         AS name
   , node_seq_id            AS ord
   , peer_state_name        AS current_state
   , peer_target_state_name AS target_state
   , interface_connstr      AS dsn
   FROM bdr.node_summary
   WHERE node_group_name = mygroup;

``current_state`` または\ ``target_state``
クエリー列で示されるノードの読み取り専用状態は、 ``STANDBY``
として示されます。
