I have a mysql docker container that maps its data and logs directories onto a host path.
The host paths are two separate zfs mount points.
When I try to start MySQL it is reporting:
[Entrypoint]: Entrypoint script for MySQL Server 8.0.28-1debian10 started.
[Entrypoint]: Switching to dedicated user 'mysql'
[Entrypoint]: Entrypoint script for MySQL Server 8.0.28-1debian10 started.
[Entrypoint]: Initializing database files
[Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.
[System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.28) initializing of server in progress as process 42
[ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
[ERROR] [MY-013236] [Server] The designated data directory /var/lib/mysql/innodb-data/ is unusable. You can remove all files that the server added to it.
[ERROR] [MY-010119] [Server] Aborting
[System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.28) MySQL Community Server - GPL.
Mysql creates the following files in the host's data directory before shutting down:
ll /db/mysql-innodb-data/dir/
total 12302
drwxr-xr-x 2 systemd-coredump root 4 May 15 12:56 ./
drwxr-xr-x 3 mysql mysql 3 May 15 12:37 ../
-rw-r----- 1 systemd-coredump systemd-coredump 56 May 15 12:37 auto.cnf
-rw-r----- 1 systemd-coredump systemd-coredump 12582912 May 15 12:37 ibdata1
The systemd-coredump user is uid 999 which I'm guessing maps to the MySQL user in the container.
So clearly the container can write to the host.
The mount command shows:
db on /db type zfs (rw,xattr,noacl)
db/mysql-innodb-data on /db/mysql-innodb-data type zfs (rw,xattr,noacl)
db/mysql-innodb-logs on /db/mysql-innodb-logs type zfs (rw,xattr,noacl)
The zfs mount command shows:
zfs mount
db /db
db/mysql-innodb-data /db/mysql-innodb-data
db/mysql-innodb-logs /db/mysql-innodb-logs
On the assumption that MySQL doesn't like writing to the root of the mount point;
I've tried moving the data and log direction into a sub dir of the zfs mount points with the docker-compose mapping set to:
volumes:
- /db/mysql-innodb-data/dir:/var/lib/mysql/innodb-data
- /db/mysql-innodb-logs/dir:/var/lib/mysql/innodb-logs
However, the above changes made no difference.
Here is the docker-compose service section:
mysql:
container_name: mysql
image: noojee/mysql-zfs:8.0
restart: on-failure
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ADMIN_PASSWORD}
MYSQL_DATABASE: ${MYSQL_SCHEMA}
TZ: ${TIME_ZONE-Australia/Melbourne}
# https://www.percona.com/blog/mysql-zfs-performance-update/
# --innodb_flush_log_at_trx_commit=1 # TPCC reqs.
# --innodb_doublewrite=0 # ZFS is transactional
command: >
--lower-case-table-names=1
--datadir=/var/lib/mysql/innodb-data
--innodb_log_group_home_dir=/var/lib/mysql/innodb-logs
--default-authentication-plugin=mysql_native_password
--max-allowed-packet=512M
--innodb_buffer_pool_instances=${MYSQL_INNODB_BUFFER_POOL_INSTANCES-32}
--innodb_buffer_pool_chunk_size=${MYSQL_INNODB_BUFFER_POOL_CHUNK_SIZE-8M}
--innodb_buffer_pool_size=${MYSQL_INNODB_BUFFER_POOL_SIZE-512M}
--table_open_cache=${MYSQL_TABLE_OPEN_CACHE-512}
--max_connections=${MYSQL_MAX_CONNECTIONS-98}
--innodb_flush_neighbors=0
--innodb_fast_shutdown=2
--innodb_flush_log_at_trx_commit=1
--innodb_flush_method=fsync
--innodb_doublewrite=0
--innodb_use_native_aio=0
--innodb_read_io_threads=10
--innodb_write_io_threads=10
--slow_query_log_file=/tmp/mysql-slow.log --long-query-time=1
--slow_query_log
# mem_limit: ${MYSQL_MEMORY}
volumes:
- /db/mysql-innodb-data/dir:/var/lib/mysql/innodb-data
- /db/mysql-innodb-logs/dir:/var/lib/mysql/innodb-logs
network_mode: "host"
logging:
driver: "journals"