Mysql

MySQL (MariaDB) 經常崩潰

  • October 24, 2018

我最近將執行 MySQL 的舊伺服器遷移到執行 MariaDB 5.5 的新 VPS。我沒有在伺服器上執行太多(只有幾個 PHP 站點),可用記憶體似乎還可以,但數據庫不斷崩潰——有時每隔幾天,有時在幾個小時內。

我在日誌中收到以下錯誤:

131231  1:43:04 [ERROR] mysqld: Out of memory (Needed 128917504 bytes)
131231  1:43:04 [ERROR] mysqld: Out of memory (Needed 96681984 bytes)
131231  1:43:04 [ERROR] mysqld: Out of memory (Needed 72499200 bytes)
131231  1:43:04 [ERROR] mysqld: Out of memory (Needed 54362112 bytes)
131231  1:43:04 InnoDB: The InnoDB memory heap is disabled
131231  1:43:04 InnoDB: Mutexes and rw_locks use GCC atomic builtins
131231  1:43:04 InnoDB: Compressed tables use zlib 1.2.3.4
131231  1:43:04 InnoDB: Using Linux native AIO
131231  1:43:04 InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(137756672 bytes) failed; errno 12
131231  1:43:04 InnoDB: Completed initialization of buffer pool
131231  1:43:04 InnoDB: Fatal error: cannot allocate memory for the buffer pool
131231  1:43:04 [ERROR] Plugin 'InnoDB' init function returned error.
131231  1:43:04 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
131231  1:43:04 [Note] Plugin 'FEEDBACK' is disabled.
131231  1:43:04 [ERROR] Unknown/unsupported storage engine: InnoDB
131231  1:43:04 [ERROR] Aborting

131231  1:43:04 [Note] /usr/sbin/mysqld: Shutdown complete

我玩過 InnoDB Heap 的 my.cnf 設置,這似乎沒有幫助。這是相關部分:

innodb_buffer_pool_size = 128M
innodb_log_buffer_size  = 8M
innodb_file_per_table   = 1
innodb_open_files       = 400
innodb_io_capacity      = 400
innodb_flush_method     = O_DIRECT

我似乎有“大量”的空閒 RAM,而且我也有一些可用的交換:

root@phoenix:~# free -m
            total       used       free     shared    buffers     cached
Mem:           994        923         71          0         19        417
-/+ buffers/cache:        486        508
Swap:         1023        131        892

我該如何解決/解決這個問題?我已經在 interwebz 上搜尋了線索,但沒有任何幫助。

我希望它對你有幫助。

嘗試

performance_schema = off

[mysqld]您的配置部分。

https://mariadb.com/resources/blog/starting-mysql-on-low-memory-virtual-machines/

引用自:https://serverfault.com/questions/564748