# Set Up a PostgreSQL Cluster

{% hint style="info" %}
**Prerequisites:** Prior to setting up a database, please make sure you are working within a provisioned [<mark style="color:blue;">VDC</mark>](https://docs.ionos.com/cloud/support/general-information/glossary-of-terms#vdc) that contains at least one [<mark style="color:blue;">virtual machine</mark>](https://docs.ionos.com/cloud/support/general-information/glossary-of-terms#virtual-machine-vm) from which to access the database. The VM you create is counted against the quota allocated in your contract.
{% endhint %}

{% hint style="info" %}
**Note:** Database Manager is available only for contract administrators, owners, and users with **Access and manage DBaaS** privilege. You can set the privilege via the DCD group privileges.
{% endhint %}

## Create a Cluster

To create a Postgres cluster, follow these steps:

1\. In the **DCD**, go to **Menu** > **Databases** > **PostgreSQL**.

{% hint style="info" %}
**Info:** The **Resource allocation** section displays the resources allotted to your contract and the number of used and unused resources if you have already created PostgreSQL clusters.
{% endhint %}

![Number of used and unused resources](https://1737632334-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MifAzdGvKLDTtvJP8sm%2Fuploads%2Fgit-blob-cc7f3fe3f983289e415b9350a859a22be69aae4c%2Fpostgres-resource-allocation.png?alt=media)

2\. In the **PostgreSQL cluster overview** window, click **Create cluster** to create a new Postgres cluster.

3\. Specify the following:

* Provide an appropriate **Cluster Name**.
* Select a **Location** where your data for the database cluster will be stored. You can select an available datacenter within the cluster's data directory to create your cluster.

![Define Cluster Properties](https://1737632334-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MifAzdGvKLDTtvJP8sm%2Fuploads%2Fgit-blob-54caae70c90fdc795090b14854e615fa20062145%2Fpostgres-cluster-properties.png?alt=media)

4\. To create a Postgres Cluster from the available backups directly, you can go to the **Create from backup** section and follow these steps:

* Select a **Backup cluster** from the drop-down list of cluster backups.
* Click the Calendar icon in the **Recover target time** field to select a date and time:
  * Select the **recovery date** from the calendar.
  * Select the **recovery time** using the clock.

![Create backup](https://1737632334-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MifAzdGvKLDTtvJP8sm%2Fuploads%2Fgit-blob-3e0723c4157da9edaa2136ff2d0b7dc02d7ea4c2%2Fpostgres-create-backup.png?alt=media)

5\. To configure your Cluster, enter the following details in the **Cluster configuration** section:

a. Select the appropriate **PostgreSQL Version**. IONOS Cloud Database Manager supports versions 14, 15, and 16.

b. Enter the number of **Instances** in the cluster. One PostgreSQL instance always manages the data of exactly one database cluster. You can create a maximum of five instances within a cluster.

{% hint style="info" %}
**Note:** Here, you will have a **primary** node and one or more standby nodes that run a copy of the active database, so you have **n-1 standby** instances in the cluster.
{% endhint %}

c. Select the mode of replication in the **Synchronization mode** field; **Asynchronous** mode is selected by default. The following are the available replication modes:

* **Asynchronous:** In asynchronous mode, the primary PostgreSQL instance does not wait for a replica to indicate that it wrote the data. The cluster can lose some committed transactions to ensure availability.
* **Synchronous:** Synchronous replication allows the primary node to be run standalone. The primary PostgreSQL instance will wait for any or all replicas. So, no transactions are lost during failover.

{% hint style="warning" %}
**Note:**

* You must choose either **Asynchronous** or **Strictly Synchronous**, as **Synchronous** replication mode is deprecated and will be fully removed in upcoming releases.

* You can update the existing clusters on **Synchronous** mode to either **Asynchronous** or **Strictly Synchronous** using the [<mark style="color:blue;">Update PostgreSQL Replication Mode</mark>](https://docs.ionos.com/sections-test/guides/databases/postgresql/api/v1-api/modify-cluster-attributes/update-postgresql-replication-mode) API.
  {% endhint %}

* **Strictly Synchronous:** It is similar to the synchronous mode but requires two operating nodes.

  d. Select a **Backup Location** that is explicitly your backup location (region). You can have off-site backups by using a region that is not included in your database region.

![Configure your Postgres Cluster](https://1737632334-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MifAzdGvKLDTtvJP8sm%2Fuploads%2Fgit-blob-b6380926dd5886a00ec3b852a9187b025826f756%2Fpostgres-configure-cluster.png?alt=media)

6\. Specify the following in the **Instance configuration** section:

* **Number of CPUs (per instance)**: Select the number of CPU cores using the slider or choose from the available shortcut values.
* **RAM Size (per instance)**: Select the RAM size using the slider or choose from the available shortcut values.
* **Storage Type**: Select a storage type for your instance. [<mark style="color:blue;">HDD</mark>](https://docs.ionos.com/cloud/support/general-information/glossary-of-terms#hdd) is set by default.
* **Storage Size**: Enter the storage size value in Gigabytes.

![Configure instance](https://1737632334-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MifAzdGvKLDTtvJP8sm%2Fuploads%2Fgit-blob-67fa84011a8eb65c88b3e9fefce8af6c4f2819b7%2Fpostgres-configure-instance.png?alt=media)

7\. In the **Network configuration** section, provide the following information to connect your cluster with the datacenter:

* **Datacenter:** Select a datacenter from the available list.
* **Datacenter LAN:** Select a LAN for your datacenter.
* **Private IP:** Select a private IP address from the drop-down list. For more information, see [<mark style="color:blue;">Private IP Address Ranges</mark>](https://www.ionos.com/help/server-cloud-infrastructure/private-network/private-ip-address-ranges/).

{% hint style="info" %}
**Note:** To know your **private IP address/Subnet**, you must:

* Create a single server connected to an empty private LAN and check the IP assigned to that NIC in that LAN. The **DHCP** in that LAN always uses a **/24 subnet**, so you must reuse the **first 3 octets** to reach your database.
* To prevent a collision with the DHCP IP range, it is recommended to use IP addresses ending between **x.x.x.3/24** and **x.x.x.10/24** (which are never assigned by DHCP).
* If you have disabled DHCP on your private LAN, you must discover the IP address on your own.
  {% endhint %}

![Configure network](https://1737632334-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MifAzdGvKLDTtvJP8sm%2Fuploads%2Fgit-blob-eb46c360010f76915e105d45ef908848c5ecbcef%2Fpostgres-configure-network.png?alt=media)

8\. In the **Maintenance period (optional)** section, you can set a maintenance day and time using the pre-defined format (hh:mm:ss) or the clock.

* Select a **Day** from the drop-down list.
* Enter a **Start Time (UTC)** using the pre-defined format (hh:mm:ss) to schedule the maintenance task. You can also click the ![](https://1737632334-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MifAzdGvKLDTtvJP8sm%2Fuploads%2Fgit-blob-78dc1fcfac8420a5b5d3dfe8bf77fb4efc818bd7%2Fmariadb-dcd-clock-icon.png?alt=media) icon to set a time.

{% hint style="info" %}
**Note:** We recommend choosing the day and time appropriately because the maintenance occurs in a **4-hour-long window**.
{% endhint %}

![Schedule maintenance](https://1737632334-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MifAzdGvKLDTtvJP8sm%2Fuploads%2Fgit-blob-4ed90023aee11779b776c88d2ce17aa200ea1d30%2Fpostgres-schedule-maintenance.png?alt=media)

9\. Provide the following details in the **User Creation** section:

* **Username:** Enter a username to provide access to the Postgres Cluster for the respective user.
* **Password:** Enter a password for the respective user.

{% hint style="info" %}
**Note:** The credentials will be overwritten if the user already exists in the backup.
{% endhint %}

![Define user](https://1737632334-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MifAzdGvKLDTtvJP8sm%2Fuploads%2Fgit-blob-0551c61e4cf76f56983a1628485b0dcdd6ccf188%2Fpostgres-define-user.png?alt=media)

{% hint style="success" %}
**Result:** The **Estimated costs** will be displayed based on the input. It is exclusive and certain variables like traffic and backup are not considered.
{% endhint %}

![Estimated costs](https://1737632334-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MifAzdGvKLDTtvJP8sm%2Fuploads%2Fgit-blob-f63a06346df737ea468e51fbe1de3beb904d0d5f%2Fpostgres-estimated-costs.png?alt=media)

10\. Click **Save** to create the Postgres Cluster.

{% hint style="success" %}
**Result:** Your Postgres Cluster is now created.
{% endhint %}
