设为首页 收藏本站
查看: 564|回复: 0

[经验分享] MySQL中ib_logfile和ibdata1参数大小被修改后

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2014-9-15 09:36:34 | 显示全部楼层 |阅读模式
1. 环境说明

RHEL 6.4 x86_64 + MySQL 5.5.37和MySQL 5.6.19



2. 案例:redo log文件(ib_logfile)大小参数被修改:innodb_log_file_size

innodb_log_file_size = 256M  -- 修改为200M

版本是5.5的,启动失败,会出现如下错误:



    InnoDB: Error: log file ./ib_logfile0 is of different size 0 268435456 bytes  ## 原来redo log的大小  
    InnoDB: than specified in the .cnf file 0 209715200 bytes!   ## redo log被修改的大小  
    140912  0:01:12 [ERROR] Plugin 'InnoDB' init function returned error.  
    140912  0:01:12 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.  
    140912  0:01:12 [ERROR] Unknown/unsupported storage engine: InnoDB  
    140912  0:01:12 [ERROR] Aborting  


版本是5.6.16之后的,正常启动,会自动将原来的redo log删除,然后重新生成新的redo log(这个比较重要):



    2014-09-11 21:57:05 1093 [Warning] InnoDB: Resizing redo log from 2*16384 to 2*12800 pages, LSN=71249171  
    2014-09-11 21:57:05 1093 [Warning] InnoDB: Starting to delete and rewrite log files.    ## 删除原redo log  
    2014-09-11 21:57:05 1093 [Note] InnoDB: Setting log file ./ib_logfile101 size to 200 MB  
    InnoDB: Progress in MB: 100 200  
    2014-09-11 21:57:06 1093 [Note] InnoDB: Setting log file ./ib_logfile1 size to 200 MB  
    InnoDB: Progress in MB: 100 200  
    2014-09-11 21:57:07 1093 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0  
    2014-09-11 21:57:07 1093 [Warning] InnoDB: New log files created, LSN=71249171   ## 新redo log重建完毕  


原redo log大小:2*16384*8(page的大小为8k)/1024=256MB

新redo log大小:2*12800*8/1024=200MB


3. 案例:ibdata1文件大小参数被修改:innodb_data_file_path

(1)ibdata1从大改小

innodb_data_file_path = ibdata1:1G:autoextend  -- 修改为:ibdata1:300M:autoextend

在版本是5.5和5.6中,启动正常,并且日志中没有任何异常。但是如果将autoextend去掉,就会报错,启动失败,如:[版本:5.5.37]



    InnoDB: Error: data file ./ibdata1 is of a different size  
    InnoDB: 65536 pages (rounded down to MB)  
    InnoDB: than specified in the .cnf file 19200 pages!  
    140911 23:51:53 InnoDB: Could not open or create data files.  
    140911 23:51:53 InnoDB: If you tried to add new data files, and it failed here,  
    140911 23:51:53 InnoDB: you should now edit innodb_data_file_path in my.cnf back  
    140911 23:51:53 InnoDB: to what it was, and remove the new ibdata files InnoDB created  
    140911 23:51:53 InnoDB: in this failed attempt. InnoDB only wrote those files full of  
    140911 23:51:53 InnoDB: zeros, but did not yet use them in any way. But be careful: do not  
    140911 23:51:53 InnoDB: remove old data files which contain your precious data!  
    140911 23:51:53 [ERROR] Plugin 'InnoDB' init function returned error.  
    140911 23:51:53 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.  
    140911 23:51:53 [ERROR] Unknown/unsupported storage engine: InnoDB  
    140911 23:51:53 [ERROR] Aborting  
      
    原来的ibdata1大小为:65536*8*2/1024=1024M=1G  
    当前ibdata1被修改为:19200*8*2/1024=300M  


(2)ibdata1值小改大

比如:

innodb_data_file_path = ibdata1:1G:autoextend  -- 修改为:ibdata1:1200M:autoextend

那么会在启动时出现如下错误:

*****在5.5版本中:[版本:5.5.37]



    InnoDB: Error: auto-extending data file ./ibdata1 is of a different size  
    InnoDB: 65536 pages (rounded down to MB) than specified in the .cnf file:  
    InnoDB: initial 76800 pages, max 0 (relevant if non-zero) pages!  
    140911 23:57:43 InnoDB: Could not open or create data files.  
    140911 23:57:43 InnoDB: If you tried to add new data files, and it failed here,  
    140911 23:57:43 InnoDB: you should now edit innodb_data_file_path in my.cnf back  
    140911 23:57:43 InnoDB: to what it was, and remove the new ibdata files InnoDB created  
    140911 23:57:43 InnoDB: in this failed attempt. InnoDB only wrote those files full of  
    140911 23:57:43 InnoDB: zeros, but did not yet use them in any way. But be careful: do not  
    140911 23:57:43 InnoDB: remove old data files which contain your precious data!  
    140911 23:57:43 [ERROR] Plugin 'InnoDB' init function returned error.  
    140911 23:57:43 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.  
    140911 23:57:43 [ERROR] Unknown/unsupported storage engine: InnoDB  
    140911 23:57:43 [ERROR] Aborting  


*****在5.6版本中:[版本:5.6.19]



    2014-09-11 22:20:01 1222 [ERROR] InnoDB: auto-extending data file ./ibdata1 is of a different size 65536 pages (rounded down to MB) than  
     specified in the .cnf file: initial 76800 pages, max 0 (relevant if non-zero) pages!  
    2014-09-11 22:20:01 1222 [ERROR] InnoDB: Could not open or create the system tablespace. If you tried to add new data files to the syste  
    m tablespace, and it failed here, you should now edit innodb_data_file_path in my.cnf back to what it was, and remove the new ibdata fil  
    es InnoDB created in this failed attempt. InnoDB only wrote those files full of zeros, but did not yet use them in any way. But be caref  
    ul: do not remove old data files which contain your precious data!  
    2014-09-11 22:20:01 1222 [ERROR] Plugin 'InnoDB' init function returned error.  
    2014-09-11 22:20:01 1222 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.  
    2014-09-11 22:20:01 1222 [ERROR] Unknown/unsupported storage engine: InnoDB  
    2014-09-11 22:20:01 1222 [ERROR] Aborting  


原来的ibdata1大小为:65536*8*2/1024=1024M=1G

当前ibdata1被修改为:76800*8*2/1024=1200M




运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.iyunv.com/thread-24797-1-1.html 上篇帖子: 基本heartbeat v1、V2实现mysql的高可用 下篇帖子: MySQL主从复制与读写分离
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表