现在的位置: 首页 > 综合 > 正文

ext3

2013年12月04日 ⁄ 综合 ⁄ 共 8293字 ⁄ 字号 评论关闭
文章目录

EXT3 Performance Tuning

Journaling Mode

The ext3 file system has three journaling mode:

  1. The "journal" mode logs all data and metadata changes by copying the datainto the journal partition. It is themost robust mode but is also the slowest one unless the applications aredoing lots of synchronous data writes.
  2. The "ordered" mode is the default. It forces the data tothe disk before the metadata are committed to the journal partition.This is to ensure file system consistency after a crash or unclean reboot.
  3. The "writeback" mode is the fastest one since it simply logs metadata changes. However, it does not force data todisk rigorously. Data corruption may occur after a crash or unclean reboot.

The journal mode is specified by the mount options as:

data={journal,ordered, writeback}

General Ext3 Tuning Tips

  • If the read pattern is mostly sequential, set larger readahead param could help (current default is 31).

    shell> echo 128 > /proc/sys/vm/max-readahead
    
  • Experiment with "elvtune" tool with different IO latencies; normally largerlatency could yield higher bandwidth (throughput) but interactive jobs couldsuffer as a result (current write latency default is 8192, read latency default is 2048).

    shell> elvtune -w 16386 /dev/sdb2
    
  • Experiment with the ext3 journal size (the journal size can be between 4MB - 400MB. the default is 32MB).

    shell> mke2fs -J size=128 /dev/sda3
    

    (this creates a 128MB internal journal on /dev/sda3).

  • Allocate an external journal, i.e., move ext3 journal to another partition (moderate gain) and/or another disk (very good performance).
    shell> mke2fs -j -J device=/dev/sda2 /dev/sda3
    

    (this creates a file system on /dev/sda3 but with an external journal device on /dev/sda2)

ext3 Filesystem

The ext3 or third extended filesystem is a journalled file system that is commonly used by the Linux operating system. It is the default file system for many popular Linux distributions

Features of ext3 File System

The ext3 file system is essentially an enhanced version of the ext2 file system. These

improvements

provide the following advantages

Availability

After an unexpected
power

failure or system crash (also called an unclean system shutdown), each mounted ext2 file system on the machine must be checked for consistency by the e2fsck program. This is a time-consuming process that can delay system boot time significantly, especially
with large volumes containing a large number of files. During this time, any data on the volumes is unreachable.

The journaling provided by the ext3 file system means that this sort of file system check is no longer necessary after an unclean system shutdown. The only time a consistency check occurs using ext3 is in certain rare hardware failure cases, such as hard
drive failures. The time to recover an ext3 file system after an unclean system shutdown does not depend on the size of the file system or the number of files; rather, it depends on the size of the journal used to maintain consistency. The default journal
size takes about a second to recover, depending on the speed of the hardware.

Data Integrity

The ext3 file system provides stronger data integrity in the event that an unclean system shutdown occurs. The ext3 file system allows you to choose the type and level of protection that your data receives. By default, Most Linux Distributions configures
ext3 volumes to keep a high level of data consistency with regard to the state of the file system.

Speed

Despite writing some data more than once, ext3 has a higher throughput in most cases than ext2 because ext3′s journaling optimizes hard drive head motion. You can choose from three journaling modes to optimize speed, but doing so means trade offs in regards
to data integrity.

Easy Transition

It is easy to change from ext2 to ext3 and gain the benefits of a robust journaling file system without reformatting. See the Section called Converting to an ext3 File System for more on how to perform this task.

ReiserFS

ReiserFS is a general-purpose, journaled computer file system designed and implemented by a team at Namesys led by Hans Reiser.ReiserFS is currently supported on Linux and may be included in other operating

systems

in the future. Introduced in version 2.4.1 of the Linux kernel, it was the first journaling file system to be included in the standard kernel.

ReiserFS Features

ReiserFS has fast journaling, which means that you don't spend your life waiting for fsck every time your laptop battery dies, or the UPS for your mission critical server gets its batteries disconnected accidentally by the UPS

company's

service crew, or your kernel was not as ready for prime time as you hoped, or the silly thing decides you mounted it too many times today.

ReiserFS is based on fast balanced trees. Balanced trees are more robust in their performance, and are a more sophisticated algorithmic foundation for a file system. When we started our project, there was a consensus in the

industry

that balanced trees were too slow for file system usage patterns. We proved that if you just do them right they are better--take a look at the benchmarks. We have fewer worst case performance scenarios than other file systems and generally better overall performance.
If you put 100,000 files in one directory, we think its fine; many other file systems try to tell you that you are wrong to want to do it.

ReiserFS is more space
efficient
.
If you write 100 byte files, we pack many of them into one block. Other file systems put each of them into their own block. We don't have fixed space allocation for inodes. That saves 6% of your disk.

Ext3 & ReiserFS has three kinds of journaling methods

1) Journal Data Writeback
2) Journal Data Ordered
3) Journal Data

By default the the 2nd method is used.To speed things up we will make it use method 1. The price to pay is that it may allow old data to appear in files after a crash and journal recovery.

How to make ext3 or reiserfs use journal data writeback

First you need to take fstab file using the following command

sudo cp /etc/fstab /etc/fstab.orig

Edit the /etc/fstab file using the following command

sudo vi /etc/fstab

Add the thing marked in bold to your fstab root mount line.

/dev/hda1 / ext3 defaults,errors=remount-ro,atime,auto,rw,dev,exec,suid,nouser,data=writeback 0 1

Save that file and exit

You need to take Grubmenu file backup using the following command

sudo cp /boot/grub/menu.lst /boot/grub/menu.lst.orig

Now you need to edit the grub menu list file using the following command

sudo vi /boot/grub/menu.lst

look for the following two lines

# defoptions=quiet splash
# altoptions=(recovery mode) single

change to

# defoptions=quiet splash rootflags=data=writeback
# altoptions=(recovery mode) single rootflags=data=writeback

Save that file and exit

Now you need to update the grub using the following command

sudo update-grub

the added flags will automatically be added to the kernel line and stay there in case of kernel update

Changes to Ext3 FileSystem Only

Note:- tune2fs only works for ext3. Reiserfs can't change the journal method

Before rebooting change the filesystem manually to writeback using the following command

sudo tune2fs -o journal_data_writeback /dev/hda1

Check that it is running or not using the following command

sudo tune2fs -l /dev/hda1

Remove update of access time for files

Having the modified time change you can understand but having the system updating the access time every time a file is accessed is not to my liking. According to the manual the only thing that might happen if you turn this off is that when compiling certain
things the make might need that info.

To change this do the following

sudo vi /etc/fstab

add the following marked in bold

/dev/hda1 / ext3 defaults,errors=remount-ro,noatime,auto,rw,dev,exec,suid,nouser,data=writeback 0 1

Now reboot and enjoy a much faster system

系统调优--关闭EXT3/4的BARRIER功能

大多数当前流行的Linux文件系统,包括EXT3和EXT4,都将文件系统barrier作为一个增强的安全特性。它保护数据不被写入日记。但是,在许多情况下,我们并不清楚这些barrier是否有用。本文就为什么要在你的Linux系统上启用barrier做出了解释。

Linux日志和barrier功能

要理解barrier,你首先需要理解文件系统日志功能。常用的文件系统使用日志功能来保证文件系统的完整性。

该功能背后的思路很简单:在写入新的数据块到磁盘之前,会先将元数据写入日志。预先将元数据写入日志可以保证在写入真实数据前后一旦发生错误,日志功能能很容易地回滚到更改之前的状态。这个方法确保了不会发生文件系统崩溃的情况。

单独使用日志功能不能保证没有任何差错。现在的磁盘大都有大容量的缓存,数据不会立即写入到磁盘中,而是先写入到磁盘缓存中。到这一步,磁盘控制器就能更加高效地将其复制到磁盘中。这对性能来说是有好处的,但是对日志功能来说则相反。为了保证日志百分之百可靠,它必须绝对保证元数据在真实数据写入之前被预先写入。这就是我们要介绍文件系统barrier的原因。

我们很容易理解使用barrier的根本原因:barrier本身禁止在barrier之后写入数据,真实的数据块将在barrier被写入之前完全写入磁盘。使用barrier可以确保文件系统的完整性,因为barrier功能在EXT4文件系统中是默认启用的(除非你的操作系统更改了这个默认设置)。

检查Linux文件系统的barrier:启用还是禁用?

你可以通过/proc/mounts文件来监控文件系统barrier的当前状态;对于每一个挂载的文件系统,打开这个文件都能看到所有的挂载选项。如果你看到barrier=1,那么你的文件系统就正在使用barrier功能。下列信息是一个文件系统的例子:

/dev/sda1 /boot ext4 rw,seclabel,relatime,barrier=1,data=ordered 0 0/dev/mapper/luks-3e67401f-44c6-4a27-a1bf-cdf0dcf45f65 /home ext4 rw,seclabel,noatime,barrier=1,data=ordered 0 0

文件系统barrier何时不工作?

Barrier的问题在于,它不能应用于所有条件下。

如果设备映射器作为存储层的优先级使用,那么文件系统barrier就无法工作了,因为设备映射器不支持barrier。所以,哪怕你的文件系统默认支持barrier,还是无法在逻辑卷、软RAID或者多路径磁盘上运行该功能(RED HAT和所有相关的Linux版本都将barrier作为默认选项)。

解决这个问题的方案之一就是避免使用设备映射器。所以在安装服务器时,你需要充分考虑配置选项。首先,你不该使用LVM安装服务器,而应该选择用传统的分区方式。接着,你不能使用和设备映射器配合工作的多路径磁盘,它会在SAN上创建多个冗余路径。某些情况下,SAN供应商会提供一个专有驱动器作为选择,但不是所有供应商都提供该选项。最好的办法是采用智能硬件。

使用barrier保护的风险之一是,在系统中断时,数据会留在缓存中,而永不会写入文件系统。一个简单的电池备份控制器可以避免这个问题。当服务器使用的这个控制器出故障了,磁盘控制器仍然能保证变更操作,这充分排除了barrier使用的需要。

使用barrier的另一个不利之处在于,你需要付出降低性能的代价。如果你需要顶级的性能,那么你可以用挂载选项-o barrier=0来关闭barrier功能,比如:mount /dev/sda2 -o barrier=0 /data。

文件系统barrier功能非常有用,但是不能和设备映射器配合工作。如果你需要使用这类设备,但是又想要保证文件系统完整性,那么你可以用电池备份磁盘控制器。如果你的硬件不支持这个,那么你只能避免使用设备映射器,这样才能用barrier功能来保障文件系统完整性。还有,如果你希望得到更好的系统性能,最好也不要开启barrier功能,它会降低系统运行速度

抱歉!评论已关闭.