mysql关于ibdata文件的理解

总结

1、默认情况下ibdata存放InnoDB表(InnoDB数据字典)元数据、undo logs、the change buffer, and the doublewrite buffer

2、如果innodb_file_per_table=off,则ibdata也存放InnoDB表的实际数据,也就是InnoDB表建立后,不会再有单独的tablename.ibd文件

3、虽然InnoDB表元数据通过information_schema.tables来读取,但是实际上information_schema是一个虚拟数据库,并不物理存在,这些数据真正存放的地方就是ibdata


备注:元数据(meta data)--"data about data" 关于数据的数据,一般是结构化数据(如存储在数据库里的数据,规定了字段的长度、类型等)



ibdata file

https://dev.mysql.com/doc/refman/5.7/en/glossary.html#glos_ibdata_file

A set of files with names such as ibdata1, ibdata2, and so on, that make up the InnoDB system tablespace. These files contain metadata about InnoDB tables, (the InnoDB data dictionary), and the storage areas for one or more undo logs, the change buffer, and the doublewrite buffer. They also can contain some or all of the table data also (depending on whether the file-per-table mode is in effect when each table is created). When the innodb_file_per_table option is enabled, data and indexes for newly created tables are stored in separate .ibd files rather than in the system tablespace.

The growth of the ibdata files is influenced by the innodb_autoextend_increment configuration option

一组名称为ibdata1,ibdata2等的文件,构成InnoDB系统表空间。 这些文件包含有关InnoDB表(InnoDB数据字典)的元数据,以及一个或多个撤消日志,更改缓冲区和双写缓冲区的存储区域。 它们还可以包含部分或全部表数据(取决于创建每个表时每个表的文件模式是否有效)。 启用innodb_file_per_table选项后,新创建的表的数据和索引将存储在单独的.ibd文件中,而不是存储在系统表空间中。

ibdata文件的增长受innodb_autoextend_increment配置选项的影响,默认是64M

The increment size (in megabytes) for extending the size of an auto-extending InnoDB system tablespace file when it becomes full. The default value is 64


MySQL开启独享表空间的参数是Innodb_file_per_table,会为每个Innodb表创建一个.ibd的文件。

开启独享表空间后,并不是说就不需要ibdata1了,因为在ibdata1中还保存着下面这些数据。

InnoDB表的元数据

Buffer

UNDO日志


undo tablespace

An undo tablespace contains undo logs. Undo logs exist within undo log segments, which are contained within rollback segments. Rollback segments have traditionally resided in the system tablespace. As of MySQL 5.6, rollback segments can reside in undo tablespaces. The number of undo tablespaces is controlled by the innodb_undo_tablespaces configuration option.

undo表空间包含undo日志。 撤消日志存在于撤消日志段中,这些日志段包含在回滚段中。 回滚段传统上驻留在系统表空间中。 从MySQL 5.6开始,回滚段可以驻留在撤消表空间中。 撤消表空间的数量由innodb_undo_tablespaces配置选项控制。

innodb_undo_tablespaces is deprecated and will be removed in a future release.

5.7.21版本开始innodb_undo_tablespaces已弃用,将在以后的版本中删除。



system tablespace

https://dev.mysql.com/doc/refman/5.7/en/glossary.html#glos_system_tablespace

One or more data files (ibdata files) containing metadata for InnoDB-related objects (the InnoDB data dictionary), and the storage areas for the change buffer, the doublewrite buffer, and possibly undo logs. It may also contain table and index data for InnoDB tables if tables were created in the system tablespace instead of file-per-table or general tablespaces. The data and metadata in the system tablespace apply to all databases in a MySQL instance.

系统表空间

包含InnoDB相关对象(InnoDB数据字典)的元数据的一个或多个数据文件(ibdata文件),以及更改缓冲区,双写缓冲区和可能的撤消日志的存储区域。 如果在系统表空间而不是每个表文件或一般表空间中创建表,它还可能包含InnoDB表的表和索引数据。 系统表空间中的数据和元数据适用于MySQL实例中的所有数据库。




实验过程

会话1

mysql> set global innodb_file_per_table=off;

mysql> show variables like '%innodb_file_per_table%';

+-----------------------+-------+

| Variable_name         | Value |

+-----------------------+-------+

| innodb_file_per_table | OFF   |

+-----------------------+-------+


打开会话2

创建了表tab4并插入数据,却发现tab4表没有tab4.ibd文件

mysql> create table test1.tab4 (hid int);

mysql> insert into test1.tab4 values (1);

[root@mydb ~]# ll /var/lib/mysql/test1 |grep tab4

-rw-r----- 1 mysql mysql    8558 Sep 30 19:56 tab4.frm

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30126024/viewspace-2215374/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/30126024/viewspace-2215374/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值