Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Azure Database for PostgreSQL with elastic cluster is a managed service that you use to run, manage, and scale highly available PostgreSQL databases in the cloud with horizontal scale-out capability. This quickstart covers how to create an elastic cluster.
If you don't have an Azure subscription, create a free Azure account before you begin.
You create an elastic cluster, like a flexible server, with a configured set of compute and storage resources. You create the cluster within an Azure resource group. The steps outlined in Create an Azure Database for PostgreSQL equally apply to elastic clusters. This section outlines the changes in the process.
Steps to create an elastic cluster
Use the Azure portal:
After filling out the basic information, select the Configure server link.
From the Cluster section, select the Elastic cluster option.
Specify the node count and configure the compute size.
Save your changes and verify your choices on the main configuration page. To change the name of the default database on which the Citus extension is created, use the Database name text box. Then, select Review + create to review your selections.
Select Create to provision the server.
The deployment starts.
When the deployment finishes, you can select Pin to dashboard. This action creates a tile for this server on your Azure portal dashboard as a shortcut to the server's Overview page. Selecting Go to resource opens the server's Overview page.
By default, a postgres database is created under your server. You can change the name of this default database at cluster provisioning time only. The postgres database is a default database meant for users, utilities, and applications. (The other default database is azure_maintenance. Its function is to separate the managed service processes from user actions. You can't access this database.)
Note
Connections to your Azure Database for PostgreSQL flexible server communicate over port 5432 and 6432 (PgBouncer). When you try to connect from within a corporate network, outbound traffic over port 5432 and 6432 might not be allowed by your network's firewall. If so, you can't connect to your server unless your IT department opens port 5432 and 6432. Elastic clusters also use port 7432 and 8432 (PgBouncer) for load balanced connections across the cluster nodes and might need to be allow listed in a similar way by your IT department.
Get the connection information
When you create your elastic cluster instance, the portal creates a default database with the name you provide. To connect to your database server, you need your full server name and the credentials of the administrator. You noted those values earlier in the quickstart article. If you didn't, you can easily find the server name and authentication information on the server Overview page in the portal.
Open your server's Overview page. Make a note of the Server name and the Administrator login. Hover your cursor over each field, and the copy symbol appears to the right of the text. Select the copy symbol as needed to copy the values.
Connect to the Azure Database for PostgreSQL database by using psql
You can use many applications to connect to your Azure Database for PostgreSQL flexible server. If your client computer has PostgreSQL installed, you can use a local instance of psql to connect to an Azure Database for PostgreSQL flexible server. Use the psql command-line utility to connect to the Azure Database for PostgreSQL flexible server.
Run the following psql command to connect to an Azure Database for PostgreSQL flexible server.
psql --host=<servername> --port=<port> --username=<user> --dbname=<dbname>For example, the following command connects to the default database called postgres on your Azure Database for PostgreSQL flexible server mydemoserver.postgres.database.azure.com by using access credentials. Enter the
<server_admin_password>you chose when prompted for password.psql --host=mydemoserver-pg.postgres.database.azure.com --port=5432 --username=myadmin --dbname=postgresTo connect to a random node in the cluster, use port 7432.
psql --host=mydemoserver-pg.postgres.database.azure.com --port=7432 --username=myadmin --dbname=postgresAfter you connect, the psql utility displays a postgres prompt where you type SQL commands. In the initial connection output, a warning might appear because the psql you're using might be a different version than the Azure Database for PostgreSQL flexible server version.
Example psql output:
psql (12.3 (Ubuntu 12.3-1.pgdg18.04+1), server 13.2) WARNING: psql major version 12, server major version 13. Some psql features might not work. SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off) Type "help" for help.Tip
If the firewall isn't configured to allow the IP address of your client, the following error occurs:
psql: FATAL: no pg_hba.conf entry for host
<IP address>, user "myadmin", database "postgres", SSL on FATAL: SSL connection is required. Specify SSL options and retry.Confirm your client's IP is allowed in the firewall rules.
Create a blank schema called
exampleschemaat the prompt by typing the following command:CREATE SCHEMA exampleschema;At the prompt, execute the following command to make the schema
exampleschemadistributed:SELECT citus_schema_distribute('exampleschema');Type
\q, and then select the Enter key to quit psql.
You connected to the elastic cluster by using psql, and you created a blank schema and made it distributed.
Clean up resources
Tip
Other quickstarts in this collection build on this quickstart. If you plan to continue working with quickstarts, don't clean up the resources that you created in this quickstart. If you don't plan to continue, follow these steps to delete the resources that this quickstart created in the portal.
To clean up the resources that you created in this quickstart, use one of the following methods. Delete the Azure resource group to remove all the resources in the resource group. If you want to keep the other resources, only delete the server.