Manually Deploying PGD Essential near-far architecture
======================================================

The following instructions describe how to manually deploy the PGD
Essential near-far architecture. This architecture is designed for a
single location that needs to be reasonably highly available and needs
to be able to recover from a disaster. It does this by having a
two-data-node cluster in the primary location and a single data node in
a secondary location.

These instructions use the pgd command line tool to create the cluster
and configure the nodes. They assume that you have already installed PGD
Essential and have access to the pgd command line tool.

The primary location is referred to as the ``active`` location and the
secondary location as the ``dr`` location.

PGD configuration
-----------------

The primary location is configured with two data nodes, in their own
group “active”. This location is where the majority of the client
connections will be made.

The secondary location is configured with one data node, in its own
group “dr”.

They are all members of the same cluster.

Once created with pgd-cli, the routing and fencing of the nodes needs to
be configured.

First, disable the routing on both the “active” and “dr” groups:

.. code:: shell

   pgd group dr set-option enable_routing off --dsn "host=localhost port=5432 dbname=pgddb user=pgdadmin"
   pgd group active set-option enable_routing off --dsn "host=localhost port=5432 dbname=pgddb user=pgdadmin"

Then, enable the routing on the “pgd” top-level group:

.. code:: shell

   pgd group pgd set-option enable_routing on --dsn "host=localhost port=5432 dbname=pgddb user=pgdadmin"

Finally, enable the fencing on the “dr” group:

.. code:: shell

   pgd group dr set-option enable_fencing on --dsn "host=localhost port=5432 dbname=pgddb user=pgdadmin"

This approach ensures that the “dr” group is fenced off from the other
nodes in the cluster and doesn’t receive client connections by default.
The “active” group will continue to operate normally and will continue
to replicate data to the “dr” group.
