0

I'm trying to store my MariaDB in a Azure Storage Account

In my YAML I've got this to define the MariaDB image:

- name: mariadb
  properties:
    image: mariadb:latest
    environmentVariables:
      - name: "MYSQL_INITDB_SKIP_TZINFO"
        value: "1"
      - name: "MYSQL_DATABASE"
        value: "metrics"
      - name: "MYSQL_USER"
        value: "user"
      - name: "MYSQL_PASSWORD"
        value: "password"
      - name: "MYSQL_ROOT_PASSWORD"
        value: "root_password"
    ports:
    - port: 3306
      protocol: TCP
    resources:
      requests:
        cpu: 1.0
        memoryInGB: 1.5
    volumeMounts:
    - mountPath: /var/lib/mysql
      name: filesharevolume

My volume definition looks like this:

volumes:
- name: filesharevolume
  azureFile:
    sharename: <share-name>
    storageAccountName: <name>
    storageAccountKey: <key>

When this image starts however, it gets terminated with an error explaining that the ibdata1 file size doesn't match what's in the config file.

If I remove the volumeMount, the database image works fine.

Is there something I'm missing?

Tom Irving
  • 10,041
  • 6
  • 47
  • 63

1 Answers1

1

For this issue, the reason had shown in the Note:

Mounting an Azure Files share to a container instance is similar to a Docker bind mount. Be aware that if you mount a share into a container directory in which files or directories exist, these files or directories are obscured by the mount and are not accessible while the container runs.

The File share mounts on the existing directory, then it overwrites the directory. And MariaDB will rebuild the ibdata1 file according to the requirement, but it's empty and not match with the previous before.

For the use of Azure File Share, I recommend you only mount the File Share to the directory which does not exist before to persist the data. Or the files in the directory does not affect the normal running of the application.

Charles Xu
  • 29,862
  • 2
  • 22
  • 39
  • Thanks, Charles. It sounds then like I cannot use the File Share to persist the database files? – Tom Irving Nov 18 '19 at 09:56
  • @TomIrving Of curse you can, but not the existing files inside the image. It's the file that will be created after the container running. – Charles Xu Nov 19 '19 at 01:12
  • Do you know how I can configure MariaDB to not fail in this case then? I’m happy for MariaDB to use the database file in the file share volume, but it doesn’t seem to be able to do this. – Tom Irving Nov 19 '19 at 10:51
  • @TomIrving I know a means, but it's a little bother. You can try to copy all the files in the directory `/var/lib/mysql` to your file share which you want to use to mount when the image runs well. – Charles Xu Nov 20 '19 at 01:55