Mysql

我的 MySQL 伺服器死了

  • March 18, 2016

每周大約 1 次我的 MySQL 伺服器關閉。

這是日誌的樣子:

2016-03-18 13:46:25 13166 [Warning] Buffered warning: Changed limits: max_open_files: 1024 (requested 5000)
2016-03-18 13:46:25 13166 [Warning] Buffered warning: Changed limits: table_open_cache: 431 (requested 2000)
2016-03-18 13:46:25 13166 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
2016-03-18 13:46:25 13166 [Note] Plugin 'FEDERATED' is disabled.
2016-03-18 13:46:25 13166 [ERROR] Function 'innodb' already exists
2016-03-18 13:46:25 13166 [Warning] Couldn't load plugin named 'innodb' with soname 'ha_innodb.so'.
2016-03-18 13:46:25 13166 [ERROR] Function 'federated' already exists
2016-03-18 13:46:25 13166 [Warning] Couldn't load plugin named 'federated' with soname 'ha_federated.so'.
2016-03-18 13:46:25 13166 [ERROR] Function 'blackhole' already exists
2016-03-18 13:46:25 13166 [Warning] Couldn't load plugin named 'blackhole' with soname 'ha_blackhole.so'.
2016-03-18 13:46:25 13166 [ERROR] Function 'archive' already exists
2016-03-18 13:46:25 13166 [Warning] Couldn't load plugin named 'archive' with soname 'ha_archive.so'.
2016-03-18 13:46:25 13166 [Note] InnoDB: Using atomics to ref count buffer pool pages
2016-03-18 13:46:25 13166 [Note] InnoDB: The InnoDB memory heap is disabled
2016-03-18 13:46:25 13166 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-03-18 13:46:25 13166 [Note] InnoDB: Memory barrier is not used
2016-03-18 13:46:25 13166 [Note] InnoDB: Compressed tables use zlib 1.2.8
2016-03-18 13:46:25 13166 [Note] InnoDB: Using Linux native AIO
2016-03-18 13:46:25 13166 [Note] InnoDB: Using CPU crc32 instructions
2016-03-18 13:46:25 13166 [Note] InnoDB: Initializing buffer pool, size = 128.0M InnoDB: mmap(137363456 bytes) failed; errno 12
2016-03-18 13:46:25 13166 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
2016-03-18 13:46:25 13166 [ERROR] Plugin 'InnoDB' init function returned error.
2016-03-18 13:46:25 13166 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2016-03-18 13:46:25 13166 [ERROR] Unknown/unsupported storage engine: InnoDB
2016-03-18 13:46:25 13166 [ERROR] Aborting
2016-03-18 13:46:25 13166 [Note] Binlog end
2016-03-18 13:46:25 13166 [Note] Shutting down plugin 'partition'
2016-03-18 13:46:25 13166 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
2016-03-18 13:46:25 13166 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
2016-03-18 13:46:25 13166 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
2016-03-18 13:46:25 13166 [Note] /usr/sbin/mysqld: Shutdown complete

160318 13:46:25 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

你怎麼看?可能記憶體不夠?

這是在執行 Ubuntu 15.10 的虛擬專用伺服器上執行的,記憶體為 512MB。

現在我什至無法重新啟動我的 MySQL 伺服器。我my.cnf是空的,我該怎麼辦?

老實說,我不認為 mysqld 正在消亡。

您發布的消息讓我想起有人或某事試圖在沒有 PID 文件的情況下重新啟動 mysqld。當沒有 PID 文件時,doingservice mysql stop不起作用。我在Percona-server time out on /etc/init.d/mysql start back on Dec 14, 2012 和MySQL Start/Stop 3 天后寫了這個。

發生的事情是 mysqld 已經在執行並且正在發出 mysqld start 。這會破壞 PID 文件(請參閱標題下的MySQL 啟動/停止PROCESSES (Shutdown))。您看到的消息是第二次嘗試啟動 mysqld 只是為了發現外掛已經載入。

更明顯的是我在 2014 年 4 月 24 日在兩台 MySQL 伺服器通過 NFS 訪問同一數據庫中寫回的內容:

  • 只有一個 mysqld 實例可以獲得系統表空間上的獨占日誌緩衝區執行緒
  • 只有一個 mysqld 實例可以獲得系統表空間上的獨占插入緩衝區執行緒

只有緩衝池已經存在才能分配緩衝池才有意義

建議

嘗試關閉mysqld

mysqladmin -h127.0.0.1 -P3306 --protocol=tcp -uroot -p shutdown

這將提示輸入密碼。輸入密碼後,如果沒有返回輸出,則 mysqld 執行了正確的關閉。(順便說一句,這是在 MySQL 5.7 中處理的,因為您可以從 mysql 客戶端會話中執行 SHUTDOWN 命令)。然後,您可以service mysql start將 PID 文件的情況理順執行。

我希望您擁有使用者root@127.0.0.1或 mysqld 足夠聰明以使用root@localhost憑據(有關 mysqld 如何對使用者進行身份驗證,請參閱我的舊文章MySQL 錯誤:使用者 ‘a’@’localhost’ 的訪問被拒絕(使用密碼:YES)

引用自:https://dba.stackexchange.com/questions/132697