为什么MariaDB加载设置大约5-8分钟? [英] Why MariaDB loads setting for about 5-8 minutes?

查看:218
本文介绍了为什么MariaDB加载设置大约5-8分钟?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用docker-compose创建两个图像: 1.我的Spring Boot应用 2. MariaDB作为应用程序的数据库

I want to create using docker-compose two images: 1. My Spring Boot app 2. MariaDB as a database for the app

MariaDB的dockerfile:

dockerfile for MariaDB:

FROM mariadb:latest

ADD my.cnf /etc/mysql/my.cnf
ENV MYSQL_USER test
ENV MYSQL_PASSWORD Test123456
ENV MYSQL_ROOT_PASSWORD lsagvcbjkz<kcnz
EXPOSE 3306

和docker.compose:

and docker.compose:

version: '2.1'

services:
  db:
    image: mariadb
    container_name: mariaDB
    environment:
      MYSQL_DATABASE: testdb
    healthcheck:
      test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
    networks:
      - backend

  app:
    image: app
    container_name: APP
    restart: on-failure
    ports:
      - 8080:8080
    depends_on:
       db:
        condition: service_healthy
    networks:
      - backend

networks:
  backend:
    driver: bridge

MariaDB日志:

MariaDB logs:

Initializing database


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 http://mariadb.com/kb or the
MySQL manual for more instructions.

Please report any problems at http://mariadb.org/jira

The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/

Database initialized
MySQL init process in progress...
2019-10-01  9:08:58 0 [Note] mysqld (mysqld 10.4.8-MariaDB-1:10.4.8+maria~bionic) starting as process 108 ...
2019-10-01  9:08:58 0 [Note] InnoDB: Using Linux native AIO
2019-10-01  9:08:59 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2019-10-01  9:08:59 0 [Note] InnoDB: Uses event mutexes
2019-10-01  9:08:59 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2019-10-01  9:08:59 0 [Note] InnoDB: Number of pools: 1
2019-10-01  9:08:59 0 [Note] InnoDB: Using SSE2 crc32 instructions
2019-10-01  9:08:59 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
2019-10-01  9:08:59 0 [Note] InnoDB: Initializing buffer pool, total size = 256M, instances = 1, chunk size = 128M
2019-10-01  9:08:59 0 [Note] InnoDB: Completed initialization of buffer pool
2019-10-01  9:08:59 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2019-10-01  9:08:59 0 [Note] InnoDB: 128 out of 128 rollback segments are active.
2019-10-01  9:08:59 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2019-10-01  9:08:59 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2019-10-01  9:08:59 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2019-10-01  9:08:59 0 [Note] InnoDB: 10.4.8 started; log sequence number 139836; transaction id 21
2019-10-01  9:08:59 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2019-10-01  9:08:59 0 [Note] Plugin 'FEEDBACK' is disabled.
2019-10-01  9:08:59 0 [Warning] 'user' entry 'root@c147913c7f5c' ignored in --skip-name-resolve mode.
2019-10-01  9:08:59 0 [Warning] 'user' entry '@c147913c7f5c' ignored in --skip-name-resolve mode.
2019-10-01  9:08:59 0 [Warning] 'proxies_priv' entry '@% root@c147913c7f5c' ignored in --skip-name-resolve mode.
2019-10-01  9:08:59 0 [Note] InnoDB: Buffer pool(s) load completed at 191001  9:08:59
2019-10-01  9:08:59 0 [Note] Reading of all Master_info entries succeeded
2019-10-01  9:08:59 0 [Note] Added new Master_info '' to hash table
2019-10-01  9:08:59 0 [Note] mysqld: ready for connections.
Version: '10.4.8-MariaDB-1:10.4.8+maria~bionic'  socket: '/var/run/mysqld/mysqld.sock'  port: 0  mariadb.org binary distribution
Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
2019-10-01  9:16:52 25 [Warning] 'proxies_priv' entry '@% root@c147913c7f5c' ignored in --skip-name-resolve mode.

如您所见,MariaDB不会加载my.cnf文件:"port:0" 几分钟后,MariaDB重置:

As you can see MariaDB do not load my.cnf file: " port: 0 " After few minutes MariaDB resets:

2019-10-01  9:16:52 0 [Note] mysqld (initiated by: unknown): Normal shutdown
2019-10-01  9:16:52 0 [Note] Event Scheduler: Purging the queue. 0 events
2019-10-01  9:16:52 0 [Note] InnoDB: FTS optimize thread exiting.
2019-10-01  9:16:52 0 [Note] InnoDB: Starting shutdown...
2019-10-01  9:16:52 0 [Note] InnoDB: Dumping buffer pool(s) to /var/lib/mysql/ib_buffer_pool
2019-10-01  9:16:52 0 [Note] InnoDB: Buffer pool(s) dump completed at 191001  9:16:52
2019-10-01  9:16:54 0 [Note] InnoDB: Shutdown completed; log sequence number 20431569; transaction id 14896
2019-10-01  9:16:54 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2019-10-01  9:16:54 0 [Note] mysqld: Shutdown complete


MySQL init process done. Ready for start up.

2019-10-01  9:16:54 0 [Note] mysqld (mysqld 10.4.8-MariaDB-1:10.4.8+maria~bionic) starting as process 1 ...
2019-10-01  9:16:54 0 [Note] InnoDB: Using Linux native AIO
2019-10-01  9:16:54 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2019-10-01  9:16:54 0 [Note] InnoDB: Uses event mutexes
2019-10-01  9:16:54 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2019-10-01  9:16:54 0 [Note] InnoDB: Number of pools: 1
2019-10-01  9:16:54 0 [Note] InnoDB: Using SSE2 crc32 instructions
2019-10-01  9:16:54 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
2019-10-01  9:16:54 0 [Note] InnoDB: Initializing buffer pool, total size = 256M, instances = 1, chunk size = 128M
2019-10-01  9:16:54 0 [Note] InnoDB: Completed initialization of buffer pool
2019-10-01  9:16:54 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2019-10-01  9:16:54 0 [Note] InnoDB: 128 out of 128 rollback segments are active.
2019-10-01  9:16:54 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2019-10-01  9:16:54 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2019-10-01  9:16:54 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2019-10-01  9:16:54 0 [Note] InnoDB: Waiting for purge to start
2019-10-01  9:16:54 0 [Note] InnoDB: 10.4.8 started; log sequence number 20431569; transaction id 14896
2019-10-01  9:16:54 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2019-10-01  9:16:54 0 [Note] Plugin 'FEEDBACK' is disabled.
2019-10-01  9:16:54 0 [Note] Server socket created on IP: '0.0.0.0'.
2019-10-01  9:16:54 0 [Warning] 'proxies_priv' entry '@% root@c147913c7f5c' ignored in --skip-name-resolve mode.
2019-10-01  9:16:54 0 [Note] Reading of all Master_info entries succeeded
2019-10-01  9:16:54 0 [Note] Added new Master_info '' to hash table
2019-10-01  9:16:54 0 [Note] mysqld: ready for connections.
Version: '10.4.8-MariaDB-1:10.4.8+maria~bionic'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  mariadb.org binary distribution
2019-10-01  9:16:54 0 [Note] InnoDB: Buffer pool(s) load completed at 191001  9:16:54

从这一刻起,我的应用最终可以连接到数据库了. 端口:3306"

And from this moment my app can finnaly connect to DB. "port: 3306"

我的问题是: MariaDB是否应该加载这么长时间? 加载my.cnf设置几分钟后,MariaDB是否应该重新启动?

My question is: Should MariaDB load so long? Should MariaDB resters after few minutes with loaded my.cnf settings?

推荐答案

mariadb docker映像的Entrypoint运行脚本 docker-entrypoint.sh .此脚本将运行以下命令的时区信息加载到数据库中:

The Entrypoint for mariadb docker image runs the script docker-entrypoint.sh. This script loads timezone info into database running the command:

mysql_tzinfo_to_sql /usr/share/zoneinfo

在测试期间,我看到运行此命令的时间可能非常长.设置环境变量MYSQL_INITDB_SKIP_TZINFO=1会跳过此步骤,并加快数据库的初始化速度.

During my testing, I saw the time to run this command could be very high. Setting the environment variable MYSQL_INITDB_SKIP_TZINFO=1 skips this step and speeds up your database initialization.

这篇关于为什么MariaDB加载设置大约5-8分钟?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆