PGSQL Basic

Basic primary-replica postgres cluster setup

Singleton

Let’s start with the simplest case.

  1. pg-test:
  2. hosts:
  3. 10.10.10.11: { pg_seq: 1, pg_role: primary }
  4. vars:
  5. pg_cluster: pg-test

Use the following command to create a primary database instance on the 10.10.10.11 node.

  1. bin/createpg pg-test

M-S Replication

Pigsty natively supports M-S replication, e.g., to declare a typical one primary & one replica HA database cluster.

  1. pg-test:
  2. hosts:
  3. 10.10.10.11: { pg_seq: 1, pg_role: primary }
  4. 10.10.10.12: { pg_seq: 2, pg_role: replica }
  5. vars:
  6. pg_cluster: pg-test

Use bin/createpg pg-test to create the cluster. If you have already finished deploying 10.10.10.11 in step 1 singleton deployment, you can also use bin/createpg 10.10.10.12 to expand the cluster.

Last modified 2022-06-04: fii en docs batch 2 (61bf601)