MariaDB社区

标题: 关于INNODB数据存储文件的问题讨论(单个与多个) [打印本页]

作者: blueyund    时间: 2009-1-26 15:44
标题: 关于INNODB数据存储文件的问题讨论(单个与多个)
我用的innodb的引擎
在mysql的数据存储目录\data 中
每新建一个数据库 mysql 就会相应的生成一个相同名字的文件夹 这个文件夹里保存着这个数据库的所有表结构。
但是mysql却把 所有数据库的数据都存在\data 中一个叫 ibdata1 的文件中

我的问题是
怎么才能让每一个数据库单独的将数据存成一个文件 而不是所有的数据库存成一个文件
这样才好备份恢复啊
作者: kider    时间: 2009-2-25 18:42
讨论总结(收藏贴):

比如
用ibdata 或者用  innodb_file_per_table

谁能说说他们各自的优缺点呢?

-----------

http://dev.mysql.com/doc/refman/5.1/en/multiple-tablespaces.html

http://bbs.linuxwind.org/viewthr ... &extra=page%3D1

-----------

单表空间对于分布式以及恢复时的灵活性优点比较突出。
共享表空间在这点就差点。


性能方面暂时还没有一个太大的对比。

-----------

1.单表可能分布IO
2.单表易于修复,对于单个表.
3.单表没有空间大小限制.不需要设置初始大小.扩展大小等


-----------
单表的空间还可以自动回收。

-----------
共享表空间 不会自动回收空间碎片,单表空间,可以回收空间。可使用空语句,alter table a engine=innodb 测试一下

-----------
I would like to recommend to use "innodb_file_per_table" for huge data records,
to easy manage tables und diskspaces.

Innodb has a big Bug! you can not shrink (or reduce) the filesize of ibdata even
real table datasize is smaller! (Postgrsql can do that with VACUUM)

But if InnoDB configured as "innodb_file_per_table", using mysqldump for
a table and restore it you can optimize <the_table>.ibd size and diskspace!

Because DROP <table> will automaticly remove <table>.ibd file. If use one
shared ibdata file will do not reduce the file size.

-----------
You mean that the second point can reduce the actual file size when remove it from database.

-----------
InnoDB通常需要使用共享表空间来存储它的内部数据和“undo logs”,“.ibd”不足以满足InnoDB的需求。
你不能向MyISAM一样随意移动InnoDB的ipd文件到其它数据库目录内,因为InnoDB共享表空间内部也定义了数据库名称;而且InnoDB还需要确保它的事务IDs和日志序列好的连续完整
需要移动.ibd文件至另一个库,使用以下命令:

RENAME TABLE db1.tbl_name TO db2.tbl_name;

也有个不好的方面,如果单个文件很大很大,它是不能分割的,而统一的ibdata是可以分割的,在配置文件里设置,也就是可扩展性好。

-----------
Another point based on this issue is that individual tablespace is better than common tablespace when you use MySQL partition function.

-----------
小数据量/高并发/数据低增长 环境可能更适合独立表空间。


原帖:
http://bbs3.chinaunix.net/thread-1369535-2-3.html




欢迎光临 MariaDB社区 (http://123.56.88.72/) Powered by Discuz! X3.2