다음을 통해 공유


빠른 시작: ARM 템플릿을 사용하여 Azure Database for PostgreSQL을 사용하여 탄력적 클러스터 만들기

탄력적 클러스터가 있는 Azure Database for PostgreSQL은 수평 스케일 아웃 기능을 사용하여 클라우드에서 고가용성 PostgreSQL 데이터베이스를 실행, 관리 및 확장하는 데 사용하는 관리형 서비스입니다. ARM 템플릿(Azure Resource Manager 템플릿)을 사용하여 탄력적 클러스터 인스턴스를 만들 수 있습니다.

Azure Resource Manager 템플릿은 프로젝트에 대한 인프라 및 구성을 정의하는 JSON(JavaScript Object Notation) 파일입니다. 이 템플릿은 선언적 구문을 사용합니다. 배포를 만들기 위한 프로그래밍 명령의 시퀀스를 작성하지 않고 의도하는 배포를 설명합니다.

Azure Resource Manager는 Azure용 배포 및 관리 서비스입니다. Azure 계정에서 리소스를 만들고, 업데이트하고, 삭제할 수 있는 관리 계층을 제공합니다. 배포 이후 액세스 제어, 잠금 및 태그와 같은 관리 기능을 사용하여 리소스를 보호하고 구성합니다. Azure Resource Manager 템플릿에 대한 자세한 내용은 템플릿 배포 개요를 참조하세요.

필수 조건

활성 구독이 있는 Azure 계정. 체험 계정 만들기

템플릿 검토

Azure Database for PostgreSQL 유연한 서버 인스턴스는 지역 내의 분산 데이터베이스에 대한 부모 리소스입니다. 클러스터에 적용되는 관리 정책의 범위(방화벽, 사용자, 역할 및 구성)를 제공합니다.

elastic-cluster-template.json 파일을 만들고 다음 JSON 스크립트를 복사합니다.

{
  "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "administratorLogin": {
      "type": "string"
    },
    "administratorLoginPassword": {
      "type": "securestring"
    },
    "location": {
      "type": "string",
      "defaultValue": "canadacentral"
    },
    "clusterName": {
      "type": "string"
    },
    "serverEdition": {
      "type": "string",
      "defaultValue": "GeneralPurpose"
    },
    "storageSizeGB": {
      "type": "int",
      "defaultValue": 64
    },
    "haEnabled": {
      "type": "string",
      "defaultValue": "Disabled"
    },
    "availabilityZone": {
      "type": "string",
      "defaultValue": "1"
    },
    "backupRetentionDays": {
      "type": "int",
      "defaultValue": 7
    },
    "skuName": {
      "type": "string",
      "defaultValue": "Standard_D4ds_v5"
    },
    "clusterSize": {
      "type": "int",
      "defaultValue": 2
    },
    "guid": {
      "type": "string",
      "defaultValue": "[newGuid()]"
    },
    "firewallRules": {
      "type": "object",
      "defaultValue": {
        "rules": [
          {
            "name": "AllowAll",
            "startIPAddress": "0.0.0.0",
            "endIPAddress": "255.255.255.255"
          }
        ]
      }
    },
    "network": {
      "type": "object",
      "defaultValue": { "publicNetworkAccess": "Enabled" }
    }
  },
  "variables": {
    "firewallRules": "[parameters('firewallRules').rules]"
  },
  "resources": [
    {
      "apiVersion": "2025-08-01",
      "location": "[parameters('location')]",
      "name": "[parameters('clusterName')]",
      "properties": {
        "createMode": "Default",
        "version": "16",
        "administratorLogin": "[parameters('administratorLogin')]",
        "administratorLoginPassword": "[parameters('administratorLoginPassword')]",
        "availabilityZone": "[parameters('availabilityZone')]",
        "Storage": {
          "StorageSizeGB": "[parameters('storageSizeGB')]",
          "Autogrow": "Disabled"
        },
        "Network": "[if(empty(parameters('network')), json('null'), parameters('network'))]",
        "Backup": {
          "backupRetentionDays": "[parameters('backupRetentionDays')]",
          "geoRedundantBackup": "Disabled"
        },
        "highAvailability": {
          "mode": "[parameters('haEnabled')]"
        },
        "cluster": {
          "clusterSize": "[parameters('clusterSize')]"
        }
      },
      "sku": {
        "name": "[parameters('skuName')]",
        "tier": "[parameters('serverEdition')]"
      },
      "type": "Microsoft.DBforPostgreSQL/flexibleServers"
    },
    {
      "condition": "[greater(length(variables('firewallRules')), 0)]",
      "type": "Microsoft.Resources/deployments",
      "apiVersion": "2019-08-01",
      "name": "[concat('firewallRules-', parameters('guid'), '-', copyIndex())]",
      "copy": {
        "count": "[if(greater(length(variables('firewallRules')), 0), length(variables('firewallRules')), 1)]",
        "mode": "Serial",
        "name": "firewallRulesIterator"
      },
      "dependsOn": [
        "[concat('Microsoft.DBforPostgreSQL/flexibleServers/', parameters('clusterName'))]"
      ],
      "properties": {
        "mode": "Incremental",
        "template": {
          "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
          "contentVersion": "1.0.0.0",
          "resources": [
            {
              "type": "Microsoft.DBforPostgreSQL/flexibleServers/firewallRules",
              "name": "[concat(parameters('clusterName'),'/',variables('firewallRules')[copyIndex()].name)]",
              "apiVersion": "2025-08-01",
              "properties": {
                "StartIpAddress": "[variables('firewallRules')[copyIndex()].startIPAddress]",
                "EndIpAddress": "[variables('firewallRules')[copyIndex()].endIPAddress]"
              }
            }
          ]
        }
      }
    }
  ]
}

이러한 리소스는 템플릿에 정의되어 있습니다.

템플릿 배포

다음 PowerShell 코드 블록에서 사용해 보세요를 선택하여 Azure Cloud Shell을 엽니다.

$clusterName = Read-Host -Prompt "Enter a name for the new Azure Database for PostgreSQL flexible server elastic cluster instance"
$resourceGroupName = Read-Host -Prompt "Enter a name for the new resource group where the elastic cluster will exist"
$adminUser = Read-Host -Prompt "Enter the Azure Database for PostgreSQL flexible server elastic cluster instance's administrator account name"
$adminPassword = Read-Host -Prompt "Enter the administrator password" -AsSecureString
# New-AzResourceGroup -Name $resourceGroupName -Location <AZURE_LOCATION>  Use this command when you need to create a new resource group for your deployment
New-AzResourceGroupDeployment -ResourceGroupName $resourceGroupName `
    -TemplateFile "elastic-cluster-template.json" `
    -clusterName $clusterName `
    -administratorLogin $adminUser `
    -administratorLoginPassword $adminPassword

Read-Host -Prompt "Press [ENTER] to continue ..."

배포된 리소스 검토

다음 단계에 따라 Azure Database for PostgreSQL 유연한 서버 탄력적 클러스터가 만들어졌는지 확인합니다.

  1. Azure Portal에서 Azure Database for PostgreSQL 유연한 서버를 검색하고 선택합니다.
  2. 데이터베이스 목록에서 새 서버를 선택하여 탄력적 클러스터를 관리하는 개요 페이지를 봅니다.

다음 단계

관련 콘텐츠 섹션에 나열된 다음 제안된 단계를 계속 진행하려면 이 리소스 그룹 및 탄력적 클러스터를 유지합니다. 다음 단계에서는 다양한 애플리케이션 분할 모델 및 디자인에서 탄력적 클러스터를 사용하는 방법을 보여 줍니다.

리소스 정리

탄력적 클러스터 환경을 완료하면 탄력적 클러스터 리소스를 삭제할 수 있습니다.

탄력적 클러스터를 삭제하려면 다음을 수행합니다.

포털에서 삭제하려는 리소스 그룹을 선택합니다.

  1. 리소스 그룹 삭제를 선택합니다.
  2. 삭제를 확인하려면 리소스 그룹의 이름을 입력합니다.