[Build and Deploy Staging Site] Publish from microsoft/azuretipsandtricks-private:main/src/blog
This commit is contained in:
Родитель
e108ff655e
Коммит
8642a437b0
|
@ -0,0 +1,96 @@
|
|||
---
|
||||
type: post
|
||||
title: "Tip 331 - How to use Flexible Server in Azure Database for PostgreSQL"
|
||||
excerpt: "Learn how to use Flexible Server in Azure Database for PostgreSQL"
|
||||
tags: [Databases]
|
||||
share: true
|
||||
date: 2021-9-1 08:00:00
|
||||
---
|
||||
|
||||
::: tip
|
||||
|
||||
:fire: Checkout the Azure Developer page at [azure.com/developer](https://azure.com/developer?WT.mc_id=azure-azuredevtips-azureappsdev).
|
||||
|
||||
:bulb: Learn more : [about Azure Database for PostgreSQL](https://docs.microsoft.com/azure/postgresql/overview?WT.mc_id=docs-azuredevtips-azureappsdev).
|
||||
|
||||
:tv: Watch the video : [How to use Flexible Server in Azure Database for PostgreSQL](https://youtu.be/uTr7-reO2Y4?WT.mc_id=youtube-azuredevtips-azureappsdev).
|
||||
|
||||
:::
|
||||
|
||||
### How to use Flexible Server in Azure Database for PostgreSQL
|
||||
|
||||
#### Highly configurable PostgreSQL server
|
||||
[Azure Database for PostgreSQL](https://docs.microsoft.com/azure/postgresql/overview?WT.mc_id=docs-azuredevtips-azureappsdev) provides a managed PostgreSQL server that allows you to focus on using PostgreSQL, instead of focusing on managing your database server. You can choose to run Azure Database for PostgreSQL as a [Single server](https://docs.microsoft.com/azure/postgresql/overview-single-server?WT.mc_id=docs-azuredevtips-azureappsdev), which is designed to handle most of the database management functions such as patching, backups, high availability, and security with minimal user configuration and control. You can also create an Azure Database for PostgreSQL with a [Flexible Server](https://docs.microsoft.com/azure/postgresql/flexible-server/overview?WT.mc_id=docs-azuredevtips-azureappsdev), which allows for more configuration and control of the database server.
|
||||
|
||||
In this post, we'll create an Azure Database for PostgreSQL with the Flexible Server option.
|
||||
|
||||
#### Prerequisites
|
||||
If you want to follow along, you'll need the following:
|
||||
* An Azure subscription (If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=azure-azuredevtips-azureappsdev) before you begin)
|
||||
|
||||
#### Create a Flexible PostgreSQL server
|
||||
We will use the Azure portal to create an Azure Database for PostgreSQL and connect to it using the [Azure Cloud Shell](https://docs.microsoft.com/azure/cloud-shell/overview?WT.mc_id=docs-azuredevtips-azureappsdev).
|
||||
|
||||
1. Go to the [Azure portal](https://portal.azure.com/?WT.mc_id=azure-azuredevtips-azureappsdev)
|
||||
2. Click the **Create a resource** button (the plus-sign in the top left corner)
|
||||
3. Search for **database for postgresql**, select the "Azure Database for PostgreSQL" result and click **Create**
|
||||
1. This shows the Select **Azure Database for PostgreSQL deployment option** screen
|
||||
|
||||
<img :src="$withBase('/files/114create1.png')">
|
||||
|
||||
(Azure Database for PostgreSQL server options)
|
||||
|
||||
2. Click the **Create** button under **Flexible server**. This opens the Flexible server blade
|
||||
3. Select a **Resource Group**
|
||||
4. Fill in a **Name** for the server
|
||||
5. Select a **Region**
|
||||
6. Choose a **Workload type**. This determines the compute and storage option that you use. Flexible server offers the option to use **Burstable compute**, which ramps up the server CPU only when needed. This is great for non-production workloads
|
||||
|
||||
<img :src="$withBase('/files/114create2.png')">
|
||||
|
||||
(Flexible server creation options)
|
||||
|
||||
7. You can configure compute and storage in more detail, by clicking on **configure server**. This brings up the **Compute + storage blade**. This allows you to set the size of the VM on which the server runs, and the storage size and performance on which your data sits. In this blade, you can also configure the server backups and make them geo-redundant (you can only choose this when you don't use a burstable compute tier)
|
||||
|
||||
<img :src="$withBase('/files/114create3.png')">
|
||||
|
||||
(Compute + storage options)
|
||||
|
||||
8. Next, choose the **availability zone** you want the VM(s) that runs the PostgreSQL server to use
|
||||
9. Leave the **High Availability** setting **unchecked**. You should use this when you want additional availability precautions within availability zones, for production workloads. As we are using the burstable compute tier for development workloads, we don't need this
|
||||
10. Leave the **PostgreSQL version** to the selected version
|
||||
11. Fill in an **Admin username** that you will use to connect to the server
|
||||
12. Type a **Password** for the admin user and **confirm the password**
|
||||
13. Select **Next:Networking**
|
||||
|
||||
<img :src="$withBase('/files/114create4.png')">
|
||||
|
||||
(Configure networking options)
|
||||
|
||||
14. Flexible server can put the server in a virtual network, so that it is not exposed to the internet. You can also allow the server to be accessed through the internet and secure it with a firewall. This is what we will do. Select **Public access (allowed IP addresses)**
|
||||
15. Under **Firewall rules**, select the **Add 0.0.0.0 - 255.255.255.255** link to add a firewall rule that allows all IP addresses to access the server. You should never use this firewall rule for a real-world application, but you can use it for development or demo purposes
|
||||
16. Click **Review + create** and then **Create** to create the server
|
||||
|
||||
When the Azure Database for PostgreSQL server is created, navigate to it in the Azure portal. In the overview blade, you'll see that you can stop the server. This is a feature of Flexible server. Stopping the server can save you a lot of money when you don't use it.
|
||||
|
||||
<img :src="$withBase('/files/114stop.png')">
|
||||
|
||||
(Stop the server from the Azure portal)
|
||||
|
||||
You can use the Azure Database for PostgreSQL server with your tool of choice. We will use the Azure Cloud Shell to connect to it. Azure Cloud Shell comes with the psql.exe tool preinstalled, through which we can use the PostgreSQL server.
|
||||
|
||||
1. Go to [https://shell.azure.com/](https://shell.azure.com/?WT.mc_id=azure-azuredevtips-azureappsdev)
|
||||
2. Execute the following command, and replace the **servername** and **username** with your own
|
||||
|
||||
```
|
||||
psql -h servername.postgres.database.azure.com -U username -p 5432 -d postgres
|
||||
```
|
||||
|
||||
That's it. We are now connected to the Azure Database for PostgreSQL flexible server.
|
||||
|
||||
<img :src="$withBase('/files/114result.png')">
|
||||
|
||||
(Connected to the flexible server from the Azure Cloud Shell)
|
||||
|
||||
#### Conclusion
|
||||
The [Flexible server](https://docs.microsoft.com/azure/postgresql/flexible-server/overview?WT.mc_id=docs-azuredevtips-azureappsdev) option for [Azure Database for PostgreSQL](https://docs.microsoft.com/azure/postgresql/overview?WT.mc_id=docs-azuredevtips-azureappsdev) allows you to customize high availability, maintenance windows, use burstable compute, and stop and start the server. Go and check it out!
|
Загрузка…
Ссылка в новой задаче