MySQL 服务器(mariadb)无过载自动关闭

MySQL 服务器(mariadb)无过载自动关闭

使用旧配置,我的 VPS(1 CPU、1 GB RAM、1 GB 交换空间)正常运行了近 2 年。我从一开始就没有改变任何东西。

但是几天前我遇到了这个问题,MySQL 服务器自动关闭,通过 DO Graph 监控观察,我发现它似乎每次 CPU 过载(>100%)时都会关闭。

然后我尝试制作:

  • 在 etc/my.cnf 中进行了一些 MySQL 服务器优化;转换为 innodb、仅接受本地主机、缓存配置等

  • 关闭服务器中的所有站点,只留下1个WordPress站点,该WordPress站点默认使用innodb

重启 Mariadb 服务器后,一切正常,我测试了一段时间,一切正常。但是当我离线大约 1 小时后,它又关闭了,但所有负载都正常,似乎这个问题与过载无关?

请帮帮我,有人遇到过这个问题吗?

并且可以告诉我什么是使用 top 命令的进程加密吗?

以下是完整日志

180918 10:02:50 mysqld_safe Number of processes running now: 0
180918 10:02:50 mysqld_safe mysqld restarted
180918 10:02:50 InnoDB: The InnoDB memory heap is disabled
180918 10:02:50 InnoDB: Mutexes and rw_locks use GCC atomic builtins
180918 10:02:50 InnoDB: Compressed tables use zlib 1.2.7
180918 10:02:50 InnoDB: Using Linux native AIO
180918 10:02:50 [Note] /usr/libexec/mysqld (mysqld 5.5.56-MariaDB) starting as process 32632 ...
180918 10:02:50 InnoDB: Initializing buffer pool, size = 800.0M
InnoDB: mmap(860979200 bytes) failed; errno 12
180918 10:02:50 InnoDB: Completed initialization of buffer pool
180918 10:02:50 InnoDB: Fatal error: cannot allocate memory for the buffer pool
180918 10:02:50 [ERROR] Plugin 'InnoDB' init function returned error.
180918 10:02:50 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
180918 10:02:50 [Note] Plugin 'FEEDBACK' is disabled.
180918 10:02:50 [ERROR] Unknown/unsupported storage engine: InnoDB
180918 10:02:50 [ERROR] Aborting

180918 10:02:50 [Note] /usr/libexec/mysqld: Shutdown complete

180918 10:02:50 mysqld_safe mysqld from pid file /var/run/mariadb/mariadb.pid ended
180918 10:10:07 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
180918 10:10:07 InnoDB: The InnoDB memory heap is disabled
180918 10:10:07 InnoDB: Mutexes and rw_locks use GCC atomic builtins
180918 10:10:07 InnoDB: Compressed tables use zlib 1.2.7
180918 10:10:07 InnoDB: Using Linux native AIO
180918 10:10:07 [Note] /usr/libexec/mysqld (mysqld 5.5.56-MariaDB) starting as process 1625 ...
180918 10:10:07 InnoDB: Initializing buffer pool, size = 800.0M
180918 10:10:08 InnoDB: Completed initialization of buffer pool
180918 10:10:08 InnoDB: highest supported file format is Barracuda.
180918 10:10:08  InnoDB: Starting crash recovery from checkpoint LSN=698432796
InnoDB: Restoring possible half-written data pages from the doublewrite buffer...
180918 10:10:08  InnoDB: Starting final batch to recover 2 pages from redo log
180918 10:10:09  InnoDB: Waiting for the background threads to start
180918 10:10:10 Percona XtraDB (http://www.percona.com) 5.5.52-MariaDB-38.3 started; log sequence nu$
180918 10:10:10 [Note] Plugin 'FEEDBACK' is disabled.
180918 10:10:10 [Note] Server socket created on IP: '127.0.0.1'.
180918 10:10:10 [Warning] 'proxies_priv' entry '@ [email protected]' ignored in --skip-name$
180918 10:10:10 [Note] Event Scheduler: Loaded 0 events
180918 10:10:10 [Note] /usr/libexec/mysqld: ready for connections.
Version: '5.5.56-MariaDB'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MariaDB Server
180918 11:19:10 mysqld_safe Number of processes running now: 0
180918 11:19:10 mysqld_safe mysqld restarted
180918 11:19:10 InnoDB: The InnoDB memory heap is disabled
180918 11:19:10 InnoDB: Mutexes and rw_locks use GCC atomic builtins
180918 11:19:10 InnoDB: Compressed tables use zlib 1.2.7
180918 11:19:10 InnoDB: Using Linux native AIO
180918 11:19:10 [Note] /usr/libexec/mysqld (mysqld 5.5.56-MariaDB) starting as process 3017 ...
180918 11:19:10 InnoDB: Initializing buffer pool, size = 800.0M
InnoDB: mmap(860979200 bytes) failed; errno 12
180918 11:19:10 InnoDB: Completed initialization of buffer pool

以下是我在 /etc/my.cnf 中所做的优化

[mysqld]
# custom
bind-address = 127.0.0.1

skip-name-resolve
skip-external-locking

key_buffer_size = 32K
max_allowed_packet = 4M
table_open_cache = 8
sort_buffer_size = 128K
read_buffer_size = 512K
read_rnd_buffer_size = 512K
net_buffer_length = 4K
thread_stack = 480K
thread_cache_size = 8

innodb_file_per_table=1
max_connections = 100
max_user_connections=50
wait_timeout=50
interactive_timeout=50
long_query_time=5

query_cache_type = 1
query_cache_limit=1M
query_cache_min_res_unit = 2k
query_cache_size=32M ## 32MB for every 1GB of RAM

tmp_table_size= 64M
max_heap_table_size= 64M

log_error = /var/log/mariadb/error.log
expire_logs_days    = 5
max_binlog_size   = 100M
innodb_buffer_pool_size=800M
innodb_buffer_pool_instances = 3

这是 top 命令

答案1

如果你读了日志,你会发现有一小段文字写着“致命错误”。这表示发生了致命错误。这之前的几行说明了原因。

进行调整innodb_buffer_pool_size以匹配您的可用内存。

您还可以通过禁用查询缓存来节省 RAM 并提高性能。

crypto,并且top中所有消耗0内存的进程都是linux内核线程。

相关内容