无法部署MySQL Pod。 --initialize指定,但是数据目录中有文件

时间:2019-03-05 14:52:06

标签: mysql kubernetes digital-ocean persistent-volume-claims

我正在尝试使用Kubernetes在Digital Ocean上设置一个MySQL pod。

我一直收到此错误:

application(_:didReceiveRemoteNotification:fetchCompletionHandler:)

我的Yaml有很多东西,但下面是配置这一部分感兴趣的行。

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

如果我在部署配置中注释掉PVC和相对于PVC的行,则一切正常。

此外,如果我更改

# ------------------- 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

---

mountPath: "/var/lib/mysql"

有效。但我显然需要mountPath: "/data" ...

它在崭新的集群上也发生。

有什么主意吗?

3 个答案:

答案 0 :(得分:6)

我在使用 Kubernetes 和 MySQL 5.7 时也遇到了这个问题。

将来自 yosifki 的建议添加到我的容器定义中,一切正常。

<块引用>

一个新的 ext4 磁盘分区通常不是空的; 有一个 lost+found 目录,已知 mysql 会阻塞它。你 可以尝试将 --ignore-db-dir=lost+found 添​​加到 CMD 以了解 确定(来自mysql docs

这是我的工作 YAML 定义的摘录:

name: mysql-master
image: mysql:5.7
args:
  - "--ignore-db-dir=lost+found"

答案 1 :(得分:1)

我遇到了这个问题。解决方法是删除pv和pvc并重新创建它们。

答案 2 :(得分:0)

我有类似的问题。

使用mysql:5.6对其进行了修复。

有关更多信息,请参阅:

https://github.com/docker-library/mysql/issues/69

https://github.com/docker-library/mysql/issues/186