Share via


Azure Arc 対応 PostgreSQL サーバーを削除する

このドキュメントでは、Azure Arc のセットアップからサーバーを削除する手順について説明します。

Note

この記事で紹介しているテクノロジはプレビュー機能であり、「Microsoft Azure プレビューの追加利用規約」に従うことを条件として提供されます。

最新の更新プログラムについては、リリース ノートを参照してください。

サーバーを削除する

たとえば、次のセットアップから postgres01 インスタンスを削除するとします。

az postgres server-arc list --k8s-namespace <namespace> --use-k8s
Name        State  
----------  -------
postgres01  Ready  

削除コマンドの一般的な形式は次のとおりです。

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

このコマンドを実行すると、サーバーの削除を確認するように求められます。 削除を自動化するスクリプトを使用している場合は、--force パラメーターを使用して確認要求をバイパスする必要があります。 たとえば、次のようなコマンドを実行します。

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

削除コマンドの詳細については、次を実行してください。

az postgres server-arc delete --help 

この例で使用されているサーバーを削除する

az postgres server-arc delete -n postgres01 --k8s-namespace <namespace> --use-k8s

Kubernetes 永続ボリューム要求 (PVC) を再利用する

PersistentVolumeClaim (PVC) は、PostgreSQL サーバーにストレージを作成して追加するときの、Kubernetes クラスターからのユーザーによるストレージの要求です。 サーバー グループを削除しても、関連付けられた PVC が削除されるわけではありません。 これは仕様です。 これは、インスタンスが誤って削除された場合に、ユーザーがデータベース ファイルにアクセスできるようにするためです。 PVC の削除は必須ではありません。 ただし、お勧めではあります。 これらの PVC を再利用しないと、Kubernetes クラスターがディスク領域が不足したと認識するため、または、同じ PostgreSQL サーバー名を使用して新しいものを作成すると不整合が発生する可能性があるため、最終的にはエラーが発生します。 PVC を再利用するには、次の手順を実行します。

1.削除したサーバー グループの PVC を一覧表示する

PVC を一覧表示するには、次のコマンドを実行します。

kubectl get pvc [-n <namespace name>]

PVC の一覧 (特に、削除したサーバー グループの PVC) が返されます。 次に例を示します。

kubectl get pvc
NAME                                         STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
data-few7hh0k4npx9phsiobdc3hq-postgres01-0   Bound    pvc-72ccc225-dad0-4dee-8eae-ed352be847aa   5Gi        RWO            default        2d18h
data-few7hh0k4npx9phsiobdc3hq-postgres01-1   Bound    pvc-ce6f0c51-faed-45ae-9472-8cdf390deb0d   5Gi        RWO            default        2d18h
data-few7hh0k4npx9phsiobdc3hq-postgres01-2   Bound    pvc-5a863ab9-522a-45f3-889b-8084c48c32f8   5Gi        RWO            default        2d18h
data-few7hh0k4npx9phsiobdc3hq-postgres01-3   Bound    pvc-00e1ace3-1452-434f-8445-767ec39c23f2   5Gi        RWO            default        2d15h
logs-few7hh0k4npx9phsiobdc3hq-postgres01-0   Bound    pvc-8b810f4c-d72a-474a-a5d7-64ec26fa32de   5Gi        RWO            default        2d18h
logs-few7hh0k4npx9phsiobdc3hq-postgres01-1   Bound    pvc-51d1e91b-08a9-4b6b-858d-38e8e06e60f9   5Gi        RWO            default        2d18h
logs-few7hh0k4npx9phsiobdc3hq-postgres01-2   Bound    pvc-8e5ad55e-300d-4353-92d8-2e383b3fe96e   5Gi        RWO            default        2d18h
logs-few7hh0k4npx9phsiobdc3hq-postgres01-3   Bound    pvc-f9e4cb98-c943-45b0-aa07-dd5cff7ea585   5Gi        RWO            default        2d15h

このサーバー グループには 8 つの PVC があります。

2.各 PVC を削除する

削除した PostgreSQL サーバーのデータとログの PVC を削除します。

このコマンドの一般的な形式は次のとおりです。

kubectl delete pvc <name of pvc>  [-n <namespace name>]

次に例を示します。

kubectl delete pvc data-few7hh0k4npx9phsiobdc3hq-postgres01-0
kubectl delete pvc data-few7hh0k4npx9phsiobdc3hq-postgres01-1
kubectl delete pvc data-few7hh0k4npx9phsiobdc3hq-postgres01-2
kubectl delete pvc data-few7hh0k4npx9phsiobdc3hq-postgres01-3
kubectl delete pvc logs-few7hh0k4npx9phsiobdc3hq-postgres01-0
kubectl delete pvc logs-few7hh0k4npx9phsiobdc3hq-postgres01-1
kubectl delete pvc logs-few7hh0k4npx9phsiobdc3hq-postgres01-2
kubectl delete pvc logs-few7hh0k4npx9phsiobdc3hq-postgres01-3

これらの各 kubectl コマンドは、PVC が正常に削除されたことを確認します。 次に例を示します。

persistentvolumeclaim "data-postgres01-0" deleted

Note

示しているように、PVC を削除しないと、最終的に Kubernetes クラスターがエラーをスローする状況になる可能性があります。 このようなエラーには、Kubernetes API からリソースを作成、読み取り、更新、削除できなくなる場合や、このストレージの問題によって、コントローラー ポッドが Kubernetes ノードから削除される可能性がある (通常の Kubernetes 動作) az arcdata dc export などのコマンドを実行できる場合があります。

たとえば、次のようなメッセージがログに表示されます。

Annotations:    microsoft.com/ignore-pod-health: true  
Status:         Failed  
Reason:         Evicted  
Message:        The node was low on resource: ephemeral-storage. Container controller was using 16372Ki, which exceeds its request of 0.

次のステップ

Azure Arc 対応 PostgreSQL サーバーを作成する