BDR-Always-ON
=============

EDB Postgres Distributed 3.7 or 4 in an Always-ON configuration is
suitable for use in test and production.

This architecture requires a subscription to the legacy 2ndQuadrant
repositories, and some options require a subscription to EDB Repos 1.0.
See :ref:`How TPA uses 2ndQuadrant and EDB repositories <How TPA uses 2ndQuadrant and EDB repositories>` 

for more detail.

The BDR-Always-ON architecture has four variants, which can be selected
with the ``--layout`` configure option:

-  ``bronze`` : 2×bdr+primary, bdr+witness, barman, 2×harp-proxy

-  ``silver`` : bronze, with bdr+witness promoted to bdr+primary, and
   barman moved to separate location

-  ``gold`` : two symmetric locations with 2×bdr+primary, 2×harp-proxy,
   and barman each; plus a bdr+witness in a third location

-  ``platinum`` : gold, but with one bdr+readonly (logical standby)
   added to each of the main locations

See EDB’s Postgres Distributed Always On Architectures :ref:`whitepaper <EDB Postgres Distributed configuration>` 

for the detailed layout diagrams.

This architecture is meant for use with PGD versions 3.7 and 4.

Cluster configuration
---------------------

Overview of configuration options
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This example shows an invocation of ``tpaexec configure`` for this
architecture:

.. code:: shell

   tpaexec configure ~/clusters/bdr \
            --architecture BDR-Always-ON \
            --platform aws --region eu-west-1 --instance-type t3.micro \
            --distribution Debian \
            --edb-postgres-advanced 14 --redwood
            --layout gold \
            --harp-consensus-protocol bdr

You can list all available options using the ``help`` command.

.. code:: shell

   tpaexec configure --architecture BDR-Always-ON --help

Mandatory options
^^^^^^^^^^^^^^^^^

.. csv-table::
  :header: Option,Description
  :widths: 10,30
  :align: left
  :class: longtable

  `--architecture` (`-a`),Must be set to `BDR-Always-ON`.
  `--postgresql 14` (for example),Any valid  :ref:`Configuring lvm-direct for production <Cluster configuration>` .
  `--layout`,"One of `bronze`, `silver`, `gold`, `platinum`."
  `--harp-consensus-protocol`,"One of `bdr`, `etcd`."

Additional options
^^^^^^^^^^^^^^^^^^

.. csv-table::
  :header: Option,Description,Behavior if omitted
  :widths: 12,25,15
  :align: left
  :class: longtable

  `--platform`,"One of `aws`, `docker`, `bare`.",Defaults to `aws`.
  `--enable-camo`,Sets two data nodes in each location as CAMO partners.,CAMO isn't enabled.
  `--bdr-database`,The name of the database to be used for replication.,Defaults to `bdrdb`.
  `--enable-harp-probes`,Enable http(s) api endpoints for harp such as `health/is-ready` to allow probing harp's health.,Disabled by default.

More detail about BDR-Always-ON configuration
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Specify ``--layout layoutname`` to choose a layout: ``bronze`` ,
``silver`` , ``gold`` , or ``platinum`` . The bronze, gold, and platinum
layouts have a PGD witness node to ensure an odd number of nodes for
Raft consensus majority. Witness nodes don’t participate in the data
replication.

You must specify ``--harp-consensus-protocol protocolname`` . The
supported protocols are bdr and etcd. See :ref:`Configuring HARP <Configuring HARP>`  for more
details.

You can optionally specify ``--bdr-database dbname`` to set the name of
the database with PGD enabled (default: ``bdrdb`` ).

You can optionally specify ``--enable-camo`` to set the pair of PGD
primary instances in each region to be each other’s CAMO partners.

You can optionally specify ``--enable-harp-probes [{http, https}]`` to
enable http(s) api endpoints that allow you to easily probe harp’s
health.

HARP2 is enabled by default in the BDR-Always-ON architecture.

You can also specify any of the options described by :ref:`tpaexec help configure-options <Cluster configuration>`  .
