【发布时间】:2021-06-05 05:32:15
【问题描述】:
我只是想用 docker compose 在 azure 上启动一个简单的 mariadb 容器。在不链接到卷的情况下它可以工作,但是每当我尝试使用卷来进行一些持久存储时,容器都会拒绝正确启动。在我的 docker compose 设置下方:
version: '3.8'
services:
db:
image: mariadb:10.5.8
volumes:
- data-volume:/var/lib/mysql
restart: always
environment:
- MYSQL_ROOT_PASSWORD=****
- MYSQL_DATABASE=****
- MYSQL_USER=****
- MYSQL_PASSWORD=****
ports:
- 3306:3306
volumes:
data-volume:
driver: azure_file
driver_opts:
share_name: myshare
storage_account_name: mystorage
我总是在 mariadb 日志中收到此错误,因此 mysql 用户似乎没有足够的权限执行某些任务。虽然有文件写在卷上。
021-02-22 16:36:18+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.5.8+maria~focal started.
2021-02-22 16:36:21+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2021-02-22 16:36:22+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.5.8+maria~focal started.
2021-02-22 16:36:22+00:00 [Note] [Entrypoint]: Initializing database files
PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following commands:
'/usr/bin/mysqladmin' -u root password 'new-password'
'/usr/bin/mysqladmin' -u root -h password 'new-password'
Alternatively you can run:
'/usr/bin/mysql_secure_installation'
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the MariaDB Knowledgebase at https://mariadb.com/kb or the
MySQL manual for more instructions.
Please report any problems at https://mariadb.org/jira
The latest information about MariaDB is available at https://mariadb.org/.
You can find additional information about the MySQL part at:
https://dev.mysql.com
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/
2021-02-22 16:36:49+00:00 [Note] [Entrypoint]: Database files initialized
2021-02-22 16:36:49+00:00 [Note] [Entrypoint]: Starting temporary server
2021-02-22 16:36:49+00:00 [Note] [Entrypoint]: Waiting for server startup
2021-02-22 16:36:49 0 [Note] mysqld (mysqld 10.5.8-MariaDB-1:10.5.8+maria~focal) starting as process 162 ...
2021-02-22 16:36:49 0 [Note] InnoDB: Using Linux native AIO
2021-02-22 16:36:49 0 [Note] InnoDB: Uses event mutexes
2021-02-22 16:36:49 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2021-02-22 16:36:49 0 [Note] InnoDB: Number of pools: 1
2021-02-22 16:36:49 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
2021-02-22 16:36:49 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
2021-02-22 16:36:49 0 [Note] InnoDB: Initializing buffer pool, total size = 134217728, chunk size = 134217728
2021-02-22 16:36:49 0 [Note] InnoDB: Completed initialization of buffer pool
2021-02-22 16:36:49 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2021-02-22 16:36:49 0 [Warning] InnoDB: Retry attempts for reading partial data failed.
2021-02-22 16:36:49 0 [ERROR] InnoDB: Operating system error number 13 in a file operation.
2021-02-22 16:36:49 0 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory.
2021-02-22 16:36:49 0 [ERROR] [FATAL] InnoDB: Tried to read 65536 bytes at offset 38400, but was only able to read 0.Cannot read from file. OS error number 13.
210222 16:36:49 [ERROR] mysqld got signal 6 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
To report this bug, see https://mariadb.com/kb/en/reporting-bugs
We will try our best to scrape up some info that will hopefully help
diagnose the problem, but since we have already crashed,
something is definitely wrong and this may fail.
Server version: 10.5.8-MariaDB-1:10.5.8+maria~focal
key_buffer_size=134217728
read_buffer_size=131072
max_used_connections=0
max_threads=153
thread_count=0
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 467860 K bytes of memory
Hope that's ok; if not, decrease some variables in the equation.
Thread pointer: 0x0
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 0x0 thread_stack 0x49000
mysqld(my_print_stacktrace+0x32)[0x55611b833692]
Printing to addr2line failed
mysqld(handle_fatal_signal+0x485)[0x55611b28ae45]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x153c0)[0x7f01295d63c0]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0xcb)[0x7f01290dd18b]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x12b)[0x7f01290bc859]
mysqld(+0x62dcbb)[0x55611af4fcbb]
mysqld(+0x610b88)[0x55611af32b88]
mysqld(+0xcd8946)[0x55611b5fa946]
mysqld(+0xcc3cbb)[0x55611b5e5cbb]
mysqld(+0xcc8b4b)[0x55611b5eab4b]
mysqld(+0xccce49)[0x55611b5eee49]
mysqld(+0xccd460)[0x55611b5ef460]
mysqld(+0x62636a)[0x55611af4836a]
mysqld(+0xc60c49)[0x55611b582c49]
mysqld(_Z24ha_initialize_handlertonP13st_plugin_int+0x82)[0x55611b28deb2]
mysqld(+0x76b36a)[0x55611b08d36a]
mysqld(_Z11plugin_initPiPPci+0x965)[0x55611b08e645]
mysqld(+0x68ab0b)[0x55611afacb0b]
mysqld(_Z11mysqld_mainiPPc+0x435)[0x55611afb26b5]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3)[0x7f01290be0b3]
mysqld(_start+0x2e)[0x55611afa712e]
The manual page at https://mariadb.com/kb/en/how-to-produce-a-full-stack-trace-for-mysqld/ contains
information that should help you find out what is causing the crash.
Writing a core file...
Working directory at /var/lib/mysql
Resource Limits:
Limit Soft Limit Hard Limit Units
Max cpu time unlimited unlimited seconds
Max file size unlimited unlimited bytes
Max data size unlimited unlimited bytes
Max stack size 8388608 unlimited bytes
Max core file size 0 unlimited bytes
Max resident set unlimited unlimited bytes
Max processes 4326 4326 processes
Max open files 32184 32184 files
Max locked memory 65536 65536 bytes
Max address space unlimited unlimited bytes
Max file locks unlimited unlimited locks
Max pending signals 4326 4326 signals
Max msgqueue size 819200 819200 bytes
Max nice priority 0 0
Max realtime priority 0 0
Max realtime timeout unlimited unlimited us
Core pattern: core
/usr/local/bin/docker-entrypoint.sh: line 103: 162 Aborted "$@" --skip-networking --socket="${SOCKET}"
2021-02-22 16:36:49 0 [ERROR] InnoDB:错误表示mysqld没有目录的访问权限。
我已经尝试过使用自定义 mariadb 图像,但没有成功
FROM mariadb:10.5.8
RUN chown 999:999 /var/lib/mysql
当我在我的 docker-compose 文件中启动没有卷规范的容器并登录到容器时,我可以看到这些文件是由 mysql 用户创建的?我在这里错过了什么?
-rw-rw---- 1 mysql mysql 32768 Mar 8 11:01 aria_log.00000001
-rw-rw---- 1 mysql mysql 52 Mar 8 11:01 aria_log_control
-rw-rw---- 1 mysql mysql 976 Mar 8 11:01 ib_buffer_pool
-rw-rw---- 1 mysql mysql 100663296 Mar 8 11:01 ib_logfile0
-rw-rw---- 1 mysql mysql 12582912 Mar 8 11:01 ibdata1
-rw-rw---- 1 mysql mysql 12582912 Mar 8 11:01 ibtmp1
drwx------ 2 mysql mysql 4096 Mar 8 11:01 mydatabase
-rw-rw---- 1 mysql mysql 0 Mar 8 11:01 multi-master.info
drwx------ 2 mysql mysql 4096 Mar 8 11:01 mysql
drwx------ 2 mysql mysql 4096 Mar 8 11:01 performance_schema
也许也很高兴知道,该卷是通过 docker aci 功能创建的。 https://docs.docker.com/cloud/aci-compose-features/#persistent-volumes
更新:官方 mysql (5.7) docker 镜像没有这个问题。它开箱即用。
【问题讨论】:
标签: azure docker docker-compose mariadb