charts icon indicating copy to clipboard operation
charts copied to clipboard

[stable/mysql] --initialize specified but the data directory has files in it. Aborting.

Open rim-wood opened this issue 6 years ago • 15 comments

Describe the bug when i`m use cmd "helm install ", deployment is start error. and i find the log
image

i`m modify the vaule.yaml

## mysql image version
## ref: https://hub.docker.com/r/library/mysql/tags/
##
image: "mysql"
imageTag: "5.7.28"

strategy:
  type: Recreate

busybox:
  image: "busybox"
  tag: "1.29.3"

testFramework:
  enabled: true
  image: "dduportal/bats"
  tag: "0.4.0"

## Specify password for root user
##
## Default: random 10 character string
mysqlRootPassword: 123456

## Create a database user
##
mysqlUser: nacos
## Default: random 10 character string
mysqlPassword: nacos

## Allow unauthenticated access, uncomment to enable
##
# mysqlAllowEmptyPassword: true

## Create a database
##
mysqlDatabase: nacos_devtest

## Specify an imagePullPolicy (Required)
## It's recommended to change this to 'Always' if the image tag is 'latest'
## ref: http://kubernetes.io/docs/user-guide/images/#updating-images
##
imagePullPolicy: IfNotPresent

## Additionnal arguments that are passed to the MySQL container.
## For example use --default-authentication-plugin=mysql_native_password if older clients need to
## connect to a MySQL 8 instance.
args: []

extraVolumes: |
  # - name: extras
  #   emptyDir: {}
extraVolumeMounts: |
  # - name: extras
  #   mountPath: /usr/share/extras
  #   readOnly: true
extraInitContainers: |
  # - name: do-something
  #   image: busybox
  #   command: ['do', 'something']
# Optionally specify an array of imagePullSecrets.
# Secrets must be manually created in the namespace.
# ref: https://kubernetes.io/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod
# imagePullSecrets:
  # - name: myRegistryKeySecretName

## Node selector
## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector
nodeSelector: {}

## Tolerations for pod assignment
## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/
##
tolerations: []

livenessProbe:
  initialDelaySeconds: 120
  periodSeconds: 10
  timeoutSeconds: 5
  successThreshold: 1
  failureThreshold: 3

readinessProbe:
  initialDelaySeconds: 5
  periodSeconds: 10
  timeoutSeconds: 1
  successThreshold: 1
  failureThreshold: 3

## Persist data to a persistent volume
persistence:
  enabled: true
  ## database data Persistent Volume Storage Class
  ## If defined, storageClassName: <storageClass>
  ## If set to "-", storageClassName: "", which disables dynamic provisioning
  ## If undefined (the default) or set to null, no storageClassName spec is
  ##   set, choosing the default provisioner.  (gp2 on AWS, standard on
  ##   GKE, AWS & OpenStack)
  ##
  storageClass: 
    storageClassName: nacos-sc-mysql
    provisioner: fuseim.pri/ifs
    classParameters: {}
  accessMode: ReadWriteOnce
  size: 10Gi
  annotations: {}

## Use an alternate scheduler, e.g. "stork".
## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/
##
# schedulerName:

## Security context
securityContext:
  enabled: false
  runAsUser: 999
  fsGroup: 999

## Configure resource requests and limits
## ref: http://kubernetes.io/docs/user-guide/compute-resources/
##
resources:
  requests:
    memory: 2Gi
    cpu: 1000m

# Custom mysql configuration files path
configurationFilesPath: /etc/mysql/conf.d/

# Custom mysql configuration files used to override default mysql settings
configurationFiles: 
  mysql.cnf: |-
    [mysqld]
    pid-file  = /var/run/mysqld/mysqld.pid
    socket    = /var/run/mysqld/mysqld.sock
    datadir   = /var/lib/mysql

    symbolic-links=0

    secure-file-priv= NULL
    skip-host-cache

    skip-name-resolve



    server-id = 1

    port = 3306

    autocommit = 0

   
    character_set_server=utf8mb4

    
    collation-server = utf8mb4_general_ci

    
    init_connect='SET NAMES utf8mb4'

   
    transaction_isolation = READ-COMMITTED

   
    lower_case_table_names = 1

  
    max_connections = 800

  
    back_log = 210

    
    max_connect_errors = 1000


    explicit_defaults_for_timestamp = true

    
    max_allowed_packet = 128M

    
    interactive_timeout = 1800
    wait_timeout = 1800


   
    tmpdir  = /tmp

   
    tmp_table_size = 134217728
    max_heap_table_size = 134217728

   
    read_buffer_size = 8388608

   
    read_rnd_buffer_size = 2097152

    
    join_buffer_size = 8388608

   
    sort_buffer_size = 4194304

    
    binlog_cache_size = 524288


    
    log_error = /var/log/mysql/error.log

    
    slow_query_log = 1
    slow_query_log_file = /var/log/mysql/slow.log

   
    log_queries_not_using_indexes = 1

   
    log_throttle_queries_not_using_indexes = 5

   
    log_slow_slave_statements = 1

    
    long_query_time = 8

    
    min_examined_row_limit = 1000

    
    expire_logs_days = 7




    
    master_info_repository = TABLE
    relay_log_info_repository = TABLE

    
    log_bin = /var/log/mysql/bin.log
    
    sync_binlog = 5

   
    log_slave_updates = 1

    
    gtid_mode = on

    
    enforce_gtid_consistency = 1

    
    binlog_gtid_simple_recovery = 1

    
    log_slave_updates = 1

  
    binlog_format = row

    
    binlog_row_image = minimal

    
    relay_log = /var/log/mysql/relay.log

    
    relay_log_recovery = 1

    
    slave_skip_errors = ddl_exist_errors




    
    innodb_page_size = 16384
    
   
    innodb_buffer_pool_size = 2G

    
    innodb_buffer_pool_instances = 8

    
    innodb_buffer_pool_load_at_startup = 1

    innodb_buffer_pool_dump_at_shutdown = 1

    
    innodb_lru_scan_depth = 2000

    innodb_io_capacity = 4000

   
    innodb_io_capacity_max = 8000

    
    innodb_lock_wait_timeout = 30

   
    innodb_file_per_table = 1

    
    innodb_undo_logs = 128

   
    innodb_log_file_size = 1073741842
    innodb_log_buffer_size = 16777216

    
    innodb_purge_threads = 4

    
    innodb_thread_concurrency = 0

    
    innodb_print_all_deadlocks = 1
   
    innodb_sort_buffer_size = 8338608 
# Custom mysql init SQL files used to initialize the database
initializationFiles: 
  nacos-config.sql: |-
    use nacos_devtest;
    CREATE TABLE `config_info` (
      `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
      `data_id` varchar(255) NOT NULL COMMENT 'data_id',
      `group_id` varchar(255) DEFAULT NULL,
      `content` longtext NOT NULL COMMENT 'content',
      `md5` varchar(32) DEFAULT NULL COMMENT 'md5',
      `gmt_create` datetime NOT NULL DEFAULT '2010-05-05 00:00:00' COMMENT '创建时间',
      `gmt_modified` datetime NOT NULL DEFAULT '2010-05-05 00:00:00' COMMENT '修改时间',
      `src_user` text COMMENT 'source user',
      `src_ip` varchar(20) DEFAULT NULL COMMENT 'source ip',
      `app_name` varchar(128) DEFAULT NULL,
      `tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段',
      `c_desc` varchar(256) DEFAULT NULL,
      `c_use` varchar(64) DEFAULT NULL,
      `effect` varchar(64) DEFAULT NULL,
      `type` varchar(64) DEFAULT NULL,
      `c_schema` text,
      PRIMARY KEY (`id`),
      UNIQUE KEY `uk_configinfo_datagrouptenant` (`data_id`,`group_id`,`tenant_id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_info';
#  first-db.sql: |-
#    CREATE DATABASE IF NOT EXISTS first DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
#  second-db.sql: |-
#    CREATE DATABASE IF NOT EXISTS second DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;

metrics:
  enabled: false
  image: prom/mysqld-exporter
  imageTag: v0.10.0
  imagePullPolicy: IfNotPresent
  resources: {}
  annotations: {}
    # prometheus.io/scrape: "true"
    # prometheus.io/port: "9104"
  livenessProbe:
    initialDelaySeconds: 15
    timeoutSeconds: 5
  readinessProbe:
    initialDelaySeconds: 5
    timeoutSeconds: 1
  flags: []
  serviceMonitor:
    enabled: false
    additionalLabels: {}

## Configure the service
## ref: http://kubernetes.io/docs/user-guide/services/
service:
  annotations: {}
  ## Specify a service type
  ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services---service-types
  type: ClusterIP
  port: 3306
  # nodePort: 32000
  # loadBalancerIP:

## Pods Service Account
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/
serviceAccount:
  ## Specifies whether a ServiceAccount should be created
  ##
  create: false
  ## The name of the ServiceAccount to use.
  ## If not set and create is true, a name is generated using the mariadb.fullname template
  # name:

ssl:
  enabled: false
  secret: mysql-ssl-certs
  certificates:
#  - name: mysql-ssl-certs
#    ca: |-
#      -----BEGIN CERTIFICATE-----
#      ...
#      -----END CERTIFICATE-----
#    cert: |-
#      -----BEGIN CERTIFICATE-----
#      ...
#      -----END CERTIFICATE-----
#    key: |-
#      -----BEGIN RSA PRIVATE KEY-----
#      ...
#      -----END RSA PRIVATE KEY-----

## Populates the 'TZ' system timezone environment variable
## ref: https://dev.mysql.com/doc/refman/5.7/en/time-zone-support.html
##
## Default: nil (mysql will use image's default timezone, normally UTC)
## Example: 'Australia/Sydney'
# timezone:

# Deployment Annotations
deploymentAnnotations: {}

# To be added to the database server pod(s)
podAnnotations: {}
podLabels: {}

## Set pod priorityClassName
# priorityClassName: {}


## Init container resources defaults
initContainer:
  resources:
    requests:
      memory: 10Mi
      cpu: 10m

and i add the storageclass.yaml

{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) -}}
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
   name: {{ .Values.persistence.storageClass.storageClassName }}
provisioner: 
{{ toYaml .Values.persistence.storageClass.provisioner | indent 2 }}
parameters:
{{ toYaml .Values.persistence.storageClass.classParameters | indent 2 }}
reclaimPolicy: Retain
allowVolumeExpansion: true
{{- end }}

I found the same error because of the lost + found folder 290 Or data exists in the mounted host folder 398

But my error is not like this,In the deployment.yaml file, initC is defined and lost + found is deleted and i'm user the storageclass create the pvc+pv,so pv is empty.

and the pod was first created,these files are created below my pv , image

Then the pod reports an error Version of Helm and Kubernetes: v1.13.5

Which chart: https://hub.helm.sh/charts/stable/mysql

rim-wood avatar Mar 06 '20 02:03 rim-wood

One more thing to add:

modify the pvc.yaml:

{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: {{ template "mysql.fullname" . }}
  namespace: {{ .Release.Namespace }}
{{- with .Values.persistence.annotations  }}
  annotations:
{{ toYaml . | indent 4 }}
{{- end }}
  labels:
    app: {{ template "mysql.fullname" . }}
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    release: "{{ .Release.Name }}"
    heritage: "{{ .Release.Service }}"
spec:
  accessModes:
    - {{ .Values.persistence.accessMode | quote }}
  resources:
    requests:
      storage: {{ .Values.persistence.size | quote }}
{{- if .Values.persistence.storageClass }}
{{- if (eq "-" .Values.persistence.storageClass.storageClassName) }}
  storageClassName: ""
{{- else }}
  storageClassName: "{{ .Values.persistence.storageClass.storageClassName }}"
{{- end }}
{{- end }}
{{- end }}

rim-wood avatar Mar 06 '20 03:03 rim-wood

helm lint 试过么

one-two-my-gad avatar Mar 06 '20 09:03 one-two-my-gad

helm lint 试过么

能创建成功,helm lint只是校验文件格式的。

我的错误时pod里面的mysql初始化时,说数据文件夹中有数据

rim-wood avatar Mar 06 '20 10:03 rim-wood

头盔皮棉试过么

能创造成功,helm lint只是校验文件格式的。

我的错误时pod里面的mysql初始化时,说数据文件夹中有数据

方便发下部署命令么

one-two-my-gad avatar Mar 06 '20 10:03 one-two-my-gad

I'm having the same issue. Any luck solving it?

dacianmujdar avatar Mar 18 '20 10:03 dacianmujdar

I'm having the same issue. Any luck solving it?

no,i have given up,if you solved,please tell me the way

rim-wood avatar Mar 19 '20 01:03 rim-wood

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Any further update will cause the issue/pull request to no longer be considered stale. Thank you for your contributions.

stale[bot] avatar Apr 18 '20 05:04 stale[bot]

This issue is being automatically closed due to inactivity.

stale[bot] avatar May 02 '20 06:05 stale[bot]

hello everybody,i have been resolved this error.The reason is nfs server,but i don·t know why. I just used the hostpath pv to replace storageclass.

rim-wood avatar May 02 '20 08:05 rim-wood

same issue here

chrouzz avatar Jun 05 '20 10:06 chrouzz

Adding the below solved my issue args: - "--ignore-db-dir=lost+found"

avnertzur avatar Jun 18 '20 12:06 avnertzur

Adding the below solved my issue args:

  • "--ignore-db-dir=lost+found"

Where abouts did you add this argument exactly? I'm having this issue when trying to mount an external volume with mysql...thanks!

mrandrewdh avatar Jul 08 '20 04:07 mrandrewdh

Adding the below solved my issue args:

  • "--ignore-db-dir=lost+found"

Where abouts did you add this argument exactly? I'm having this issue when trying to mount an external volume with mysql...thanks!

I'm using helm chart, so in the Deployment template I added the "args" as below:

          args:
            - "--ignore-db-dir=lost+found"
          volumeMounts:
            - name: mysql-initdb
              mountPath: /docker-entrypoint-initdb.d
            - name: {{ .Values.Mysql.name }}-persistent-storage
              mountPath: /var/lib/mysql

avnertzur avatar Jul 08 '20 05:07 avnertzur

Adding the below solved my issue args:

  • "--ignore-db-dir=lost+found"

This is it!

ricardoandre97 avatar Sep 24 '20 11:09 ricardoandre97

Adding the below solved my issue args:

  • "--ignore-db-dir=lost+found"

Where abouts did you add this argument exactly? I'm having this issue when trying to mount an external volume with mysql...thanks!

I'm using helm chart, so in the Deployment template I added the "args" as below:

          args:
            - "--ignore-db-dir=lost+found"
          volumeMounts:
            - name: mysql-initdb
              mountPath: /docker-entrypoint-initdb.d
            - name: {{ .Values.Mysql.name }}-persistent-storage
              mountPath: /var/lib/mysql

This solution is working on OpenShift 4.5, thanks

294434171 avatar Dec 03 '20 04:12 294434171