MySQL 守护进程不断意外终止

MySQL 守护进程不断意外终止

我的 CentOS 服务器上的 MySQL 守护进程不断崩溃,我从 /var/logs/mysqld 获取了日志,但我仍然不确定如何修复它:

    121114 16:22:56 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended                                                                                                 
    121114 21:55:11 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql                                                                                             
    121114 21:55:11 [Note] Plugin 'FEDERATED' is disabled.                                                                                                                            
    121114 21:55:11 InnoDB: The InnoDB memory heap is disabled                                                                                                                        
        121114 21:55:11 InnoDB: Mutexes and rw_locks

 use GCC atomic builtins                                                                                                              
    121114 21:55:11 InnoDB: Compressed tables use zlib 1.2.3                                                                                                                          
    121114 21:55:11 InnoDB: Using Linux native AIO                                                                                                                                    
    121114 21:55:11 InnoDB: Initializing buffer pool, size = 128.0M                                                                                                                   
    121114 21:55:11 InnoDB: Completed initialization of buffer pool                                                                                                                   
    121114 21:55:11 InnoDB: highest supported file format is Barracuda.                                                                                                               
    InnoDB: The log sequence number in ibdata files does not match                                                                                                                    
    InnoDB: the log sequence number in the ib_logfiles!                                                                                                                               
    121114 21:55:11  InnoDB: Database was not shut down normally!                                                                                                                     
    InnoDB: Starting crash recovery.                                                                                                                                                  
    InnoDB: Reading tablespace information from the .ibd files...                                                                                                                     
    InnoDB: Restoring possible half-written data pages from the doublewrite                                                                                                           
    InnoDB: buffer...                                                                                                                                                                 
    121114 21:55:12  InnoDB: Waiting for the background threads to start                                                                                                              
    121114 21:55:13 InnoDB: 1.1.6 started; log sequence number 77177262                                                                                                               
    121114 21:55:13 [Note] Event Scheduler: Loaded 0 events                                                                                                                           
    121114 21:55:13 [Note] /usr/libexec/mysqld: ready for connections.                                                                                                                
    Version: '5.5.12'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MySQL Community Server (GPL) by Remi                                                                          
    121115 00:19:44 mysqld_safe Number of processes running now: 0                                                                                                                    
    121115 00:19:44 mysqld_safe mysqld restarted                                                                                                                                      
    121115  0:19:47 [Note] Plugin 'FEDERATED' is disabled.                                                                                                                            
    121115  0:19:47 InnoDB: The InnoDB memory heap is disabled                                                                                                                        
    121115  0:19:47 InnoDB: Mutexes and rw_locks use GCC atomic builtins                                                                                                              
    121115  0:19:47 InnoDB: Compressed tables use zlib 1.2.3                                                                                                                          
    121115  0:19:47 InnoDB: Using Linux native AIO                                                                                                                                    
    121115  0:19:47 InnoDB: Initializing buffer pool, size = 128.0M                                                                                                                   
    InnoDB: mmap(137363456 bytes) failed; errno 12                                                                                                                                    
    121115  0:19:47 InnoDB: Completed initialization of buffer pool                                                                                                                   
    121115  0:19:47 InnoDB: Fatal error: cannot allocate memory for the buffer pool                                                                                                   
    121115  0:19:47 [ERROR] Plugin 'InnoDB' init function returned error.                                                                                                             
    121115  0:19:47 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.                                                                                                  
    121115  0:19:47 [ERROR] Unknown/unsupported storage engine: InnoDB                                                                                                                
    121115  0:19:47 [ERROR] Aborting  

编辑#1

             total       used       free     shared    buffers     cached                                                                                                         
Mem:           496        370        126          0         24        110                                                                                                         
-/+ buffers/cache:        234        261                                                                                                                                          
Swap:         1023          9       1014  

编辑#2

另外,我的 mysql 中最大的表是 20MB,所以使用的内存应该相当适中。

SELECT CONCAT(table_schema, '.', table_name),
       CONCAT(ROUND(table_rows / 1000000, 2), 'M')                                    rows,
       CONCAT(ROUND(data_length / ( 1024 * 1024 * 1024 ), 2), 'G')                    DATA,
       CONCAT(ROUND(index_length / ( 1024 * 1024 * 1024 ), 2), 'G')                   idx,
       CONCAT(ROUND(( data_length + index_length ) / ( 1024 * 1024 * 1024 ), 2), 'G') total_size,
       ROUND(index_length / data_length, 2)                                           idxfrac
FROM   information_schema.TABLES
ORDER  BY data_length + index_length DESC
LIMIT  10;

在此处输入图片描述

答案1

InnoDB: Fatal error: cannot allocate memory for the buffer pool

从外观上看,您的服务器无法为 innodb 分配足够的内存。

写入free -m以查看您必须分配多少内存。查看您的/etc/my.cnf并查看innodb_buffer_pool_size所做的更改。

如果您愿意,您可以启动不使用 innodb 的 mysql,有些人这样做是为了降低内存占用。mysqld --skip-innodb --default-storage-engine=myisam

相关内容