MySQL错误日志:
INNOB 启动错误:
错误日志:
120310 22:22:18 mysqld_safe mysqld from pid file /data/db-data/localhost.localdomain.pid ended
120311 01:38:53 mysqld_safe Starting mysqld daemon with databases from /data/db-data
120311 1:38:53 [Warning] You need to use --log-bin to make --binlog-format work.
120311 1:38:53 [Note] Plugin 'FEDERATED' is disabled.
120311 1:38:53 InnoDB: The InnoDB memory heap is disabled
120311 1:38:53 InnoDB: Mutexes and rw_locks use GCC atomic builtins
120311 1:38:53 InnoDB: Compressed tables use zlib 1.2.3
120311 1:38:53 InnoDB: Using Linux native AIO
120311 1:38:53 InnoDB: Initializing buffer pool, size = 3.0G
120311 1:38:53 InnoDB: Completed initialization of buffer pool
InnoDB: Error: auto-extending data file ./ibdata1 is of a different size
InnoDB: 16384 pages (rounded down to MB) than specified in the .cnf file:
InnoDB: initial 32768 pages, max 0 (relevant if non-zero) pages!
120311 1:38:53 InnoDB: Could not open or create data files.
120311 1:38:53 InnoDB: If you tried to add new data files, and it failed here,
120311 1:38:53 InnoDB: you should now edit innodb_data_file_path in my.cnf back
120311 1:38:53 InnoDB: to what it was, and remove the new ibdata files InnoDB created
120311 1:38:53 InnoDB: in this failed attempt. InnoDB only wrote those files full of
120311 1:38:53 InnoDB: zeros, but did not yet use them in any way. But be careful: do not
120311 1:38:53 InnoDB: remove old data files which contain your precious data!
120311 1:38:53 [ERROR] Plugin 'InnoDB' init function returned error.
120311 1:38:53 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
120311 1:38:53 [ERROR] Unknown/unsupported storage engine: InnoDB
120311 1:38:53 [ERROR] Aborting
看红字部分:
大致意思是 my.cnf配置文件中的
ibdata1自动扩展初始化属性与已经存在的innodb表空间
ibdata1不一致
vi /etc/my.cnf
看到如下:
innodb_data_file_path = ibdata1:512M:autoextend 自动扩展为512M
cd 到 数据库文件目录
ls ibdata1 -lh
显示为:256M
和共享表空间文件 ibdata1文件不一致,找到 ibdata1大小为256M,InnoDB默认一个page大小为16K也就是1/64 M
16384 *16K
=256M(已经存在的表空间) 或者16384/64=256M
32768
*16K=512M (即初始化32768个page,大小为512M) 或者
32768/64=512M
如果不知道innodb page页大小的话,可以反推:
256M/
16384个=256*1024K/
16384=16k/page
所以修改my.cnf为如下配置即可
innodb_data_file_path = ibdata1:
256M:autoextend
然后重新启动mysql: service mysql restart即可。