Postgresql 无法在OpenShift上附加或装载Postgres pod副本的卷

Postgresql 无法在OpenShift上附加或装载Postgres pod副本的卷,postgresql,docker,kubernetes,openshift,kubernetes-pvc,Postgresql,Docker,Kubernetes,Openshift,Kubernetes Pvc,我有一个部署在OpenShift上的postgres吊舱和一个PVC,我认为我连接正确,但我可能错了。这是我的PVC,装订正确- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: postgres-pvc spec: accessModes: - ReadWriteOnce resources: requests: storage: 1Gi storageClassName: xxxxx 我用PG

我有一个部署在OpenShift上的postgres吊舱和一个PVC,我认为我连接正确,但我可能错了。这是我的PVC,装订正确-

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
 name: postgres-pvc
spec:
 accessModes:
   - ReadWriteOnce
 resources:
   requests:
     storage: 1Gi
 storageClassName: xxxxx
我用
PGDATA
env设置为
/var/lib/postgresql/PGDATA
创建了postgres吊舱,并像这样安装了PVC-

oc set volume dc/postgres --add --name=postgres-pvc --type=persistentVolumeClaim \
    --claim-name=postgres-pvc --mount-path=/var/lib/postgresql/pgdata --containers=postgres
我最初试图通过覆盖原始容器卷将PVC连接到
/var/lib/postgresql/data
,但它说直接装载到
数据
文件夹路径有问题,所以我使用了
pgdata
路径

oc set volume dc/postgres --add --overwrite --name=postgres-volume-1 --type=persistentVolumeClaim \
  --claim-name=postgres-pvc --mount-path=/var/lib/postgresql/data --containers=postgres
我现在遇到的错误是,当我尝试通过DC放大pod/添加副本时,它会出现以下错误-

Unable to attach or mount volumes: unmounted volumes=[postgres-pvc], unattached volumes=[postgres-volume-1 postgres-pvc postgres-token-h7jvr]: timed out waiting for the condition


是因为我的PVC安装不正确吗?或者我需要创建一个新的PVC,然后手动将新pod更新为新创建的PVC吗?

您可以看到错误

已经连接到另一个节点xx.xx.xxx.x,并且有活动的pod[postgres-7-6p6sz]正在使用该节点

您将块存储用作pv,它具有accessModes
ReadWriteOnce
,这意味着在任何给定时间卷都可以连接到单个kubernetes节点,然后在该节点上,pod可以挂载它。 现在,如果你想连接到另一个pod,你需要移除现有的pod,这将使pv从上一个节点卸载,重新连接到新节点


进一步的细节

是的,在做了一些挖掘之后,我现在看到了。我试图用
ReadWriteMany
创建一个新的PVC,但结果表明块存储类只支持
ReadWriteOnce
。嗯,你不知道我应该做什么来达到HA的目的?我应该创建新的
ReadWriteOnce
pvc,然后为每个新副本手动附加它们吗?我想,这是ReadWriteOnce的警告,我想我建议您检查statefleset,它创建一个pod和它自己的pvc。谢谢,我想我需要做更多的阅读来理解它的技术细节。本质上,当使用状态集时,这些副本只是备用副本,对吗?由于它们各自使用自己的PVC,我是否需要编写某种类型的侧容器或在这些POD之间复制数据的东西?不,worreis:)这就是应用程序智能的重要性所在。如果有状态应用程序本身不能在其对等或集群之间复制数据,那么有一些元应用程序可以帮助实现这一目标。我建议你们阅读关于操作符模式和postgres的特定操作符。这可能会很有用
Error while attaching the device pv pvc-b87b49ff-2bce-495c-b17f-b45f51eab27b cannot be attached to the node xx.xx.xxx.xx. Error: PV pvc-b87b49ff-2bce-495c-b17f-b45f51eab27b is already attached to another node xx.xx.xxx.x and there are active pods [postgres-7-6p6sz] using that