[英]Cannot deploy MySQL pod. --initialize specified but the data directory has files in it
I'm trying to setup a MySQL pod on Digital Ocean with Kubernetes.我正在尝试使用 Kubernetes 在 Digital Ocean 上设置一个 MySQL pod。
I kept getting this error:我不断收到此错误:
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
My yaml as a lot of stuff but the lines that interest this part of the config are the following.我的 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
---
If I comment out the PVC and the lines relative to PVC in the deployment config, everything works.如果我在部署配置中注释掉 PVC 和与 PVC 相关的行,一切正常。
Also, if I change另外,如果我改变
mountPath: "/var/lib/mysql"
to到
mountPath: "/data"
it works.有用。 But I obviously need
/var/lib/mysql
...但我显然需要
/var/lib/mysql
...
It happens also on brand new clusters.它也发生在全新的集群上。
Any idea?任何的想法?
I had this issue with Kubernetes and MySQL 5.7 as well.我在 Kubernetes 和 MySQL 5.7 上也有这个问题。
Adding the suggestion from yosifki to my container's definition got things working.将yosifki的建议添加到我的容器定义中,事情就开始了。
A new ext4 disk partition is not usually empty;
一个新的 ext4 磁盘分区通常不是空的; there is a lost+found directory, which mysql is known to choke on.
有一个 lost+found 目录,已知 mysql 会阻塞它。 You could try adding --ignore-db-dir=lost+found to the CMD to know for sure (from mysql docs )
您可以尝试将 --ignore-db-dir=lost+found 添加到 CMD 以确保知道(来自mysql docs )
Here's an extract of my working YAML definition:这是我的工作 YAML 定义的摘录:
name: mysql-master
image: mysql:5.7
args:
- "--ignore-db-dir=lost+found"
I had a similar problem.我有一个类似的问题。
Using mysql:5.6 fixed it.使用 mysql:5.6 修复它。
For more information refer to:更多信息请参考:
https://github.com/docker-library/mysql/issues/69 https://github.com/docker-library/mysql/issues/69
https://github.com/docker-library/mysql/issues/186 https://github.com/docker-library/mysql/issues/186
I have come across this issue.我遇到过这个问题。 Work around is to delete the pv and pvc and recreate them.
解决方法是删除 pv 和 pvc 并重新创建它们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.