AWS MYSQL(mysqli_real_connect():(HY000 / 2002)):无法为缓冲池分配内存

时间:2019-06-17 07:22:01

标签: mysql amazon-web-services

我在 AWS 中有一个 t2.small 实例,该实例已经运行了十个月之久,而无需重启EC2实例/ apache服务器/ mysqld服务器,突然之间,到几分钟前,它无法连接到数据库。

我无法访问连接到数据库的任何页面,尝试登录phpmyadmin会返回错误mysqli_real_connect(): (HY000/2002): No such file or directory

所以在恐慌时,我做了以下事情:

  1. 尝试使用sudo service mysqld restart重新启动mysql服务器,但它一直在提出STOPPED
  2. 重新启动EC2实例
  3. 它存活了(暂时直到再次崩溃)

既然它崩溃了,我想知道为什么它崩溃了,以及如何防止它再次崩溃。

我钻入mysqld.log并找到以下信息:

Version: '5.6.39'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MySQL Community Server (GPL)
2019-06-17 14:08:19 15623 [Warning] Buffered warning: Performance schema disabled (reason: init fa
iled).

2019-06-17 14:08:19 15623 [Note] Plugin 'FEDERATED' is disabled.
2019-06-17 14:08:19 15623 [Note] InnoDB: Using atomics to ref count buffer pool pages
2019-06-17 14:08:19 15623 [Note] InnoDB: The InnoDB memory heap is disabled
2019-06-17 14:08:19 15623 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2019-06-17 14:08:19 15623 [Note] InnoDB: Memory barrier is not used
2019-06-17 14:08:19 15623 [Note] InnoDB: Compressed tables use zlib 1.2.8       
2019-06-17 14:08:19 15623 [Note] InnoDB: Using Linux native AIO                 
2019-06-17 14:08:19 15623 [Note] InnoDB: Using CPU crc32 instructions           
2019-06-17 14:08:19 15623 [Note] InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(137363456 bytes) failed; errno 12                                  
2019-06-17 14:08:19 15623 [ERROR] InnoDB: Cannot allocate memory for the buffer pool           
2019-06-17 14:08:19 15623 [ERROR] Plugin 'InnoDB' init function returned error. 
2019-06-17 14:08:19 15623 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.     
2019-06-17 14:08:19 15623 [ERROR] Unknown/unsupported storage engine: InnoDB    
2019-06-17 14:08:19 15623 [ERROR] Aborting 
...
...(shutdown a bunch of plugins)
...
2019-06-17 14:08:19 15623 [Note] /usr/libexec/mysql56/mysqld: Shutdown complete

我四处搜索,发现 InnoDB缓冲池大小不一致 https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/MySQL.KnownIssuesAndLimitations.html

具体地说,它详细说明了一种解决方法,以解决缓冲池大小不一致的问题:

innodb_buffer_pool_chunk_size = 536870912
innodb_buffer_pool_instances = 4
innodb_buffer_pool_size = (536870912 * 4) * 8 = 17179869184

问题:

  1. 你们中有人遇到过吗?您是如何解决它的?
  2. 服务器实际发生了什么?我真的为mysqld耗尽了内存,因为日志说无法为缓冲池分配内存? (我总是不时top进行检查,并且总是至少有一半是免费的。)
  3. 以上示例从AWS哪里获得了数字536870912?而我在哪里? (/etc/my.cnf)?

感谢您阅读以及任何意见或建议。

1 个答案:

答案 0 :(得分:0)

1)我遇到了同样的问题,并按照this解决了这个问题。