简体   繁体   English

带有挂载卷的MySQL k8s Pod在AWS上失败

[英]Mysql k8s Pod with mount volume on AWS failing

I tried mysql with mount-volume to obtain persistence across /var/lib/mysql 我尝试用mount-volume尝试在/var/lib/mysql获得持久性

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mysql-pv-claim
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 20Gi
 ---
apiVersion: apps/v1beta2
kind: Deployment
metadata:
  name: mysql
spec:
 selector:
   matchLabels:
     app: mysql
 strategy:
   type: Recreate
 template:
   metadata:
     labels:
       app: mysql
   spec:
    containers:
    - image: mysql:5.6
      name: mysql
      env:
      - name: MYSQL_ROOT_PASSWORD
        value: password
      ports:
      - containerPort: 3306
        name: mysql
      volumeMounts:
      - name: mysql-persistent-storage
        mountPath: /var/lib/mysql
     volumes:
     - name: mysql-persistent-storage
       persistentVolumeClaim:
         claimName: mysql-pv-claim

kubelogs as below kubelogs如下

sh-3.2# kubectl logs acds-catchup-db-6f7d4b6c5b-2jwds  
Initializing database
2018-04-16T09:23:18.020740Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-04-16T09:23:18.022014Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2018-04-16T09:23:18.022037Z 0 [ERROR] Aborting

On investigating, I found a directory with name Lost+Found creating in MountVolume. 经过调查,我在MountVolume中找到了一个名为Lost+Found的目录。

Can any help me on this issue 任何可以帮助我解决这个问题

That directory is always present in the root path of the volume, so you cannot just remove it. 该目录始终存在于卷的根路径中,因此您不能仅将其删除。

You have 2 options how to fix it: 您有2种解决方法:

  1. Add --ignore-db-dir=lost+found option to the MySQL configuration. 在MySQL配置中添加--ignore-db-dir=lost+found选项。 I think that is the better way. 我认为那是更好的方法。
  2. Set the database directory to the path inside the volume, not to the root path of the volume. 将数据库目录设置为卷内部的路径,而不是卷的根路径。 You can specify the database directory by --datadir= option. 您可以通过--datadir=选项指定数据库目录。

Here is the example of args settings: 这是args设置的示例:

spec:
  containers:
  - name: mysql
    image: mysql:5.6
    args: ["--ignore-db-dir=lost+found"]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM