博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
mysql关于ibdata文件的理解
阅读量:7056 次
发布时间:2019-06-28

本文共 3080 字,大约阅读时间需要 10 分钟。

总结

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日志

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

最后送波福利。现在加群即可获取Java工程化、高性能及分布式、高性能、高架构。性能调优、Spring,MyBatis,Netty源码分析和大数据等多个知识点高级进阶干货的直播免费学习权限及领取相关资料,群号:835638062 点击链接加入群聊【Java高级架构】:https://jq.qq.com/?_wv=1027&k=5S3kL3v

转载地址:http://bkmol.baihongyu.com/

你可能感兴趣的文章
大文件排序问题
查看>>
php实现rar文件的读取和解压
查看>>
2014年天津市第一批科技计划项目
查看>>
@芥末的糖 ---------- node连接数据库两种方式mysql和moogoDB
查看>>
MongoDB 学习笔记2----条件操作符
查看>>
关于Hibernate5.x的那点事
查看>>
sk-learn 选择正确的估算器
查看>>
python操作mysql数据库
查看>>
erp的核心代码,替代orm
查看>>
字符串--manacher算法(回文串匹配)
查看>>
[LeetCode]: 242: Valid Anagram
查看>>
项目机器在开机器的时候做好标签,汉字标注
查看>>
expr判断整数是相加的值,返回命令的返回值$? 是0,但是少数情况是1,例如1 + -1 ,$? 的结果是1 ,判断要大于1最准确...
查看>>
Matplotlib
查看>>
DES 加密----笔记
查看>>
docker 运行redis
查看>>
VS2015 C#6.0 中的那些新特性(转自http://www.cnblogs.com/henryzhu/p/new-feature-in-csharp-6.html)...
查看>>
魔法森林[NOI2014]
查看>>
bzoj4002[JLOI2015]有意义的字符串
查看>>
python爬虫-抓取acg12动漫壁纸排行设置为桌面壁纸
查看>>