MySQL表空间集

--MySQL表空间集
----------------------2014-09-20

1. 收缩ibdata的方法,目前MySQL依然没有提供收缩ibdata的方法,只能重构,下面是5.7的步骤。

Decreasing the Size of the InnoDB Tablespace
Currently, you cannot remove a data file from the system tablespace. To decrease the system tablespace size, use this procedure:

1. Use mysqldump to dump all your InnoDB tables, including InnoDB tables located in the MySQL database. As of 5.6, there are five InnoDB tables included in the MySQL database:

mysql> select table_name from information_schema.tables where table_schema=‘mysql‘ and engine=‘InnoDB‘;
+----------------------+
| table_name           |
+----------------------+
| innodb_index_stats   |
| innodb_table_stats   |
| slave_master_info    |
| slave_relay_log_info |
| slave_worker_info    |
+----------------------+
5 rows in set (0.00 sec)

Stop the server.

2. Remove all the existing tablespace files (*.ibd), including the ibdata and ib_log files. Do not forget to remove *.ibd files for tables located in the MySQL database.

3. Remove any .frm files for InnoDB tables.

4. Configure a new tablespace.

5. Restart the server.

6. Import the dump files.

2. 再看一个官方说明,file-per-table的优势,同时也指出了ibdata文件的空间只能被重用,但无法释放给操作系统。

You can reclaim operating system disk space when truncating or dropping a table. For tables created when file-per-table mode is turned off, truncating or dropping the tables creates free space internally in the ibdata files but the free space can only be used for new InnoDB data.

3. 对于file-per-table的表,回收空间,使用optimize table,实现原理如下面所示,其实就是重建+改名。

You can run OPTIMIZE TABLE to compact or recreate a tablespace. When you run an OPTIMIZE TABLE, InnoDB will create a new .ibd file with a temporary name, using only the space required to store actual data. When the optimization is complete, InnoDB removes the old .ibd file and replaces it with the new .ibd file. If the previous .ibd file had grown significantly but actual data only accounted for a portion of its size, running OPTIMIZE TABLE allows you to reclaim the unused space.
时间: 2024-08-27 02:05:36

MySQL表空间集的相关文章

MySQL 表空间传送

1.源库查询表结构 mysql> show create table s_show\G *************************** 1. row ***************************        Table: study_show Create Table: CREATE TABLE `study_show` (   `id` int(11) unsigned NOT NULL AUTO_INCREMENT,   `uid` int(11) DEFAULT '0'

mysql 表空间。

mysql使用磁盘空间: 1.ps -ef | grep mysql 2.select @@datadir; 3.show create table mytab; show create table t; 一个myisam存储引擎.一个innodb存储引擎 4.insert into t select * from t; insert into mytab select * from mytab; 发现数据文件变大了 5.innodb使用共享表空间. select @@innodb_file_p

mysql表空间损坏

在没有备份数据的情况下,突然断电导致表损坏,打不开数据库.1)拷贝库目录到新库中[[email protected] ~]# cp -r /application/mysql/data/world/ /data/3307/data/2)启动新数据库[[email protected] ~]# mysqld_safe --defaults-file=/data/3307/my.cnf &3)登陆数据库查看mysql> show databases;4)查询表中数据mysql> selec

【TTS】传输表空间AIX asm -> linux asm

[TTS]传输表空间AIX asm -> linux asm 一.1  BLOG文档结构图       一.2  前言部分   一.2.1  导读和注意事项 各位技术爱好者,看完本文后,你可以掌握如下的技能,也可以学到一些其它你所不知道的知识,~O(∩_∩)O~: ① 异构平台下传输表空间的实施 ② 传输表空间基于表空间的read only和rman2种方式 ③ 平台字节序.自包含概念 ④ expdp/impdp的应用     Tips:        ① 若文章代码格式有错乱,推荐使用搜狗或3

【TTS】传输表空间Linux asm -> AIX asm

[TTS]传输表空间Linux asm -> AIX asm 一.1  BLOG文档结构图       一.2  前言部分   一.2.1  导读和注意事项 各位技术爱好者,看完本文后,你可以掌握如下的技能,也可以学到一些其它你所不知道的知识,~O(∩_∩)O~: ① 异构平台下传输表空间的实施 ② 传输表空间基于表空间的read only和rman2种方式 ③ 平台字节序.自包含概念 ④ expdp/impdp的应用     Tips:        ① 若文章代码格式有错乱,推荐使用QQ或3

可传输表空间

oracle2271 对于可传输表空间有一个重要概念:自包含(Self-Contained). 在表空间传输的中,要求表空间集为自包含的,自包含表示用于传输的内部表空间集没有引用指向外部表空间集.自包含分为两种:一般自包含表空间集和完全(严格)自包含表空间集. 常见的以下情况是违反自包含原则的:  索引在内部表空间集,而表在外部表空间集(相反地,如果表在内部表空间集,而索引在外部表空间集,则不违反自包含原则).  分区表一部分区在内部表空间集,一部分在外部表空间集(对于分区表,要么全部包含在

使用传输表空间迁移数据

一.检查是否满足传输表空间的条件1.检查源库与目标库的平台支持 源库: SQL> select d.name,i.version,d.platform_name,endian_format from v$transportable_platform tp,v$database d,v$instance i 2 where tp.PLATFORM_NAME=d.platform_name; NAME VERSION PLATFORM_NAME ENDIAN_FORMAT --------- ---

[转]Oracle DB 执行表空间时间点恢复

• 列出在执行表空间时间点恢复(TSPITR) 时会发生的操作 • 阐释TSPITR 使用的术语的定义 • 确定适合将TSPITR 用作解决方案的情况 • 确定时间点恢复的正确目标时间 • 确定不能使用TSPITR 的情况以及解决方法 • 执行自动TSPITR 表空间时间点恢复(TSPITR):概念 • 通过执行TSPITR 可将一个或多个表空间快速恢复到以前的某个时间. • 执行TSPITR 不会影响数据库中其它表空间或对象的状态. 使用RMAN 自动表空间时间点恢复(TSPITR) 可将Or

如何通过RMAN使用传输表空间迁移到不同的Endian平台 (Doc ID 371556.1)

How to Migrate to different Endian Platform Using Transportable Tablespaces With RMAN (Doc ID 371556.1) APPLIES TO: Oracle Database - Enterprise Edition - Version 12.1.0.2 to 12.2.0.1 [Release 12.1 to 12.2]Oracle Database - Enterprise Edition - Versi