天天看點

容器開啟資料服務之旅系列(一):Kubernetes如何解自建PostgreSQL運維之痛

本文為大家介紹一種容器化的資料服務 posgresql db on ACK,通過使用雲盤自動挂載實作的塊存儲PVC來做到資料庫的免運維恢複。借助阿裡雲Kubernetes服務與阿裡雲存儲資源的深度整合,打造資料庫執行個體的免運維異地(ECS)恢複的不死神話。

阿裡雲容器服務的存儲插件(預設情況存儲插件已經自動部署在阿裡雲Kubernetes容器服務)

使用三次點選來建立一個postgresql的不死執行個體

點選 “應用目錄”

選擇 "postgresql"

容器開啟資料服務之旅系列(一):Kubernetes如何解自建PostgreSQL運維之痛

4 (可選)選擇你的Kubernetes叢集. e.g. k8s-gpu

5 (可選)選擇你的應用的命名空間。預設: default

6 給你的資料庫應用取個容易記住的名字。 e.g. postgresql-online

容器開啟資料服務之旅系列(一):Kubernetes如何解自建PostgreSQL運維之痛

7 (可選) 點選 “參數” 來定制你的資料庫執行個體

修改 <code>persistence.size: 20Gi</code> 增加資料庫雲盤的容量

修改 <code>persistence.storageClass: alicloud-disk-efficiency</code> 調整資料卷所在雲盤的性能。比如改為<code>alicloud-disk-ssd</code> 挂載ssd類型的

容器開啟資料服務之旅系列(一):Kubernetes如何解自建PostgreSQL運維之痛

8 點選 “部署”, 完成資料釋出

9 點選 “Kubernetes 控制台”,檢視部署執行個體

容器開啟資料服務之旅系列(一):Kubernetes如何解自建PostgreSQL運維之痛

10 點選容器組,點選 postgresql-online-postgresql 檢視資料庫執行個體密碼。容器執行個體啟動在節點:cn-hangzhou.i-bp1fazljd8u2ylk2otdo

容器開啟資料服務之旅系列(一):Kubernetes如何解自建PostgreSQL運維之痛
容器開啟資料服務之旅系列(一):Kubernetes如何解自建PostgreSQL運維之痛

11 測試postgresql資料庫的異地(ECS)恢複

添加測試資料

驅逐資料庫執行個體從ECS節點 i-bp1fazljd8u2ylk2otdo 到 i-bp1fazljd8u2ylk2otdp

檢驗資料,執行個體遷移, 資料庫執行個體自動化恢複, 資料不丢失。

<code>ssh &lt;public ip of kubernetes master node &gt;</code>

<code>helm install -n postgresql-online --set 'persistence.size=30Gi,persistence.storageClass=alicloud-disk-ssd' stable/postgresql</code>

To get your user password run:

To connect to your database run the following command (using the env variable from above):

To connect to your database directly from outside the K8s cluster:

Test original postgresql db could be recovered on different node.