实验环境
系统版本
[root@Mysql data]# cat /etc/issue
Red Hat Enterprise Linux Server release 6.3 (Santiago)
mysql版本
[root@Mysql data]# mysql --version
mysql Ver 14.14 Distrib 5.5.19, for Linux (x86_64) using EditLine wrapper
查看默认存储引擎
mysql> show variables like 'default%';
+------------------------+--------+
| Variable_name | Value |
+------------------------+--------+
| default_storage_engine | InnoDB | #默认存储引擎为Innodb
查看参数值
mysql> show variables like 'innodb_log_file_size';
+----------------------+-----------+
| Variable_name | Value |
+----------------------+-----------+
| innodb_log_file_size | 157286400 | #150M
+----------------------+-----------+
1 row in set (0.00 sec)
此时可以在操作系统查看 日志文件的大小
[root@Mysql data]# ll -h ib_logfile*
-rw-rw----. 1 mysql mysql 150M Aug 30 01:36 ib_logfile0
-rw-rw----. 1 mysql mysql 150M Aug 30 01:24 ib_logfile1
模拟错误:
假设因为调试而修改了配置文件/etc/my.cnf
.................
121 innodb_buffer_pool_size = 600M
122 innodb_additional_mem_pool_size = 2M
123 # Set .._log_file_size to 25 % of buffer pool size
124 innodb_log_file_size = 100M 这个值有原先的150M改为现在的100M
125 innodb_log_buffer_size = 10M
......................
因为修改了这个参数值,导致mysql死活不能起来了
[root@Mysql data]# /etc/init.d/mysqld restart
Shutting down MySQL. SUCCESS!
Starting MySQL. ERROR! The server quit without updating PID file (/usr/local/mysql/data/Mysql.host.com.pid).
此时查看/data 目录下的err错误日志文件
[root@Mysql data]# vim Mysql.host.com.err
在最后面发现如下报错
40830 1:36:55 InnoDB: Completed initialization of buffer pool
InnoDB: Error: log file /usr/local/mysql/data/ib_logfile0 is of different size 0 157286400 bytes
InnoDB: than specified in the .cnf file 0 104857600 bytes!
140830 1:36:55 [ERROR] Plugin 'InnoDB' init function returned error.
140830 1:36:55 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
140830 1:36:55 [ERROR] Unknown/unsupported storage engine: InnoDB
140830 1:36:55 [ERROR] Aborting
140830 1:36:55 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete
140830 01:36:55 mysqld_safe mysqld from pid file /usr/local/mysql/data/Mysql.host.com.pid ended
这段报错的意思是 真实的logfile的大小和 my.cnf 中指定的大小不一样。解决方法是删除原有的logfile* ,然后重启mysql
删除
[root@Mysql data]# rm -rf ib_logfile*
重启
[root@Mysql data]# /etc/init.d/mysqld restart
ERROR! MySQL server PID file could not be found!
Starting MySQL... SUCCESS! 启动成功
并且我们看到logfile的大小已经改变为调整后的100M
[root@Mysql data]# ll ib_logfile* -h
-rw-rw----. 1 mysql mysql 100M Aug 30 01:44 ib_logfile0
-rw-rw----. 1 mysql mysql 100M Aug 30 01:44 ib_logfile1
配置文件中有多个关于innodb的参数
[root@Mysql data]# grep innodb_ /etc/my.cnf
innodb_data_home_dir = /usr/local/mysql/data
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /usr/local/mysql/data
innodb_buffer_pool_size = 600M
innodb_additional_mem_pool_size = 2M
innodb_log_file_size = 100M
innodb_log_buffer_size = 10M
#innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50
其他参数几乎都可以修改,而后直接可以重启mysql,只有innodb_log_file_size参数修改后须删除原有logfile才能重启,切记。
阅读(3911) | 评论(0) | 转发(0) |