pgd node setup v6.0.0
Synopsis
The pgd node setup
command is used to configure PGD data nodes in a cluster. It can be used to set up a new node, join an existing node to a cluster, or perform a logical join of a node to the cluster.
The behavior of the command depends on the state of the local node and the remote node specified in the command.
If this is the first node in the cluster, pgd node setup
will perform initdb and setup PGD node.
If this is not the first node, but the local node is not up and running, pgd node setup
will perform a physical join of the node to the cluster. This will copy the data from the remote node to the local node as part of the initialization process, then join the local node to the cluster. This is the fastest way to load data into a new node.
If the local node is up and running and remote node also is reachable, pgd node setup
will perform a logical join of the node to the cluster. This will create a new node in the cluster and start streaming replication from the remote node. This is the recommended way to add a new node to an existing cluster.
If the local node is up and running and remote node dsn is not provided, pgd node setup
will do a node group switch if node not part of the given group.
Syntax
pgd node <NODE_NAME> setup [OPTIONS] -D <PG_DATA> <NODE_DSN>
Arguments
<NODE_DSN>
DSN of the local node. This is the connection string to the local node. It is used to connect to the local node and perform the setup operation.
This is a mandatory argument and should be in the format host=localhost port=5432 user=postgres dbname=bdrdb
.
Options
Option | Description |
---|---|
-D, --pgdata <PG_DATA> | Uses <PG_DATA> as the data directory of the node. (Also set with environment variable PGDATA ) |
--listen-address <ADDRESS> | Sets listen address the new node should listen to <ADDRESS> (defaults to localhost ) |
--initial-node-count | Number of nodes in the cluster (or planned to be in the cluster). Used to calculate various resource settings for the node. Default is 3. |
--bindir <BINDIR> | <BINDIR> Specifies the directory where the binaries are located. Defaults to the directory where the running pgd binary is located. |
--superuser <SUPERUSER> | The superuser to use for the connection. |
--node-kind <NODE_KIND> | Specifies the kind of node to be created. Applies to first node only. Default is data .Possible values are data , witness , subscriber-only . |
--group-name <GROUP_NAME> | Node group name. If not provided, the node will be added to the group of the active node. It is a mandatory argument for the first node of a group. |
--create-group | Set this flag to create the given group, if it is not already present. This will be true by default for the first node. |
--cluster-name <CLUSTER_NAME> | Name of the cluster to join the node to. Defaults to pgd |
--cluster-dsn <CLUSTER_DSN> | A DSN which belongs to the active PGD cluster. When configuring the first node of a cluster, should point to the DSN for the first node. |
--postgresql-conf <POSTGRESQL_CONF> | Optional path of the postgresql.conf file to be used for the node. |
--postgresql-auto-conf <POSTGRESQL_AUTO_CONF> | Optional path of the postgresql.auto.conf file to be used for the node. |
--hba-conf <HBA_CONF> | Optional path of the pg_hba.conf file to be used for the node. |
--update-pgpass | If set, the pgpass file for the new nodes password will be stored in the current user's .pgpass file. |
--debug | Print debug messages, useful while troubleshooting. |
--verbose | Print verbose messages. |
--log-file <LOG_FILE> | Log file to write the log messages to. Records log messages for any external commands executed. Default is to write a file in the current directory named postgres-<port>.log where the port value |
See also Global Options.
Examples
In these examples, we will set up a cluster with on three hosts, host-1
, host-2
and host-3
, to create three nodes: node-one
, node-two
, and node-three
.
The three nodes will be data nodes, and part of a cluster named dc1-cluster
with the group name dc1
.
Configuring the first node
pgd node node-one setup --group-name dc1 --cluster-name dc1-cluster --create-group \ --cluster-dsn "host=localhost port=5432 user=postgres dbname=bdrdb" \ --pgdata /var/lib/edb-pge/17/main
Stepping through the command, we are setting up "node-one". This is the first node in the cluster, so we set the group name to dc1
and the cluster name to dc1-cluster
. The --create-group
option indicates that this is the first node in the group, so it will create the group as well.
We also need to provide the --cluster-dsn
option, which is the connection string for the first node. This is typically set to host=localhost port=5432 user=postgres dbname=bdrdb
, which is a typical connection string for a local Postgres instance.
Finally, we set the data directory for the node with the --pgdata
option; this is where the Postgres data files will be stored. In this example, we are using /var/lib/edb-pge/17/main
as the data directory.
The command will create the data directory and initialize the database correctly for PGD. It will then start the node and make it available for new connections, including the other nodes joining the cluster.
Configuring the second node
pgd node node-two setup --pgdata /var/lib/edb-pge/17/main --group-name dc1 --cluster-name dc1-cluster --cluster-dsn "host= port=5444 user=postgres dbname=bdrdb" --create-group