我正在尝试使用 Kubernetes 在 Digital Ocean 上设置 MySQL pod。
我不断收到此错误:
Initializing database
2019-03-05T14:32:58.707421Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-03-05T14:32:58.708753Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2019-03-05T14:32:58.711746Z 0 [ERROR] Aborting
我的 yaml 有很多东西,但对这部分配置感兴趣的行如下。
# ------------------- Persistent Volume Claim ------------------- #
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: test-mysql-volume-claim
...
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 2Gi
storageClassName: do-block-storage
---
# ------------------- Deployment ------------------- #
kind: Deployment
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
...
spec:
...
spec:
containers:
- image: mysql:5.7
...
volumeMounts:
- name: test-mysql-volume
mountPath: "/var/lib/mysql"
volumes:
- name: test-mysql-volume
persistentVolumeClaim:
claimName: test-mysql-volume-claim
---
如果我在部署配置中注释掉 PVC 和与 PVC 相关的行,一切正常。
另外,如果我改变
mountPath: "/var/lib/mysql"
到
mountPath: "/data"
有用。但我显然需要/var/lib/mysql
...
它也发生在全新的集群上。
任何的想法?