Managing clusters using the CLI

These examples show Azure as the cloud provider unless indicated otherwise. The functionality is the same when using AWS or Google Cloud.

Managing single-node and primary/standby high-availability clusters

Use the cluster commands to create, retrieve information on, and manage single-node and primary/standby high-availability clusters.

Create a cluster in interactive mode

The default mode for the cluster create and pgd create commands is an interactive mode that guides you through the required cluster configuration by providing you with the valid values.

Tip

You can turn off prompting using the biganimal config set interactive_mode off command. With prompting disabled, if any required flags are missing, the CLI exits with an error.

For example, to create a primary/standby high-availability cluster:

biganimal cluster create
Output
Cluster architecture: High Availability
Number of standby replicas: 2 Replicas
Enable read-only workloads: No
Provider: Azure
Cluster Name: my-biganimal-cluster
Password: ****************
PostgreSQL type: EDB Postgres Advanced Server
PostgreSQL version: 14
Region: East US
Instance type: E2s v3(2vCPU, 16GB RAM)
Volume type: Azure Premium Storage
Volume properties: P1 (4 Gi, 120 Provisioned IOPS, 25 Provisioned MB/s)
Networking: Public
By default your cluster allows all inbound communications, add IP allowed list to restrict the access: Yes
Add CIDR blocks "192.168.1.1/16=Sample Description" leave empty to stop adding: 
Add database config in the format "application_name=sample_app&array_nulls=true", Leave empty for default configuration: 
Backup Retention Period, note backups will incur storage charges from the cloud provider directly. e.g. "7d", "2w" or "3m": 30d 

You're prompted to confirm that you want to create the cluster. After the cluster creation process is complete, it generates a cluster ID.

biganimal cluster create
Output
........
Are you sure you want to Create Cluster ? [y|N]: y
Create Cluster operation is started
Cluster ID is "p-gxhkfww1fe"
To check current state, run: biganimal cluster show --id p-gxhkfww1fe

Check your cluster was created successfully using the cluster show command shown in the return message:

biganimal cluster show --id p-gxhkfww1fe
Output
┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Clusters                                                                                                                                                                                 │
├──────────────┬──────────────────────┬──────────┬──────────────┬──────────────────────────┬─────────────┬───────────────┬───────────────────────────────┬────────────────────┬────────────┤
│ ID           │ Name                 │ Provider │ Architecture │ Status                   │ Region      │ Instance Type │ Postgres Details              │ Maintenance Window │ FAReplicas │
├──────────────┼──────────────────────┼──────────┼──────────────┼──────────────────────────┼─────────────┼───────────────┼───────────────────────────────┼────────────────────┼────────────┤
│ p-gxhkfww1fe │ my-biganimal-cluster │ Azure    │ ha           │ Cluster in healthy state │ East US     │ E2s v3        │ EDB Postgres Advanced Server  │ Disabled           │ N/A        │
│              │                      │          │              │                          │             │               │                               │                    │            │
└──────────────┴──────────────────────┴──────────┴──────────────┴──────────────────────────┴─────────────┴───────────────┴───────────────────────────────┴────────────────────┴────────────┘

Create a cluster using a configuration file

You can use the create --config-file command to create one or more clusters with the same configuration in a noninteractive mode.

Here's a sample configuration file in YAML format with Azure specified as the provider:

  # config_file.yaml
  ---
  clusterArchitecture: ha                     # <string:  cluster architecture, valid values ["single" | "ha" | "eha"]>
  haStandbyReplicas: 2                        # <number:  Number of standby replicas. Field must be specified if user has selected high availability cluster type. Default value is 2, valid values [1, 2].>
  provider: azure                             # <string:  cloud provider id>
  clusterName: my-biganimal-cluster           # <string:  cluster name>
  password: ************                      # <string:  cluster password (must be at least 12 characters)>
  iamAuthentication: false                    # <bool:    Identity and Access Management, enabling IAM authentication will allow database users to authenticate to Postgres using your cloud provider's IAM(currently supported only for AWS). You can set up IAM authentication after your cluster is provisioned.>
  postgresType: epas                          # <string:  postgresType id, valid values ["postgres" | "epas" | "pgextended"]>
  postgresVersion: "14"                       # <string:  postgres version>
  region: eastus                              # <string:  provider region id>
  instanceType: azure:Standard_E2s_v3         # <string:  instance type id>
  volumeType: azurepremiumstorage             # <string:  volume type id>
  volumeProperties: P1                        # <string:  Applicable to Azure only, volume properties id>
  volumePropertySize: "4Gi"                   # <string:  Applicable to AWS gp3 only and Azure Ultradisk, volume size in Byte, you may append unit suffix 'Gi' or 'G'.>
  volumePropertyIOPS: 3000                    # <number>: Applicable to AWS gp3 and Azure Ultradisk, volume Input/Output Operations Per Second> 
  networking: public                          # <string:  input "private" or "public" network>
  allowIpRangeMap:                            # <list:    IP Range to allow network traffic to your cluster from the public Internet>
    - cidr: 9.9.9.9/28                        # <string:  CIDR of allowed source IP range>
      description: Allow traffic from App A   # <string:  The description of this allowed ip range>
    - cidr: 10.10.10.10/27                    # <string:  CIDR of allowed source IP range>
      description: Allow traffic from App B   # <string:  The description of this allowed ip range>
  pgConfigMap:                                # <Object:  Postgres configuration>
    application_name: test_app                # <string:  set the database "application_name" property to "test_app">
    array_nulls: true                         # <bool:    set the database "array_nulls" property to True>
  backupRetentionPeriod: 30d                  # <string:  Use strings like “7d“ or “2w“ or “3m” to specify days (1-180), weeks (1-25) or months (1-6) to set retention period>
  readOnlyWorkloads:                          # <bool:    Set True to enable read-only connection and route all read-only queries to standby replicas and reduce the workload on primary>
  ---
Note

For backward compatibility, allowIpRangeMap and pgConfigMap properties also support embedded JSON format.

allowIpRangeMap: [["9.9.9.9/28", "Allow traffic from App A"],["10.10.10.10/27", "Allow traffic from App B"]]
pgConfigMap: [["application_name","test_app"],["array_nulls","true"]] 

To create the cluster using the sample configuration file config_file.yaml:

biganimal cluster create --config-file "./config_file.yaml"

To query an enumeration of valid values for the BigAnimal and cloud service provider-related properties, CLI provides a series of subcommands. For example, you can use cluster show-architectures to list all cloud architectures available to your current login account:

biganimal cluster show-architectures
Output
┌───────────────────────────────────────────────┐
│ Architecture                                  │
├────────┬───────────────────────────┬──────────┤
│ ID     │ Name                      │ Status   │
├────────┼───────────────────────────┼──────────┤
│ ha     │ High Availability         │ enabled  │
│ pgd    │ Extreme High Availability │ disabled │
│ single │ Single Node               │ enabled  │
└────────┴───────────────────────────┴──────────┘
Tip

You can turn off the confirmation step with the biganimal disable-confirm command.

Get cluster connection information

To use your BigAnimal cluster, you first need to get your cluster's connection information. To get your cluster's connection information, use the cluster show-connection command:

biganimal cluster show-connection \
  --name "my-biganimal-cluster" \
  --provider "azure" \
  --region "eastus"
Output
┌─────────────┬──────────────────────────────────────────────────────────────────────────────────────────┐
│ Access Type │ Connection String                                                                        │
├─────────────┼──────────────────────────────────────────────────────────────────────────────────────────┤
│ read-write  │ postgresql://edb_admin@p-gxhkfww1fe.30glixgayvwhtmn3.enterprisedb.network:5432/edb_admin │
│ read-only   │ Disabled                                                                                 │
└─────────────┴──────────────────────────────────────────────────────────────────────────────────────────┘
Tip

You can query the complete connection information with other output formats, like JSON or YAML. For example:

biganimal cluster show-connection \
  --name "my-biganimal-cluster" \
  --provider "azure" \
  --region "eastus" \
  --output "json"

Update cluster

After the cluster is created, you can update attributes of the cluster, including both the cluster’s profile and its deployment architecture. You can update the following attributes:

  • Cluster name
  • Password of administrator account
  • Cluster architecture
  • Number of standby replicas
  • Instance type of cluster
  • Instance volume properties
  • Networking
  • Allowed IP list
  • Postgres database configuration
  • Volume properties, size, IOPS
  • Retention period
  • Read-only workloads
  • IAM authentication

For example, to set the public allowed IP range list, use the --cidr-blocks flag:

./biganimal cluster update --name "my-biganimal-cluster" --provider "azure" \
  --region "eastus" \
  --cidr-blocks "9.9.9.9/28=Traffic from App A"

To check whether the setting took effect, use the cluster show command, and view the detailed cluster information output in JSON format. For example:

biganimal cluster show --name "my-biganimal-cluster" --provider "azure" \
  --region "eastus" \
  --output "json" \
| jq '.[0].allowIpRangeMap'
Output
[
  [
    "9.9.9.9/28",
    "Traffic from App A"
  ]
]

Update the Postgres configuration of a cluster

To update the Postgres configuration of a BigAnimal cluster directly from the CLI:

biganimal cluster update --id "p-gxhkfww1fe" \
  --pg-config "application_name=ba_test_app,array_nulls=false"
Output
Update Cluster operation is started
Cluster ID is "p-gxhkfww1fe"

To specify multiple configurations, you can use multiple --pg-config flags or include multiple configuration settings as a key-value array string separated by commas in one --pg-config flag. If a Postgres setting contains a comma, you need to specify it with a separate --pg-config flag.

Note

You can update the cluster architecture with the --cluster-architecture flag. The only supported scenario is to update a single-node cluster to a primary/standby high-availability cluster.

Delete a cluster

To delete a cluster you no longer need, use the cluster delete command. For example:

biganimal cluster delete \
  --name "my-biganimal-cluster" \
  --provider "azure" \
  --region "eastus"

You can list all deleted clusters using the show-deleted-clusters command and restore them from their history backups as needed.

Restore a cluster

BigAnimal continuously backs up your PostgreSQL clusters. Using the CLI, you can restore a cluster from its backup to any point in time as long as the backups are retained in the backup storage. The restored cluster can be in another region and have different configurations. You can specify new configurations in the cluster restore command. For example:

biganimal cluster restore\
  --name "my-biganimal-cluster" \
  --provider "azure" \
  --region "eastus" \
  --password "mypassword@123" \
  --new-name "my-biganimal-cluster-restored" \
  --new-region="eastus2" \
  --cluster-architecture "single" \
  --instance-type "azure:Standard_E2s_v3" \
  --volume-type "azurepremiumstorage" \
  --volume-property "P1" \
  --networking "public" \
  --cidr-blocks="10.10.10.10/27=Traffic from App B" \
  --restore-point "2022-01-26T15:04:05+0800" \
  --backup-retention-period "2w" \
  --read-only-workloads: "true"

The password for the restored cluster is mandatory. The other parameters, if not specified, inherit the source database's settings.

To restore a deleted cluster, use the --from-deleted flag in the command.

Note

You can restore a cluster in a single cluster to a primary/standby high-availability cluster and vice versa. You can restore a distributed high-availability cluster only to a cluster using the same architecture.

Managing distributed high-availability clusters

Use the BigAnimal pgd commands to create, retrieve information on, and manage distributed high-availability clusters.

Note

In addition to the BigAnimal pgd commands, you can switch over and use commands available in the EDB Postgres Distributed CLI to perform PGD-specific operations. The only EDB Postgres Distributed CLI commands that don't apply to BigAnimal are create-proxy and delete-proxy.

Create a distributed high-availability cluster

Create a distributed high-availability cluster using a YAML configuration file.

The syntax of the command is:

biganimal pgd create --config-file <config_file>

Where <conf_file> is a valid path to a YAML configuration file. For example:

clusterName: pgd-cli-name
password: Meredith Palmer Memorial
postgresType: epas
postgresVersion: "14" 
provider: azure
dataNodes: 2
dataGroups:
  - iamAuthentication: false                                       
    region: westus2                             
    instanceType: azure:Standard_E2s_v3        
    volumeType: azurepremiumstorage
    volumeProperties: P2
    networking: public                         
    allowIpRangeMap:                           
      - cidr: 9.9.9.9/28                       
        description: Allow traffic from App A  
      - cidr: 10.10.10.10/27                   
        description: Allow traffic from App B  
    pgConfigMap:                               
      application_name: test
      array_nulls: true                        
    backupRetentionPeriod: 30d
  - iamAuthentication: false                                                               
    region: canadacentral                             
    instanceType: azure:Standard_E2s_v3        
    volumeType: azurepremiumstorage
    volumeProperties: P2
    networking: public                         
    allowIpRangeMap:                           
      - cidr: 9.9.9.9/28                       
        description: Allow traffic from App A  
      - cidr: 10.10.10.10/27                   
        description: Allow traffic from App B  
    pgConfigMap:                               
      application_name: test1
      array_nulls: true                        
    backupRetentionPeriod: 30d
witnessGroups:
  - region: uksouth

Add a data group

Add a data group using a YAML configuration file.

The syntax of the command is:

biganimal pgd add-group --config-file <config_file>

Where <conf_file> is a valid path to a YAML configuration file. For example:

clusterId: clusterID
password: Meredith Palmer Memorial
dataGroups:
  - iamAuthentication: false                                                               
    region: centralus                             
    instanceType: azure:Standard_E2s_v3        
    volumeType: azurepremiumstorage
    volumeProperties: P2
    networking: public                         
    allowIpRangeMap:                           
      - cidr: 9.9.9.9/28                       
        description: Allow traffic from App A  
      - cidr: 10.10.10.10/27                   
        description: Allow traffic from App B  
    pgConfigMap:                               
      application_name: test1
      array_nulls: true                        
    backupRetentionPeriod: 30d
    customMaintenanceWindow:
      maintenanceStartTime: 15:00
      maintenanceStartDay: wednesday
witnessGroups:
  - region: westus2      

Update a distributed high-availability cluster

Update a distributed high-availability cluster and its data groups using a YAML configuration file.

The syntax of the command is:

pgd update [--config-file]

Where <conf_file> is a valid path to a YAML configuration file with the same format as a configuration file for creating a distributed high-availability cluster. See Create a distributed high-availability cluster.

Show distributed high-availability clusters

Show all active clusters or a specific cluster. You can also optionally show deleted clusters.

The syntax of the command is:

biganimal pgd show [--id] [--deleted]

Restore a distributed high-availability cluster

Restore a distributed high-availability cluster or a deleted distributed high-availability cluster to a new cluster on the same cloud provider. You can restore an active cluster or a deleted cluster within its retention period. You can restore only one data group. By default, the new cluster inherits all settings of the source cluster. You can change the cluster setting and database configurations by specifying new values in the configuration file.

The syntax of the command is:

pgd restore [--config-file]

Where <conf_file> is a valid path to a YAML configuration file. For example:

clusterName: pgd-restore-name
password: Meredith Palmer Memorial
dataNodes: 2
clusterId: p-9fdkl5ju29
dataGroups:
  - iamAuthentication: false                                       
    region: uksouth                             
    instanceType: azure:Standard_E2s_v3        
    volumeType: azurepremiumstorage
    volumeProperties: P2        
    allowIpRangeMap:                           
      - cidr: 9.9.9.9/28                       
        description: Allow traffic from App A  
      - cidr: 10.10.10.10/27                   
        description: Allow traffic from App B  
    pgConfigMap:                               
      application_name: test
      array_nulls: true                        
    backupRetentionPeriod: 30d
    sourceGroupId: p-9fdkl5ju29-a

Get distributed high-availability cluster connection information

To connect to and use your BigAnimal distributed high-availability cluster, you first need to get your cluster group's connection information.

The syntax of the command is:

biganimal pgd show-group-connection {--id --group-id} [--read-only] \ 
                                    [--read-write]