我在Rackspace Centos 6.4服务器实例上遇到MySQL问题。该问题类似于this StackOverflow question中描述的问题。由于mysqld_safe在某些时候会自动重启MySQL,并且重启失败,因为InnoDB会尝试分配128Mb的RAM,从而导致失败。的mysqld.log
输出如下:MySQL在重启时失败,InnoDB我分配错误12
140129 18:05:26 mysqld_safe Number of processes running now: 0
140129 18:07:30 InnoDB: Mutexes and rw_locks use GCC atomic builtins
140129 18:07:30 InnoDB: Compressed tables use zlib 1.2.3
140129 18:07:30 InnoDB: Using Linux native AIO
140129 18:07:35 InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(137363456 bytes) failed; errno 12
140129 18:07:46 InnoDB: Completed initialization of buffer pool
140129 18:07:46 InnoDB: Fatal error: cannot allocate memory for the buffer pool
140129 18:07:47 [ERROR] Plugin 'InnoDB' init function returned error.
140129 18:07:47 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
140129 18:08:07 [ERROR] Unknown/unsupported storage engine: InnoDB
140129 18:08:10 [ERROR] Aborting
140129 18:08:53 [Note] /usr/libexec/mysqld: Shutdown complete
140129 18:18:18 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
在该另一问题提供的解决方案似乎是的“创建一个交换文件”之一。我检查了我的服务器,它似乎已经有一个活跃的交换文件:
# swapon -s
Filename Type Size Used Priority
/dev/xvdc1 partition 499992 34876 -1
和,看着那输出,它的大小我想我需要(512MB)。为了完整起见,这里是我的/etc/fstab
文件的内容:
/dev/xvda1 / ext3 defaults,noatime,barrier=0 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/dev/xvdc1 none swap sw 0 0
所以我失去了一些东西,还是我已经有一个工作交换文件,约512MB,这是相当空的,因此应该能够处理请求128Mb?我应该将InnoDB缓冲区的大小减少到64Mb吗?是否有任何与缩小此缓冲区有关的问题?
(我Rackspace公司的服务器是最小的一个可用的,它拥有512MB的RAM。每当我在服务器上做top
,它似乎已经MB 50和80之间的自由。)
thx为您的答案!我已经将innodb缓冲区减少到了64Mb,我只能等待,看看这是否能解决问题 - 崩溃和随后的重启失败是非常随机的。 –
太棒了。请让我知道它是否适合你。崩溃本身可能是需要看的东西。 MySQL本身不应该“定期”崩溃。 – mrjandro