innodb_buffer_pool_size以前是2G,今天改为innodb_buffer_pool_size = 3G时候,mysqld无法起来,
查看日志:130320 13:29:21 InnoDB: Initializing buffer pool, size = 3.0G
InnoDB: mmap(3280207872 bytes) failed; errno 12
130320 13:29:21 InnoDB: Completed initialization of buffer pool
130320 13:29:21 InnoDB: Fatal error: cannot allocate memory for the buffer pool
130320 13:29:21 [ERROR] Plugin 'InnoDB' init function returned error.
130320 13:29:21 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
130320 13:29:21 [ERROR] Unknown/unsupported storage engine: InnoDB
130320 13:29:21 [ERROR] Aborting
说是无法分配这么大的innodb_buffer_pool_size 
但是我的系统内存是8G,但交换分区是2G,猜想是不是跟swap的大小有关呢?还是另有原因?

解决方案 »

  1.   

    free一下看你系统还剩余多少G的内存  
      

  2.   

    [root@localhost /]# free -m
                 total       used       free     shared    buffers     cached
    Mem:          8071       5408       2662          0         72       5106
    -/+ buffers/cache:        228       7842
    Swap:         8001          0       8001
    看样子是2662M, 2G多,我刚才试了一下,确实能够分配到2560;分配到2660的时候,mysql就报错。
    难道mysql是通过动态判断剩余内存来判断能够分给innodb_buffer_pool_size的大小的?
      

  3.   

    我现在已经释放了内存,但还是分配不了那么大:
    [root@edata0 /]# free -m
                 total       used       free     shared    buffers     cached
    Mem:          8071        155       7916          0          1         19
    -/+ buffers/cache:        135       7936
    Swap:         8001          0       8001
    现在有7916,但分配到3072(即3G)时,还是提示不让分配那么多