首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >错误: PostgreSQL Kubernetes数据目录"/var/lib/postgresql/ data“具有错误的所有权窗口

错误: PostgreSQL Kubernetes数据目录"/var/lib/postgresql/ data“具有错误的所有权窗口
EN

Stack Overflow用户
提问于 2020-04-12 11:08:24
回答 1查看 631关注 0票数 0

我刚接触kubernetes之类的东西。在浏览教程时,我在使用pstgres数据库和持久化卷声明时遇到错误。我非常确定所有的权限都被赋予了用户,但错误仍然表明文件夹的所有权错误。

以下是我的配置文件

这是永久卷声明文件

代码语言:javascript
复制
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: database-persistent-volume-claim
spec:
  accessModes: 
    - ReadWriteOnce
  resources:
    requests:
      storage: 2Gi

这是我的postgres部署文件

代码语言:javascript
复制
apiVersion: apps/v1
kind: Deployment
metadata: 
  name: postgres-deployment
spec:
  replicas: 1
  selector:
    matchLabels: 
      component: postgres
  template: 
     metadata:
       labels:
         component: postgres
     spec:
       volumes:
        - name: postgres-storage
          persistentVolumeClaim:
            claimName: database-persistent-volume-claim
       containers:
         - name: postgres
           image: postgres
           ports:
             - containerPort: 5432
           volumeMounts:
             - name: postgres-storage
               mountPath: /var/lib/postgresql/data
               subPath: postgres
           env:
             - name: POSTGRES_HOST_AUTH_METHOD
               value: "trust"
             - name: PGPASSWORD
               valueFrom:
                 secretKeyRef:
                   name: pgpassword
                   key: PGPASSWORD
代码语言:javascript
复制
Here is the error message 
2020-04-12 01:57:11.986 UTC [82] FATAL:  data directory "/var/lib/postgresql/data" has wrong ownership
2020-04-12 01:57:11.986 UTC [82] HINT:  The server must be started by the user that owns the data directory.
child process exited with exit code 1
initdb: removing contents of data directory "/var/lib/postgresql/data"

有什么需要帮忙的吗?

EN

回答 1

Stack Overflow用户

发布于 2020-04-12 14:55:05

这对我是有效的卷装载中的检查子路径

代码语言:javascript
复制
apiVersion: apps/v1
    kind: StatefulSet
    metadata:
    spec:
      podManagementPolicy: OrderedReady
      replicas: 1
      revisionHistoryLimit: 10
      selector:
        matchLabels:
          app: postgres
      serviceName: postgres
      template:
        metadata:
          creationTimestamp: null
          labels:
            app: postgres
        spec:
          containers:
          - env:
            - name: POSTGRES_USER
              value: root
            - name: POSTGRES_PASSWORD
              value: <Password>
            - name: POSTGRES_DB
              value: <DB name>
            - name: PGDATA
              value: /var/lib/postgresql/data/pgdata
            image: postgres:9.5
            imagePullPolicy: IfNotPresent
            name: postgres
            ports:
            - containerPort: 5432
              protocol: TCP
            resources: {}
            terminationMessagePath: /dev/termination-log
            terminationMessagePolicy: File
            volumeMounts:
            - mountPath: /var/lib/postgresql/data
              name: postgres-data
              subPath: pgdata
          dnsPolicy: ClusterFirst
          restartPolicy: Always
          schedulerName: default-scheduler
          securityContext: {}
          terminationGracePeriodSeconds: 60
      updateStrategy:
        rollingUpdate:
          partition: 0
        type: RollingUpdate
      volumeClaimTemplates:
      - metadata:
          creationTimestamp: null
          name: postgres-data
        spec:
          accessModes:
          - ReadWriteOnce
          resources:
            requests:
              storage: 3Gi
          volumeMode: Filesystem
        status:
          phase: Pending
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61166353

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档