14.7.1 重新调整InnoDB系统表空间的大小

一、增加系统表空间的大小

(一)操作步骤:

1.停止服务

2.查看表空间物理文件大小,修改my.cnf文件,将原表空间文件大小调整为当前物理文件大小,以MB为单位

3.在变量innodb_data_file_path后面追加一个数据文件,大小随意,并设置成自动扩展

4.重启服务生效

(二)实例:

1.my.cnf原始配置

innodb_data_file_path = ibdata1:10M:autoextend

物理文件大小76MB

2.my.cnf调整后的配置

innodb_data_file_path = ibdata1:76M;ibdata2:10M:autoextend

(三)故障实验:

innodb_data_file_path = ibdata1:10M;ibdata2:10M:autoextend

服务启动报如下错误

2017-04-19 20:43:05 4570 [ERROR] InnoDB: Data file ./ibdata1 is of a different size 4864 pages (rounded down to MB) than specified in the .cnf file 640 pages!
2017-04-19 20:43:05 4570 [ERROR] InnoDB: Could not open or create the system tablespace. If you tried to add new data files to the system 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 files 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 careful: do not remove old data files which contain your precious data!
2017-04-19 20:43:05 4570 [ERROR] Plugin 'InnoDB' init function returned error.
2017-04-19 20:43:05 4570 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2017-04-19 20:43:05 4570 [ERROR] Unknown/unsupported storage engine: InnoDB
2017-04-19 20:43:05 4570 [ERROR] Aborting

 

二、缩小InnoDB表空间的大小

你不能直接的删除系统表空间的物理文件,要缩小系统表空间的大小,按如下步骤操作:
1.用mysqldump将所有的包括MySQL数据库中的InnoDB表dump出来,在5.6当前版本中,包括5张InnoDB表:
2.停止服务.
3.删除所有的表空间文件(*.ibd),包括ibdata和ib_log文件,MySQL数据库中的*.ibd文件也删除.
4.删除所有的InnoDB表的.frm文件.
5.重新设置一个新的表空间.
6.重启服务.
7.导入dump文件.

实验:

1.mysqldump -uroot -p -A > /root/all_databases_20170726.sql

2.mysqladmin -uroot -p shutdown

3.

rm -fr fission_action/*
rm -fr fission_log/*
rm -fr mydb/*
rm -fr fission_ha/*

rm ibdata* -fr
rm ib_logfile* -f

rm -fr innodb_index_stats*
rm -fr innodb_table_stats*
rm -fr slave_master_info*
rm -fr slave_relay_log_info*
rm -fr slave_worker_info*

4.vi my.cnf

innodb_data_file_path = ibdata1:10M:autoextend

5../bin/mysqld_safe --defaults-file=/etc/my.cnf &

6.导入文件

ERROR 1813 (HY000): Tablespace for table '`mysql`.`slave_relay_log_info`' exists. Please DISCARD the tablespace before IMPORT.

可能原因:1.source前没有stop slave;还存在InnoDB表空间没清理干净 

参考文档:Increasing the Size of the InnoDB System Tablespace.

转载于:https://www.cnblogs.com/geek-ace/p/7239505.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值