Why MariaDB loads setting for about 5-8 minutes?

淺唱寂寞╮ 提交于 2020-02-07 02:26:46

问题


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

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

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 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.

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

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

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


回答1:


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

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.




回答2:


I had the same issue. It seems that loading the timezone info (sometimes) takes up a lot of time (+6 min.).

You can check this by disabling it:

  db:
    image: mariadb
    environment:
      - MYSQL_INITDB_SKIP_TZINFO=1

Now it starts in less than 30s.



来源:https://stackoverflow.com/questions/58182042/why-mariadb-loads-setting-for-about-5-8-minutes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!