mysql - 无法部署 MySQL pod。 --initialize 指定但数据目录中有文件

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

我正在尝试使用 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...

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

有什么想法吗?

最佳答案

我在 Kubernetes 和 MySQL 5.7 上也有这个问题。

添加来自 yosifki 的建议根据我容器的定义,一切正常。

A new ext4 disk partition is not usually empty; there is a lost+found directory, which mysql is known to choke on. You could try adding --ignore-db-dir=lost+found to the CMD to know for sure (from mysql docs)

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

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

关于mysql - 无法部署 MySQL pod。 --initialize 指定但数据目录中有文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55005539/

相关文章:

kubernetes - Kubernetes 中的自定义负载均衡

deployment - EC2中的Google Kubernetes存储

node.js - Redis 客户端连接到 redis 远程服务器,但无法在其上读取或写入

mysql 连接数与正在运行的查询相比过高

php - 在 MySQL 中更新表

mysql - 使用 Poco 选择 EXISTS 的值

MYSQL按组加权平均

kubernetes - 无法完全删除 Kubernetes CustomResource

python - 引用pymysql中的记录来搜索一下

ssh - 需要帮助让我的 ssh key 在 digital ocean 水滴上工作