在我的 PostgreSQL pod 失败后,我从重新启动的 pod 中得到以下日志,该日志不断崩溃
<块引用>mkdir: 无法创建目录 ‘/var/lib/postgresql/data’: 文件存在
我在上述位置的容器中通过 PVC 挂载 PV(nfs 共享),以避免在 pod 出现故障时丢失数据。我做错了什么吗?
以下是我对 sts 的 yaml 描述。
apiVersion: apps/v1
kind: StatefulSet
metadata:
creationTimestamp: "2020-11-20T18:59:43Z"
generation: 2
managedFields:
- apiVersion: apps/v1
fieldsType: FieldsV1
fieldsV1:
f:spec:
f:podManagementPolicy: {}
f:replicas: {}
f:revisionHistoryLimit: {}
f:selector:
f:matchLabels:
.: {}
f:app: {}
f:serviceName: {}
f:template:
f:metadata:
f:labels:
.: {}
f:app: {}
f:spec:
f:containers:
k:{"name":"postgres"}:
.: {}
f:envFrom: {}
f:image: {}
f:name: {}
f:ports:
.: {}
k:{"containerPort":5432,"protocol":"TCP"}:
.: {}
f:containerPort: {}
f:protocol: {}
f:resources: {}
f:terminationMessagePath: {}
f:terminationMessagePolicy: {}
f:volumeMounts:
.: {}
k:{"mountPath":"/var/lib/postgresql/data"}:
.: {}
f:mountPath: {}
f:name: {}
f:dnsPolicy: {}
f:restartPolicy: {}
f:schedulerName: {}
f:securityContext: {}
f:terminationGracePeriodSeconds: {}
f:volumes:
.: {}
k:{"name":"postgres-nfs"}:
.: {}
f:name: {}
f:persistentVolumeClaim:
.: {}
f:claimName: {}
f:updateStrategy:
f:rollingUpdate:
.: {}
f:partition: {}
f:type: {}
manager: kubectl-create
operation: Update
time: "2020-11-20T18:59:43Z"
- apiVersion: apps/v1
fieldsType: FieldsV1
fieldsV1:
f:spec:
f:template:
f:spec:
f:containers:
k:{"name":"postgres"}:
f:imagePullPolicy: {}
manager: kubectl-edit
operation: Update
time: "2021-06-29T15:42:01Z"
- apiVersion: apps/v1
fieldsType: FieldsV1
fieldsV1:
f:status:
f:collisionCount: {}
f:currentReplicas: {}
f:currentRevision: {}
f:observedGeneration: {}
f:replicas: {}
f:updateRevision: {}
f:updatedReplicas: {}
manager: kube-controller-manager
operation: Update
time: "2021-06-30T21:54:36Z"
name: postgres
namespace: klos
resourceVersion: "86776831"
selfLink: /apis/apps/v1/namespaces/klos/statefulsets/postgres
uid: 89931f08-0a5d-4d9a-885b-b12bc0264c5d
spec:
podManagementPolicy: OrderedReady
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app: postgres
serviceName: database
template:
metadata:
creationTimestamp: null
labels:
app: postgres
spec:
containers:
- envFrom:
- configMapRef:
name: postgres-config
image: postgres
imagePullPolicy: IfNotPresent
name: postgres
ports:
- containerPort: 5432
protocol: TCP
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /var/lib/postgresql/data
name: postgres-nfs
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
volumes:
- name: postgres-nfs
persistentVolumeClaim:
claimName: postgres-nfs-claim
updateStrategy:
rollingUpdate:
partition: 0
type: RollingUpdate
status:
collisionCount: 0
currentReplicas: 1
currentRevision: postgres-57d8d67cd5
observedGeneration: 2
replicas: 1
updateRevision: postgres-57d8d67cd5
updatedReplicas: 1
在另一个命名空间中,我的其他由 kubedb 管理的 postgresql pod 也失败并显示以下错误日志
<块引用>I0630 22:32:14.854128 1 log.go:172] 标志:
--alsologtostderr="false" I0630 22:32:14.854192 1 log.go:172] 标志:--enable-analytics="true" I0630 22:32:14.854202 1
log.go:172] 标志:--help="false" I0630 22:32:14.854212 1
log.go:172] 标志:--log-flush-frequency="5s" I0630 22:32:14.854226
1 log.go:172] 标志:--log_backtrace_at=":0" I0630 22:32:14.854235
1 log.go:172] 标志:--log_dir="" I0630 22:32:14.854244 1
log.go:172] 标志:--logtostderr="true" I0630 22:32:14.854252 1
log.go:172] 标志:--stderrthreshold="0" I0630 22:32:14.854267 1
log.go:172] 标志:--use-kubeapiserver-fqdn-for-aks="true" I0630
22:32:14.854274 1 log.go:172] 标志:--v="3" I0630
22:32:14.854281 1 log.go:172] 标志:--vmodule="" I0630
22:32:18.072864 1 log.go:172] 我们希望“postgres-0”作为我们的领导者
I0630 22:32:18.105157 1 leaderelection.go:217] 试图
获得领导租约 postgres-ha/postgres-leader-lock... I0630
22:32:18.107698 1 log.go:172] 领导者从“”更改为
'postgres-2' I0630 22:32:18.127571 1 log.go:172] 注释 pods
for statefulset I0630 22:32:18.134472 1 log.go:172] 这个pod是
现在是副本 I0630 22:32:18.134495 1 log.go:172] 开始
数据库包装器脚本作为副本运行作为副本尝试
pg_isready on primary Attempting pg_isready on primary Attempting
pg_isready on primary Attempting pg_isready on primary Attempting
主要 I0630 上的 pg_isready 22:32:35.707460 1
leaderelection.go:227] 成功获得租约
postgres-ha/postgres-leader-lock I0630 22:32:35.707543 1
log.go:172] 领导者从“postgres-2”更改为“postgres-0”I0630
22:32:35.707580 1 log.go:172] 得到领导,创建
触发文件 I0630 22:32:35.808205 1 log.go:172] 注释 pods
对于 statefulset I0630 22:32:35.809106 1 pod.go:56] 修补 Pod
postgres-ha/postgres-0 with
{"metadata":{"labels":{"kubedb.com/role":"primary"}}} I0630
22:32:35.821348 1 pod.go:56] 修补 Pod postgres-ha/postgres-2
使用 {"metadata":{"labels":{"kubedb.com/role":"replica"}}} I0630
22:32:35.868268 1 log.go:172] 这个 pod 现在是一个主要的 Postgres
找到促销 trigger_file。运行主运行脚本 以
身份运行
主 mkdir:无法创建目录“/var/pv/”:陈旧的文件句柄
rm: can't stat '/var/pv/data/*': 陈旧的文件句柄 chmod:
/var/pv/data: Stale file handle 属于这个数据库的文件
系统将由用户“postgres”拥有。该用户还必须拥有
服务器进程。
数据库集群将使用区域设置“en_US.utf8”进行初始化。这 默认数据库编码已相应设置为“UTF8”。这 默认文本搜索配置将设置为“english”。
数据页校验和被禁用。
initdb:无法访问目录“/var/pv/data”:陈旧的文件句柄
mv: can't stat '/var/pv/data/postgresql.conf': 陈旧的文件句柄
/scripts/primary/start.sh:第 48 行:/var/pv/data/pg_hba.conf:陈旧
文件句柄/scripts/primary/start.sh:第49行:
/var/pv/data/pg_hba.conf:陈旧的文件句柄
/scripts/primary/start.sh:
第 50 行:/var/pv/data/pg_hba.conf:陈旧的文件句柄
/scripts/primary/start.sh:第 51 行:/var/pv/data/pg_hba.conf:陈旧
文件句柄 pg_ctl:无法访问目录“/var/pv/data”:陈旧
文件句柄 psql: 无法连接到服务器: 没有那个文件或
directory 是本地运行的服务器并在
上接受连接
Unix域套接字“/var/run/postgresql/.s.PGSQL.5432”?
/scripts/primary/start.sh: 忽略 /var/initdb/*
pg_ctl:无法访问目录“/var/pv/data”:陈旧的文件句柄
cat:无法打开'/var/pv/data/postgresql.conf':陈旧的文件句柄
I0630 22:32:36.181192 1 log.go:172] DB Wrapper 终止,
也退出。如果有错误,请在下面找到。 I0630
22:32:36.181216 1 log.go:172] 退出状态 1
任何帮助将不胜感激!