linux文件系统评估之inode
存储系统上线前要做资源评估,通常需要在性能(即iops、带宽等)和容量维度进行业务评估;而具体到本地文件系统存储的容量时,需要根据具体业务对文件系统的可用数据空间和可用inode数进行评估,作者通过工作中一事例对此有了更深刻的认识:
由于系统需求,要将linux服务器A的本地磁盘数据(数据量260GB左右)同步至linux服务器B的本地磁盘,A和B相应的分区可用空间均为293GB左右;在数据同步接近完成时,log开始提示错误信息机器B“No space left on device”,而df -lh命令显示B本地文件系统还有50GB左右可用空间;猜测是inode已用完所致,使用df -i命令显示B本地文件系统的IFree确实为0,IUsed为1946万,IUse%为100%;而机器A同样分区大小的文件系统却显示Inodes总数为3900万、IUsed为1986万,其inode总数为机器B的2倍,那如何将增加机器B文件系统的inode数量呢?
通过man page了解到,extX文件系统格式化完成后,其inode数不能在线调整,只能重新格式化并通过参数配置;通常使用mke2fs创建文件系统时,会使用/etc/mke2fs.conf中的预设参数配置,其中与inode相关的有inode_size(ext4默认为256)和inode_ratio(默认为16384),inode_size参数的含义容易理解,即单个inode结构自身所占字节数,man page(CentOS 6.4,kernel 2.6.32)介绍如下:
Specify the size of each inode in bytes. mke2fs creates 256-byte inodes by default. In kernels after 2.6.10 and some earlier vendor kernels it is possible to utilize inodes larger than 128 bytes to store extended attributes for improved performance. The inode-size value must be a power of 2 larger or equal to 128. The larger the inode-size the more space the inode table will consume, and this reduces the usable space in the filesystem and can also negatively impact performance. Extended attributes stored in large inodes are not visible with older kernels, and such filesystems will not be mountable with 2.4 kernels at all. It is not possible to change this value after the filesystem is created.
将机器B的ext4文件系统加上“-I 128”参数重新格式化,虽其inode_size从256变为128,其inode总数却并未发生变化;另一个参数inode_ratio在man page上的描述却不易理解:
Specify the bytes/inode ratio. mke2fs creates an inode for every bytes-per-inode bytes of space on the disk. The larger the bytes-per-inode ratio, the fewer inodes will be created. This value generally shouldn't be smaller than the blocksize of the filesystem, since in that case more inodes would be made than can ever be used. Be warned that it is not possible to expand the number of inodes on a filesystem after it is created, so be careful deciding the correct value for this parameter.
经过求证与测试后顿悟,其含义可通俗描述为:格式化时,每bytes-per-inode(或inode_ratio)字节大小的空间就创建一个inode,在分区大小固定前提下,该值越大,inode个数越少,data block就越多,该值越小,inode个数越多,data block就越少;以默认值16384(即16KiB)为例,如果文件系统上所有文件大小均为16KiB(或平均值),则data block耗尽的同时inode也将耗尽,二者占文件系统比例处于最理想状态,对于大量小文件的业务,通常将该值调小以增加inode数量;
上述机器B的问题正是如此,参照机器A的inode总数是机器B的2倍,将inode_ratio值设置为8KiB,加上"-i 8192"参数重新格式化,成功将机器B的inode总数翻倍。
另外,相对于ext3默认inode_size为128,ext4默认inode_size变为256,以存储其它字段(如nanosecond timestamps,inode versioning,extend attributes等)。
此事例告诉我们,使用extX文件系统时,需要在上线前根据存储业务情况对文件系统的data block和inode数做综合评估;如果是和上述相反的大文件存储业务,可以将inode_ratio值调大,以增加data block数量,如使用“-T largefile”选项对应的inode_ratio值为1MiB,在1.8TiB大小的分区创建ext4文件系统时,可增加20~30GiB左右的数据空间。
对于不能准备评估或需求特殊(如海量小文件)的存储业务,可考虑使用ReiserFS、XFS、JFS等,以避免inode耗尽的风险;关于这些filesystem的介绍,请关注后续博文。
参考文章:
http://www.linux-mag.com/id/8658/
http://www.geekride.com/understanding-unix-linux-filesystem-inodes/
http://stackoverflow.com/questions/3618820/how-many-bytes-per-inodes
https://ext4.wiki.kernel.org/index.php/Main_Page
https://en.wikipedia.org/wiki/ReiserFS
http://www.serverfocus.org/reiserfs-vs-ext4-vs-xfs-vs-zfs-vs-btrfs
------------------------------------
http://www.cnblogs.com/wuhuiyuan/p/linux-filesystem-inodes.html
个人原创,转载请注明出处。
linux文件系统评估之inode的更多相关文章
- Linux文件系统中的inode节点详细介绍
这篇文章主要介绍了Linux文件系统中的inode节点,详细讲解了inode是什么.inode包含的信息.inode号码的相关资料等,需要的朋友可以参考下 一.inode是什么? 理解inode,要从 ...
- linux文件系统软链接硬链接
引子 目前,UNIX的文件系统有很多种实现,例如UFS(基于BSD的UNIX文件系统).ext3.ext4.ZFS和Reiserfs等等. 不论哪一种文件系统,总是需要存储数据.硬盘的最小存储单位是扇 ...
- 【Linux学习】Linux文件系统4—Linux文件硬链接与软连接
Linux文件系统4-Linux文件硬链接与软连接 inode:索引节点 (连接文件)link 一.文件硬链接 1.Linux文件系统中,inode只相同的文件是硬链接文件 2.不同文件名,inode ...
- Linux文件系统(inode、block……)
内容源于<鸟哥的Linux私房菜> 认识 EXT2 文件系统 文件系统的特殊观察与操作 文件系统 superblock,inode,block superblock,inode,block ...
- linux 文件系统(inode和block)
linux文件系统(inode block superblock) 先说一下格式化:每种操作系统所设置的文件属性/权限并不相同,为了存放这些文件所需的数据,因此就需要将分区格式化,以成为操作系统能 ...
- 理解Linux文件系统之inode
很少转发别人的文章,但是这篇写的太好了. 理解inode 作者: 阮一峰 inode是一个重要概念,是理解Unix/Linux文件系统和硬盘储存的基础. 我觉得,理解inode,不仅有助于提高系统 ...
- # linux文件系统(inode block superblock)
先说一下格式化:每种操作系统所设置的文件属性/权限并不相同,为了存放这些文件所需的数据,因此就需要将分区格式化,以成为操作系统能够利用的文件系统格式.linux的文件格式为Ext2/Ext3,现在好像 ...
- [转]理解Linux文件系统之inode
很少转发别人的文章,但是这篇写的太好了. 理解inode 作者: 阮一峰 inode是一个重要概念,是理解Unix/Linux文件系统和硬盘储存的基础. 我觉得,理解inode,不仅有助于提高系统 ...
- Linux基础篇学习——Linux文件系统之文件存储与读取:inode,block,superblock
Linux文件类型 代表符号 含义 - 常规文件,即file d directory,目录文件 b block device,块设备文件,支持以"block"为单位进行随机访问 c ...
随机推荐
- BNUOJ-26480 Horror List 最短路
题目链接:http://www.bnuoj.com/bnuoj/problem_show.php?pid=26480 题意:简单来说,就是给一个图,然后从每个honor list中的点求最短路.. 边 ...
- Spring配置MyBatis
1.MyBatis配置文件(mybatis-config) <?xml version="1.0" encoding="UTF-8"?> <! ...
- hdoj 1234 开门人和关门人
开门人和关门人 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) #include ...
- MongoDB系列一(安装)
一.MongoDB在Windows平台下的安装: 安装包官方下载地址:http://www.mongodb.org/downloads 第一步:下载安装包:如果是win系统,注意是64位还是32位版本 ...
- C#中让窗体自动靠边隐藏
1: private void Yincangtimer_Tick(object sender, EventArgs e)//窗体隐藏事件 2: { 3: int a = Control.MouseP ...
- 8000401a 错误及解决办法
将web程序部署到服务器上时,偶尔会遇到下面的错误: System.Runtime.InteropServices.COMException (0x8000401A): 检索 COM 类工厂中 CLS ...
- IOS UILabel自动换行
{ UILabel *lb=[[UILabel alloc]initWithFrame:CGRectMake(offset_xx, offset_yy, , )]; [lb setText:@&quo ...
- 查看SQL语句执行时间、IO开销
SET STATISTICS TIME ON SET STATISTICS IO ON或者set statistics io,time on
- 理解 traits
1.为什么使用traits? 考虑下面的需求,实现一个方法Advance(iter,n),接收一个迭代器iter和移动距离n,将iter向前移动n个距离. 分析,因为存在不同类型的迭代器,做同一件事情 ...
- 成员方法与const之间的关系
const可以放在成员方法的三个地方,前.中.后. 首先考虑在中间: 1.const修饰形参,表示形参是否为const 2.如果const修饰引用(指针指向的对象),可以进行过载,如果不是修饰引用(指 ...