Bitnami Postgresql-ha 和 AKS 存储错误

问题描述 投票:0回答:1

我正在尝试在 AKS 集群上部署 Bitnami Postgresql-ha 图表的实例,但是我遇到了持久性问题。您应该能够将 Azure 磁盘多重附加到多个 Pod,但是控制器抱怨其无法配置,因此我使用 Azure 文件共享。我在

mountOptions
中添加了一些
StorageClass
,以获得遵守 Bitnami 图表的权限,并且我还在
image.debug
上启用了
postgresql
以获取更多信息。我不认为这是一个问题(与此错误相关),但我正在使用 Istio。

这是我的

StorageClass

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: azurefile-csi
provisioner: file.csi.azure.com
parameters:
  skuName: Standard_LRS
reclaimPolicy: Retain
volumeBindingMode: Immediate
mountOptions:
  - dir_mode=0750
  - file_mode=0750
  - uid=1001
  - gid=1001
  - mfsymlinks
  - cache=strict
  - nosharesock
  - actimeo=30 

我将

replicaCount
设置为 3,这些是来自第一个 pod 的日志:

The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /bitnami/postgresql/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Etc/UTC
creating configuration files ... ok
2023-10-15 19:06:59.371 UTC [139] LOG:  could not link file "pg_wal/xlogtemp.139" to "pg_wal/000000010000000000000001": Operation not supported
2023-10-15 19:06:59.392 UTC [139] FATAL:  could not open file "pg_wal/000000010000000000000001": No such file or directory
child process exited with exit code 1
initdb: removing contents of data directory "/bitnami/postgresql/data"
running bootstrap script ... 

我读到 Postgres 需要创建一些硬链接,而 Azure 文件不支持此功能,这是真的吗?我已经读了很多关于这个问题的文章,但没有运气,请帮忙:)

postgresql azure-aks bitnami
1个回答
0
投票

“无法将文件“pg_wal/xlogtemp.139”链接到 “pg_wal/000000010000000000000001”:不支持操作。”

从错误中我们可以看到,PostgreSQL 不支持 Azure 文件。这是因为 PostgreSQL 需要 Azure File 目录中的硬链接,并且由于 Azure File 不支持硬链接,因此 pod 无法启动。

修复这个问题,您可以为 PostgreSQL 使用不同的存储后端,例如 Azure 磁盘,因为 Azure 磁盘支持硬链接。

创建一个使用

azure-disk
配置程序的 PersistentVolumeClaim (PVC),如下所示 -

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: postgresql-data
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi  #choice of storage size 
  storageClassName: azure-disk

enter image description here

创建使用此 PVC 的 PostgreSQL 部署,如下所示:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: postgresql
spec:
  replicas: 3 #choice of replicas
  selector:
    matchLabels:
      app: postgresql
  template:
    metadata:
      labels:
        app: postgresql
    spec:
      containers:
      - name: postgresql
        image: bitnami/postgresql:latest
        volumeMounts:
        - name: postgresql-data
          mountPath: /bitnami/postgresql/data
      volumes:
      - name: postgresql-data
        persistentVolumeClaim:
          claimName: postgresql-data

enter image description here

最后使用 bitnami Helm 图表部署 PostgreSQL-HA 图表,如下所示 -

helm install my-release bitnami/postgresql-ha

enter image description here
enter image description here
enter image description here

您还可以参考以下文档:
AKS 上的后期
Azure Kubernetes 上的 Postgresql 具有数据持久性
MS 文档

© www.soinside.com 2019 - 2024. All rights reserved.