LoginSignup
1
0

MySQLがクラッシュした際に、Docker環境のDBサーバーを強制的に立ち上げる方法

Last updated at Posted at 2024-03-05

エラー内容

insides-db-1   | 2024-03-05 02:01:18+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.33-1debian10 started.
insides-db-1   | 2024-03-05 02:01:18+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
insides-db-1   | 2024-03-05 02:01:18+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.33-1debian10 started.
insides-db-1   | 2024-03-05T02:01:19.128047Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
insides-db-1   | 2024-03-05T02:01:19.128640Z 0 [Warning] Insecure configuration for --secure-file-priv: Location is accessible to all OS users. Consider choosing a different directory.
insides-db-1   | 2024-03-05T02:01:19.128675Z 0 [Note] mysqld (mysqld 5.7.33) starting as process 1 ...
insides-db-1   | 2024-03-05T02:01:19.130885Z 0 [Note] InnoDB: PUNCH HOLE support available
insides-db-1   | 2024-03-05T02:01:19.130926Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
insides-db-1   | 2024-03-05T02:01:19.130930Z 0 [Note] InnoDB: Uses event mutexes
insides-db-1   | 2024-03-05T02:01:19.130932Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
insides-db-1   | 2024-03-05T02:01:19.130934Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
insides-db-1   | 2024-03-05T02:01:19.130936Z 0 [Note] InnoDB: Using Linux native AIO
insides-db-1   | 2024-03-05T02:01:19.131108Z 0 [Note] InnoDB: Number of pools: 1
insides-db-1   | 2024-03-05T02:01:19.131216Z 0 [Note] InnoDB: Using CPU crc32 instructions
insides-db-1   | 2024-03-05T02:01:19.132606Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
insides-db-1   | 2024-03-05T02:01:19.138304Z 0 [Note] InnoDB: Completed initialization of buffer pool
insides-db-1   | 2024-03-05T02:01:19.140350Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
insides-db-1   | 2024-03-05T02:01:19.151506Z 0 [ERROR] [FATAL] InnoDB: Table flags are 0 in the data dictionary but the flags in file ./ibdata1 are 0x4000!
insides-db-1   | 2024-03-05 02:01:19 0x7f36ef986740  InnoDB: Assertion failure in thread 139873924704064 in file ut0ut.cc line 921
insides-db-1   | InnoDB: We intentionally generate a memory trap.
insides-db-1   | InnoDB: Submit a detailed bug report to http://bugs.mysql.com.
insides-db-1   | InnoDB: If you get repeated assertion failures or crashes, even
insides-db-1   | InnoDB: immediately after the mysqld startup, there may be
insides-db-1   | InnoDB: corruption in the InnoDB tablespace. Please refer to
insides-db-1   | InnoDB: http://dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html
insides-db-1   | InnoDB: about forcing recovery.
insides-db-1   | 02:01:19 UTC - mysqld got signal 6 ;
insides-db-1   | This could be because you hit a bug. It is also possible that this binary
insides-db-1   | or one of the libraries it was linked against is corrupt, improperly built,
insides-db-1   | or misconfigured. This error can also be caused by malfunctioning hardware.
insides-db-1   | Attempting to collect some information that could help diagnose the problem.
insides-db-1   | As this is a crash and something is definitely wrong, the information
insides-db-1   | collection process might fail.
insides-db-1   |
insides-db-1   | key_buffer_size=8388608
insides-db-1   | read_buffer_size=131072
insides-db-1   | max_used_connections=0
insides-db-1   | max_threads=151
insides-db-1   | thread_count=0
insides-db-1   | connection_count=0
insides-db-1   | It is possible that mysqld could use up to
insides-db-1   | key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 68196 K  bytes of memory
insides-db-1   | Hope that's ok; if not, decrease some variables in the equation.
insides-db-1   |
insides-db-1   | Thread pointer: 0x0
insides-db-1   | Attempting backtrace. You can use the following information to find out
insides-db-1   | where mysqld died. If you see no messages after this, something went
insides-db-1   | terribly wrong...
insides-db-1   | stack_bottom = 0 thread_stack 0x40000
insides-db-1   | mysqld(my_print_stacktrace+0x2c)[0x55a80bf136bc]
insides-db-1   | mysqld(handle_fatal_signal+0x501)[0x55a80b82a0c1]
insides-db-1   | /lib/x86_64-linux-gnu/libpthread.so.0(+0x12730)[0x7f36efee7730]
insides-db-1   | /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x10b)[0x7f36ef9c27bb]
insides-db-1   | /lib/x86_64-linux-gnu/libc.so.6(abort+0x121)[0x7f36ef9ad535]
insides-db-1   | mysqld(+0x6c40bf)[0x55a80b7f10bf]
insides-db-1   | mysqld(+0x6c449d)[0x55a80b7f149d]
insides-db-1   | mysqld(+0x11b303c)[0x55a80c2e003c]
insides-db-1   | mysqld(+0x11b366e)[0x55a80c2e066e]
insides-db-1   | mysqld(_Z6fil_ioRK9IORequestbRK9page_id_tRK11page_size_tmmPvS8_+0x312)[0x55a80c2e7f12]
insides-db-1   | mysqld(+0x11732db)[0x55a80c2a02db]
insides-db-1   | mysqld(_Z13buf_read_pageRK9page_id_tRK11page_size_t+0x37)[0x55a80c2a0b27]
insides-db-1   | mysqld(_Z16buf_page_get_genRK9page_id_tRK11page_size_tmP11buf_block_tmPKcmP5mtr_tb+0x409)[0x55a80c275bd9]
insides-db-1   | mysqld(_Z31trx_rseg_get_n_undo_tablespacesPm+0x13e)[0x55a80c212e9e]
insides-db-1   | mysqld(+0x10b7b47)[0x55a80c1e4b47]
insides-db-1   | mysqld(_Z34innobase_start_or_create_for_mysqlv+0x2f67)[0x55a80c1e8707]
insides-db-1   | mysqld(+0xf8c9e0)[0x55a80c0b99e0]
insides-db-1   | mysqld(_Z24ha_initialize_handlertonP13st_plugin_int+0x55)[0x55a80b87b2f5]
insides-db-1   | mysqld(+0xbe3346)[0x55a80bd10346]
insides-db-1   | mysqld(_Z40plugin_register_builtin_and_init_core_sePiPPc+0x1dc)[0x55a80bd1221c]
insides-db-1   | mysqld(+0x6f603e)[0x55a80b82303e]
insides-db-1   | mysqld(_Z11mysqld_mainiPPc+0x758)[0x55a80b8244e8]
insides-db-1   | /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xeb)[0x7f36ef9af09b]
insides-db-1   | mysqld(_start+0x2a)[0x55a80b81ad9a]
insides-db-1   | The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
insides-db-1   | information that should help you find out what is causing the crash.
insides-db-1 exited with code 2

原因: MySQLのバージョンアップの際に、データが破損した。

解決策: 正常のDBをリストアしよう!

まずは、DockerのDBを強制的を立ち上げるための設定を追加

mysqld.cnf
innodb_force_recovery = 3

Dockerをキャッシュを使わずに立ち上げなおそう

docker-compose build --no-cache

そうすれば、DBサーバーは立ち上げるので、正常なDBを再度リストアしてください。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0