内存不足

xcitsw88  于 2021-06-19  发布在  Mysql
关注(0)|答案(1)|浏览(690)

我的数据库崩溃,内存不足错误~每天1-2次。上次崩溃是在17:30的日志和19:30的指标(不同的时区)。
mariadb.log中的错误:

  1. 181120 16:09:00 [Warning] IP address '185.156.177.144' could not be resolved: Name or service not known
  2. 181120 16:35:40 [Warning] IP address '58.221.58.248' could not be resolved: Name or service not known
  3. 181120 17:30:38 mysqld_safe Number of processes running now: 0
  4. 181120 17:30:38 mysqld_safe mysqld restarted
  5. 181120 17:30:41 [Warning] 'THREAD_CONCURRENCY' is deprecated and will be removed in a future release.
  6. 181120 17:30:41 [Note] /usr/libexec/mysqld (mysqld 5.5.52-MariaDB) starting as process 16636 ...
  7. 181120 17:30:41 [Warning] Changed limits: max_open_files: 1024 max_connections: 70 table_cache: 472
  8. 181120 17:30:41 InnoDB: The InnoDB memory heap is disabled
  9. 181120 17:30:41 InnoDB: Mutexes and rw_locks use GCC atomic builtins
  10. 181120 17:30:41 InnoDB: Compressed tables use zlib 1.2.7
  11. 181120 17:30:41 InnoDB: Using Linux native AIO
  12. 181120 17:30:41 InnoDB: Initializing buffer pool, size = 150.0M
  13. 181120 17:30:42 InnoDB: Completed initialization of buffer pool
  14. 181120 17:30:42 InnoDB: highest supported file format is Barracuda.
  15. InnoDB: The log sequence number in ibdata files does not match
  16. InnoDB: the log sequence number in the ib_logfiles!
  17. 181120 17:30:42 InnoDB: Database was not shut down normally!
  18. InnoDB: Starting crash recovery.
  19. InnoDB: Reading tablespace information from the .ibd files...
  20. InnoDB: Restoring possible half-written data pages from the doublewrite
  21. InnoDB: buffer...
  22. 181120 17:30:46 InnoDB: Waiting for the background threads to start
  23. 181120 17:30:47 Percona XtraDB (http://www.percona.com) 5.5.49-MariaDB-38.0 started; log sequence number 18741266161
  24. 181120 17:30:47 [Note] Plugin 'FEEDBACK' is disabled.
  25. 181120 17:30:48 [Note] Server socket created on IP: '0.0.0.0'.
  26. 181120 17:30:49 [Note] Event Scheduler: Loaded 0 events
  27. 181120 17:30:49 [Note] /usr/libexec/mysqld: ready for connections.
  28. Version: '5.5.52-MariaDB' socket: '/var/lib/mysql/mysql.sock' port: 3306 MariaDB Server
  29. 181120 17:30:53 [ERROR] mysqld: Table './admin_wikis/wp_posts' is marked as crashed and should be repaired
  30. 181120 17:30:53 [Warning] Checking table: './admin_wikis/wp_posts'
  31. 181120 17:31:58 mysqld_safe Number of processes running now: 0
  32. 181120 17:31:58 mysqld_safe mysqld restarted
  33. 181120 17:32:01 [Warning] 'THREAD_CONCURRENCY' is deprecated and will be removed in a future release.
  34. 181120 17:32:01 [Note] /usr/libexec/mysqld (mysqld 5.5.52-MariaDB) starting as process 16899 ...
  35. 181120 17:32:01 [Warning] Changed limits: max_open_files: 1024 max_connections: 70 table_cache: 472
  36. 181120 17:32:01 InnoDB: The InnoDB memory heap is disabled
  37. 181120 17:32:01 InnoDB: Mutexes and rw_locks use GCC atomic builtins
  38. 181120 17:32:01 InnoDB: Compressed tables use zlib 1.2.7
  39. 181120 17:32:01 InnoDB: Using Linux native AIO
  40. 181120 17:32:01 InnoDB: Initializing buffer pool, size = 150.0M
  41. InnoDB: mmap(161447936 bytes) failed; errno 12
  42. 181120 17:32:01 InnoDB: Completed initialization of buffer pool
  43. 181120 17:32:01 InnoDB: Fatal error: cannot allocate memory for the buffer pool
  44. 181120 17:32:01 [ERROR] Plugin 'InnoDB' init function returned error.
  45. 181120 17:32:01 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
  46. 181120 17:32:01 [ERROR] mysqld: Out of memory (Needed 128917504 bytes)
  47. 181120 17:32:01 [ERROR] mysqld: Out of memory (Needed 96681984 bytes)
  48. 181120 17:32:01 [ERROR] mysqld: Out of memory (Needed 72499200 bytes)
  49. 181120 17:32:01 [Note] Plugin 'FEEDBACK' is disabled.
  50. 181120 17:32:02 [ERROR] Unknown/unsupported storage engine: InnoDB
  51. 181120 17:32:02 [ERROR] Aborting
  52. 181120 17:32:02 [Note] /usr/libexec/mysqld: Shutdown complete

在这个时候,apache日志中没有什么有趣的东西。事件请求计数

  1. $ sudo grep -r "GET \/" /etc/httpd/logs/domains/ | cut -d' ' -f4 | sed 's/\[//;s/\]//;s/\"//' | cut -d':' -f1-2 | sort | uniq -c
  2. 459 19/Nov/2018:03
  3. 426 19/Nov/2018:04
  4. 239 19/Nov/2018:05
  5. 350 19/Nov/2018:06
  6. 381 19/Nov/2018:07
  7. 415 19/Nov/2018:08
  8. 778 19/Nov/2018:09
  9. 500 19/Nov/2018:10
  10. 450 19/Nov/2018:11
  11. 633 19/Nov/2018:12
  12. 458 19/Nov/2018:13
  13. 527 19/Nov/2018:14
  14. 713 19/Nov/2018:15
  15. 654 19/Nov/2018:16
  16. 573 19/Nov/2018:17
  17. 413 19/Nov/2018:18
  18. 471 19/Nov/2018:19
  19. 499 19/Nov/2018:20
  20. 661 19/Nov/2018:21
  21. 452 19/Nov/2018:22
  22. 773 19/Nov/2018:23
  23. 934 20/Nov/2018:00
  24. 295 20/Nov/2018:01
  25. 369 20/Nov/2018:02
  26. 441 20/Nov/2018:03
  27. 384 20/Nov/2018:04
  28. 927 20/Nov/2018:05
  29. 524 20/Nov/2018:06
  30. 972 20/Nov/2018:07
  31. 612 20/Nov/2018:08
  32. 609 20/Nov/2018:09
  33. 677 20/Nov/2018:10
  34. 753 20/Nov/2018:11
  35. 615 20/Nov/2018:12
  36. 717 20/Nov/2018:13
  37. 474 20/Nov/2018:14
  38. 973 20/Nov/2018:15
  39. 510 20/Nov/2018:16
  40. 534 20/Nov/2018:17
  41. 415 20/Nov/2018:18
  42. 90 20/Nov/2018:19

我得到一些指标:
崩溃前处理:

碰撞瞬间的过程:

内存和cpu使用率:

总ram 3.6克。有人有什么想法吗?

bvpmtnay

bvpmtnay1#

httpd 是最大的内存用户;减少它的设置,尤其是它愿意产生的“子”的数量(对于大多数小型装置来说,10岁以下就足够了。) max_connections: 70 table_cache: 472 --把它们各切成两半;这对内存分配有一点帮助。
下次cpu达到100%时,执行 SHOW FULL PROCESSLIST; 在mysql中。这可能会给你一个线索,你有什么失控的查询。然后我们可以关注他们。如果失败了,打开slowlog;它会抓住他们中的一些人。
考虑转移到8gb服务器(这是云服务器吗?)

相关问题