skip to Main Content

I want to customize some MariaDB server configs (wait_timeout, etc.). I followed the instructions on the official Docker image and created two .cnf files inside my host dir config/mariadb which is mounted in the container via these volumes:

volumes:
  - /config/mariadb:/etc/mysql/conf.d:ro
  - /config/mariadb:/etc/mysql/mariadb.conf.d:ro
root@server:~# ls -l /config/mariadb
total 12
-rwxrwx--- 1 root root 263 Jun  8 13:43 mariadb-finetuning.cnf
-rwxrwx--- 1 root root 367 Jun  8 13:43 mariadb-inno.cnf

These are the config files:

[mysqld]
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
# default_storage_engine    = InnoDB
# innodb_buffer_pool_size   = 256M
# innodb_log_buffer_size    = 8M
# innodb_file_per_table = 1
# innodb_open_files = 400
# innodb_io_capacity    = 400
innodb_flush_method = fsync
[mysqld]
# * Fine Tuning
#
# max_connections       = 100
# connect_timeout       = 5
wait_timeout        = 3600
# max_allowed_packet    = 16M
# thread_cache_size       = 128
# sort_buffer_size  = 4M
# bulk_insert_buffer_size   = 16M
# tmp_table_size        = 32M
# max_heap_table_size   = 32M

Somehow the options have no effect and I don’t know why:

show variables where variable_name = 'innodb_flush_method'

# Variable_name Value
# innodb_flush_method   O_DIRECT

Is there any better way to check why mariadb does not pick up these configs?

Update:

  • Manually editing my.cnf inside the container works but isn’t what I want to do.
  • Runnnig mysqld --print-defaults will print out ... --innodb_flush_method=fsync as result. It seems to me that this may be due to the entrypoint script /docker-entrypoint.sh ?

2

Answers


  1. Chosen as BEST ANSWER

    Problem were file permissions.

    The config files must be readable by the linux user running the database.

    There may be several solutions, in my case the simplest is to apply 774 file permissions so that the file is readable by every user:

    root@server:~# ls -l /config/mariadb
    total 12
    -rwxrwxr-- 1 root root 263 Jun  8 13:43 mariadb-finetuning.cnf
    -rwxrwxr-- 1 root root 367 Jun  8 13:43 mariadb-inno.cnf
    

  2. If your MariaDB can run with your settings, perform ‘docker exec’ to run a bash inside your MariaDB container and check if your volume mount shows the expected files in the expected location.

    Then also check that the configuation or startup of MariaDB inside the container is configured to read these files at all. You could to that by providing empty files, or files with gibberish inside.

    Only then start looking at the content of the files. Once you reach here, you seem to have power over the containerized database engine.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search