2016-05-31 31 views
-1

我不知道为什么这是,但我的Wordpress网站不断崩溃的“有一个错误建立数据库连接”错误。EC2实例 - WordPress的数据库不断崩溃

重新启动mysql服务似乎暂时解决这个问题,但它不可避免地崩溃一次又一次。

我认为这可能是一个内存问题,所以我升级我的实例从1GB到2GB。但似乎没有任何变化..如果它不是内存相关的,我宁愿不支付这笔巨额的额外费用。

这里是一些与崩溃有关的mysql日志文件。所有的崩溃似乎包含以下内容:

160519 13:03:21 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended 
160519 13:03:21 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 
160519 13:03:21 [Note] /usr/libexec/mysql55/mysqld (mysqld 5.5.46) starting as process 18275 ... 
160519 13:03:21 [Note] Plugin 'FEDERATED' is disabled. 
160519 13:03:21 InnoDB: The InnoDB memory heap is disabled 
160519 13:03:21 InnoDB: Mutexes and rw_locks use GCC atomic builtins 
160519 13:03:21 InnoDB: Compressed tables use zlib 1.2.8 
160519 13:03:21 InnoDB: Using Linux native AIO 
160519 13:03:21 InnoDB: Initializing buffer pool, size = 128.0M 
InnoDB: mmap(137363456 bytes) failed; errno 12 
160519 13:03:21 InnoDB: Completed initialization of buffer pool 
160519 13:03:21 InnoDB: Fatal error: cannot allocate memory for the buffer pool 
160519 13:03:21 [ERROR] Plugin 'InnoDB' init function returned error. 
160519 13:03:21 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 
160519 13:03:21 [ERROR] Unknown/unsupported storage engine: InnoDB 
160519 13:03:21 [ERROR] Aborting 

160519 13:03:21 [Note] /usr/libexec/mysql55/mysqld: Shutdown complete 

**** ****更新

所以我已经改变了innodb_buffer_pool_size的大小,下文提到的和也做了交换文件。我的网站每隔几个小时仍然崩溃,我正在慢慢失去生活的意愿。

160507 16:28:20 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 
160507 16:28:20 [Note] /usr/libexec/mysql55/mysqld (mysqld 5.5.46) starting as process 26457 ... 
160507 16:28:20 [Note] Plugin 'FEDERATED' is disabled. 
160507 16:28:20 InnoDB: The InnoDB memory heap is disabled 
160507 16:28:20 InnoDB: Mutexes and rw_locks use GCC atomic builtins 
160507 16:28:20 InnoDB: Compressed tables use zlib 1.2.8 
160507 16:28:20 InnoDB: Using Linux native AIO 
160507 16:28:20 InnoDB: Initializing buffer pool, size = 128.0M 
160507 16:28:20 InnoDB: Completed initialization of buffer pool 
InnoDB: The first specified data file ./ibdata1 did not exist: 
InnoDB: a new database to be created! 
160507 16:28:20 InnoDB: Setting file ./ibdata1 size to 10 MB 
InnoDB: Database physically writes the file full: wait... 
160507 16:28:21 InnoDB: Log file ./ib_logfile0 did not exist: new to be created 
InnoDB: Setting log file ./ib_logfile0 size to 5 MB 
InnoDB: Database physically writes the file full: wait... 
160507 16:28:21 InnoDB: Log file ./ib_logfile1 did not exist: new to be created 
InnoDB: Setting log file ./ib_logfile1 size to 5 MB 
InnoDB: Database physically writes the file full: wait... 
InnoDB: Doublewrite buffer not found: creating new 
InnoDB: Doublewrite buffer created 
InnoDB: 127 rollback segment(s) active. 
InnoDB: Creating foreign key constraint system tables 
InnoDB: Foreign key constraint system tables created 
160507 16:28:21 InnoDB: Waiting for the background threads to start 
160507 16:28:22 InnoDB: 5.5.46 started; log sequence number 0 
160507 16:28:22 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306 
160507 16:28:22 [Note] - '0.0.0.0' resolves to '0.0.0.0'; 
160507 16:28:22 [Note] Server socket created on IP: '0.0.0.0'. 
160507 16:28:22 [Note] Event Scheduler: Loaded 0 events 
160507 16:28:22 [Note] /usr/libexec/mysql55/mysqld: ready for connections. 
Version: '5.5.46' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Community Server (GPL) 
160507 17:56:05 [Note] /usr/libexec/mysql55/mysqld: Normal shutdown 

160507 17:56:05 [Note] Event Scheduler: Purging the queue. 0 events 
160507 17:56:05 InnoDB: Starting shutdown... 
160507 17:56:06 InnoDB: Shutdown completed; log sequence number 2733606 
160507 17:56:06 [Note] /usr/libexec/mysql55/mysqld: Shutdown complete 
+0

有些东西会导致数据库负载过重。尝试增加交换内存,并检查您的查询或尝试禁用插件,看看崩溃是否再次发生 –

+0

试图增加这个,但每次我失去了我的帐户权限或似乎搞砸了实例。 – zarate32

+0

检查此问题http://stackoverflow.com/questions/25965638/mysql-fatal-error-cannot-allocate-memory-for-the-buffer-pool – error2007s

回答

0

您的缓冲区太大。它可能并不需要是尺寸,看到dba.stackexchange.com这个答案

https://dba.stackexchange.com/questions/27328/how-large-should-be-mysql-innodb-buffer-pool-size

如果使用的是亚马逊的Linux,根据MySQL的文档(https://dev.mysql.com/doc/refman/5.7/en/ha-vm-aws-setup.html)这个设置是在/ etc /my.cnf

可能改变此文件中的设置来innodb_buffer_pool_size = 10M将解决您的问题

上述修复在上面的日志中显示的具体问题。如果没有被记录的其他问题涉及内存使用再添加一个交换文件4GiB使用这些命令

/bin/dd if=/dev/zero of=/swapfile bs=1M count=4096; /sbin/mkswap /swapfile; /sbin/swapon /swapfile 

使用互换并不神奇它可以让你的系统运行缓慢和臃肿。但是,如果这让你在内存使用中发生“闪烁”,它可能会很好

+0

我试过这样做,但我的网站继续下去,无法访问。如果我重新启动mysql和apache,它会很好地工作,但会在半小时左右死亡。我只是不明白。现在它根本不加载,只是挂起之前说网站无法到达 – zarate32

+0

如果你已经做了这个改变,那么它必须记录一个不同的错误 – Vorsprung

+0

你认为它可能是交换文件的事情也记录了这个问题吗? – zarate32