Share via


顯示已啟用 Azure Arc 的 PostgreSQL 伺服器設定

本文說明如何顯示伺服器的設定。 其方式是預期您可能會詢問的一些問題,並回答這些問題。 有時候,可能有數個有效的答案。 本文會提供最常見或有用的資訊。 其會依主題將這些問題分組:

  • 從 Kubernetes 的觀點來看
  • 從已啟用 Azure Arc 的資料服務觀點來看

注意

作為預覽功能,本文所述的技術受限於 Microsoft Azure 預覽版增補使用規定

版本資訊中提供的最新更新。

從 Kubernetes 的觀點來看

部署的 Postgres 伺服器及其使用的 Pod 數目為何?

列出 Postgres 類型的 Kubernetes 資源。 執行 命令:

kubectl get postgresqls -n <namespace>

此命令的輸出會顯示所建立的伺服器群組清單。 針對每個群組,其會指出 Pod 的數目。 例如:

NAME         STATE   READY-PODS   PRIMARY-ENDPOINT     AGE
postgres01   Ready   1/1          20.101.12.221:5432   12d

此範例顯示已建立一部伺服器。 伺服器會在一個 Pod 上執行。

已啟用 Azure Arc 的 PostgreSQL 伺服器會使用哪些 Pod?

請執行:

kubectl get pods -n <namespace>

命令會傳回 Pod 清單。 您會根據您提供給這些伺服器的名稱,看到伺服器所使用的 Pod。 例如:

NAME                 READY   STATUS    RESTARTS   AGE
bootstrapper-4jrtl   1/1     Running   0          12d
control-kz8gh        2/2     Running   0          12d
controldb-0          2/2     Running   0          12d
logsdb-0             3/3     Running   0          12d
logsui-qjkgz         3/3     Running   0          12d
metricsdb-0          2/2     Running   0          12d
metricsdc-4jslw      2/2     Running   0          12d
metricsdc-4tl2g      2/2     Running   0          12d
metricsdc-fkxv2      2/2     Running   0          12d
metricsdc-hs4h5      2/2     Running   0          12d
metricsdc-tvz22      2/2     Running   0          12d
metricsui-7pcch      2/2     Running   0          12d
postgres01-0         3/3     Running   0          2d19h

Pod 的狀態為何?

執行 kubectl get pods -n <namespace> 並查看資料行 STATUS

正在使用哪些永續性磁碟區宣告 (PVC)?

若要瞭解使用哪些 PVC,以及哪些 PVC 用於資料和記錄,請執行:

kubectl get pvc -n <namespace>

根據預設,PVC 名稱的首碼會指出其使用方式:

  • data-...:是用於資料檔案的 PVC
  • logs-...:是用於交易記錄/WAL 檔案的PVC

例如:

NAME                                            STATUS   VOLUME              CAPACITY   ACCESS MODES   STORAGECLASS    AGE
data-few7hh0k4npx9phsiobdc3hq-postgres01-0      Bound    local-pv-3c1a8cc5   1938Gi     RWO            local-storage   6d6h
data-few7hh0k4npx9phsiobdc3hq-postgres01-1      Bound    local-pv-8303ab19   1938Gi     RWO            local-storage   6d6h
data-few7hh0k4npx9phsiobdc3hq-postgres01-2      Bound    local-pv-55572fe6   1938Gi     RWO            local-storage   6d6h
...
logs-few7hh0k4npx9phsiobdc3hq-postgres01-0      Bound    local-pv-5e852b76   1938Gi     RWO            local-storage   6d6h
logs-few7hh0k4npx9phsiobdc3hq-postgres01-1      Bound    local-pv-55d309a7   1938Gi     RWO            local-storage   6d6h
logs-few7hh0k4npx9phsiobdc3hq-postgres01-2      Bound    local-pv-5ccd02e6   1938Gi     RWO            local-storage   6d6h
...

伺服器正在使用多少記憶體和虛擬核心?

使用 kubectl 描述 Postgres 資源。 若要這樣做,您需要其種類 (適用於 Azure Arc 中 Postgres 的 Kubernetes 資源名稱 (CRD)),以及伺服器群組的名稱。

命令的一般格式為:

kubectl describe <CRD name>/<server name> -n <namespace>

例如:

kubectl describe postgresql/postgres01 -n arc

此命令會顯示伺服器群組的設定:

Name:         postgres01
Namespace:    arc
Labels:       <none>
Annotations:  <none>
API Version:  arcdata.microsoft.com/v1beta2
Kind:         PostgreSql
Metadata:
  Creation Timestamp:  2021-10-13T01:09:25Z
  Generation:          29
  Managed Fields:
    API Version:  arcdata.microsoft.com/v1beta2
    Fields Type:  FieldsV1
    fieldsV1:
      f:spec:
        .:
        f:dev:
        f:scheduling:
          .:
          f:default:
            .:
            f:resources:
              .:
              f:limits:
                .:
                f:cpu:
                f:memory:
              f:requests:
                .:
                f:cpu:
                f:memory:
        f:services:
          .:
          f:primary:
            .:
            f:port:
            f:type:
        f:storage:
          .:
          f:data:
            .:
            f:volumes:
          f:logs:
            .:
            f:volumes:
    Manager:      OpenAPI-Generator
    Operation:    Update
    Time:         2021-10-22T22:37:51Z
    API Version:  arcdata.microsoft.com/v1beta2
    Fields Type:  FieldsV1
    fieldsV1:
      f:IsValid:
      f:status:
        .:
        f:lastUpdateTime:
        f:logSearchDashboard:
        f:metricsDashboard:
        f:observedGeneration:
        f:primaryEndpoint:
        f:readyPods:
        f:state:
    Manager:         unknown
    Operation:       Update
    Time:            2021-10-22T22:37:53Z
  Resource Version:  1541521
  UID:               23565e53-2e7a-4cd6-8f80-3a79397e1d7a
Spec:
  Dev:  false
  Scheduling:
    Default:
      Resources:
        Limits:
          Cpu:     2
          Memory:  1Gi
        Requests:
          Cpu:     1
          Memory:  256Mi
  Services:
    Primary:
      Port:  5432
      Type:  LoadBalancer
  Storage:
    Data:
      Volumes:
        Class Name:  managed-premium
        Size:        5Gi
    Logs:
      Volumes:
        Class Name:  managed-premium
        Size:        5Gi
Status:
  Last Update Time:      2021-10-22T22:37:53.000000Z
  Log Search Dashboard:  https://12.235.78.99:5601/app/kibana#/discover?_a=(query:(language:kuery,query:'custom_resource_name:postgres01'))
  Metrics Dashboard:     https://12.346.578.99:3000/d/postgres-metrics?var-Namespace=arc&var-Name=postgres01
  Observed Generation:   29
  Primary Endpoint:      20.101.12.221:5432
  Ready Pods:            1/1
  State:                 Ready
Events:                  <none>

解譯設定資訊

讓我們在上述的 server 描述中指出一些特定 POI。 其中告訴我們此伺服器的相關資訊為何?

  • 其是在 2021 年 10 月 13 日建立的:

       Metadata:
       Creation Timestamp:  2021-10-13T01:09:25Z
    
  • 資源設定:在此範例中,其保證為 256Mi 的記憶體。 伺服器無法使用超過 1Gi 的記憶體。 其保證有一個虛擬核心,且無法取用兩個以上的虛擬核心。

          Scheduling:
         Default:
           Resources:
              Limits:
                Cpu:     2
                Memory:  1Gi
              Requests:
                Cpu:     1
                Memory:  256Mi
    
  • 伺服器的狀態為何? 我的應用程式可以使用嗎?

    是,Pod 已就緒

    Ready Pods:                1/1
    

從已啟用 Azure Arc 的資料服務觀點來看

使用 Az CLI 命令。

部署了哪些 Postgres 伺服器?

執行下列命令。

az postgres server-arc list --k8s-namespace <namespace> --use-k8s

其會列出已部署的伺服器。

[
  {
    "name": "postgres01",
    "state": "Ready"
  }
]

正在使用多少記憶體和虛擬核心?

執行下列任一命令

az postgres server-arc show -n <server name>  --k8s-namespace <namespace> --use-k8s

例如:

az postgres server-arc show -n postgres01 --k8s-namespace arc --use-k8s

傳回格式和內容的資訊,類似於 kubectl 所傳回的資訊。 使用您選擇的工具來與系統互動。